Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Using compactRIO and NI-CAN with multiple NI 9853 ports simultaneously

Here's my problem.  I need to receive and log J1939 channel information on 4 seperate CAN buses IN REAL TIME.  I have a CompactRIO with 2 x NI 9853 giving me a total of 4 CAN ports.  Using the example "CAN Channel Receive" included with the CompactRIO I can see this is very easy to do on one CAN port using the CAN256 and CAN257 virtual interfaces in conjunction with the Channel and Frame APIs.  However, I need to do this very same thing 4 times simultaneously on 4 different CAN ports and I only have available 2 virtual CAN interfaces.  In order to do this on 4 physical CAN ports, I need 8 virtual CAN interfaces apparently.  In other words I need a CAN258, CAN259, CAN260, CAN261, CAN262, and CAN263.
I know that it's possible to simply log the raw CAN messages and post process them to get channel information, but I'd rather not do this.  I'd rather receive the CAN messages and log the channel data in real time if possible.  Is this even possible on the CompactRIO and is this the only way to do it (using virtual interfaces)?  Why don't the CAN ports on the NI 9853 modules show up as CAN interfaces in MAX.  If they did, that would solve my problem and I wouldn't have to screw around with the virtual interfaces.  What's the use of being able to use multiple NI 9853 modules if you can only utilize the Frame and Channel APIs on one of the CAN ports at a time?

Any help would be appreciated.  Thanks.
0 Kudos
Message 1 of 3
(3,461 Views)

Hi,

Well the driver has only one pair of virtual Interfaces for Frame to channel conversion, so you have to make changes on the cRIO part of your application.

Try to bundle all messages from all 4 ports in one stream of data and use DMA technologie to transmit the data to the host for processing. If you have one stream of data, you should be able to do the conversion with the virtual interfaces you have.

The only risk i see is the performance for the virtual interfaces. It depends on your Busload, whether or not the controller is able to convert the streamin realtime.

Hopefully you work with an R-series Board.  😉

Attached you can find an picture for an example of bundling two ports together for receiving one stream using DMA.

Hope that helps

DirkW

0 Kudos
Message 2 of 3
(3,443 Views)
I actually thought about streaming all my CAN traffic to the virtual buses, but I really need to keep all the traffic seperate for logging purposes, and I am also in a bit of a time crunch.  So what I think i'm going to do have to do is use some examples I have that log raw CAN traffic to a log file and then post-process that file to convert the raw CAN traffic to J1939 channel data using yet another example.  I'll have to do this for every physical CAN port, and it won't be in real time due to the post processing, but in the end it accomplishes the same thing and I don't have much of a choice at this point.

It wouldn't be so big of a deal if I didn't have to keep all 4 buses seperate as I could simply stream all the traffic to the virtual bus and be done with it.
0 Kudos
Message 3 of 3
(3,440 Views)