06-14-2012 03:48 PM - edited 06-14-2012 03:54 PM
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
06-14-2012 04:35 PM
Use typecast and type cast your U16 value to an I16 value.
06-14-2012 05:18 PM - edited 06-14-2012 05:19 PM
As an expansion to the recommendation by Ravens Fan you can do it like this.
06-15-2012 08:27 AM
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
06-15-2012 08:39 AM
ACtually!,
NVM it works great 🙂 Thanks rolf