Hi every one,
I have a 32bits Signed Integer coming from Ethernet/IP towards two 16bits GI.
I need your help to get it back in a 32bits Signed Integer.
What i've done does'nt work for a negative value.
R-30iB Mate Plus
Don't have Karel.
Thanks.
Hi every one,
I have a 32bits Signed Integer coming from Ethernet/IP towards two 16bits GI.
I need your help to get it back in a 32bits Signed Integer.
What i've done does'nt work for a negative value.
R-30iB Mate Plus
Don't have Karel.
Thanks.
Is this coming from a PLC? If so you can message it to a numeric register and have your 32 bit integer with no extra work.
No. It came from a vision sytem.
Let's assume the 32-bit signed integer is received on DI[1]..DI[32], configured as GI[1]=DI[1]..DI[16] and GI[2]=DI[17]..DI[32].
In such case, the DI[32] indicates negative value.
The signed 32-bit integer can be merged into R[1] as follows:
IF (!DI[32]), R[1]=(GI[2]*32768+GI[1]);
IF (DI[32]), R[1]=((GI[2]-65536)*65536+GI[1]));
NOTE: This is a corrected version of deleted post.
This one was tested on a live robot.
Thanks for your answer.
There is an error in the line for the positive value and paranthese mismach in the negative one.
The corrected ones are:
IF (!DI[32]), R[1]=(GI[2]*65536+GI[1]);
IF (DI[32]), R[1]=((GI[2]-65536)*65536+GI[1]);