LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the hexadecimal value of a channel of a message on CAN bus using channel API only ?

Hi,
I'm trying to read the hex value of a channel. The channel belongs to a message on the CAN bus. I'm supposed to use only channel API.
 
In the VI, I'm using an index array to extract the 5th channel of a message. I need to get hex value of this particular channel on the CAN bus .
 
0 Kudos
Message 1 of 7
(3,785 Views)


@Lab V wrote:
"I'm supposed to use only channel API."

What does that statement mean, exactly???
0 Kudos
Message 2 of 7
(3,781 Views)
An important point: You need to remember that in the computer a number of just a pattern of binary bits that we humans tell the computer to interpret for us in a few set ways. LV can display a number in a variety of ways depending on the radix of the indicator or control holding it. However, this is only a display issue the underlying bit pattern that is the numbers real value remains unchanged.

So if this "conversion" is required for display only, wire the data value up to a numeric indicator, set the indicator's radix to hex, and you're done.

If you need to output this hex representation of the number to say a text file, either Format into String or Number to Hexidecimal String can make the conversion for you.

Mike..

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 7
(3,773 Views)
Hi Christian,

There are two sets of VIs for the CAN bus : Frame API and Channel API. Read this document for more details.

Wish you a nice day
0 Kudos
Message 4 of 7
(3,766 Views)

I'm supposed to use only channel API means, I've have 2 NI CAN ports. I'm using channel API for one of the ports and frame API for the other. This issue is with channel API. I tried to change the radix of the 'Value' to hex, but it doesn't work. 

-Arun

0 Kudos
Message 5 of 7
(3,766 Views)
What type of value are you expecting : float or integer ? CAN Read.vi returns an array of DBL and it is obviously not possible to change the display mode of a float to HEX.

If the expected value is an integer :
1. Change the representation of your indicator to the appropriate type -->
right-click on the indicator >> Representation
2. Make the radix visible --> right-click on the indicator (Front panel) >> Visible Items >> Radix
3. Change the display mode to hexadecimal --> right-click on the indicator >> Properties >> Format and Precision >> Hexadecimal
4. (Insert the appropriate conversion function between the index array and the indicator to avoid the coercion dot)

If the expected value is a float, then it makes no sense to display it in hex !
0 Kudos
Message 6 of 7
(3,760 Views)
Ok, if the value you are wanting to convert is essentially an integer that is being represented as a float, first convert the number into an integer datatype using something like the To Unsigned Long Integer function and then do the hex conversion. If the number coming back is a non-integer what exactly are you looking for in a hex representation? Are you wanting to see the IEEE floating-point representation of the value?

Mike..

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 7
(3,747 Views)