From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert modbus registers

Solved!
Go to solution

Hi,

 

I have a Modbus serial code, but my conversion is wrong, I have tried the solutions that I found in others posts, but I didn't have a success. My code is attached.  May someone help me? 

 

Thank you in advance.

 

0 Kudos
Message 1 of 7
(4,318 Views)

It looks fine to me.

 

So if something is wrong post a VI that has some data saved in it as default and tell us what you expect the values to be.

0 Kudos
Message 2 of 7
(4,300 Views)

We need to know that you are trying to convert and how...

 

See my reply to a similar question here and see if that is what you need to do

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 7
(4,297 Views)

Here is my table,

 

In this table you can see the conversion, my number is 65436, it should be -10C, when that number is positive for instance, the temperature is 30C, the number shown is 300, in this case need to divide by 10, but when the number is negative, I can't apply the same rule.

 

Thank you

conversionnumbers.png

0 Kudos
Message 4 of 7
(4,241 Views)
Solution
Accepted by topic author TgRamos

What does the monitor say about those registers?

 

Those don't look like paired registers, but only a single register.

 

It looks like you need to typecast your register to an I16 integer, then divide by 10.

 

RavensFan_0-1573827278838.png

 

Message 5 of 7
(4,229 Views)

That is perfect, Thank you so much RavensFan.

 

Yes, my monitor shows me a single registers.

 

May you suggest me some course, or tutorial about the registers conversion, I would like to understand more about it?

0 Kudos
Message 6 of 7
(4,221 Views)

One thing you can read if you haven't seen this is the Modbus spec  http://www.modbus.org/specs.php

 

The other thing to read is the manual for your device and see how they describe the data for each register your interested in.  This manual should have said that the U16 register contains the value in an I16 format and that you need to divide by 10.

 

The other thing to understand is the various ways numbers can be represented in computer memory.  8, 16, 32, 64 bit,  signed vs. unsigned.  integer versus floating point.  What 2's complement means as that is what is used for negative numbers in signed integers.

Message 7 of 7
(4,218 Views)