Sign in to follow this  
Followers 0
moteam

Mitsh A series - conversion of 16 to 32 bit

5 posts in this topic

I am new to the Mitsubishi A series PLC. I have a question regarding the conversion of a 16 bit to 32 bit reg. From the information I have the Q series has an instruction to perform this operation, but it is not available on the A series. Would anyone have some sample code that would convert a single word to a double word or know of any way this can be done?

Share this post


Link to post
Share on other sites
if we are talking about 16 and 32-bit integers (i guess this is the format you are interested in) there is distinction between signed and unsigned integer(s). in unsigned integers all bits are used to present the value. this means that 16 bit register can be used to present values 0-65535 (0..64k or 0...2^16-1). in this case there is nothing to convert. if you are copying 16bit register to 32-bit register (in Mitsubishi that is pair of 16-bit registers) simply clear all bits in register representing higher values. in SIGNED integers, this also works but only for positive numbers. sign (+ or -) is the highest bit. in 16-bit register such as D13, sign is stored in bit D13.F If you have 32-bit representation such as in register pair D10, D11 then the highest bith in the two is represeting sign but this time that bit is in different register. note: signed integers still have same number of increments but range is split to positive and negative half (well, nearly half at least) which is (-32k...+32k).

Share this post


Link to post
Share on other sites
Ie. D10 has a value (16 bit: -32768 to 32767); let us say 1236. If you want to address this value as 32bit (long: -2 billion to +2 billion) then you have to ensure that the following register is 0. So for example this instruction: D+ D10 K200000 D12 D12 = 201236 Basically, a 32 bit register is two consecutive 16 registers. Most arithmetic functions have a D as a suffix to the normal command: 16 bit - 32 bit + D+ - D- * D* / D/ Hope this helps

Share this post


Link to post
Share on other sites
If the register is negative, this doesn't work. If negative you must copy HFFFF to upper register. Try the attached program snippet. Program copies 16 bit register D0 to 32 bit register D2.

Share this post


Link to post
Share on other sites
Or, if you're using IEC Developer, you just the "INT to DINT" function block. Job done.

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