Move Thru Mask

Guest

Guest
G
Could someone here give me an simple "read as not too techie" explantation of how the move thru mask instruction actually works.
if not too much trouble possible an example or two of practical uses of the same. I can't quite get the A.B. explanation in rsl. Any help would be apreciated
 
0000 1010 SOURCE

0000 0011 MASK

0000 0010 RESULT


The Source Word and MASK are "AND"'d to produce the result.

That is,... SOURCE "AND" MASK = RESULT

Simple enough?

The bits in the MASK that are ON indicate the bits that you want to see from the SOURCE.


(18)
 
Last edited:
If this is the MVM command we're discussing, another aspect of the command ,not clearly shown in Terry's example, is that bits in the result which are not covered by the mask are preserved. A pure AND would reset the non-masked bits in the result. So the actual equation would be:

RESULT = (RESULT AND (NOT MASK)) OR (SOURCE AND MASK)



SOURCE 0101 0101
MASK 0000 0011
ORIGINAL RESULT 1010 1010
RESULT 1010 1001


 
Oh no, not again.

Terry, we've gone over this before. http://www.plctalk.net/qanda/showthread.php?s=&threadid=731

The only way that a MASK is like an AND is if the SOURCE word and RESULT word are the same memory address. Otherwise, it's quite different.

1) You have to pay attention to what the RESULT memory address was before the instruction with the mask is used. If the mask has a '0' in that bit location, then RESULT bit location will remain unchanged, regardless of the data in the SOURCE.

2) If the mask has a '1' in a bit location, then the RESULT bit location will be exactly the same as the Source bit location. Not AND'ed, but MOVED.

I think of a mask like a filter. Only the data that I want (both the ones and zeros) will come through; the rest stays behind.



Where may they be used? Any place that you need to pick out select bits from within a word:

• Picking out select alarms from within a word of alarms, to drive a horn if the result <> 0

• Splitting an ASCII character word pair into its two individual ASCII characters, so that they can be converted into something else (Real numbers, Hex equivalents).

• Used with Peter's tidbit technique, to count the number of bits in a word quickly and efficiently (Repeatedly masking out the lowest set bits).

• ???
 
Thanks all for your responses. I am going to study this a little, (as I get time), Looks facinating. Got to go for now, machines need me.
Thanks again!
 
Allen,...

This is definitely not a case of "A Rose is a Rose, by any other name".

It's not my fault that AB does not seem to know what a MASK (Mask Operation) is.

They have obviously decided to Ba$tardize the Mask Operation into something... well... A-Ba$tardized. (Hello, Ken!)

The MASK Operation is, and always has been, just as I have described, since the age of programming was born. A MASK is a "filter"... just as it is at a masqarade-ball... the EYES show through... the rest of the face doesn't... by design!

Look at what Bernie said... (I assume he knows what he speaks of.)

What he described ain't no MASK Operation... at least not your everyday, run-of-the-mill MASK Operation.

Something that programmers and programmer-wanna-be's need to know is...

Your basic MASK Operation is performed by using a simple "AND" instruction as I have described.

ANYBODY can explicitly do the extra steps that A-B has included in their particular ba$tardized version of the MASK Operation.

So... it's an extra step or two, but you will have performed a "REAL" MASK Operation in the process, and come to know that there are ways to do things besides marching to the A-Ba$... tune!

WE ARE TALKING COMPUTERS HERE, PEOPLE!!! ...Not just PLC's according to A-B.


(57)
 
I see a tangent looming...

Originally posted by Terry Woods
WE ARE TALKING COMPUTERS HERE, PEOPLE!!! ...Not just PLC's according to A-B.

Yes, you are, but notice the thread starter's question:

Originally posted by some unknown guy
Could someone here give me an simple "read as not too techie" explantation of how the move thru mask instruction actually works.
if not too much trouble possible an example or two of practical uses of the same. I can't quite get the A.B. explanation in rsl. Any help would be apreciated

As Bernie pointed out, it seems that this guy is trying to understand the MVM instruction, which A-B calls the "Masked Move" instruction (Note the addition of the word MOVE). A-B does not have a "Mask Without Move" instruction as far as I know... :unsure:

beerchug

-Eric
 
OK - let's get some sanity here. AB has a move (MOV) instruction. They also have an AND instruction (which Terry also labels as MASK). Finally they have the Masked Move (MVM) instruction as described above. Apparently the operations performed by the MVM were wanted enough that AB supplied it as an additional instruction. If you want to do the MASK instruction which Terry describes, just do the AND instruction and be done with it.
 
be careful what you ask for ...

here’s my best shot at the
... not too techie ...
explanation that you asked for ...

first of all ... here is a breakdown of all eight possible bit combinations for the source, mask, and destination entries for a MVM (Masked Move) instruction ...

[attachment]

in column A ... the 0 in the source wants to move down to the destination ... but it can’t because there’s a 0 in the mask ... the 0 in the mask disables the move ... so the 0 which was already in the destination does not change ... the final result of column A is still a 0 ...

in column B ... the 1 in the source wants to move down to the destination ... but it can’t because there’s a 0 in the mask ... the 0 in the mask disables the move ... so the 0 which was already in the destination does not change ... the final result of column B is still a 0 ...

in column C ... the 0 in the source wants to move down to the destination ... and it can because there’s a 1 in the mask ... the 1 in the mask enables the move ... so the 0 that was already in the destination gets overwritten by the 0 from the source ... the destination does not APPEAR to change ... the final result of column C is still a 0 ...

in column D ... the 1 in the source wants to move down to the destination ... and it can because there’s a 1 in the mask ... the 1 in the mask enables the move ... so the 0 which was already in the destination is overwritten by the 1 from the source ... the final result of column D is now a 1 ...

in column E ... the 0 in the source wants to move down to the destination ... but it can’t because there’s a 0 in the mask ... the 0 in the mask disables the move ... so the 1 which was already in the destination does not change ... the final result of column E is still a 1 ...

in column F ... the 1 in the source wants to move down to the destination ... but it can’t because there’s a 0 in the mask ... the 0 in the mask disables the move ... so the 1 which was already in the destination does not change ... the final result of column F is still a 1 ...

in column G ... the 0 in the source wants to move down to the destination ... and it can because there’s a 1 in the mask ... the 1 in the mask enables the move ... so the 1 which was already in the destination is overwritten by the 0 from the source... the final result of column G is now a 0 ...

in column H ... the 1 in the source wants to move down to the destination ... and it can because there’s a 1 in the mask ... the 1 in the mask enables the move ... so the 1 that was already in the destination gets overwritten by the 1 from the source ... the destination does not APPEAR to change ... the final result of column H is still a 1 ...

continued in next post ...

mvm.jpg
 
you asked for an example ... this ladder demonstrates a fairly common use of the MVM (Masked Move) instruction in an SLC processor ... if you’re interested seeing it done in a PLC-5 processor, then post again ...

the task is to take the hours and minutes readings of the SLC’s wall clock and show them on a common four-digit 7-segment LED display ... think: “alarm clock” type readout ... this type of display is often wired to a 16-point output module ... the signal is usually sent over in a BCD (Binary Coded Decimal) format ... we’ll use military (24-hour) format for the hours reading ...

[attachment]

note that the decimal value "5155" which appears at output O:3.0 would be displayed as "1423" in the readout's BCD format ... that's the "14" for the hours (2:00 pm) and "23" for the minutes ...

if you have any questions about this program post again ...

continued in next post ...

mvm ladder.jpg
 
Last edited:
and here’s the secret handshake on how to decipher any “Mask” entries that you might run into in a ladder logic program ...

consider the example “0E7A3h” ...

first ... the “h” at the end stands for “hexadecimal” ... ignore it for now ...

next: the “0” at the beginning is just there to confuse you ... don’t let it ... ignore it for now ...

that leaves “E7A3” as our mask ...

now find an UNUSED integer in the processor’s memory ... post again if you’re not sure how to tell if the integer is unused ... now change the radix to “Hex/BCD” ... type in the mask value ... now change the radix to “Binary” ... now you’ll see the mask’s binary bit pattern (example: “1110011110100011”... note: you can even do this offline – you do not need a processor to use this conversion feature ...

[attachment]

note that a mask of “0FFFFh” translates as “all bits enabled” ... the mask “0FF00h” (used in the Hours/Minutes program above) specifies “move the bits at the high end of the word (bits 8-15) ... but not the bits at the low end of the word (bits 0-7)” ...

let us know if you need any more detail ...

mask.jpg
 
Last edited:
Ron

Very well put. I have never actually used the Masked Move instruction but have seen it often. Although I have never had to completely decode it, I think I can now. Another great post that will be saved in my fav's

thanks,
Bob
 

Similar Topics

So I'm pretty green when it comes to troubleshooting in the field so bear with me. We have a Danfoss valve that opens/closes from an analog output...
Replies
23
Views
892
Hi. This is pretty basic but I'm struggling to find an efficient solution. I have a float value of let say 666.555 that I want to move / split...
Replies
3
Views
146
hi, I got a plc S7-1200 with SEW movitrac **** and i need to program something ridiculous if my application reaches sensor 1 then my SEW has to...
Replies
0
Views
177
Afternoon, I have a DB in TIA Portal V16 that is optimised. I cannot change this. There is an array inside that block which consists of 3000...
Replies
9
Views
1,036
Hello, I am working on an application that inserts a splined shaft into a 'gearbox'. The shaft is rotating slightly to allow engagement of the...
Replies
8
Views
1,157
Back
Top Bottom