NathanG86

COP instruction conversion

8 posts in this topic

Working on my first programming project, converting a SLC500 program to compactlogix in Studio5000. Having trouble figuring out the correct way of converting my COP instructions. 

For example 

Copy File

Source #N48:250

Dest.    #N48:[N48:9]

Length 5

Share this post


Link to post
Share on other sites

Why not use the COP in CLX? 

It's been awhile but that looks like indirect addressing

Share this post


Link to post
Share on other sites

I probably didn't word that very well. I will still use the COP I just need help with what I need to do to fix the addressing. 

Share this post


Link to post
Share on other sites

In general:

When I'm converting old address-based programs to a tag-based processor, I usually transcribe the code manually (there usually isn't more than a couple of days' worth of this in the programs I usually work with).  Sometimes copy-paste works, sometimes it doesn't.  During the first pass, I go through and create tags with names like the addresses with a consistent pattern.  In this case, N48:250 would become N048_250 and N48:9 would be N048_009. During the second pass, I go through and rename the tags to something more reasonable.  I usually move the address text into the tag description until I'm 100% done with the conversion and proving, just so I can back-track and double check things with the original code.  In a similar vein, input I:20/5 would become I02005 in the new processor until I'm done, then I change it to PB_MotorStart or whatever.

 

In your case:

Since you're using indirect addressing here, it looks like they're using at least parts of the N48 data file as an array and the number stored in N48:9 is the index they want to start copying to.  I would suspect that this COP is part of an initialization routine since it's copying 5 elements from the end of N48 back to somewhere in the middle, but I can't tell for sure.  The simplest way to duplicate this is to create a tag in Logix 5k called "N48" of type SINT[x], where "x" is the number of elements in your N48 file. Since this is Logix 500, and you're copying from N48:250 with length 5, this "x" will be 256 in your case (Logix 500 only allows up to 256 elements per data file; in a PLC5, they can be much bigger).  You would declare the tag N48, type SINT[256].  This is then very simple to transcribe/translate, but kind of leaves you locked into this addressing pattern.  When you're all done, you can rename tags if you like.

In the long run, it may be better to re-do that part of the code.  I would need to see what's happening with N48 before I can suggest a way to do that.

Share this post


Link to post
Share on other sites

The corresponding data type would be INT, not SINT.

Also, the index variable should be DINT.

Share this post


Link to post
Share on other sites

Thanks for the information. Here is a picture of what I am working with. It's used in a routine for saving recipe data. Heats, positions, etc.

Capture.JPG

Share this post


Link to post
Share on other sites

The problem COP, you are copying to a destination that is a function of itself.  Can you buffer your index register, N48:9, to another register before COP?

Share this post


Link to post
Share on other sites

You are correct about INT vs SINT; I had a different platform on my brain. And I didn't know you couldn't use something like N48[N48[9]] in Logix 5k, so forget most of what I said...

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