I'm using SoMachine, which runs Codesys V3. I'm using a Schneider M258 connected to 3 Leeson SM2 drives via CANopen.
I have imported the EDS, but now I'm not sure what to do. Read through the SM2 manuals on CANopen, but still can't come up with a way to talk to it.
What I'm trying to do is tell the drive to start/stop and set a speed.
I'm pretty sure I need to use the SDO_WRITE function block to write to some SDO's, but not sure how I would send the values.
Hopefully someone has some insight on this because I've been searching for days and can't come up with a solution
thanks!
Hi,
use CAA CIA405 library:
Snippet: Declare ciaSDOWrite4 : CiA405.SDO_WRITE4; usiNetwork : USINT := 1; // NetId = 0 <=> Network = NetId + 1 = 1 xEnable : BOOL; udiTimeout : UDINT := 0; Device : CIA405.DEVICE := 1; // Addressed device // range 0 β¦ 127 // 0 means local device
wIndex : WORD := 16#1020; bySubIndex : BYTE := 16#02; aData : ARRAY[0..3] OF BYTE := [16#11,16#22,16#33,16#44]; usiDataLength : USINT := 4; xLastEnable : BOOL;
Code:
(This example code writes a 4 byte object with a SDO Write Expedited Transfer)
ciaSDOWrite4( NETWORK:= usiNetwork, ENABLE:= xEnable, TIMEOUT:= udiTimeout, DEVICE:= Device, CHANNEL:= 1, INDEX:= wIndex, SUBINDEX:= bySubIndex, DATA:= aData, DATALENGTH:= usiDataLength, );
IF ciaSDOWrite4.CONFIRM THEN xEnable := FALSE; ciaSDOWrite4(Enable := xEnable); ELSIF ciaSDOWrite4.ERROR <> CiA405.CANOPEN_KERNEL_ERROR.CANOPEN_KERNEL_NO_ERROR THEN //Error occured xEnable := FALSE; ciaSDOWrite4(Enable := xEnable); END_IF
xLastEnable := xEnable;
hope this snippet is useful... BR Edwin
Log in to post a comment.
I'm using SoMachine, which runs Codesys V3. I'm using a Schneider M258 connected to 3 Leeson SM2 drives via CANopen.
I have imported the EDS, but now I'm not sure what to do. Read through the SM2 manuals on CANopen, but still can't come up with a way to talk to it.
What I'm trying to do is tell the drive to start/stop and set a speed.
I'm pretty sure I need to use the SDO_WRITE function block to write to some SDO's, but not sure how I would send the values.
Hopefully someone has some insight on this because I've been searching for days and can't come up with a solution
thanks!
Hi,
use CAA CIA405 library:
Snippet:
Declare
ciaSDOWrite4 : CiA405.SDO_WRITE4;
usiNetwork : USINT := 1; // NetId = 0 <=> Network = NetId + 1 = 1
xEnable : BOOL;
udiTimeout : UDINT := 0;
Device : CIA405.DEVICE := 1; // Addressed device
// range 0 β¦ 127
// 0 means local device
Code:
(This example code writes a 4 byte object with a SDO Write Expedited Transfer)
ciaSDOWrite4(
NETWORK:= usiNetwork,
ENABLE:= xEnable,
TIMEOUT:= udiTimeout,
DEVICE:= Device,
CHANNEL:= 1,
INDEX:= wIndex,
SUBINDEX:= bySubIndex,
DATA:= aData,
DATALENGTH:= usiDataLength,
);
IF ciaSDOWrite4.CONFIRM THEN
xEnable := FALSE;
ciaSDOWrite4(Enable := xEnable);
ELSIF ciaSDOWrite4.ERROR <> CiA405.CANOPEN_KERNEL_ERROR.CANOPEN_KERNEL_NO_ERROR THEN
//Error occured
xEnable := FALSE;
ciaSDOWrite4(Enable := xEnable);
END_IF
xLastEnable := xEnable;
hope this snippet is useful...
BR
Edwin