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: 

Convert binary data to decimal in CAN XNET

I am using NI-XNET Read function to read CAN frames from port CAN1 , the data out put comes in cluster in binary format is there any function that I can use to convert the binary to decimal ? I prefer not to write another sub-vi to do conversion but using the existing functions that can use my .dbc file and parse all frames in decimal format.

 

Thanks.

0 Kudos
Message 1 of 12
(4,511 Views)

Hi shimbloo,

 

Are you wanting to pull the "payload" out of the can frame in a decimal format or represent the entire frame as a decimal? In the first case you can index the array of "data" and then unbundle the payload to get the actual data being sent in the frame, and it will come out as an array of U8. If you are trying to represent the entire frame itself as a decimal then could you describe a little more as to why you are wanting to do this and what the end goal is? I don't believe we would have a VI prebuilt to accomplish this but we might be able to work something out with more information.

 

Regards,

Peter W.

0 Kudos
Message 2 of 12
(4,501 Views)

Hi Peter,

 

I am trying to parse the entire frame including short name , time stamps , and frame data in decimal format , these data will be represented in my GUI for end user, the array of U8 need to be converted in engineering values, I would like to represent the most recent frames recived at the CAN port in a table on my front panel.

0 Kudos
Message 3 of 12
(4,497 Views)

You can typecast an array of integers to a floating point value, if the bytes are in the right order.  For example if the entire CAN packet is a single double-precision value, you could typecast that array of 8 bytes to a double-precision value.  Likewise you could take a subset of 4 bytes and typecast to a single-precision.  However, if your values are fixed-point or some other representation, you'll need to scale them from integers to floating point yourself.

0 Kudos
Message 4 of 12
(4,488 Views)

Thanks Nathand for the reply, my intention is not to subtract the data from CAN frame and process them but using the dbc file along with XNET functions to do it for me , I just learnt  there are conversion functions available in XNET ver 1.1.3 that do purpose, these functions are not available in earlier XNET versions.  

0 Kudos
Message 5 of 12
(4,475 Views)

Hello i think i have the same problem with the friend above.

 

We have a USB to CAN compact device from IXXAT and we have build a labview driver according to the manual to communicate and read through the CANBus.In our PCB we have two sensors which are measuring the distance and the software the PCB have give us the adc values of both sensors through the CANBus.The message we are taking through the CANBus can be in HEX,BINARY or DECIMAL format and we must transpose these data to voltage because that is our concern.How we can achieve this?Can you guide us?

 

I try several times to add a photo or even to send you the program i have create but for some reason i cannot upload

 

:

0 Kudos
Message 6 of 12
(4,409 Views)

Hey gtathatos,

 

This thread seems to be about converting binary data to decimal data in XNET. Your question seems to be quite different. You seem to be trying to convert the CAN data you are getting at the Bus to actual voltage data. If you could be more specific as to how you are acquiring your CAN data and what form you want it to end up as I will be able to be more helpful.

 

Thanks,

 

Doug B

Applications Engineer
National Instruments
0 Kudos
Message 7 of 12
(4,380 Views)

 

Yes Doug You are correct. We have a PCB and we have connected two inductive  sensors over the PCB which are measuring the distance and transpose it to voltage. The PCB has a software which transpose this voltage through an ADC and through the Can Bus we are reading the sensors .To communicate with the PCB  we are using a USB to Can device from IXXAT to communicate, we have build the Labview drivers and our problem as you mention is that we want to transpose this data to voltage. How we can do this? I try several times to upload photos or even the program we have create but for some reason the site is not letting me to do that. If you have an email i can send you the program we have create to tell us your opinion in this problem we have, we can also send you the Labview drivers and the datasheet of the sensor we are using.

0 Kudos
Message 8 of 12
(4,376 Views)

Hey gathatos,

 

You said "The PCB has a software which transpose this voltage through an ADC and through the Can Bus we are reading the sensors" you will need to know how that software transposes the voltage into CAN formatting in order to then read the CAN message and 'unpack' it back into voltage data. I would look into how that software performs this operation and maybe even get a hold of that manufacturer. 

 

Regards,

 

Doug B

Applications Engineer
National Instruments
0 Kudos
Message 9 of 12
(4,349 Views)

Hi Gathados,

 

you may need a *.dbc ( CAN data base) file or *.ncd ( CAN data base in LabVIEW application)  , *.dbc file maps all the received CAN messages to engineering format, each CAN massage has a unique ID that links to its information including conversion factor, offset, unit,..Etc in *ODBC file. There are several functions in CAN XNET that you can upload a *.dbc file and read CAN messages in engineering units, the *.dbc file should be provided by the PCB supplier or if you have the documentation you can make your *.dbc file using a CAN editor in MAX. Hope it helps,

 

H.T

0 Kudos
Message 10 of 12
(4,334 Views)