Advertising

KUKA INT to REAL

  • Hello,


    I was looking for a solution on data type conversation, like i have krc4 connected via ProfiNet, i have defined a variable for data like

    SIGNAL VAR $IN[X]  TO $IN[X+32] in a length of a type REAL so i receive a bits of a number ak(01111110 00101011 01010100 00100010) in a signal view i see the value of INT like 2116768802 i just don't know how to define it like REAL to get ak (354.325)

  • AD
  • You will have to either send mantissa and exponent separately (or treat 32 bits as two different numbers) or use modified binary to decimal conversion with decimal places included (depending on the precision you have at the source)


    e.g. 32, 16..4, 2, 1, 0.5, 0.25, 0.125

  • 1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • one common workaround is to just convert floating point to a fixed point format:

    - when sending multiply REAL by some number such as 1000 and place result into an integer

    - when receiving, place value into REAL and divide by same factor (1000 or whatever).


    multiplier does not have to be powper of 10 but this makes convreted value directly observable.

    that is a bit crude and does mean data loss but... it is simple and often can be used in robotic applications since one can still get acceptable resolution and value range.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Thanks for additional informations, yes but there was a problem with multiplayer option because of signed var you have limited range if you have a 432,54 number you can get out a 43256 and is over a range of a max 32757. Upper code looks like a thing to try. Tnx

  • functions i posted work fine and do not compromise range or accuracy.

    btw. KUKA uses 32-bit integers so although signed, they go past +/-32k limits common to 16-bit SINT.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

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