03-25-2024 02:33 AM
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.
Solved! Go to Solution.
03-25-2024 09:27 AM - edited 03-25-2024 09:30 AM
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.
03-25-2024 12:42 PM
Play with the function spreadsheet string to array
03-25-2024 02:20 PM - edited 03-25-2024 02:30 PM
It can get a little messy, but I went with the assumption that the final number is always in the last column.
However, if your CAN Measurements & Characteristics are properly defined, this should automatically be retrieved as a 2-D array of DBL.
03-25-2024 02:39 PM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-25-2024 06:11 PM
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.
03-26-2024 01:51 AM
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.
03-26-2024 02:35 AM
The problem working with strings is that is too slow. I have tried it but it may cost an hour with my string.
03-26-2024 08:38 AM
@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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-26-2024 08:46 AM
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.