BCD with MVM Instruction

RBergmann

Member
Join Date
Jun 2002
Location
California
Posts
258
In an effort to configure BCD switches on my CompactLogix input module. I thought the MVM (masked move), in Studio 5000, instruction might be the way to go. So, below is the way I configured two BCD switches on the same input module. I do not yet have a PLC to validate.

*******************
First BCD device using inputs:
I:2/1
I:2/2
I:2/3

MVM
Source Local:2:I.Data
2#0000_0000_0000_0000
Mask 14
Dest BCD_Wash1

*******************
Second BCD device using inputs
I:2/9
I:2/10
I:2/11

MVM
Source Local:2:I.Data
2#0000_0000_0000_0000
Mask 3584
Dest BCD_Wash2

*******************
Am I on the right track? I'm expecting to get values 0-7 from each BCD device.
 
Last edited:
Yes Masked Move MVM would be the most efficient way to transfer the bits to a stored word. One thing, you might want to clear (set to 0) the destination word just before the MVM just to make sure the bits are correct.
Just be aware as pointed out on this site, other programmers following you may not understand what you are trying to do with the MVM
 
Yes Masked Move MVM would be the most efficient way to transfer the bits to a stored word. One thing, you might want to clear (set to 0) the destination word just before the MVM just to make sure the bits are correct.
Just be aware as pointed out on this site, other programmers following you may not understand what you are trying to do with the MVM
Thanks for the feedback and tip, Gary ...


I've done a similar thing with other PLCs, but not with AB.
 
It's not clear exactly what you are trying to accomplish, but it seems like a bitwise AND or bit distributor (BTD) are worth looking at.
 
A Masked move will leave the bits at the same location, i.e., bits 1-3 and bits 9-11

If you were to look at your destination file for the bits 1-3 MVM, you'll see numbers 0,2,4,6,8, etc., not 0-7, as you want.

The BTD instruction, can take only the three bits (.01 to .03) and move them into the FIRST three bits of your destination word (BCD_Wash1.0, .1., and .2), resulting in the 0-7 numbers that you're after.
 
A Masked move will leave the bits at the same location, i.e., bits 1-3 and bits 9-11

If you were to look at your destination file for the bits 1-3 MVM, you'll see numbers 0,2,4,6,8, etc., not 0-7, as you want.

The BTD instruction, can take only the three bits (.01 to .03) and move them into the FIRST three bits of your destination word (BCD_Wash1.0, .1., and .2), resulting in the 0-7 numbers that you're after.
Almost sounds like a bit shift operation. That's not what I'm looking for. In my destination, I'm looking for a static value that changes only when I put the detented selector into a new position. I'm interpreting the BCD value in order to select the appropriate recipe program I wish to run. I'm looking for eight programs maximum so I will select program '0', program '1', ... program '7'.



Am I confused as to what the MVM will provide me?
 
As I said, a masked move does not change the bit location. So for your example with the BCD switch wired into bits 1, 2 and 3, a MVM will set the bits in the destination as such:
Bit    ... 5  4  3  2  1  0   (Decimal value)
----------------------------------
Data 1 0 1 0 1 0 (42)

Mask 0 0 1 1 1 0 (14)
- - ║ ║ ║ -
▼ ▼ ▼

Dest 0 0 1 0 1 0 (10)



So rather getting the value of 5 that you'd expect with the 1st and 3rd bits set, you get 10.

The BTD on the other hand, would take bits 1, 2 & 3, and move them into you destination words 0, 1, & 2, giving you the value of 5.

It's not a "bit shift" in that the source file is not affected, nor are any of the other other bits. It performs a copy, on a bit-by-bit basis, and changes where the starting location is.

It is the instruction you're looking for.
 
There seams to be some confusion about the masked Move
It only moves the selected bits it dos not cate about the value of the word
It will overwrite only the selected bits in the destination with the same bit value (1 or 0)
with the bit value of the selected source bits. It will not change any bits in the destination that are not selected in the mask. It you select bits 1,2,3 using the mask only what's in the source 1 or 0 will be copied to the same bits in the destination again as selected by the mask bit 1,2,3 bit 0, 4,5, 6 - 16 ect, will remain as they were befor the Masked Move

I hope this helps
 
There seams to be some confusion about the masked Move
It only moves the selected bits it dos not cate about the value of the word
It will overwrite only the selected bits in the destination with the same bit value (1 or 0)
with the bit value of the selected source bits. It will not change any bits in the destination that are not selected in the mask. It you select bits 1,2,3 using the mask only what's in the source 1 or 0 will be copied to the same bits in the destination again as selected by the mask bit 1,2,3 bit 0, 4,5, 6 - 16 ect, will remain as they were befor the Masked Move

I hope this helps
 
As I said, a masked move does not change the bit location. So for your example with the BCD switch wired into bits 1, 2 and 3, a MVM will set the bits in the destination as such:
Bit    ... 5  4  3  2  1  0   (Decimal value)
----------------------------------
Data 1 0 1 0 1 0 (42)

Mask 0 0 1 1 1 0 (14)
- - ║ ║ ║ -
▼ ▼ ▼

Dest 0 0 1 0 1 0 (10)



So rather getting the value of 5 that you'd expect with the 1st and 3rd bits set, you get 10.

The BTD on the other hand, would take bits 1, 2 & 3, and move them into you destination words 0, 1, & 2, giving you the value of 5.

It's not a "bit shift" in that the source file is not affected, nor are any of the other other bits. It performs a copy, on a bit-by-bit basis, and changes where the starting location is.

It is the instruction you're looking for.
If I understand correctly, using the BTD instruction, then my setup as in the original example would be


*******************
First BCD device using inputs:
I:2/1
I:2/2
I:2/3

BTD
Source Local:2:I.Data
2#0000_0000_0000_0000
Source Bit 1
Dest BCD_Wash1
Dest Bit 0
Length 3


*******************
Second BCD device using inputs
I:2/9
I:2/10
I:2/11

BTD
Source Local:2:I.Data
2#0000_0000_0000_0000
Source Bit 9
Dest BCD_Wash2
Dest Bit 0
Length 3

*******************
Am I getting warmer???
 
Last edited:
There are graphic representations of this instruction which illustrate what is being discussed in chapter 7 of the instruction set reference.
Thanks for your suggestion.


When dealing with RSLogix/Studio 5000 or any other Rockwell product, I do refer to the instruction manual before posting to this site. Perhaps it's due to old age or my denseness in understanding but I don't always find the Rockwell examples clear, and do find the PLCs.net board to be most helpful in giving an alternative explanation of Rockwell concepts, instructions and methodologies.


I greatly appreciate all the assistance this board has given me over the years.
 

Similar Topics

Hi. I’m doing a PV 1400e to PVP 7 migration and I don’t know how to convert the old 8digit BCD type from PB1400e into something that will work on...
Replies
2
Views
569
I'm working on converting an old PanelBuilder 1200 HMI application into FactoryTalk View ME. The PLC was an old SLC 5/02 with a scanner card for...
Replies
2
Views
1,075
I have a Cmore screen which is communicating to the DL06 in BCD and need to create a timer that works in real numbers for a test, I simply need to...
Replies
3
Views
2,085
Hello, I am stumped on how to tackle this issue. I am working on an Energy project on a solar / wind farm and I am trying to read in some data...
Replies
7
Views
2,452
Studio 5000 v24.11 on a 1769-L33ERM Pretty simple question today! I have a piece of testing hardware with four outputs wired to four inputs on my...
Replies
5
Views
1,609
Back
Top Bottom