LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Kvaser CAN txt to numeric array

Solved!
Go to solution

Hello, I have some CAN plots taken with Kvaser in a txt. I want to make some graphs with Labview. In order to do that, I want to transform the txt data to numeric data. I have attacht a picture where it shows what I have and what I want to do. My txt i very large, so when I work with it like a string, it costs to me a lot of time. I don't know if there is a fastest way to change my txt to a 2 dimension array of numeric. 

 

labview CAN to numeric.png

0 Kudos
Message 1 of 12
(714 Views)

I have tried "Read Delimited Spreadsheet". The problem is that in every line, the delimiter between a number and others are spaces (but the number of them varies). Also, the lines with the ID being 3 numbers are different to the 4 number ones. So I don't know how to make it. If Labview had the posibility to consider consecutive spaces as one would be perfect.

0 Kudos
Message 2 of 12
(673 Views)

LVNinja_0-1711388483788.png

Play with the function spreadsheet string to array

 

LVNinja_1-1711388548799.png

 

0 Kudos
Message 3 of 12
(663 Views)

It can get a little messy, but I went with the assumption that the final number is always in the last column.

Read into Array.png

Minions_0-1711394368997.png

 

 However, if your CAN Measurements & Characteristics are properly defined, this should automatically be retrieved as a 2-D array of DBL.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 4 of 12
(651 Views)

It looks like you are looking at raw frames from a CAN trace.  The 2nd column in the data is the arbitration ID, and the 3rd column of real data is the number of bytes in the payload.  This is then followed by that many bytes.  

 

Graphing this information is usually not very useful.  It is raw bytes of a stream of data.  Is it displaying temperature? Voltage? What are the units?  Is it display status where a 0 means it is in park, and a 1 it is in drive?

 

To understand this conversion you usually need a DBC or CAN Database.  It is a file that defines what the bytes mean.  I talk about this in Part 5 of my CAN blog.  Using XNet, or my conversion library you can convert from raw bytes in a trace, to the engineering units.  This can then be graphed more easily.  Without a DBC, and without the scaling information you are going to have a real hard time trying to understand what you are looking at, and graphing it.

0 Kudos
Message 5 of 12
(643 Views)

As a first step, switch your string indicator to a fixed-width font (e.g. Consolas), so we can see if the numbers have fixed relative positions. Alternatively, a typical text file with your string.

0 Kudos
Message 6 of 12
(629 Views)

Hello, I understand the format of the CAN and as I have already seen in these traces, graphing the bytes won't be useful because there is very different data on them. Anyway, as I don't have the DBC of it (I wish I had it, so it was going to be so easy), I am reverse engineering the data. As seen with some test, I can see the gear where the car is in a specific byte, so that's why I want to graph it, cause I can see when it changes. Of course will be better to graph the bits corresponding to every signal, but I don't know it. I will be evolving my program when I discover different signals.

0 Kudos
Message 7 of 12
(614 Views)

The problem working with strings is that is too slow. I have tried it but it may cost an hour with my string.

0 Kudos
Message 8 of 12
(605 Views)

@electronic_lab wrote:

Hello, I understand the format of the CAN and as I have already seen in these traces, graphing the bytes won't be useful because there is very different data on them. Anyway, as I don't have the DBC of it (I wish I had it, so it was going to be so easy), I am reverse engineering the data. As seen with some test, I can see the gear where the car is in a specific byte, so that's why I want to graph it, cause I can see when it changes. Of course will be better to graph the bits corresponding to every signal, but I don't know it. I will be evolving my program when I discover different signals.


You should be using a database for this.  If you look at the blog post I made you can see the XNet Database Editor.  It lets you create your own database, and visualize what bytes and bits, from the payload make up the signals.  This also allows for custom scaling if needed.  As you discover signals you can put them into your database.  Then you can still use them to perform the conversion from raw frames into channels.

Message 9 of 12
(590 Views)

Perfect, i will check it. I finally solved my problem open the txt in excel and saving it as delimited by tabs, so I can open it in Labview with Read Delimited Spreadsheet.

0 Kudos
Message 10 of 12
(587 Views)