Hi all,
i'm trying to send a sdo to a slave by using the following code... The SDO is transmitted correcly and also the slave received it correcly and answered with the acknoalge (60 xx xx xx xx xx xx xx) but the SDO_Write4.CONFIRM never rise up...
Do you have an idea about this strange behaviour?
IFxEnable=FALSETHENxLastEnable :=TRUE;xEnable :=TRUE;wsdo_index :=16#1400; // SDO write 0x1400 SUB index 1 Γ 7F 02 00 80 (Receive PDO disabled wsdo_subindex :=16#0001;SDOWrite4.DATA[1] :=16#7F;SDOWrite4.DATA[2] :=16#02;SDOWrite4.DATA[3] :=16#00;SDOWrite4.DATA[4] :=16#80;SDOWrite4(NETWORK:=CANbus.NetId+1, //CODESYSNetIdstartsby0(thenumberenteredintotheCANbusconfigurator); CiA405 NETWORK by 1; That is the reason why we have to increment it here.ENABLE:=xEnable,
TIMEOUT:=50, //TimeoutforSDOreadinms. Here: 0==>notimeout//DEVICE:=CANopen_Device_1.NodeID, //NodeIDofdestinationdeviceDEVICE:=126, //NodeIDofdestinationdeviceCHANNEL:=1, //SDOchannelwhichshouldbeused. 0meansautochanneling==>thenextfreechannelwillbeused. Itdependsontheslavewhichsettingsareworkingherebut0andchannel1isalwaysworking.
INDEX:=wsdo_index, //objectindexwhichshouldbereadSUBINDEX:=wsdo_subindex//objectsubindexwhichshouldberead);ELSEIFSDOWrite4.CONFIRMTHENxEnable :=FALSE;SDOWrite4(Enable :=xEnable);ELSIFSDOWrite4.ERROR<>CiA405.CANOPEN_KERNEL_ERROR.CANOPEN_KERNEL_NO_ERRORTHEN//ErroroccuredxEnable :=FALSE;SDOWrite4(Enable :=xEnable);END_IFxLastEnable :=xEnable;END_IF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think, you should call the function block "SDOWRITE4" cyclical, i.e. outside of the IF ... ENDIF query. If I take your code, the easiest way is to move the call below the END_IF:
IF xEnable = FALSE THEN
xLastEnable := TRUE;
xEnable := TRUE;
ELSE
IF SDOWrite4.CONFIRM THEN
xEnable := FALSE;
// don't call here !!!! SDOWrite4(Enable := xEnable);
ELSIF SDOWrite4.ERROR <> CiA405.CANOPEN_KERNEL_ERROR.CANOPEN_KERNEL_NO_ERROR THEN
//Error occured
xEnable := FALSE;
// don't call here !!!! SDOWrite4(Enable := xEnable);
END_IF
xLastEnable := xEnable;
END_IF
SDOWrite4(
NETWORK:= CANbus.NetId + 1, //CODESYS NetId starts by 0 (the number entered into the CANbus configurator); CiA405 NETWORK by 1; That is the reason why we have to increment it here.
ENABLE:= xEnable,
TIMEOUT:= 50, //Timeout for SDO read in ms. Here: 0 ==> no timeout
//DEVICE:= CANopen_Device_1.NodeID, // NodeID of destination device
DEVICE:= 126, // NodeID of destination device
CHANNEL:= 1, //SDO channel which should be used. 0 means auto channeling ==> the next free channel will be used. It depends on the slave which settings are working here but 0 and channel 1 is always working.
INDEX:= wsdo_index, //object index which should be read
SUBINDEX:= wsdo_subindex //object sub index which should be read
);
Just try, and good luck!
Alfred
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
i'm trying to send a sdo to a slave by using the following code... The SDO is transmitted correcly and also the slave received it correcly and answered with the acknoalge (60 xx xx xx xx xx xx xx) but the SDO_Write4.CONFIRM never rise up...
Do you have an idea about this strange behaviour?
Hi Stefno86!
I think, you should call the function block "SDOWRITE4" cyclical, i.e. outside of the IF ... ENDIF query. If I take your code, the easiest way is to move the call below the END_IF:
IF xEnable = FALSE THEN
xLastEnable := TRUE;
xEnable := TRUE;
wsdo_index := 16#1400; // SDO write 0x1400 SUB index 1 Γ 7F 02 00 80 (Receive PDO disabled
wsdo_subindex := 16#0001;
SDOWrite4.DATA[1] := 16#7F;
SDOWrite4.DATA[2] := 16#02;
SDOWrite4.DATA[3] := 16#00;
SDOWrite4.DATA[4] := 16#80;
ELSE
IF SDOWrite4.CONFIRM THEN
xEnable := FALSE;
// don't call here !!!! SDOWrite4(Enable := xEnable);
ELSIF SDOWrite4.ERROR <> CiA405.CANOPEN_KERNEL_ERROR.CANOPEN_KERNEL_NO_ERROR THEN
//Error occured
xEnable := FALSE;
// don't call here !!!! SDOWrite4(Enable := xEnable);
END_IF
xLastEnable := xEnable;
END_IF
SDOWrite4(
NETWORK:= CANbus.NetId + 1, //CODESYS NetId starts by 0 (the number entered into the CANbus configurator); CiA405 NETWORK by 1; That is the reason why we have to increment it here.
ENABLE:= xEnable,
TIMEOUT:= 50, //Timeout for SDO read in ms. Here: 0 ==> no timeout
//DEVICE:= CANopen_Device_1.NodeID, // NodeID of destination device
DEVICE:= 126, // NodeID of destination device
CHANNEL:= 1, //SDO channel which should be used. 0 means auto channeling ==> the next free channel will be used. It depends on the slave which settings are working here but 0 and channel 1 is always working.
INDEX:= wsdo_index, //object index which should be read
SUBINDEX:= wsdo_subindex //object sub index which should be read
);
Just try, and good luck!
Alfred