Mitsubishi input to D register

mattrobbins

Member
Join Date
Aug 2007
Location
Michigan
Posts
14
I am new to programming Mitsubishi PLC's and GX Developer. I am trying to do, what seems to be simple, is take the status of a single input and use that to set the bit pattern in a word. EX:

X037
-| |------------(D50.0)

This does not seem to work. I have various inputs (not all sequential) that I want to combine together into a DWORD to create a state that can be stored and referenced.

Any help is appreciated.
 
It depends on which PLC you are talking to. The Q and FX3U do allow the addressing of bits in a word as you said. Bits would be .0 for least significant and .F for most, in hex.

If the PLC does not, you can use the MOV instruction to move nibbles of bits to a word or a word to bits. It's done like this:

MOV K4M0 D0 would move 16 bits starting at M0 into the 16-bit word D0.

MOV D1 K4M20 would move D1 to 16 consecutive bits starting at M20.
 
I am using a FX2(N). I know of being able to use the MOV in order to move a nibble's worth of info, but doesn't that just move the information into the lowest portion of the word? What do I do if I want to move information into the next 4 most significan bits of the word? Example: move x32-x35 status into the lowest 4 bits, then move x40-x43 into the next significant bits?

The only thing I have figured out is to move the entire block of inputs x14-x47 into a DWORD, restore it into 24 M bits and ignore all of the bits I do not want to keep track of. This seems wasteful of memory.

Also, if I do the above stated sequence, when I store the status of the inputs with the following command:

DMOV K6 D0 M50

will it only store the status of the inputs and ignore the lapses in between? i.e.: store x14-x17 then skip to x20..... or will it attempt to try to read the bits that do not exist (I assume it it the first statement). Sorry I have to ask this, but I have to learn to program, this without a PLC next to me try these commands out.

Thanks.
 
The following code solves your example:
MOV K1X40 D100 'Write X40-X43 to bits 0-3 of D100.
MUL D100 K16 D100 or MUL D100 H10 D100 'Shift them to bits 4-7 in D100 (each multiplication by 2 shifts all the bits in the word one position left, the leftmost bit is lost, the new rightmost bit is 0).
WOR D100 K1X32 D100 'Copy X32-X35 to bits 0-3 of D100 leaving other bits intact.
However, it is not obvious if not well commented, and must be rewritten for specific bits.
Using several tens of bits is not such a memory waste for FX2N, so I would do it more straightforward, as you mentioned in your post.
 
Last edited:
Thanks. It does seem like quite a bit of extra work to do something that simple. I am going to do the copy of all of the inputs. Is there any recommended way to pull that information out of the D register back into M registers? I tried a [MOVP D120V0 M50] and this is unacceptable.

Edit:

OK, put the -required- K4 in front of the M50 to allow the program to accept it. If there is still any helpful programming hint, it would be appreciated.
 
Last edited:

Similar Topics

In this sample programming, what does U4 mean? Any assistance would be greatly appreciated.
Replies
8
Views
298
I need to add a QX10 module to our PLC because we've run out of DI channels. Does this module need to be configured in a similar way to the...
Replies
7
Views
2,233
Hi, I'm planning to install a new Analogue Input module Q68AD-G. It will inserted on Rack 0 Slot 4. When it's installed, will the code recognise...
Replies
6
Views
2,439
Hi, I've got a Q68AD-G card (8 channel). I want to configure it for 0-10v analogue input. I've enabled the channel by using Un\G0. Then I used the...
Replies
4
Views
1,847
Hi, I've run out of analogue input channels on my Q68AD-G module. If I add a new Q68AD-G module and install it into a spare (blanked-off) slot, it...
Replies
2
Views
1,350
Back
Top Bottom