ScriptName "Transparent 1 Byte I/O" ScriptAuthor "(dA) " ScriptVersion "V 1.0" // 30.10.02 V 1.0 create for UNIGATE IC and basis board SetErrorHandler ( : AddressLable1 ) ; var vb_error : Byte ; Var b : BUFFER [10]; // die buffer sin linear hintereinander angereit Var b1 : BUFFER [90]; Var s : BUFFER [10]; Var s1 : BUFFER [90]; Var k : BUFFER [10]; Var k1 : BUFFER [90]; var test : byte ; // 7 Var test : WORD ; var size : word; moveconst (size, 1); var time : word ; moveconst (time, 10); var vb_ErCo : byte ; var v2 : byte ; var vbcx00 : byte ; moveconst ( vbcx00 , 0x00 ) ; var vbcx01 : byte ; moveconst ( vbcx01 , 0x01 ) ; var vbcx02 : byte ; moveconst ( vbcx02 , 0x02 ) ; // ... // Warning: timout var vbcx04 : byte ; moveconst ( vbcx04 , 0x04 ) ; var vbcx08 : byte ; moveconst ( vbcx08 , 0x08 ) ; var vbcx10 : byte ; moveconst ( vbcx10 , 0x10 ) ; var vbcx20 : byte ; moveconst ( vbcx20 , 0x20 ) ; var vbcx40 : byte ; moveconst ( vbcx40 , 0x40 ) ; var vbcx80 : byte ; moveconst ( vbcx80 , 0x80 ) ; var vbcxFF : byte ; moveconst ( vbcxFF , 0xFF ) ; var vbcxFE : byte ; moveconst ( vbcxFE , 0xFE ) ; var vbcxFD : byte ; moveconst ( vbcxFD , 0xFD ) ; var vbcxFB : byte ; moveconst ( vbcxFB , 0xFB ) ; var vbcxF7 : byte ; moveconst ( vbcxF7 , 0xF7 ) ; var vbcxEF : byte ; moveconst ( vbcxEF , 0xEF ) ; var vbcxDF : byte ; moveconst ( vbcxDF , 0xDF ) ; var vbcxBF : byte ; moveconst ( vbcxBF , 0xBF ) ; var vbcx7F : byte ; moveconst ( vbcx7F , 0x7F ) ; var RxSync : buffer[10] ; var vltemp : long ; Set ( Baudrate , 9600 ) ; Set ( Databits , 8 ) ; Set ( Startbits , 1 ) ; Set ( Parity , none ) ; Set ( ShiftRegisterInputType , RiseClock_LowLoad ) ; Set ( ShiftRegisterOutputType , RiseClock_RiseLoad ) ; Set ( ShiftRegisterInputBitLength , 16 ) ; Set ( ShiftRegisterOutputBitLength , 8 ) ; WriteShiftRegister ( vbcxFF ) ; // 0 WriteShiftRegister ( vbcxFE ) ; // 1 WriteShiftRegister ( vbcxFD ) ; // 2 WriteShiftRegister ( vbcxFB ) ; // 3 WriteShiftRegister ( vbcxF7 ) ; // 4 WriteShiftRegister ( vbcxEF ) ; // FB State rt WriteShiftRegister ( vbcxDF ) ; // FB State gn WriteShiftRegister ( vbcxBF ) ; // RS State gn WriteShiftRegister ( vbcx7F ) ; // RS State rt ReadShiftRegister ( RxSync[0] ) ; // read fieldbus switch CalculateByte ( RxSync[0] , v2 , not , RxSync[0] ) ; // invert CalculateByte ( RxSync[0] , vbcx04 , rol , RxSync[0] ) ; // swap nibble Convert ( RxSync[0] , Byte , vltemp , Long ) ; // convert to the long type SetByVar ( FieldbusID , vltemp ) ; // set the fieldbus ID Set ( FieldbusID , 1 ) ; // set the fieldbus ID Set ( BusBaudrate , 125000 ) ; Set ( BusInputSize , 8 ) ; Set ( BusOutputSize , 8 ) ; call : SetLedsOff ; // Set ( RS_State_LED , StaticRed ) ; // only for SC call : Set_RS_State_LED_StaticRed ; BusStart ; Wait ( Bus_Active ) ; // Set (RS_State_LED, RedGreenFlashing) ; // only for SC // call : Set_RS_State_LED_RedGreenFlashing ; // not implement :start ; ReceiveSomeCharRS( time, s[0], size ); Get ( ErrorCode , vb_ErCo ) ; if vb_ErCo equal vbcx02 then :read_bus else :write_bus ; :write_bus; WriteBus( s[0], size) ; // Set ( RS_State_LED , GreenFlashing ) ; // call : Set_RS_State_LED_GreenFlashing ; // not implement :read_bus ; ReadBus ( b[0] , size ) ; if b[0] notequal k[0] then :write_rs else :start; :write_rs; Copy( b[0], k[0], size ) ; SendRS( b[0], size ) ; // Set( RS_State_LED, StaticGreen ) ; call : Set_RS_State_LED_StaticGreen ; jump :start; : AddressLable1 ; Get ( ErrorCode , vb_error ) ; if vb_error less vbcx10 then :ShowNo else :NoShow ; : ShowNo ; CalculateByte ( vb_error , v2 , not , vb_error ) ; WriteShiftRegister ( vb_error ) ; : NoShow ; //user evaluation for the value of Errorcode return ; : Set_RS_State_LED_StaticRed ; WriteShiftRegister ( vbcx7F ) ; return ; : Set_RS_State_LED_StaticGreen ; WriteShiftRegister ( vbcxBF ) ; return ; : SetLedsOff ; WriteShiftRegister ( vbcxFF ) ; return ;