ScriptName "IC Shift" ScriptAuthor "(dA)" ScriptVersion "(?)" // init the shift register hardware commands // 01.11.01 V1.0 St include SetErrorHandler 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 x ge Ledīs and 2 x bi Ledīs CalculateByte ( Data , v2 , not , Data ) ; // for var window in the debugger jump :Start; // S1, S2, S4 und S5 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 / 2 x bi = Low aktiv // Beispiel: write F -> alle Ledīs sind aus // write E -> Led (1) ist an // +----------------------------------------+ // | +---+---+ (State) rt | bi | rt/gn // | | L | H | | rt:(4) // | +---+---+ | gn:(5) // | (S1)|(S2) | // | IC Basisbord | // | | // | | // | +---+---+ bi - - - - - - - - - - - > | rt/gn // | | L | H | | gn:(6) // | +---+---+ gn(Pw) ge ge ge ge +|- | rt:(7) // | (S4)|(S4) (3) (2) (1) (0) | // +----------------------------------------+ // S4 und S5 ist Bit 8 - 15 : Address ; Get ( ErrorCode , vbErrorNo ) ; // do anything stop ; return ;