LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Read using Frame API

I'm working with raw CAN data. The protocol sends out response as raw bytes(8 or upto 30)  on CAN Bus when data is requested by a CAN message.

 

Example:

 

Tx : Message ID with number of bytes you want to receive

Tx   12X   30 00 00 00 00 00 00 00

 

You'll receive the requested 30 bytes (only once) in this format

 

 22 00 00 00 00 00 00 00

 23 00 00 00 00 00 00 00

 24 00 00 00 00 00 00 00

 

I started working using the Transmit Receive same Port.vi in the examples modified it to suite my application.

 

I changed the Vi to identify the 24 as the last byte and stop the Vi or wait 1/2 sec if it does not find any data.

 

The Problem:

 

The Problem I'm facing is sometimes the Vi is missing reading the data and runs for 1/2 sec and shuts off. I am using other trace tools to make sure the desired data is on the bus.

 

If I run the Vi 10 times the Vi would miss reading the data atlest 4 times. Since the data is received only once after the request it is important to read immediately after the write.I'm posting the code and help to improve the read process would be appreciated.

 

 

 

0 Kudos
Message 1 of 4
(4,116 Views)

Hi Vamsi539,

Which hardware are you working with, and which operating system? 


Mark E.
National Instruments

0 Kudos
Message 2 of 4
(4,087 Views)

I'm using NI CAN card and running Windows XP.

 

 

0 Kudos
Message 3 of 4
(4,078 Views)

Hi Vamsi,

If your NI CAN card has 2 ports, you can use the bus monitor to check that the data on the bus is seen by the NI CAN card (you had mentioned that you have other trace tools, but this will make sure that the NI CAN card is reading the bus properly).  You can learn about the bus monitor:

How Can I Monitor the NI-CAN Bus?

Using the NI-CAN Bus Monitor Without Going Through MAX 

To troubleshoot your code, you can use indicators and probes on your String wires at various pointsto make sure that the frame data looks like you expect as you're parsing it.  


Mark E.
National Instruments

0 Kudos
Message 4 of 4
(4,049 Views)