Sign in to follow this  
Followers 0
Jonathon

Batch Help

11 posts in this topic

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
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 by Colin Carpenter

Share this post


Link to post
Share on other sites
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
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
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
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 by Sergei Troizky
1 person likes this

Share this post


Link to post
Share on other sites
Thanks y'all. I think I'm on the right track now.

Share this post


Link to post
Share on other sites
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
Don't you mean FMOV ??

Share this post


Link to post
Share on other sites
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

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