how split double integer into two integers

jugenzhu1963

Member
Join Date
Jun 2006
Location
toronto
Posts
72
Hi
I have an application need send some position data to Mitsubishi A800 drive via Modbus rtu. I have double integer value in plc. There are two integers to hold that data in drive side. Each integer value range is 0-9999. I need split the double integer into two integers. Let's say if the double integer value is 123456 i need one integer hold 12 and another hold 3456. i can't figure out how to do it. The plc is fx5u.
Please help me out. thanks.
 
If that is really what you want to do (sounds wrong, but..)
Integer Divide 123456 by 10000, that gives the 12.
Multiply the 12 by 10000, and subtract that from the original number, that gives the 3456.

IF on the other hand, you actually need to SPLIT the double into two integers with the same binary representation, mask off the value by 0xFFFF0000 shift right (for little endians) 16 bits for the high word, and mask off by 0x0000FFFF for the low word.
 
Last edited:
If that is really what you want to do (sounds wrong, but..)
Integer Divide 123456 by 10000, that gives the 12.
Multiply the 12 by 10000, and subtract that from the original number, that gives the 3456.

That is how we humans understand numbers on 10-base, on PLC integer is 0-65565 or -32768..32767 (depending if integer is unsigned or signed) and splitting with 10000 gives wrong result for drive ;)
Time to shift numbers or calculate differently
 
Thanks. i check the drive manual again. from what i understand rdrast is right. just divide by 10000 i can get what i want. i also attach the page from manual.
 

Similar Topics

Hi all I'm trying to convert an S5 program to S7 and part of the old S5 program calls FB242. This was a special function block that had the...
Replies
11
Views
10,689
hey all, I am struggling with a problem here and out of ideas on how else to achieve the desired result. I have a monitor inside a machine with...
Replies
0
Views
121
Hello everyone. I have an PLC L35 (fmw 16) with address 192.168.1.1 and too many connected ethernet devices (3 hmi, a lot of ethernet port, asi...
Replies
11
Views
731
Basic question: I don't understand why Network 4 is split over two lines. I want it to appear like for Network 3, i.e. all on one line. Does...
Replies
1
Views
748
Hello I have a project to record temperature from thermocouple and store it to memory card, the problem is my client didn't provide new...
Replies
11
Views
2,933
Back
Top Bottom