ScriptName "Basisboard Set RS State" ScriptAuthor "(dA) " ScriptVersion "V 1.0" // 25.04.05 V1.0 create for IC Basisboard SetErrorHandler( :ErrorHandler ) ; // Initialize ErrorHandler SetSystemErrorHandler( :SystemErrorHandler ) ; // Initialize SystemErrorHandler // ********************** Basisboard Init ************************************** //********** shift-register init *********************************************** Set ( ShiftRegisterInputType , RiseClock_LowLoad ) ; Set ( ShiftRegisterOutputType , RiseClock_RiseLoad ) ; Set ( ShiftRegisterInputBitLength , 16 ) ; Set ( ShiftRegisterOutputBitLength , 8 ) ; //********** show LEDīs ******************************************************** var hFF : Byte ; moveconst (hFF, 0xFF); var hFE : Byte ; moveconst (hFE, 0xFE); var hFD : Byte ; moveconst (hFD, 0xFD); var hFB : Byte ; moveconst (hFB, 0xFB); var hF7 : Byte ; moveconst (hF7, 0xF7); var h7F : Byte ; moveconst (h7F, 0x7F); var hBF : Byte ; moveconst (hBF, 0xBF); var hDF : Byte ; moveconst (hDF, 0xDF); var hEF : Byte ; moveconst (hEF, 0xEF); WriteShiftRegister ( hFE ) ; // 1 WriteShiftRegister ( hFD ) ; // 2 WriteShiftRegister ( hFB ) ; // 3 WriteShiftRegister ( hF7 ) ; // 4 WriteShiftRegister ( h7F ) ; // RS State rt => 7 = 7d = 0111 xxxx WriteShiftRegister ( hBF ) ; // RS State gn => B = 11d = 1011 xxxx WriteShiftRegister ( hDF ) ; // FB State gn => D = 13d = 1101 xxxx WriteShiftRegister ( hEF ) ; // FB State rt => E = 14d = 1110 xxxx WriteShiftRegister ( hFF ) ; // 0 var wLED : Word ; moveconst ( wLED, 0xFF); var bReturnCode : Byte; var btemp : Byte ; var RSgn : Byte ; var lToggle250 : Byte ; var TRUE : Byte ; moveconst ( TRUE, 1); var RS_StateLED : Byte ; var b0 : Byte ; moveconst ( b0, 0); var b1 : Byte ; moveconst ( b1, 1); var b2 : Byte ; moveconst ( b2, 2); var b3 : Byte ; moveconst ( b3, 3); var b4 : Byte ; moveconst ( b4, 4); var b5 : Byte ; moveconst ( b5, 5); var w4 : Word ; moveconst (w4, 4); var w6 : Word ; moveconst (w6, 6); var w7 : Word ; moveconst (w7, 7); var l_TimerOld : Long ; var l_Result : Long ; var ltemp : Long ; var l_250 : Long ; moveconst (l_250, 250); var l_500 : Long ; moveconst (l_500, 500); //var lReadBusState : Long; moveconst (RS_StateLED, 3);// Set (RS_State_LED, RedGreenFlashing) ; :start ; //---- call :Update_RS_StateLED; // MainLOOP //moveconst (RS_StateLED, 1);// Set (RS_State_LED, StaticRed) ; //moveconst (RS_StateLED, 2);// Set (RS_State_LED, StaticGreen) ; //moveconst (RS_StateLED, 3);// Set (RS_State_LED, RedGreenFlashing) ; //moveconst (RS_StateLED, 4);// Set (RS_State_LED, RedFlashing) ; //moveconst (RS_StateLED, 5);// Set (RS_State_LED, GreenFlashing) ; jump :start; // ***************** Subroutines *********************************************** : ErrorHandler ; //------------ Get ( ErrorCode , bReturnCode ) ; SetByVar ( Errorcode , bReturnCode ) ; // ErrorCode display on yellow LED's moveconst (RS_StateLED, 1);// Set (RS_State_LED, StaticRed) ; return ; :SystemErrorHandler; //------------------ Get ( systemError , bReturnCode ) ; // Systemerrorcode will be displayed on yellow LED's by Firmware. // Other action by user will be here possible return; // ****************** set State LEDs RS **************************************** :Update_RS_StateLED; if RS_StateLED equal b0 then :RS_State_LED_OFF; if RS_StateLED equal b1 then :RS_State_LED_Staticred; if RS_StateLED equal b2 then :RS_State_LED_StaticGreen; if RS_StateLED equal b3 then :RS_State_LED_RedGreenFlashing; if RS_StateLED equal b4 then :RS_State_LED_RedFlashing; if RS_StateLED equal b5 then :RS_State_LED_GreenFlashing; return; :RS_State_LED_OFF; CalculateByte ( wLED , w7 , SetBit , wLED ) ; CalculateByte ( wLED , w6 , SetBit , wLED ) ; call :UpdateLEDs; return; :RS_State_LED_Staticred; CalculateByte ( wLED , w6 , SetBit , wLED ) ; CalculateByte ( wLED , w7 , ClearBit , wLED ) ; call :UpdateLEDs; return; :RS_State_LED_StaticGreen; CalculateByte ( wLED , w7 , SetBit , wLED ) ; CalculateByte ( wLED , w6 , ClearBit , wLED ) ; call :UpdateLEDs; return; :RS_State_LED_RedGreenFlashing; call :UpdateToggle250; if lToggle250 equal TRUE then :RS_State_LED_StaticRed; call :RS_State_LED_StaticGreen; return; :RS_State_LED_RedFlashing; call :UpdateToggle250; if lToggle250 equal TRUE then :RS_State_LED_StaticRed; call :RS_State_LED_OFF; return; :RS_State_LED_GreenFlashing; call :UpdateToggle250; if lToggle250 equal TRUE then :RS_State_LED_StaticGreen; call :RS_State_LED_OFF; return; //------------------------------------------------------------------------------ :UpdateToggle250; Get ( Timer , ltemp ) ; CalculateLong ( ltemp , l_TimerOld , sub , l_Result ) ; if l_Result less l_250 then :SetlToggle250FALSE; if l_Result less l_500 then :SetlToggle250TRUE; Copy ( ltemp, l_TimerOld, w4); // oder alternativ Set ( Timer , 0 ) ; return; :SetlToggle250FALSE; moveconst (lToggle250, 0); return; :SetlToggle250TRUE; moveconst (lToggle250, 1); return; :UpdateLEDs; Convert ( wLED , Word , btemp , Byte ) ; WriteShiftRegister ( btemp ) ; // RS State gn = 10xx xxxx return;