LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert decimal to literal value in HEX

Solved!
Go to solution

I have a VSD speed setpoint that ranges from 0-4000 in HEX representing 0-100% of my max speed

 

I am trying to use a slider that is numerical 0-4000 that inputs the values over two bytes via RS485 as  40 00   which is 4000 in hex

I have all the comms working I just cannot figure out how to convert the literal decimal value to its hex format..

not 4000 in decimal = 0F A0

I want 4000 in decimal to = 40 00    

 

any help in the right direction would be greatly appreciated

0 Kudos
Message 1 of 11
(3,629 Views)

That's a crazy way to pass numbers.

 

Decimal to string.  Width of 4.

String to Hex.  Datatype U16.

0 Kudos
Message 2 of 11
(3,623 Views)

Would you mind showing some code?

Are you sending the data as a string?

What format does the data need to be in (4000 vs 40 00,etc)?

 

There are plenty of ways of converting numerics to strings and parsing them or manipulating them to look certain ways.

0 Kudos
Message 3 of 11
(3,620 Views)
Solution
Accepted by topic author davidgrayden

Hi,

 sure you can do that, but have you thought about setting the slider's range from 0 to 1 (or "100%") and use it only as factor in your BD?

 

Regards

ʍolɟɐʇɐp ʞuıɥʇ
0 Kudos
Message 4 of 11
(3,611 Views)

Hi David,

 

I just cannot figure out how to convert the literal decimal value to its hex format..

Are you REALLY sure about this decimal/hex thing?

Using your approach you are missing 37.5% of the possible setpoint range!

You could set values of x000-x999, but you miss all the range from xA00 to xFFF…

(Well, you miss even more values, like x0A0-x0FF, too!)

 

Would it help to just change the formatting of the slider to numeric hex format?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 11
(3,606 Views)

I am trying to create a dynamic PDU, 

4000 in hex is 100% of the setpoint speed

2000 is 50%

 

maybe I am thinking of it in the wrong way

Download All
0 Kudos
Message 6 of 11
(3,588 Views)

You are definitely thinking about it the wrong way.  It looks like 0-4000 hex is your range from 0-100%.  I'm not sure why it wouldn't scale to FFFF hex.

You don't want 4000 in decimal converted to 4000 in hex, the table doesn't show that at all.

 

The table is a somewhat confusing example because it never shows a "hex" character (A-F) except for 1% at A4.

 

Take your percentage, divide by 1000, and multiply times 4000, an integer constant formatted as hex display.

 

Example_VI

0 Kudos
Message 7 of 11
(3,580 Views)

I think this is what you are looking for...

 

image.png

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 8 of 11
(3,573 Views)

What's wrong just formatting the tick marks in hex? (make sure the slide datatype is U16)

 

HexedSlide.png

0 Kudos
Message 9 of 11
(3,558 Views)

I decided to go with a 0-100% slide bar with the correct correction factor

Download All
0 Kudos
Message 10 of 11
(3,543 Views)