From 12:00 AM CDT Sunday, October 17 - 11:30 AM CDT Sunday, October 17, ni.com will be undergoing 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: 

Join 2 modbus registers

Solved!
Go to solution
Modbus TCP.png

Good Afternoon!

I have tried joining 2 modbus registers to generate a single floating type with decimal point. I am working with modbus tcp and I want to read the position of the encoder of a servomotor, everything works fine when the numbers are positive but when the position of the encoder becomes negative is when the problems begin. I am going to put an example. when my first modbus register is = 17615 and the second is = 7 (1 = 17615, 2 = 7) and together with the numbers it generates a number that if it is the correct position of the encoder (476367), so far so good. But when the encoder becomes negative, my first modbus register is = 24635 and the second is = 65533 (1 = 24635, 2 = 65533), it should give me a value of (-17.20) but labview generates another very different number. remove the main code and just leave an example with an array of 2 numbers which is exactly the same when modbus gives me the 2 registers. I've seen examples but they don't work for me, can someone help me?

Code Images Annex

0 Kudos
Message 1 of 7
(613 Views)

If you need negative numbers then you shouldn't you be using SIGNED integers?

 

What is the device and do you have a manual for it?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 7
(612 Views)

If you are expecting a value of -17.20, obviously all your "blue" solutions are out unless there is some scaling (or FXP interpretation) involved. As has been said, we simply need to see the manual.

(and if you primary number is integer, you probably want to simply change the indicator to I32 or convert to I32 for further processing. Do you know the byte order?)


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 3 of 7
(602 Views)
Solution
Accepted by topic author BibianoFlores

@BibianoFlores wrote:
but when the encoder becomes negative, my first modbus register is = 24635 and the second is = 65533 (1 = 24635, 2 = 65533), it should give me a value of (-17.20) 

Wild guess (you can change the 10k to SGL if you want a SGL result, but it does not matter for the value):

 

altenbach_0-1631549316180.png

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 4 of 7
(596 Views)
Solution
Accepted by topic author BibianoFlores

Kyle97330_0-1631549405089.png

Divide that by 10000 and you get -17.1973, I think that's probably it.

 

Edit: Was beat to it, the previous post wasn't there when I clicked Reply...

Message 5 of 7
(595 Views)

Thanks Friend, It worked perfect. I appreciate your cooperation.

0 Kudos
Message 6 of 7
(575 Views)

Thanks Friend, It worked perfect. I appreciate your cooperation.

Kyle97330
altenbach

Either of the 2 solutions worked great

0 Kudos
Message 7 of 7
(574 Views)