LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to graph CAN data?

Hi All,

 

Even after years of trying, I am still really lousy at using the LabVIEW graphing functions, so I hope you will be patient with me.

 

I am currently writing code to monitor a CAN bus.  I have messages with five different arbitration IDs coming in at irregular time intervals.  Generally, there is between between 5ms and 100ms between packet arrival times.  My first currently captures the raw CAN data and parses it according to the format requirements for each arbitration ID and shows the corresponding values from the parsed data.   It also saves the raw data into a txt file.  Each entry saves a time stamp, Arb ID, message length and 8 CAN bytes, which is the length of each CAN packet.

 

I have another program which takes the raw data from the original txt file and resaves it as formatted data, broken out into parsed values.  I use this two-step process to make my CAN capture program run faster.

 

I have two graphing needs right now:

 

1.  Graphing the ruasi-real-time values of the parsed CAN data as they are acquired in my CAN capture program.  This needs to happen in as little time as possible, giving me usable graphs or charts without bogging down the program.  If graphing the data takes up too much CPU time, I could graph data samples once every XXXms, instead of graphing everything that comes in.  If graphing the data proves too CPU intensive, I might just give up on this real time graphing.

 

2.  Graphing the entire parsed data set in my second, post-capture program.  Speed is not as important in this program because I am not capturing real time data while it is running.  This graph needs to include each data point vs. its associated timestamp.

 

Any recommendations on which graphing functions to use in these programs would be greatly appreciated.

 

Thanks!

 

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 1 of 3
(2,478 Views)

I'm not sure what you mean by "graphing functions."  I have code running now that receives a CAN message every 1ms.  Every 100ms, all the data received in that period is added to a chart.  I'm using a less-expensive USB CAN card (so no on-board filtering) and my code has no problem filtering by arb id in software.  I'm doing this by grabbing all received messages from the buffer every 10ms and, in a for loop, checking the arbitration ID of each packet.  If the ID matches the one I want to graph, I convert the CAN packet to 4 16-bit values and put them in a queue.  In a separate loop, every 100ms I flush the queue and write the contents to the chart.  Here's the relevant bit of my code.  Does this help?

receive CAN data.PNG

Message 2 of 3
(2,468 Views)

Yes!  Helps greatly.  I was thinking along those lines as well, but I did not know how to impliment.  Thanks!

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 3 of 3
(2,463 Views)