CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Wed Sep 18, 2019 1:00 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
 Post subject: CANopen SDO_Write4
PostPosted: Tue Jan 29, 2019 9:25 am 
Offline

Joined: Tue Jan 22, 2019 6:35 pm
Posts: 4
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?

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;

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
);



ELSE
IF SDOWrite4.CONFIRM THEN
xEnable := FALSE;
SDOWrite4(Enable := xEnable);
ELSIF SDOWrite4.ERROR <> CiA405.CANOPEN_KERNEL_ERROR.CANOPEN_KERNEL_NO_ERROR THEN
//Error occured
xEnable := FALSE;
SDOWrite4(Enable := xEnable);

END_IF

xLastEnable := xEnable;

END_IF


Top
   
 Post subject: Re: CANopen SDO_Write4
PostPosted: Wed Jan 30, 2019 3:55 pm 
Offline

Joined: Mon Nov 03, 2014 7:15 am
Posts: 48
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited