Issue with COP Instruction

liberati

Member
Join Date
Sep 2013
Location
Atlanta
Posts
39
I am working on a project where I have to create an array where the newest value will pop into the first element of the array and then shift the other values down by one.

This is the setup.

I have a string array[5,48] where [0,0],[1,0],[2,0][3,0],[4,0] are the first elements of each array.

Each array corresponds to a set of data from a different location so [0,0] corresponds to the temp in the garage [1,0] corresponds to the temp in the kitchen etc.

So once I have my string I use a technique that I found on this site.

I copy array[0,0] - > tmp_array[0,0] and then copy tmp_array[0,0] -> array[0,1] and then copy the data in using mid or copy Final_String -> array[0,0].

And then use that same logic for all of the arrays.
Now the logic works exactly the way that it is supposed to except for one routine ( I made each Stack Handler per say into its own routine) in that particular routine instead of moving array[3,0] -> tmp_array[3,0] it moves array[3,0] -> tmp_array[3,16]
and then tmp_array[3,16] -> array[3,17]

I have talked with many people and none have a clue as to why this is happening. I have deleted the routine to see if the value is still getting set ( to eliminate the possiblity of an outside routine modifying the values and this is not the case) and it isn't. So the issue is within the routine itsef and as of now there are 3 copies and one JSR

so

array[3,0] copy to -> tmp_array[3,0]
tmp_array[3,0] copy to -> tmp_array[3,1]
final_string copy to -> array[3,0]

If you have any insight as to why this copy is messing up please let me know this is driving me insane.

Thanks,
JustAGreenHorn
 
Hi

Why not post the code and we can have a look at it because what you have done looks correct to me anyway

Donnchadh
 
I created a new routine with a new tmp_array and a new array and did the exact same thing and it worked as it should.

My mind is blown. I am using an Emulogix 5868 Controller to test with if that may be an issue.

I can post the code but as I said above the routine now works as long as I use a new tmp_array and a new array
so I now have tmp_array, array, new_array, and new_tmp_array.
 
i didn't look thoroughly into what you are trying to do but, i have had instances where using a COP instruction did not yield the results i expected, instead anywhere you are using a COP instruction replace it with a CPS instructions which stands for a (synchronous copy). If my memory servers me right what this instruction does is, first it acts the same way as a COP intructions but does not move or progress to the next part of the code till the copy instruction is done copying. So you can try that out
 
i didn't look thoroughly into what you are trying to do but, i have had instances where using a COP instruction did not yield the results i expected, instead anywhere you are using a COP instruction replace it with a CPS instructions which stands for a (synchronous copy). If my memory servers me right what this instruction does is, first it acts the same way as a COP intructions but does not move or progress to the next part of the code till the copy instruction is done copying. So you can try that out

Neither COP nor CPS is an instruction that you "kick into operation" and then get on with running the rest of the code. Very few instructions do this, they all execute to completion. Exceptions are things like MSG instructions, which trigger execution to be performed as a system task during the "System Overhead Time Slice".

Now there's the key to the difference between COP and CPS.

The "System Overhead Time Slice" (SOTS) that interrupts the user program at regular intervals to perform "system" operations, has the highest priority over everything, and can interrupt any instruction's execution, e.g. COP, when it is half-way through copying data from source to destination.

Most times that doesn't matter, but the COP may be the source or destination data for a message transfer that occurs during the SOTS.

Either way, if COP gets interrupted part-way through its copying, and the SOTS modifies the COP source or destination data, then you will get data corruption.

The idea of the CPS is that it can't get interrupted, so you can guarantee that a specific data area can't get "split".

I suspect the same thing happens with periodic or event tasks, although I havn't tested it or read anything to back me up.

Personally I would use CPS in preference to COP, at least I'm guaranteed to perform the copy to completion before anything looks at it.
 
Last edited:
@daba thanks on the clarified detail, @ liberati you can try using the CPS instruction as we have suggested but the I suspect that's not the issue because the original temp_array and array was only one place holder where the each different arrays like [0,0], [1,0] where all referring the same place holder so the fact that when you created another place holder like new_array and temp_ new array and assigned it specifically to [3,0] and you no longer have the issue tells me something

Sorry for typos I'm typing this on my phone
 

Similar Topics

So we have a few associates that like to write the date in the file name when saving the program to back it up. We back up the programs every...
Replies
12
Views
136
Hello there, I am having two plcs of mitsubishi (FX5U and R32ENCPU) and one GOT hmi (GS2110 WTBD-N) , I am able to ping all three devices from...
Replies
2
Views
77
Hi all smart and knowledgeable people.I have a hmi connected to 2 Plcs via ethernet.These 2 Plcs connected to control 2 systems in one machine...
Replies
2
Views
112
Hello everybody, I have Kinetix 5500 (2198-H040-ERS). I'm having issue with this drive. (I believe it's the drive/Kinetix and need confirmation)...
Replies
0
Views
71
Hi Everyone, I am facing an issue while installing the STUDIO 5000 in my windows 10 PC. During installation I am getting an error that " Error...
Replies
4
Views
197
Back
Top Bottom