From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo 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: 

Decimal to hexadecimal number

Solved!
Go to solution

Hello All, 

 

I need to convert decimal number to hexadecimal number (not a hexadecimal string).

 

I need to send hexadecimal number to some microcontroller via LIN bus.

it demands to be a array of hexadecimal string.

Please check VI in attachment. 

 

Total byte should have 8 bits. 

0-5 bit are from red scale, and 6th bit is from toggle switch. 

 

How to convert to hexadecimal number???

It is not possible to send hexadecimal string, because ASCII is defferent for string and number.

 

Any help are welcome.

Thank you.

Milan

0 Kudos
Message 1 of 9
(3,240 Views)

Hi Milan,

 

I need to convert decimal number to hexadecimal number (not a hexadecimal string).

This is just a problem of display presentation (aka formatting options). The value stays the same!

 

I need to send hexadecimal number to some microcontroller via LIN bus.

it demands to be a array of hexadecimal string.

So you need a string and not a number?

 

Please check VI in attachment.

Can you attach your VI for LV2017?

 

Total byte should have 8 bits. 0-5 bit are from red scale, and 6th bit is from toggle switch.

What is the 7th bit?

 

How to convert to hexadecimal number???

check.png

 

It is not possible to send hexadecimal string, because ASCII is defferent for string and number.

Why isn't that possible?

Best regards,
GerdW


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

Hi Gerd,

 

Hi Milan,

 

I need to convert decimal number to hexadecimal number (not a hexadecimal string).

This is just a problem of display presentation (aka formatting options). The value stays the same!

 

I need to send hexadecimal number to some microcontroller via LIN bus.

it demands to be a array of hexadecimal string.

So you need a string and not a number? I need number.

This is first byte from 8 Byte in Lin data frame. Another byts are hexadecimal numbers form start.

 

Please check VI in attachment.

Can you attach your VI for LV2017? I saved in 2016. You  should be able to open.

 

Total byte should have 8 bits. 0-5 bit are from red scale, and 6th bit is from toggle switch.

What is the 7th bit? No information should be sent with 7th bit. It is false.

 

 

How to convert to hexadecimal number???

check.png

 

It is not possible to send hexadecimal string, because ASCII is defferent for string and number.

Why isn't that possible? I am not shure, if number and string has same value in ASCII code.

 

Thanks

 

0 Kudos
Message 3 of 9
(3,214 Views)

Hi Milan,

 

I saved in 2016. You  should be able to open.

No, still the LV2018 version…

 

This is first byte from 8 Byte in Lin data frame. Another byts are hexadecimal numbers form start.

A LIN frame consists of (upto) 8 bytes. The bytes contain some values from 0 to 255.

Their representation (decimal, binary, octal, hexadecimal) is irrelevant: the value is important!

 

No information should be sent with 7th bit. It is false.

So there is some information: the 7th bit is FALSE!

 

I am not shure, if number and string has same value in ASCII code.

ASCII codes also are just bytes. The value stays the same, only the representation changes!

An "A" is the same as 65d, 41x, 1000001b, or 101o…

Best regards,
GerdW


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

Hi,

 

please check attachment again...

 

So you are saining that I can send 8byte array of strings to LIN slave...

Ok, I can try that, but then all byts I need to convert to hexadecimal string.

 

Thanks

0 Kudos
Message 5 of 9
(3,199 Views)

Hi Milan,

 

So you are saining that I can send 8byte array of strings to LIN slave...

My LIN driver expects an array of byte, but no string.

Which LIN driver do you use?

 

Ok, I can try that, but then all byts I need to convert to hexadecimal string.

No, you don't need any "hexadecimal strings"!

All you need is an array of (upto) 8 bytes - and maybe the U8ArrayToString function…

 

I prefer logical functions to handle bit fields:

check.png

Please take note of all those constants and indicators with a visible radix display!

Best regards,
GerdW


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

Hi,

 

I use NI usb-8476 device and NI-CAN package for labview.

 

I find some example... Is this method OK?

 Capture.PNG

Best regards.

0 Kudos
Message 7 of 9
(3,182 Views)
Solution
Accepted by topic author milan87

Hi Milan,

 

I use NI usb-8476 device and NI-CAN package for labview.

NI-CAN doesn't use any strings for CAN/LIN messages. Why do you think so?

 

I find some example... Is this method OK?

It would be ok, when the author would have used the Auto-Cleanup function…

 

But it clearly shows: the message data consist of 8 bytes (aka U8 values). No need for any decimal/hexadecimal/whatever conversion!

Best regards,
GerdW


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

HI Gerd,

 

You have right. I manage to send signal by using decimal values U8.

 

Thank you for support.

0 Kudos
Message 9 of 9
(3,142 Views)