why is my mov instruction not working?

rscott9399

Member
Join Date
Aug 2017
Location
in space
Posts
114
Hey guys

What is wrong with this rung?

I am just trying to sequence something down a FIFO stack

the one second pulse is working fine

The move should just be copying things down the array

When i run this and i look at the array the values are all the same

they should be all one numeric number behind the other.

what am i missing?

forum1.PNG
 
Have you tried reversing the order of the MOV instructions? Make the top one the MOV from array element 1 to array element 2, leave the middle one as is, and make the bottom one the MOV from current time to array element 0. I believe that parallel MOVs are executed from top to bottom, so that when the CPU executes the middle MOV, old_clock(0) already has the value from current_clock which it MOVs into old_clock(1).
 
Have you tried reversing the order of the MOV instructions? Make the top one the MOV from array element 1 to array element 2, leave the middle one as is, and make the bottom one the MOV from current time to array element 0. I believe that parallel MOVs are executed from top to bottom, so that when the CPU executes the middle MOV, old_clock(0) already has the value from current_clock which it MOVs into old_clock(1).


Thanks

I will try that now
appreciate the reply
 
When you put them on three different rungs you can be confident in the order of execution. The order of the MOV instructions will then definitely need to be reversed from the way they were originally presented.

This is correct, but you can be certain that they will execute from left to right and top to bottom with A/B. The nested branches can lead to some lack of clarity, but if you double click the "power rail" to the left of the rung, the mnemonic code representing the rung will display, and reading it from left to right will reveal the order of execution.

What you're doing could also be done with a single COP instruction, but again, you will want to copy from element[1] to element[0] with a length of one less than the length of the array, and then move the newest data into element[x] where s is the number of items you want "FIFO'd". This will assure that the data is not overwritten, but shifted.

If you COP element[0] to element[1] length 3, then internally, the instruction will copy element[0] to element[1], then element[1] to element[2], and then element[2] to element[3] thereby filling up the array with the same value originally found in element[0]. Moving the data in the reverse order avoids this overlap and acts just like a FIFO without the overhead of the FIFO instructions.
 
If your one second pulse is on for one second, your logic will copy the current clock over every scan, and then they will be the same until the clock changes. You need to trigger the move logic only one time when the timer is done.

While your move logic is 'correct', it is not 'obvious', as most people are used to going top to bottom, and won't catch that the move rungs are nested, and not parallel. But rather than nesting, or putting on separate rungs, just put them in series on one unbranched rung.
 
You can try something like this

206l8pc.png
 
If your one second pulse is on for one second, your logic will copy the current clock over every scan, and then they will be the same until the clock changes. You need to trigger the move logic only one time when the timer is done.

While your move logic is 'correct', it is not 'obvious', as most people are used to going top to bottom, and won't catch that the move rungs are nested, and not parallel. But rather than nesting, or putting on separate rungs, just put them in series on one unbranched rung.

how do you mean top to bottom?

I am shifting the "old_clock" array down

from top to bottom?

I just tried the 3 different rungs and its still not working
 
you guys are the best! seriously....
what a great forum this is

how bizzare is that?

so im more of a c c++ guy and i would of never guessed this

So i left them all in one rung

I did the shift in reverse order like you all suggested and its fine now.

Thank you very much
 
how do you mean top to bottom?

I am shifting the "old_clock" array down

from top to bottom?

I just tried the 3 different rungs and its still not working

The logic that you shown that does the move as you intend. However, it looks like it executes on multiple scans. I don't know for sure, as you didn't show the logic that controls timer2. Add an ONS after the XIC(One_Second_Pulse).
 

Similar Topics

Anybody have a clue as to why this MOV statement isn't working properly?
Replies
7
Views
2,443
Is K4M101 a constant? Is K7 a constant? What does this instruction do? Thanks
Replies
19
Views
5,006
I have to create a sample mov template in add on instruction.I just want to know the list of tags which is used to create a mov logic instruction...
Replies
6
Views
2,053
Good evening! I am having trouble making this work. I need the counter to count up to 3 seconds if the DI_01 is off, and to count up to 30s if...
Replies
2
Views
2,081
Hi everyone, I have a short question about BLKMOV instruction, illustrated in the image below. I have the same piece of code in STEP 7 (ET200S)...
Replies
2
Views
2,655
Back
Top Bottom