Sign in to follow this  
Followers 0
RobinA

Data value to Switch on M Flags

8 posts in this topic

Hi I'm sure there is an easier way or simple command to do this rather than the long winded compare i've done. We have a PC linked to PLC, (The PC handles data logging along with other CAD type functions) PC Sets D1000 to 1 : I Want M100 on PC Sets D1000 to 2 : I Want M101 on PC Set D1000 to 3 : I Want M101 and M102 on etc etc The Binary number in D1000 is reflected by Head address M100 + 8 These Flags are set to trigger various other control functions with in System ta

Share this post


Link to post
Share on other sites
Do you mean: PC Sets D1000 to 1 : I Want M100 on PC Sets D1000 to 2 : I Want M101 on PC Set D1000 to 3 : I Want M100 and M101 on ? If so someone will be along with an answer very soon. If you mean: PC Sets D1000 to 1 : I Want M100 on PC Sets D1000 to 2 : I Want M101 on PC Set D1000 to 3 : I Want M101 and M102 on etc. You may be stuck with compares.

Share this post


Link to post
Share on other sites
Looks like you need the ENCO DECO instruction. Which CPU are you using ? Edited by Gambit

Share this post


Link to post
Share on other sites
If you're trying to get the bit pattern in D1000 to map to M100 and following, then you can just use a move command: MOV D1000 K4M100 The KxMy style of addressing works with a range of bits. The "x" indicates the number of nibbles (4-bit chunks) that you are addressing, and the "y" indicates the first bit you are looking at. So in my example above, K4M100 is looking at M100 - M115. It's mapping the bits in D1000 to those addresses. The "x" can be any number from 1-8, though anything over 4 requires using the double (D) version of the instructions.

Share this post


Link to post
Share on other sites
For M100-M107 (8points) it has to look like MOV D1000 K2M100. Of course, if the topicstarter want really to get the binary interpretation of D register in M area (as Verganic suggested). Edited by Inntele

Share this post


Link to post
Share on other sites
That's the one I was thinking of.. MOV D1000 K4M100. I've not come across ENCO /DECO before - interesting. (Maybe someone should do a "Instruction of the day" thread.)

Share this post


Link to post
Share on other sites
I use the DECO instruction occasionally to create a simple state machine: DECO D100 M100 K4 In this, D100 is my step number from 0-15. Only the first four bits are being decoded, so numbers above 15 will be decoded according to the first four bits only. M100-M115 are my step bits. I would then use M100 for standby, M101 for step 1, etc. These days I usually just use comparison instructions for step routines. Using the above method creates a smaller (i.e. faster) program, but is harder to understand for the uninitiate. Plus it's platform specific, and I work in enough different platforms that I try to keep things generic.

Share this post


Link to post
Share on other sites
Thanks guys, that was what I was looking for. ! didnt realise you could just simply : MOV D1000 K2M100

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