ScriptName "Transparent 8 Byte I/O" ScriptAuthor "(dA) " ScriptVersion "V 1.0" // 08.07.04 V 1.0 create for UNIGATE IC-CO 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 ; var wTemp : word; var bTemp : byte; var w0 :word; moveconst (w0, 0); var w1 :word; moveconst (w1, 1); var b0 :byte; moveconst (b0, 0); var bReturnCode:byte; var aFBTx:buffer[20]; var aFBRx:buffer[20]; var wDestOffset:word; var BusOutputSize:byte; var BusInputSize:byte; var wBusOutputSize:word; var wBusInputSize:word; var size : word; moveconst (size, 1); var wTimeOut : word ; moveconst (wTimeOut, 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 call :Init_ICCO_Basis; Set ( FieldbusID , 1 ) ; // set the fieldbus ID Set ( BusBaudrate , 125000 ) ; Set ( BusInputSize , 3 ) ; Set ( BusOutputSize , 6 ) ; // Object 1000h: Device Type // Contains information about the device type. The object at index 1000h describes the type of device // and its functionality. It is composed of a 16-bit field which describes the device profile that is used and // a second 16-bit field which gives additional information about optional functionality of the device. The // Additional Information parameter is device profile specific. Its specification does not fall within the // scope of this document, it is defined in the appropriate device profile. The value 0000h indicates a // device that does not follow a standardised device profile. For multiple device modules the Additional // Information parameter contains FFFFh and the device profile number referenced by object 1000h is // the device profile of the first device in the Object Dictionary. All other devices of a multiple device // module identify their profiles at objects 67FFh + x * 800h with x = internal number of the device (0 Ð 7). // These entries describe the device type of the preceding device. // [1000] // ParameterName=Device Type // DefaultValue=0 // PARA_GERAETE_TYP /* "Long" 0..0xFFFFFFFF - */ /* CO+DN:DeviceTyp,PB:IdentNr */ // DeviceTyp = DatL Set ( DeviceType , 1 ) ; // [1008] // ParameterName=Manufacturer Device Name // DefaultValue=UNIGATE CanOpen // PARA_GERAETE_NAME /* "SPtr" (Nullterminierter String) "" */ /* CO:DeviceName, DN:ProductName */ var DeviceNameBuf : buffer[15]; moveconst ( DeviceNameBuf[0], "UNIGATE IC-CanOpen"#0x00); SetByVar ( DeviceName , DeviceNameBuf[0] ) ; // [1009] // ParameterName=Manufacturer Hardware Version // DefaultValue=D // [100a] // ParameterName=Manufacturer Software Version // DefaultValue=3.60 // PARA_GERAETE_REVISION /* "Word" 0..65535 (ParaSet VOR Busstart)- */ // /* CO:0x4134=Hardrev.'A',Softrev.V3.4 DN:MSB=Maj.Rev,LSB=Min.Rev */ // DeviceRevision = DatW Set ( DeviceRevision , 0x4212 ) ; //****************************************************************************** // 1. Initialisierung: // CANopen: Defaultkonfiguration (Kanal 0): // -------- =============================== // Rx < "="La. 8 Byte => Data in Rx-PDO1 und Obj. 2000H // Rx > 8 Byte => Data nur in Obj. 2000H (Rx-PDO1 nicht aktiv) // Tx < 8 Byte => Data in Tx-PDO1 und Obj. 2001H // Tx > 8 Byte => Data nur in Obj. 2001H (Tx-PDO1 = SendLen = Obj. 2002H) // Im Obj. 2002H befindet sich immer die Tx-Len // Rx- und Tx-Len werden über die Param. "BusInput/OutputSize" eingestellt. // // ACHTUNG:Sobald mind. einmal der Befehl "InitCommChannel" aufgerufen wird, // ======= wird diese Defaultkonfig. des Kanal 0 ungültig ! // // // OPCODE_READ_KANAL_DATA /* WPtr_Kanal_Nr MPtr_Zieladr */ // CO: Kanal_Nr=1-16 => Rx-PDO1-16 // OPCODE_WRITE_KANAL_DATA /* WPtr_Kanal_Nr MPtr_Quelladr */ // CO: WPtr_Kanal_Nr=0xFFFF => Emgncy-Msg(WO) // == Kanal_Nr=1-16 => Tx-PDO1-16 // OPCODE_INIT_KANAL_DATA /* WPtr_Kanal_Nr BPtr_Richtung WPtr_ByteLen WPtr_ObjAdr WPtr_COBId */ // CO: Kanal_Nr: 1-16 => PDO 1-16 // == Richtung: 0=Tx, sonst Rx // ByteLen: Länge des Objektes in Byte. Wenn > 8 werden nur die ersten 8 Byte über die PDO gesendet // ObjAdr: 2000H bis 5FFFH erlaubt // COBId: 0000H=PDO nicht aktiv, Daten werden nur über Objekt ausgetauscht // FFFFH=COBId gem. "predefined connection set" (Nur bei PDO1+2 möglich) // FFFE=COBID von Master vergeben var vw_Channel : word ; var vb_Direction : byte ; var vw_len : word ; var vw_Obj_Nr : word ; var vw_COBId : word ; var Channel : byte ; // 1. RxPDO mitCOB ID 0x0200 + Node ID moveconst ( vw_Channel, 1 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2000 ) ; // auf ObjektAdr 2000 immer starres PDO Mapping moveconst ( vw_COBId, 0x0200 ) ; // fix siehe EDS file //call :CalcCOBIDwithFBID; //call :SetCOInit; // 2. RxPDO mitCOB ID 0x0300 + Node ID moveconst ( vw_Channel, 2 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2001 ) ; // auf ObjektAdr 2001 immer starres PDO Mapping moveconst ( vw_COBId, 0x0300 ) ; // fix siehe EDS file //call :CalcCOBIDwithFBID; //call :SetCOInit; // 3. RxPDO mitCOB ID 0x0400 + Node ID moveconst ( vw_Channel, 3 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2002 ) ; // auf ObjektAdr 2002 immer starres PDO Mapping moveconst ( vw_COBId, 0x0400 ) ; // fix siehe EDS file call :CalcCOBIDwithFBID; call :SetCOInit; // 4. RxPDO mitCOB ID 0x0500 + Node ID moveconst ( vw_Channel, 4 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2003 ) ; // auf ObjektAdr 2003 immer starres PDO Mapping moveconst ( vw_COBId, 0x0500 ) ; // fix siehe EDS file call :CalcCOBIDwithFBID; call :SetCOInit; // 5. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 5 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2004 ) ; // auf ObjektAdr 2004 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 6. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 6 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2005 ) ; // auf ObjektAdr 2005 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 7. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 7 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2006 ) ; // auf ObjektAdr 2004 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 8. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 8 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2007 ) ; // auf ObjektAdr 2007 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 9. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 9 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2008 ) ; // auf ObjektAdr 2008 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 10. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 10 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2009 ) ; // auf ObjektAdr 2009 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 11. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 11 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x200A ) ; // auf ObjektAdr 200A immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 12. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 12 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x200B ) ; // auf ObjektAdr 200B immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 13. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 13 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x200C ) ; // auf ObjektAdr 200C immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 14. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 14 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x200D ) ; // auf ObjektAdr 200D immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 15. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 15 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x200E ) ; // auf ObjektAdr 200E immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 16. RxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 16 ) ; moveconst ( vb_Direction, 1 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x200F ) ; // auf ObjektAdr 200F immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 1. TxPDO mitCOB ID 0x0180 + Node ID moveconst ( vw_Channel, 1 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2010 ) ; // auf ObjektAdr 2010 immer starres PDO Mapping moveconst ( vw_COBId, 0x0180 ) ; // fix siehe EDS file call :CalcCOBIDwithFBID; call :SetCOInit; // 2. TxPDO mitCOB ID 0x0280 + Node ID moveconst ( vw_Channel, 2 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2011 ) ; // auf ObjektAdr 2011 immer starres PDO Mapping moveconst ( vw_COBId, 0x0280 ) ; // fix siehe EDS file call :CalcCOBIDwithFBID; call :SetCOInit; // 3. TxPDO mitCOB ID 0x0380 + Node ID moveconst ( vw_Channel, 3 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2012 ) ; // auf ObjektAdr 2012 immer starres PDO Mapping moveconst ( vw_COBId, 0x0400 ) ; // fix siehe EDS file call :CalcCOBIDwithFBID; call :SetCOInit; // 4. TxPDO mitCOB ID 0x0480 + Node ID moveconst ( vw_Channel, 4 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2013 ) ; // auf ObjektAdr 2013 immer starres PDO Mapping moveconst ( vw_COBId, 0x0500 ) ; // fix siehe EDS file call :CalcCOBIDwithFBID; call :SetCOInit; // 5. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 5 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2014 ) ; // auf ObjektAdr 2014 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 6. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 6 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2015 ) ; // auf ObjektAdr 2015 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 7. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 7 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2016 ) ; // auf ObjektAdr 2014 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 8. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 8 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2017 ) ; // auf ObjektAdr 2017 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 9. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 9 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2018 ) ; // auf ObjektAdr 2018 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 10. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 10 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x2019 ) ; // auf ObjektAdr 2019 immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 11. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 11 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x201A ) ; // auf ObjektAdr 201A immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 12. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 12 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x201B ) ; // auf ObjektAdr 201B immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 13. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 13 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x201C ) ; // auf ObjektAdr 201C immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 14. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 14 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x201D ) ; // auf ObjektAdr 201D immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 15. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 15 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x201E ) ; // auf ObjektAdr 201E immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 16. TxPDO mitCOB ID (master defines the COB-ID's) moveconst ( vw_Channel, 16 ) ; moveconst ( vb_Direction, 0 ) ; moveconst ( vw_len, 0x08 ) ; moveconst ( vw_Obj_Nr, 0x201F ) ; // auf ObjektAdr 201F immer starres PDO Mapping moveconst ( vw_COBId, 0xFFFE ) ; call :SetCOInit; // 2. Datenaustausch: // OPCODE_READ_KANAL_DATA /* WPtr_Kanal_Nr MPtr_Zieladr */ // OPCODE_WRITE_KANAL_DATA /* WPtr_Kanal_Nr MPtr_Quelladr */ // Kanal-Nr bei CO:0=Emgncy-Msg(WO), 1-8=PDO(RW), 1000H-20FFH=Direkte Objektzugriff(RO) // 3. Statusabfrage (Datenlänge der Empfangspuffer): // APARA_ANZ_BUSINPUT_CHAR / //****************************************************************************** call :SetLedsOff ; // Set ( RS_State_LED , StaticRed ) ; // only for SC call :Set_RS_State_LED_StaticRed ; BusStart ; Wait ( Bus_Active ) ; Get ( BusInputSize , BusInputSize ) ; Get ( BusOutputSize , BusOutputSize ) ; Convert ( BusOutputSize , Byte , wBusOutputSize , Word ) ; Convert ( BusInputSize , Byte , wBusInputSize , Word ) ; // Set (RS_State_LED, RedGreenFlashing) ; // only for SC // call : Set_RS_State_LED_RedGreenFlashing ; // not implement :start ; Get ( RSInputCharacter16 , wTemp ) ; if wTemp equal w0 then :read_bus; // Read always one char until timeout :ReadRS ; ReceiveSomeCharRS ( wTimeout , bTemp , w1) ; Get ( ErrorCode , bReturnCode ) ; if bReturnCode equal b0 then :SaveRxChar else :write_bus ; :SaveRxChar ; CopyIndexed ( w1 , bTemp , w0 , aFBTx[0] , wDestOffset ) ; CalculateWord ( wDestOffset , w1 , add , wDestOffset ) ; jump :ReadRS ; :write_bus; WriteBus( aFBTx[0], wBusOutputSize) ; // Set ( RS_State_LED , GreenFlashing ) ; // call : Set_RS_State_LED_GreenFlashing ; // not implement :read_bus ; ReadBus ( aFBRx[0] , wBusInputSize ) ; Get ( ErrorCode , bReturnCode ) ; if bReturnCode equal b0 then :write_rs else :start; :write_rs; SendRS( aFBRx[0], wBusInputSize ) ; // Set( RS_State_LED, StaticGreen ) ; call :Set_RS_State_LED_StaticGreen ; jump :start; : AddressLable1 ; Get ( ErrorCode , bReturnCode ) ; if bReturnCode less vbcx10 then :ShowNo else :NoShow ; :ShowNo ; //!!!CalculateByte ( bReturnCode , v2 , not , bReturnCode ) ; WriteShiftRegister ( bReturnCode ) ; :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 ; :Init_ICCO_Basis; var vw_Baud :word ; var vw_fieldbusID :word ; var vw_fbSwitch :word ; var vl_fieldbusID :long ; var vwc0 :word ; moveconst ( vwc0 , 0 ) ; var vwc1 :word ; moveconst ( vwc1 , 1 ) ; var vwc4 :word ; moveconst ( vwc4 , 4 ); var vwc64 :word ; moveconst ( vwc64 , 64 ) ; var vwc128 :word ; moveconst ( vwc128 , 128 ) ; var vwcx3F :word ; moveconst ( vwcx3F , 0x3F ) ; var vwcxC0 :word ; moveconst ( vwcxC0 , 0xC0 ) ; Set ( ShiftRegisterInputType , RiseClock_LowLoad ) ; Set ( ShiftRegisterInputBitLength , 16 ) ; Set ( ShiftRegisterOutputType , RiseClock_RiseLoad ) ; Set ( ShiftRegisterOutputBitLength , 8 ) ; ReadShiftRegister ( vw_fbSwitch ) ; CalculateByte ( vw_fbSwitch , vwc1 , not , vw_fbSwitch ) ; // Hardware ist low aktiv CalculateByte ( vw_fbSwitch , vwc4 , rol , vw_fbSwitch ) ; // oben Links Baudrate: 7 6 ; CO ID: 5 4 3 2 1 0 //:Set_CO_Init ; //Set ( BusInputSize , 3 ) ; //Set ( BusOutputSize , 6 ) ; :CO_SwapNibble; CalculateByte ( vw_fbSwitch , vwcx3F , and , vw_fieldbusID ) ; // ID Mask CalculateByte ( vw_fbSwitch , vwcxC0 , and , vw_Baud ) ; // CO Baudrate call :CO_SetFieldbusID ; call :CO_SetBaudrate ; return; //**************************** :CO_SetFieldbusID ; if vw_fieldbusID greater vwc0 then :CheckLess64 else :TestMode ; :CheckLess64 ; if vw_fieldbusID less vwc64 then :SetIDfromSwitch else :TestMode ; :SetIDfromSwitch ; Convert ( vw_fieldbusID , word , vl_fieldbusID , Long ) ; SetByVar ( FieldbusID , vl_fieldbusID ) ; // must be a long type jump :EndID_Init ; :TestMode ; if vw_fieldbusID equal vwc0 then :SetIDto1 else :EndID_Init ; :SetIDto1 ; Set ( FieldbusID , 1 ) ; :EndID_Init ; return ; //************************* //************************* :CO_SetBaudrate ; if vw_Baud equal vwc0 then :SetBaud_1_Mbaud else :CheckBaud_500_kbaud ; :SetBaud_1_Mbaud ; Set ( BusBaudrate, 1000000 ); // CANopen only jump :SetBaudrateEnd ; :CheckBaud_500_kbaud ; if vw_Baud equal vwc64 then :SetBaud_500_kbaud else :CheckBaud_250_kbaud ; :SetBaud_500_kbaud ; Set ( BusBaudrate, 500000 ); // CANopen, DeviceNet jump :SetBaudrateEnd ; :CheckBaud_250_kbaud ; if vw_Baud equal vwc128 then :SetBaud_250_kbaud else :SetBaud_125_kbaud ; :SetBaud_250_kbaud ; Set ( BusBaudrate, 250000 ); // CANopen, DeviceNet jump :SetBaudrateEnd ; :SetBaud_125_kbaud ; Set ( BusBaudrate, 125000 ); // CANopen, DeviceNet :SetBaudrateEnd ; return ; //************************* //!!!