Codesys Question

WainDude

Member
Join Date
Aug 2010
Location
Edmonton
Posts
26
Good day, I have a Codesys question. I am using 2 IFM units, a controller and a display, both are programmed using Codesys. I want to use Canbus to send data between the two. How is the data transfer accomplished? In Modbus, you write data to the slave memory location, its not set up the same way in Codesys.

Is the data transfer location part of the Global Variables list in the master and slave in Codesys? I know the actual communication protocol is already set up by using the template for the devise, but I am wondering what data locations we are writing to.

Any thoughts.
 
WainDude,

The implementation will depend mostly on what IFM supports. They may have specific function blocks to implement for comms between the controller and display. Or, they may use something called network variables.

Hopefully they have a sample worked up.

You also could try posting your question on the CoDeSys forum at:
http://forum-en.3s-software.com/
 
There are three methods you can use.
1, CANOpen. You can setup one as the master and one as the slave and transfer messages via PDO. This works well, but is limited to 4 of 8 byte messages.
2, Raw CAN, this is using the basic raw canbus to transfer messages. If you use templates, you will see that this method is partially setup. Advantage is no restriction on number of messages. Disadvantage is you cannot use CANOpen IO on that Canbus line, or at least not without some advanced programming.
3, Network Variables, this is similar to what you were talking about with Modbus. It is also compatible with CANOpen, and uses up the unused bandwidth of the Canbus line.

Hope this helps

Doug
 
Doug, I like the idea of network variables, I know that in resouces there if a list of network variables, do I enter them in the controller and display here?
 
Actually, I had the same question as you a short time before you had it.
I don't kow exactly how to do it in detail, but if you can wait a few days, I should have worked it out. Otherwise, you will have to try and see.
 
I use network variables a lot in IFM codesyss aplications. You just configure the Global Variables in each node and configure the ID and If they shall be read or write and how often you should read/write.

It is possible to configure varaibles as both read and write which would be nice but I have not got it to work the way I want. Has anyone had any luck with it.
 
OK, checked this out and have got it working.

I have attached my projects. I used a CR0403 and CR0451 HMI for this, basically I had the two setup on my test bench, so it was easiest.

First, you make sure "Support network variables" is enabled in the target settings.

Then you setup blocks of global variables in the global variables data area. I called mine "Data_NW1" and "Data_NW2".
You then edit the object properties, clicking the "add network" button.

You have to setup whether the block is read, write or both. Also, if you use cyclic transmission, the interval to use. Finally, and this is important, you must shoose COB IDs that do not conflict with anything else on the network. Please also note that if your message goes over 8 bytes, the next COB ID will be taken.
Also, If a variable spans 2 COB IDs, then there is a chance it may change between the first and second half of the variable being transmitted. For this reason, IFM recommends that each set of messages is setup for 8 bytes with each COB ID setup, and that you do not span the COB IDs.
Finally, although you can setup variables for Read/Write, it is also discoraged.

If you have more questions, please post.
 
But if you have a RETAINed variable in the PLC is it possible to set it as WRITE in the PLC and READ/WRITE in the HMI? Is there no chance/risk that the value in the PLC gets overwritten with 0 at restart or so?
 
Hi Karsten,
Logically, if it is write only in the PLC, and read write in the HMI, then if the HMI writes it the PLC will ignore it. Both have to be read/write for this to work.
My guess is that for a read/write exchange to work, the variable would have to be sent on change, not cyclicly.
Finally, for the retained variables, possibly have both ends setup as read write, with the PLC transmitting cyclicly, and the HMI transmitting on change. I may try this out if I have time.
 
Hi everyone, I am now trying to get two ifm units to talk via Can using Network Variables. Can anyone take a look at my code and see what they think the problem is. I have attached the two files, one for the IFM CR2500 PLC and IFM CR1080 Display.

Thanks,
 

Similar Topics

I only have one POU in the program that is written in Function Block Diagram. It is only 12 rungs, so I could just re write it into structured...
Replies
14
Views
1,805
Hi all, I'm just starting out in the plc world. For school we had some introduction into codesys v3.5, basically we get given visualizations and...
Replies
9
Views
2,377
Hello. I'm wanting to use a boolean value associated with turning an output on to control the visibility of an image. The visibility option in...
Replies
6
Views
2,124
I'm having trouble locating string data to %MW registers. This does not appear to work: site_name AT %MW200: STRING[20];
Replies
3
Views
1,551
Hello! I think I have a basic question and I'm hoping someone can point me in the direction of a solution. I am new to PLC programming and my...
Replies
2
Views
1,638
Back
Top Bottom