Posted 14 Mar 2014 I have a batch of bits and a batch of words (M2000-M2207 and D5000-D5207) that correspond with each other (when m2004 is high, a number is moved into d5004). However, the batch of words also gets data from another location. My question is, when I use a BKRST to reset the batch of bits, is there a way that I can move a 0 into the words that corresponded with the bits that were high....without a days worth of programming? Thanks. Share this post Link to post Share on other sites
Posted 14 Mar 2014 (edited) Possibly not the best way to do it, but try BMOV. Set up 16 data registers (could be any number, but 16 is decent choice) number them consecutively (say D100 to D115) and name them ALWAYS_ZERO_0 to ALWAYS_ZER0_15. Write some code that continuously writes 0 into these 16 registers using the MOV instruction to ensure that they are always zero (this may be overkill?) then use the BMOV command BMOV D100 K16 D5000 which will copy the contents of D100 to D115 into D5000 to D5015. (the K16 determines the number of registers) Repeat the BMOV command as many times as needed. Thinking about it, I suppose you could use 207 File Registers which would always be zero and use one BMOV commmand with a K value of 207, or for that matter, any other block of data 207 data registers that you know ill ALWAYS be zero? The key point is that the programme will never write values to the data registers that must be zero. Edited 14 Mar 2014 by Colin Carpenter Share this post Link to post Share on other sites
Posted 14 Mar 2014 If you don't have the ZRST instruction or similar I would rather do a FOR-NEXT loop and MOV 0 into all the registers (we're talking about just 208 loops so that's not a problem). Share this post Link to post Share on other sites
Posted 14 Mar 2014 I'm using GX Works 2, ladder. The problem is, at some point in time they will all need to be something other than 0. I was just hoping to find something to keep me from writing 208 rungs. Share this post Link to post Share on other sites
Posted 14 Mar 2014 Use a FOR-NEXT loop, make it loop 208 times and use a simple MOV instruction together with a Z index... That's five lines of code for setting all the registers to your defined value: 1. RST Z0 2. FOR 208 times 3. MOV ?? into D5000Z0 4. INC Z0 5 NEXT That's it. 1 person likes this Share this post Link to post Share on other sites
Posted 15 Mar 2014 (edited) Jonathon, if I understand correctly, you need to reset a group of consecutive bits, and at the same time reset the value in the corresponding registers if the bit was set. If so, the following will do both. It will use 4 consecutive auxiliary bits M100-M103. You can change their starting address if necessary. Replace the M8000 by the necessary condition. Edited 15 Mar 2014 by Sergei Troizky 1 person likes this Share this post Link to post Share on other sites
Posted 17 Mar 2014 Thanks y'all. I think I'm on the right track now. Share this post Link to post Share on other sites
Posted 20 Mar 2014 For setting a single value to a range of registers, there is no better option than BMOV. BMOV K0 D0 K100 writes 0 to 100 registers starting at D0. You can change the K0 to any number you want written to all of them. Share this post Link to post Share on other sites
Posted 21 Mar 2014 I do... Sorry. Guess I should not be answering questions at 11:30 at night.. Share this post Link to post Share on other sites