LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Syntax reading CAN data serially

Solved!
Go to solution

R/All

I am reading vehicle ECU data (CAN bus) through serial module - 3onedata CAN232. 

I am getting values in labview as Hex, Code shown in image attached. 

But I am  not able to interpet/convert the data as shown in dbc file attached vehicle EOL testing.txt (can convert to .dbc and read in CANdb software)

This file is generated in another software directly reading CAN data.

 

My queries are,

1. How to give proper sytax to read data in labview?

2. I want to use some data for calculation like voltage and current, how to find the particular data in the serial read if it stays in hex?

3. Serial read data changes every time, how to gather and manipulate data for query 1 & 2?

 

0 Kudos
Message 1 of 5
(855 Views)
Solution
Accepted by topic author vaibhavsl

Hi vaibhavsl,

 

so what do you know about CAN communication? Heard of long/short ArbID, message payload and so on?

Can you read and understand dbc files from reading at the text file (or using a DBC editor like CANdb++)?

 

Example:

BO_ 1034 Battery_1_40A: 8 Vector__XXX
 SG_ current_sign1 : 23|1@0+ (1,0) [0|1] "" Vector__XXX
 SG_ Battery_Current_Pack_1 : 22|31@0+ (0.01,0) [0|21474836.47] "mA" Vector__XXX
  • "BO" is "Botschaft" (German) or "message".
  • "SG" is "Signal"/"signal".
  • 1034 (decimal) = 040A (hex) is the ArbID of the message, I see that also in your "received string" image…
  • The "8" in this line describes the length of the message payload: CAN can transport upto 8 bytes usually.
  • "23|1" means "starting from bit #23 in the message for 1 bit" you will find the value for signal "current_sign1".
  • "(0.01,0)" describes the scaling factor/offset for the signal.
  • "[0|21474836.47]" describes the resulting value range after applying the scaling.
  • "mA" is the unit for the signal.

Read the manual for your CAN interface to learn how to read message by message (or blocks of messages) correctly. There you should also find an explanation on how to separate signal values from message payload…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(837 Views)

R/All


I am using a follwoing program to hex data string (file trimmed for size to attach) to convert it into number which i got normal text.

This is CAN bus data. I am attaching CAN bus read file in hex format too. Also CAN bus DBC file is attached.

 

1. I am not sure while for calculation from data, whether for 8 bits i can directly take 4bits of HEX. ( open as CAN bus DBC file.dbc)

2. Or should i take 2 bits of HEX while data manipulation and add next bits?

3. I want take only fix bits from dbc to read current and voltage for each battery pack. Which are shown in DBC viewer.

0 Kudos
Message 3 of 5
(807 Views)
Solution
Accepted by topic author vaibhavsl

Hello vaibhavsl,

 

perhaps this can help you:

String conversion

 

 

Greets, Dave
0 Kudos
Message 4 of 5
(801 Views)
Solution
Accepted by topic author vaibhavsl

Hi vaib,

 

please don't send PMs, post all your questions (and data) in the forum. And please stick with your thread instead of creating multiple threads for the same problem!

 

See this:

It's a very basic way of converting CAN data to meaningful values…

(I'm not sure I'm implemented the conversion correctly as I don't have a CAN-DBC editor available right now. I just implement based on experience and memory. Are the values in the image resonable?)

 

General suggestion:

Don't convert the CAN data to hex-formatted ASCII strings, but handle the message payload data as U8 array (or as U64 entity when you work with default CAN messages)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 5
(780 Views)