Reading Float32T
Seb
✭
Hello!
I´m having problem reading an input (32FloatT)
I have tried both group and analog input and neither work.
The value I´m sending and then reading can be understood through reading the bits individually and then using an IEEE-754 Floating Point Converter to get the correct decimal value.
But whenever i try reading the whole bytes in either analog or group input the values doesn´t make any sense.
Any ideas how to solve this problem?
0
Answers
-
Are you talking about on the robot side or PLC side?Lee Justice0
-
The robot side, I´m not using a PLC in this case0
-
It might be due to a different endianness of the bytes. Can you try a device mapping like this in the I/O Signal configuration?:
24-31, 16-23, 8-15, 0-70 -
Hello,Here what I use:
! Returns Float value from Group Input (unsigned double integer) FUNC num GInputToFloat(VAR signalgi giValue) VAR rawbytes rbData; VAR num nResult; PackRawBytes GInputDnum(giValue),rbData,1\IntX:=UDINT; UnpackRawBytes rbData,1,nResult\Float4; RETURN nResult; ENDFUNC
You needs a GI with 32 bits.
0 -
I have now tried the 24-31, 16-23, 8-15, 0-7 configuration but unfortunately it did not work. How should I think regarding the signal scaling here?
Converting it in a function won´t be doable in our current application I´m afraid0 -
You're saying the values you receive don't make sense. Can you give an example of a decimal value you're sending, the corresponding bits and what you're seeing when you read the AI/GI signal?0
-
AI = 128-135,120-127,112-119,104-111, max log value = 1000, max bit value = 2147483647, min log = 0, min bit = -2147483647GI = 128-135,120-127,112-119,104-111Bit wise in order = (128-135,120-127,112-119,104-111)Decimal = 1000AI = 767,49GI = 1148846000Bit 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 1 0 0 0 1 0I´ve noticed that if i read the bits as (128-135,120-127,111-104,119-112) with bit 111 as the sign bit, i get the correct decimal value using an online float calculatorin that case bit=0 1 0 0 0 1 0 0 0 1 1 1 1 0 1 00
-
Try bits 135-104 or bits 104-135 mapping. Since they are contiguous, this is allowed. Allowed values for max bit value are -2,147,483,648 to 2,147,483,647.
Do you have these bits mapped as AI and GI at the same time or only one at a time for different trials? Since you have no PLC, what device is sending these values to the robot?Lee Justice0 -
I have them mapped as two different signals, one AI and one GI at the same time.
Decimal still 1000;AI 135-104 =247483600AI 104-135 =31300GI 135-104 =576585728GI 104-135 =31300I´m using an IO - link master to connect a stepper motor to the robot (over EtherNet/IP)0 -
Is your data Float or Integer?
0 -
My data coming in is float32T0
-
So you should find incomprehensible value in your GI.Take a look at this site:To make sure you don't have byte swap, look at your PLC data in hexadecimal view and compare it with your GI.Then if it's correct, you can use my function shown inhttps://forums.robotstudio.com/discussion/comment/35954/#Comment_35954
0 -
Mapping those signals as both at the same time could be part of your problem. To eliminate that variable I suggest that you only map as one or the other.Lee Justice0
-
Unfortunately the problem still remains, I´ve tried only mapping as one or the other and tried all kinds of combination for the mapping0
Categories
- All Categories
- 5.5K RobotStudio
- 391 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 305 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 3 RobotStudio AR Viewer
- 773 RAPID Programming
- 17 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings