CPS instruction question

hazemabdulrab

Member
Join Date
Feb 2014
Location
dearborn
Posts
46
I was having an issue where I would use the CPS instruction to copy a sint value to a string value( len=decimal , data= sint[82]) The data values in the string would get updated but the length value would stay at 0. Should't the length automatically update based on the values in the data values?
Capture1.jpg

so I just decided to add a cps instruction that would copy the length value of the result data to the length value of the string im copying too
Capture.jpg
 
I was having an issue where I would use the CPS instruction to copy a sint value to a string value( len=decimal , data= sint[82]) The data values in the string would get updated but the length value would stay at 0. Should't the length automatically update based on the values in the data values?
View attachment 34190

so I just decided to add a cps instruction that would copy the length value of the result data to the length value of the string im copying too
View attachment 34191

That is correct, copying data into the STRING's SINT array will not affect the Length member of the STRING data-type.

Your solution is fine, providing that the source of the Length value is a DINT tag. If it is not, use a MOV to convert it to the DINT data-type of the STRING's Length parameter.
 
I went through exactly that process a year or so ago :) something I learned in the process, almost as a side note, is that you're generally better to use the COP rather than CPS instruction - the CPS uses a whole lot more headroom than the COP as it blocks all other processes and checks after execution to ensure the data didn't change while you were copying it. So CPS is good when you're dealing with produced/consumed tags or i/o from an fieldbus device, and you need to make sure that the remote device doesn't update your data halfway through the copy and turn your results into gibberish, but if you're just copying data within a program the COP will execute much faster and affect other processes less.

A couple of technotes on the subject explain it better than I can:
TN 46251: choosing between COP and CPS
Access Level: TechConnect
https://rockwellautomation.custhelp.com/app/answers/detail/a_id/46251

TN 50235: How CPS and COP work
Access Level: TechConnect
https://rockwellautomation.custhelp.com/app/answers/detail/a_id/50235
 

Similar Topics

Using Studio 5000 Version 28.02 Professional Processor is a ControlLogix L73S with L7SP safety partner I always use the Synchronous Copy [CPS]...
Replies
15
Views
4,607
Dear all, In RS Logix 5000 i m using the CPS instruction to copy an UDT with 8 strings & 1 DINT tag in it. While the rung is executed sometimes...
Replies
2
Views
1,250
Hi, I wish to verify the CPS instruction using RSLogix 5000 v20 on Controllogix PLC. Is there any method i could do this and generate a...
Replies
1
Views
4,247
Gents, I've a recipe program which uses UDT which has 58 int's / bool / dint's. I like to copy UDT[0] to UDT [1]. What should be the lenght ...
Replies
9
Views
5,167
I very rarely work with STRINGS and can't remember the last time. I've attached a l5k file that contains four rungs where I'm simulating...
Replies
6
Views
1,721
Back
Top Bottom