ScriptName "IC ShiftReg on FB/FB basis board" ScriptAuthor " G/St" ScriptVersion "(?)" // init the shift register hardware commands // 01.11.01 V1.0 St create the example // 10.11.04 V1.01 St string to long in ScriptName SetErrorHandler ( :Address ) ; var vbErrorNo : byte ; // Pfad: IC functions -> ... // Feldbus-Seite // RS-Seite // Intern -> Ja // min value = // max value = // Example for shift registers and the base board // the LED's of the base board are connected to the // shift register // In this example a simple value is shifted, so some LED // are on and some other are off. // The calculate function ignores any overflow, // so we have an ring counter, and // the 4 yellow LEDs behave like a binary counter // This script will compile and run from // Version 1.28 of Protocol Developer, // earlier Versions produce compile errors var Data: byte; MoveConst (Data, 0); var Const1: byte; MoveConst (Const1, 1); var v2 : byte ; // Initialization // define type of input and output shift registers Set ( ShiftRegisterInputType , RiseClock_LowLoad ) ; Set ( ShiftRegisterOutputType , RiseClock_RiseLoad ) ; // define number of bits for the shift register. // those sizes may be smaller then the real hardware. // in those cases only the defined number of bits are shifted Set ( ShiftRegisterInputBitLength , 8 ) ; Set ( ShiftRegisterOutputBitLength , 8 ) ; // Main program loop :Start ; ReadShiftRegister ( Data ) ; // S1 und S2 WriteShiftRegister( Data ) ; // 4 x4 ge Ledīs and 2 x bi Ledīs // CalculateByte ( Data , v2 , not , Data ) ; // for var window in the debugger jump :Start; // S1, S2 und S6 sind Low aktiv // S1 ist Low Nibble // S2 ist High Nibble // Beispiel: S1 = E // S2 = 4 // ReadShiftRegister ( Data ) ; // Data: 0xB1 // LED`S 4 x ge / 1 x bi = High aktiv // Beispiel: write 0x00 -> alle Ledīs sind aus // write 0x01 -> Led (1) ist an // +- - - > rt/gn // | gn:(6) // | rt:(7) // | // +----------------------------------------+ // | bi ge ge ge ge rt | // | (3) (2) (1) (0) (State) | // | +---------------+ | // | (S6) |1|2|3|4|5|6|7|8| | al switches are OFF means 0xFF // | +---------------+ | example: switch no 8 is ON -> 0xFE // | | | | | | | | | | // | BitNo: 7-6-5-4-3-2-1-0 | // | | // | FB - FB Basisbord | // | | // | | // | | // | + - - - - - - - - - - - > | rt/gn // | | | rt:(4) // | | | gn:(5) // | | | // | bi ge ge ge ge rt | // | (3) (2) (1) (0) (State)| // | +---+---+ | // | | L | H | +|- | // | +---+---+ 24V | // | (S1)|(S2) | // +----------------------------------------+ : Address ; Get ( ErrorCode , vbErrorNo ) ; // do anything stop ; return ; // // moveconst ( Data , 0x00 ) ; // WriteShiftRegister( Data ) ; // moveconst ( Data , 0x01 ) ; // WriteShiftRegister( Data ) ; // moveconst ( Data , 0x02 ) ; // WriteShiftRegister( Data ) ; // moveconst ( Data , 0x04 ) ; // WriteShiftRegister( Data ) ; // moveconst ( Data , 0x08 ) ; // WriteShiftRegister( Data ) ; // moveconst ( Data , 0x10 ) ; // WriteShiftRegister( Data ) ; // moveconst ( Data , 0x20 ) ; // WriteShiftRegister( Data ) ; // moveconst ( Data , 0x40 ) ; // WriteShiftRegister( Data ) ; // moveconst ( Data , 0x80 ) ; // WriteShiftRegister( Data ) ;