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 Mon Sep 16, 2019 3:55 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Nov 13, 2012 6:52 pm 
Offline

Joined: Mon Feb 27, 2012 6:13 pm
Posts: 23
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!


Top
   
PostPosted: Fri Nov 16, 2012 6:49 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3447
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


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 2 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