Register   |   Login

Print

[Technical Inquiry] 16-bit to floating value of the Analog Inputs read from ADAM-6717 by Modbus TCP

16-bit to floating value of the Analog Inputs read from ADAM-6717 by Modbus TCP

I am trying to read the 8 analog signals from the ADAM-6717 device. I can read them without problems by Modbus TCP connecting to their IP and Port from:
1) Advantech Adam.NET Utility located on the remote ADAM-5550.
2) A vb.NET program on my computer
3) Node-RED utility on the ADAM-6717 website.
Each digital signal I receive in one bit, each analog signal in 2 bytes. However, I am not able to interpret the 16 bit value of each analog. For example, analog channel 1 constantly shows 61866 (F1AA Hex.). However, when looking at the web page for ADAM-6717, that value shows up as 5.217 v. How do you make the transformation from 16 bits to that real number?

That is, what function is applied to 61866 to convert it to the physical unit measure of 5.217 v?

Could it be some specification of Half-precision floating-point format (16 bits)? Which one and how?

Please, can you help me?

Thanks,
Pedro

TOP

What range did you select for the AI channel?

TOP

I selected 0~10 v.

TOP

https://en.wikipedia.org/wiki/Li ... 80%93intercept_form

y=mx+b
where m = (10-0)/(65535-0) = 10/65535 , b = 0
if x = 61866 then y = 9.88VDC.

Something about your 'inputs' do not work to get an output of 5.217. Remember that it is an unsigned 16-bit value. If you treat it as signed it will 'roll-over' @ 32768 to -32767 which breaks the equation.

THe correct X for y=5.122 would have been 34190

TOP

In that case, the ADAM-6717 device must have a problem. On the one hand, it shows 5,217v on its website and on the other (Red_NODE) 61866.


Attach images where you see both values.


Thanks you for your interest,
Pedro
Attachment: Your usergroup does not have permission to access attachments

TOP

I changed the range for all AI channels From 0-10v to +-10v. However, the measurement does not change, it is still 5,217 v. and 61866

I don't understand anything!!!

TOP

Finally, I found out why the5,217 volt analog signal, when read by modbus tcp, marked F1AAhex:
5,217 formatted in single precision floating point is 40A6F1AA hex(https://gregstoll.com/~gregstoll/floattohex/)
So, it shows the two low significant bytes. But how can I read the high twobytes?.


Can anyone give me any ideas?
I use the adamTCP.Modbus (). ReadHoldingRegs function from AdamApax.NET ClassLibrary.
I show the vb.NET example program to read the analog inputs of theADAM-6717 device:
I have applied 5,216 volts to analog inputs 1 and 2 (5,216 = 40A6E979Hex) and the values output arrays are:

byteData={00E9;0079;00E9;0079;00F1;00AA;00DF;003B;00D7;000A;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000}
iData={E979;E979;F1AA;DF3B;D70A;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000;0000}
fData={-1,888282E+25;9,922354E+36;-1,517326E+14;0;0;0;0;0}

Imports Advantech.Adam
Module Module1

    Sub Main()
        Dim Ok As Boolean
        Dim byteData() As Byte = {}
        Dim iData() As Integer = {}
        Dim fData() As Single = {}

        Dim adamTCP AsAdvantech.Adam.AdamSocket
        Dim IP As String ="192.168.2.159"
        Dim NPort As Integer = 502

        adamTCP = New AdamSocket
        adamTCP.SetTimeout(1000, 1000, 1000)

        If adamTCP.Connect(IP,Net.Sockets.ProtocolType.Tcp, NPort) Then 'ADAM-6717
            Ok =adamTCP.Modbus().ReadHoldingRegs(1, 32, byteData)
            Ok =adamTCP.Modbus().ReadHoldingRegs(1, 16, iData)
            Ok =adamTCP.Modbus().ReadHoldingRegs(1, 8, True, fData)
           adamTCP.Disconnect()    'disconnect the slave
        End If
    End Sub
End Module

TOP

Quick search in Advantech Support Portal