LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to transmit CAN messages on cRIO system Examples

I am working on a project that will measure 16 thermocouple signals and 32 pressure signals and transmit scaled values over CAN into a data collection center at 10 Hz.  My plan is to acquire the signal at the FPGA layer at 100 Hz and perform all scale calculations on the RT layer.  

 

The system I have configured uses a cRIO 9066 and a NI 9881 CAN module.  The analog input and thermalcouple input modules are NI 9203 and NI 9211.  My data collection center uses .dbc files to convert CAN messages.    

 

I am looking for any advice, recommendations or examples on software/hardware structure.  I am very famillar with using cRIO systems for control applications but this will be my first CAN application.

 

Logic Sequence:

 

1. FPGA (Acquire Raw Signal, 100 Hz)

 

2. FPGA (Transmit to RT Layer using DMA)

 

3. RT (Scale and Offset raw signal and convert to engineering units)

 

4. RT (Transmit signals using CAN at 10Hz)

0 Kudos
Message 1 of 8
(4,148 Views)

ChadAnd,

 

Off hand, your setup looks good. What kind of advice are you looking for specifically? If you are less familiar with CAN, there are a variety of examples in the example finder that demonstrate the  different ways to send CAN signals. 

0 Kudos
Message 2 of 8
(4,120 Views)

Kyle thanks for the feedback.

 

I'm just looking for some does and don'ts with the CAN software and any experience people might have had with doing the same thing I'm trying to do.

 

0 Kudos
Message 3 of 8
(4,113 Views)

We use cRIOs for CAN applications and generally this is what we do, even though you aren't using the same hardware so some of it might not apply.

 

We use two FIFOs, one for reading CAN messages and one for writing CAN messages with an NI 9853 (FPGA CAN) module. We use separate loops on the FPGA for reading/writing the CAN data.

 

We take the CAN data cluster and package it into U32s (2 for data - 8 bytes) with a header and write those into the FIFO. Then on the RT/PC side we read them into a buffer and look for a header + N U32s to pick out the CAN messages. We then use X-NET to parse the messages into signal/value data using a DBC file. We basically do the reverse for transmitting.

 

We also sometimes pick apart / modify certain CAN messages on the FPGA by picking apart the CAN data cluster to allow us to do monitoring/control on the FPGA.

 

Some things to watch out for:

- CAN read/write timeouts are very long by default, you may want to reduce them and handle the error

- We've had some issues before where the CAN module can error if power or the CAN connection is disconnected, this error won't clear until the CAN module is reset (which you can do through an invoke node)

 

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 8
(4,111 Views)

I am having similar issues with the 9853.  I am also having the problem that the card does not recover from a Bus Off.  I tried invoking a reset, but that doesn't seem to bring it back.  I have to reset the FPGA to get it to communicate again.

I was wondering if I could see what you you did for your 9853 error handling code?

0 Kudos
Message 5 of 8
(3,979 Views)

Hi Daufdi,

 

The problem we were seeing is that if you physically disconnect the CAN bus while it's transmitting or remove power from a device during a transmit (and as such, no acknowledge is received), the CAN module throws error 65538 and you can't send/receive anything on the bus until you reset the module.

 

For us, we simply reset the module on receiving that error out of the CAN node:

2015-03-23_09-43-33.png

 

Note, you may also need to reduce the timeout on the CAN read/transmit (from the CAN module properties) - by default it's set to 10s which is a long time for you to realise your CAN had timed out.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 6 of 8
(3,938 Views)

Hi, 

 

We are also developing a similar application with same modules (NI 9066 + NI 9881), could you please tell us if you were able to achieve? 

 

Are you using CANopen for your application ? 

I'm getting CANopen interference create.vi port Error at start. 

 

Br, 

Rohith

0 Kudos
Message 7 of 8
(3,306 Views)

I would suggest to make a new thread with your problem. 

This is a 2 year old thread. 

When you make a new thread, please post your code, project and a picture of what software you have installed on the RIO. 

0 Kudos
Message 8 of 8
(3,293 Views)