Sign in to follow this  
Followers 0
Andy_P

Multiple word shift register

9 posts in this topic

Hi, Can anyone tell me if there is a preferred method of producing a multiple word shift register? I need to shift blocks of ten data memories for a few shifts, maybe seven or so. I have achieved this at present by using several successive XFER instructions, transferring ten words to the next ten word slot. This works fine, but if I needed to shift a larger number of times, this would mean a large number of XFER's, and that just seems a little cumbersome. I can't seem to find a dedicated instruction for this (on the CJ1M at least), so I was just curious to know if there are any more elegant solutions. Thanks, Andy.

Share this post


Link to post
Share on other sites
I will have to look throught the instruction list again.... but off the top of my head try the Block Move... it may help you do what you want. I will get back to you when I have time to look at the manual. I am pulling 16 hr days right now so

Share this post


Link to post
Share on other sites
Would this have anything to do with the other post regarding TXD-RXD and Protocol Macro? If so, are you trying to buffer the output of the serial reception?

Share this post


Link to post
Share on other sites
Not exactly Jay, although I am using the shift register with data collected via rs232 in this case. Once I have received a message and performed a few operations on it, I transfer it as a block of ten words to the beginning of my shift register. The shift register block is at D2010 to D2019. On each cycle of the machine, I shift blocks of ten words in the following manner: @LD W160.01 <-- 'Shift' trigger bit. XFER(070) &10 D2080 D2090 XFER(070) &10 D2070 D2080 XFER(070) &10 D2060 D2070 XFER(070) &10 D2050 D2060 XFER(070) &10 D2030 D2040 XFER(070) &10 D2020 D2030 XFER(070) &10 D2010 D2020 This works perfectly ok, and for only a few shifts like this, there is probably no point in changing it. However, if I needed to shift data many more times it would mean an extra XFER for each shift. Also, if blocks of more than ten words were required, I assume the increase in PLC cycle time would start become noticable? I am just curious to know if this is the only way to do it, or if there is an instruction I have missed? Once again, many thanks for your prompt replies, Andy.

Share this post


Link to post
Share on other sites
Two things come to mind: ASFT - Asynchronous Word Shift Register and SSET =- Set Stack. 1. ASFT(017) sets aside a defineable block of DMs to be used as a FIFO or LIFO stack. Your XFER command will then shift each word one location down every scan until the data bumps against non-zero data. Advantage - all the shifting is automatic. Disadvantage - Non-Zero Data and only one location shift per scan. 2. SSET(630) sets aside a defineable block of DMs to be used as a FIFO stack. Your XFER command would have to be broken up into ten PUSH(632) commands to individually "push" the RS232 data onto the stack. The Data can be retrieved with ten individual FIFO(633) commands to " pop" the data off the stack. Advantage - Extremely flexible because of multiple commands that operate on the stack (PUSH,FIFO,StackInsert,StackDelete, StackOverwrite, Stack Size, etc.) - Operates in one scan, Large stack sizes (65535 max.) Disadvantage - All operands in Hex except for the Data, more ladder involved, etc.

Share this post


Link to post
Share on other sites
I did something like this recently with only 1 XFER instruction on a CQM1-CPU21. LDNOT TIM0 TIM 000 #100 LD TIM000 @XFER(070) #500 D500 D510 Timer 0 was set to 10 seconds, and so every 10 seconds the data in DM 500 to DM999 would be shifted to DM510 to DM1009, essentially shifting the data 10 DM registers at a time. I do recall the scan time increasing substantially with the number of words being transferred, but I'm sure this must be better than using 50 separate XFER rungs. Your CJ1M will still be quite fast compared to my old CQM1. Hope this helps.

Share this post


Link to post
Share on other sites
Good concept! So basically you overlay the entire area except ten words up in DM word numbers. I'd never thought of that one. With today's processor speeds, scan time is becoming negligible.

Share this post


Link to post
Share on other sites
Good concept indeed ECSI. Very slick! Why didn't I think of that? They say the best ideas are the simplest. Many thanks guys for your help and suggestions. Andy.

Share this post


Link to post
Share on other sites
Nice one, I can use that too, so simple yet very effective

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