Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple frames reading in can communication

I am facing one problem in reading the multiple frames for the CAN communication. After sending a command to the ECU( Flow control command in Seq 2), ECU is transmitting three consecutive frames. I am using CAN Read.vi to read the response from the ECU (Seq 3). But I am missing some frames randomly. Attached is the vi and the data captured by the CANape. I am able to see all the frames in Max. Can anybody help me on this.
0 Kudos
Message 1 of 2
(3,460 Views)
Hi Suhas

I think the problem is the 'Input Mode' that you used for the receiving task. It is set to 'Input' with a sample rate of '100' (100Hz => every 10 ms).

In a sampled mode, whenever the sample period expires the CAN driver looks only at the last frames that was received during that period. Thus, if within the 10ms period there were multiple frames received, only the data from the last one will be returned.
So you see the effects of 'undersampling'. Of course, you could just increase the sample rate (e.g. 1000 Hz), but then there's still the chance that there's more than one frame in the 1ms window (depends on the baud rate, though).
Sampled input modes are great if you want to acquire continuous data that is coded into the CAN frames, e.g. a waveforms of some kind (pressure, RPMs, etc.). However, it looks like as if your application doesn't need sampled data.

If you're primarily interested in getting every single individual frame, you should use the 'Timestamed Input' mode. The sample rate is not used in that mode, instead the read returns the exact number of frames that where received for that task since the last read call.

The NI-CAN Hardware and Software Manual explains this more detailed (page 6-6, NI-CAN 2.2).

Hope this helps,
-B2k
0 Kudos
Message 2 of 2
(3,453 Views)