You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old November 13th, 2018, 05:49 PM   #1
rscott9399
Member
Norfolk Island

rscott9399 is offline
 
Join Date: Aug 2017
Location: in space
Posts: 86
why is my mov instruction not working?

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?
Attached Images
File Type: png forum1.PNG (14.4 KB, 149 views)
  Reply With Quote
Old November 13th, 2018, 06:30 PM   #2
Steve Bailey
Lifetime Supporting Member + Moderator
United States

Steve Bailey is offline
 
Steve Bailey's Avatar
 
Join Date: Apr 2002
Location: The boondocks of Western Massachusetts USA
Posts: 6,629
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).
  Reply With Quote
Old November 13th, 2018, 06:40 PM   #3
rscott9399
Member
Norfolk Island

rscott9399 is offline
 
Join Date: Aug 2017
Location: in space
Posts: 86
Quote:
Originally Posted by Steve Bailey View Post
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
  Reply With Quote
Old November 13th, 2018, 07:05 PM   #4
janner_10
Supporting Member
United Kingdom

janner_10 is offline
 
Join Date: Dec 2014
Location: Tewkesbury
Posts: 667
Just put on 3 different rungs.
  Reply With Quote
Old November 13th, 2018, 07:09 PM   #5
Steve Bailey
Lifetime Supporting Member + Moderator
United States

Steve Bailey is offline
 
Steve Bailey's Avatar
 
Join Date: Apr 2002
Location: The boondocks of Western Massachusetts USA
Posts: 6,629
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.
  Reply With Quote
Old November 13th, 2018, 08:23 PM   #6
OkiePC
Lifetime Supporting Member
United States

OkiePC is offline
 
OkiePC's Avatar
 
Join Date: Mar 2005
Location: ENE of Nowhere Oklahoma
Posts: 9,983
Quote:
Originally Posted by Steve Bailey View Post
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.
__________________
It's not all the variables I am most concerned with, it's the undiscovered constants.
  Reply With Quote
Old November 14th, 2018, 08:41 AM   #7
rscott9399
Member
Norfolk Island

rscott9399 is offline
 
Join Date: Aug 2017
Location: in space
Posts: 86
Thanks for the input guys, much appreciated
  Reply With Quote
Old November 14th, 2018, 08:56 AM   #8
proof
Member
United States

proof is offline
 
Join Date: Jan 2014
Location: Illinois
Posts: 153
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.
  Reply With Quote
Old November 14th, 2018, 09:13 AM   #9
tarik1978
Member
Morocco

tarik1978 is offline
 
Join Date: Mar 2010
Location: casablanca
Posts: 399
You can try something like this

  Reply With Quote
Old November 14th, 2018, 09:31 AM   #10
rscott9399
Member
Norfolk Island

rscott9399 is offline
 
Join Date: Aug 2017
Location: in space
Posts: 86
Quote:
Originally Posted by proof View Post
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
  Reply With Quote
Old November 14th, 2018, 09:40 AM   #11
rscott9399
Member
Norfolk Island

rscott9399 is offline
 
Join Date: Aug 2017
Location: in space
Posts: 86
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
  Reply With Quote
Old November 14th, 2018, 11:06 AM   #12
proof
Member
United States

proof is offline
 
Join Date: Jan 2014
Location: Illinois
Posts: 153
Quote:
Originally Posted by rscott9399 View Post
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).
  Reply With Quote
Old November 14th, 2018, 05:11 PM   #13
Chuck Woodbury
Member
United States

Chuck Woodbury is offline
 
Chuck Woodbury's Avatar
 
Join Date: Apr 2005
Location: Valley Springs, California
Posts: 64
Do you have a JSR in the main program to call that ladder to execute?
__________________
A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools. - Douglas Adams
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Source MOV instruction John Morris LIVE PLC Questions And Answers 6 October 22nd, 2015 02:59 PM
Micrologix 1400: AWT instruction is not working in CH0 asteroide LIVE PLC Questions And Answers 2 March 3rd, 2015 08:29 PM
MID instruction not working hazemabdulrab LIVE PLC Questions And Answers 8 November 7th, 2014 03:05 PM
MOV Instruction oxlacey LIVE PLC Questions And Answers 7 August 23rd, 2012 06:59 PM
FBD MOV Instruction BENNY LIVE PLC Questions And Answers 1 October 4th, 2005 03:19 PM


All times are GMT -5. The time now is 10:52 AM.


.