LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dealing with Positive and Negative Binary Values - Modbus Project

Hello,

 

I have a motion control system and I am receiving register values for velocity. I am receiving 2 register values, 1 for the integer (Register1) and 1 for the decimal (Register2).  Each register is via U16.

 

Example:

 

Register1 = 1

Register2 = 54823

 

Since I am dealing with U16:

(1x2^16) + 54823 = 120359 units/s

 

This motion system can also have a negative motion.  When this happens

Register1 = 65525

Register2 = ***** (arbitruary value decreasing as negative motion continues)

 

Since Register1 is maxed (1111 1111 1111 1111) this tells me that this system uses ones or twos compliment to deal with negative velocities.

 

How can I construct a VI to deal with both negative and positive velocities?  Any ideas?

 

 

 

Thanks,

Danny

 

 

 

0 Kudos
Message 1 of 5
(3,039 Views)

Use typecast and type cast your U16 value to an I16 value.

Message 2 of 5
(3,030 Views)

As an expansion to the recommendation by Ravens Fan you can do it like this.

 

combine u16 to i32.png

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 3 of 5
(3,024 Views)

Thanks rolfk!

 

Looks great, but the values I will be recieving in my registers are not definite.  They can and will be going negative and positive.  So my many concern is how to design this portion of the system to distinguish when the registers are showing a negative number vs when the registers are showing a positive number.

 

Danny

0 Kudos
Message 4 of 5
(3,007 Views)

ACtually!,

 

NVM it works great 🙂 Thanks rolf

0 Kudos
Message 5 of 5
(3,004 Views)