LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert modbus registers

Solved!
Go to solution
Highlighted

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
(231 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
(213 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

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 3 of 7
(210 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
(154 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
(142 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
(134 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
(131 Views)