Sign in to follow this  
Followers 0
plcdp

trouble with bmov command

13 posts in this topic

Hello, I am having a bit of a problem with the BMOV command. I am using a FX3U PLC. I am trying to take a current value of a timer and move once per cycle to a block of registers to then pull an average from it. For some reason it moves the data to the head register, but no more. [bMOV T0 D300 K50] is the syntax. Am I doing something wrong here? Thank you, -Dave

Share this post


Link to post
Share on other sites
I think you want to use indexing, ie first time move to D300 then D301, then D302...etc. I believe what you are doing is moving T0-T49 to D300-D349

Share this post


Link to post
Share on other sites
correct, you need to use index register. on some CPUs number of Z registers is quite limited so check programming manual. basic form is [MOV T0 D300Z0] where Z0 is index register

Share this post


Link to post
Share on other sites
I see...thanks very much. -Dave

Share this post


Link to post
Share on other sites
You might consider using the SFWR and SFRD instructions which are essentially FIFO stack control. Use SFWR to push the value into the stack, then once the stack is full, use SFRD to pull the oldest value out to discard it. In the instruction, the first register of the block is your stack length, so you'll want to start with D299.

Share this post


Link to post
Share on other sites
This actually sound like what I want, I basically want to save 50 consecutive pieces of data and pull an average from them. The FIFO stack will be ideal because the oldest data will fall off. Thanks very much, -Dave

Share this post


Link to post
Share on other sites
No problem. I've used that setup for averaging, and it works pretty well. Just make sure to only average the values that are in the stack. For example, what will you do when you only have five pieces of data?

Share this post


Link to post
Share on other sites
One more thing, I would want to use a word shift instead of a bit shift to move the current accumulated time of a timer...correct? Thanks again for the help, -Dave

Share this post


Link to post
Share on other sites
Yes and no. If you want the stack functionality, use SFWR (shift write) and SFRD (shift read). If all you want to do is cycle the values through the stack, then use word shift (WSFR or WSFL). Bit shift cycles the bits within a word or range of bits. A word shift instruction would be simpler for your application, because you would only need the one instruction to push the new value in and the old value out. The SFWR and SFRD instructions give you the added advantage of knowing how many values are in the stack. If you are averaging cycle times and don't have to worry about having a half-full stack, then word shift is the way to go. Just realize that the average will be off for the first forty-nine cycles after you implement the code, unless you put in your own counter. In my application, I was averaging tank level over time, and needed to reset the average any time there was a power cycle, as it would throw off the average if the tank was manually filled or emptied while power was down. I had to reset the stack, and needed the average to be accurate, even when there was only one value in the stack.

Share this post


Link to post
Share on other sites
I got ya. Thanks for all the help, I have this working well now. Thanks again, -Dave

Share this post


Link to post
Share on other sites
......What??????

Share this post


Link to post
Share on other sites
Handled... We won't hear from that IP address again...

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
Sign in to follow this  
Followers 0