Sign in to follow this  
Followers 0
Hugo Brown

Logix 5000 COP and data types

9 posts in this topic

Hi Guys, So I have a ControlLogix 5000 PLC which we are linking through a Prosoft Technology ILX56-MM card to a S7-300 plc. There are a lot of individual tags so I am trying to transfer it all across as an array of INTs. All good so far.. The problem comes when I try and transfer data from a User Defined data type tag which consists of all the data I’m trying to send (mix of int, bool and real) to the array of INTs. For some reason when I run a COP instruction to transfer the structure in to the INTs data types which are Real and Exponential sometimes take up 6 bytes but not always. To be clear: there isn’t data in all 6 bytes just the last 4, but there is still a two byte spacer in the middle of my block which doesn’t line up with the DB in my Siemens PLC causing all sorts of problems. So my question basically is: Is there any reason why the real type is some times (not always??) 6 bytes? Is there anyway I can limit it to 4? Is there anyway of seeing the specific memory locations which are being used by a tag? I’m hoping this will make me understand why it’s doing this. P.s like the forum, been reading it for a while but this is my first post. Any help anyone can give would be most appreciated and I’ll do my best to reciprocate.

Share this post


Link to post
Share on other sites
If it is a reasonable sized post the UDT setup screen. That may help explain why the UDT occupies the amount of space it does. Don't post a tag of that type. In the tag view it alphabetizes the elements. The primary thing to remember is that 4 byte (DINT, REAL) will always begin on a 4 byte boundary. An INT will occur on a 2 byte boundary. A SINT will occur on a 1 byte boundary. For minimum packing gather all similar types together then start from the smallest type to the largest type. But this may not fit the packing of the DB in the Siemens system. Edited by b_carlton

Share this post


Link to post
Share on other sites
Aha ok that makes sense now! Thank you. Unfortunately the structure of the Siemens DB is outside my control so I can’t do anything about the fact that a real is in word starting on byte number 46 (not divisible by 4). For anyone who happens across this in google, example below: So I have a User-Defined type as below: Int_no_01 INT Int_no_02 INT Int_no_03 INT Int_no_04 INT Real_no_01 Real Real_no_02 Real Int_no_05 INT Real_no_03 Real Real_no_04 Real If I use a COP instruction to put this in to a series of SINTs (makes more sense to me when they are in bytes) I end up with the example in the attached pic. So you can see that Real_no_01 and 02 go where you expect as they start on the 8th and 12th byte. Real_no_03 however lands on byte 18 but the controller wont put it there so it ends up on byte 20 leaving 2 bytes empty. Then Real_no_04 is fine because it’s been pushed back to the correct place So at least I know why its happening even if it doesn’t fix my problem. I’ll post again if I come up with some work around other than changing the Siemens block. Thanks for your help.

Share this post


Link to post
Share on other sites
bernie, you can switch this on and off - see the pic

Share this post


Link to post
Share on other sites
You might need to break the COP into a series of MOVs. Also I've got it in my head (don't know siemens that well) that the byte order might be reversed (Big-Endian, Little-Endian - see Wiki article). There is a SWPB instruction you may need to use.... Have fun....

Share this post


Link to post
Share on other sites
Thanks, daba, for the tip on alphabetizing of the tags. It really gets to me sometimes when I have placed them in a particular order for just the reasons we are discussing here. I'll check for that the next time it comes up. I love these forums.

Share this post


Link to post
Share on other sites
If you get weird gibberish, look again at daba's post about byte swapping. I have attached a sort of map showing how the S7 assembles bits/bytes/words/doubles. The byte with the highest address becomes the least significant byte within the word/double. This caused me no end of headaches when I first got started with Siemens hardware.

Share this post


Link to post
Share on other sites
Aha ! Just as I thought... Good diagram !

Share this post


Link to post
Share on other sites
Hi guys, thanks for the info about the data differences. you are right it did do that. I had the pro soft card transferring everything as INTS so I think it did an element of that conversion for me but I still need to swap round the words of a real and play with the bools to make everything line up and fall in to place. All a bit less neat than I was hoping for but it works and only need to do it once. Also good diagram, searched high and low on the Siemens website for something like that. And I have failed to come up with any other way of doing this so we are going to bite the bullet and change the s7 data structure, seems to be the only realistic way to make this work. obviously I could put all the tags in individually but we are talking thousands and a very slow interface, so that's not an option anyone is keen on.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0