ScriptName "Basisboard Set RS and FB 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 bReturnCode : Byte; var btemp : Byte ; var RSgn : Byte ; var lToggle250 : Byte ; var TRUE : Byte ; moveconst ( TRUE, 1); var RS_StateLED : Byte ; var FB_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 b0x15 : Byte ; moveconst ( b0x15, 0x15); var b0xE1 : Byte ; moveconst ( b0xE1, b0xE1); var b0xFF : Byte ; moveconst ( b0xFF, b0xFF); var w4 : Word ; moveconst (w4, 4); var w5 : Word ; moveconst (w5, 5); var w6 : Word ; moveconst (w6, 6); var w7 : Word ; moveconst (w7, 7); var wLED : Word ; moveconst (wLED, 0xFF); 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; call :GetFBState; //****************************************************************************** BusStart; moveconst (RS_StateLED, 3);// Set (RS_State_LED, RedGreenFlashing) ; // main :start ; //---- call :Update_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_StateLED; call :Update_FB_StateLED; call :Update_RS_StateLED; return; :Update_FB_StateLED; call :GetFBState; if FB_StateLED equal b0 then :FB_State_LED_OFF; if FB_StateLED equal b1 then :FB_State_LED_Staticred; if FB_StateLED equal b2 then :FB_State_LED_StaticGreen; if FB_StateLED equal b3 then :FB_State_LED_RedGreenFlashing; if FB_StateLED equal b4 then :FB_State_LED_RedFlashing; if FB_StateLED equal b5 then :FB_State_LED_GreenFlashing; return; :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; :FB_State_LED_OFF; CalculateByte ( wLED , w5 , SetBit , wLED ) ; CalculateByte ( wLED , w4 , SetBit , wLED ) ; call :UpdateLEDs; return; :RS_State_LED_Staticred; CalculateByte ( wLED , w6 , SetBit , wLED ) ; CalculateByte ( wLED , w7 , ClearBit , wLED ) ; call :UpdateLEDs; return; :FB_State_LED_Staticred; CalculateByte ( wLED , w5 , SetBit , wLED ) ; CalculateByte ( wLED , w4 , ClearBit , wLED ) ; call :UpdateLEDs; return; :RS_State_LED_StaticGreen; CalculateByte ( wLED , w7 , SetBit , wLED ) ; CalculateByte ( wLED , w6 , ClearBit , wLED ) ; call :UpdateLEDs; return; :FB_State_LED_StaticGreen; CalculateByte ( wLED , w4 , SetBit , wLED ) ; CalculateByte ( wLED , w5 , 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; :FB_State_LED_RedGreenFlashing; call :UpdateToggle250; if lToggle250 equal TRUE then :FB_State_LED_StaticRed; call :FB_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; :FB_State_LED_RedFlashing; call :UpdateToggle250; if lToggle250 equal TRUE then :FB_State_LED_StaticRed; call :FB_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; :FB_State_LED_GreenFlashing; call :UpdateToggle250; if lToggle250 equal TRUE then :FB_State_LED_StaticGreen; call :FB_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; //------------------------------------------------------------------------------ :GetFBState; Get ( ReadBusState , lReadBusState ) ; Convert ( lReadBusState , Long , btemp , Byte ) ; if btemp greater b0 then :CheckFBState0x0F; moveconst (FB_StateLED, 0);// Set (FB_State_LED, OFF) ; jump :CheckFBStateENDE; :CheckFBState0x0F; if btemp greater b0x15 then :CheckFBState0xE1; moveconst (FB_StateLED, 4);// Set (FB_State_LED, Redflashing) ; jump :CheckFBStateENDE; :CheckFBState0xE1; if btemp greater b0xE1 then :CheckFBState0xFF; moveconst (FB_StateLED, 2);// Set (FB_State_LED, StaticGreen) ; jump :CheckFBStateENDE; :CheckFBState0xFF; if btemp greater b0xFF then :CheckFBStateENDE; moveconst (FB_StateLED, 1);// Set (FB_State_LED, StaticRed) ; jump :CheckFBStateENDE; :CheckFBStateENDE; return; // PB CO DN IB EN FE MP LN AN // READ_BUS_STATE_NOT_ACTIV 0x00 // * * * * * * * * * (BusStart = 0) // READ_BUS_STATE_WAIT_CONFIG 0x01 // * - - - - - - - - // READ_BUS_STATE_WAIT_PARAMETER 0x02 // * - - - - - - - - // READ_BUS_STATE_INITIALIZING 0x10 // - * - * - * - - - // READ_BUS_STATE_DISCONNECTED 0x11 // - * - - - - - - - // READ_BUS_STATE_CONNECTING 0x12 // - * - - - - - - - // READ_BUS_STATE_PREPARING 0x13 // - * - - - - - - - // READ_BUS_STATE_PREPARED 0x14 // - * - - - - - - - // READ_BUS_STATE_PREOPERATIONAL 0x15 // - * - - - - - - - // READ_BUS_STATE_LISTEN 0x20 // - - - - - * - - - // READ_BUS_STATE_CLOSE_WAIT 0x21 // - - - - - * - - - // READ_BUS_STATE_CLOSED 0x22 // - - - - - * - - - // READ_BUS_STATE_DATA_EXCHANGE 0xE0 // * - * * * - * * * // READ_BUS_STATE_OPERATIONAL 0xE1 // - * - - - - - - - // READ_BUS_STATE_UDP 0xE2 // - - - - - * - - - // READ_BUS_STATE_ESTABLISHED 0xE3 // - - - - - * - - - // READ_BUS_STATE_TIMEOUT 0xFD // - - - * - - - - - // READ_BUS_STATE_ERROR 0xFE // * - - - - - - - - // READ_BUS_STATE_UNKNOWN 0xFF // * * - - - * - - - //------------------------------------------------------------------------------