Jump to content

Recommended Posts

Posted
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
Posted
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
Posted
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.
Posted
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
Posted
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?
Posted
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
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...