Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Using CAN channel and CAN frame API simultaneously

Good afternoon.

Here is my situation and what I am trying to implement in LabVIEW 7.1:

I need to both send and receive CAN messages simultaneously.

To send messages, users provide a *.ncd file with message and channel configuration. Each message (containing multiple channels) can have a distinct periodic rate. So the users provide another file with periodic rates for each message in the *.ncd file. I use CAN channel API to create a task per message so I can set individual periodic rates. This sends all of my messages out on the network at it's intended intervals.
Channel interface is also great to input each channel's data in its true format (i.e. vehicle speed in kph, instead of calculating the real value that is sent out on the CAN with all the offsets and resolution multipliers).
This sending part works great.

I also need to receive messages. I need to receive everything I send to verify the data. I use "self reception" feature of TYPE2 PCMCIA card for that. In this case channel API also works great, since I know which messages and channels to look for.

However (here comes the question) I also need to monitor the entire CAN link for ANY communications on it. Because I don't know which Message IDs might show up on the network, I can't use channel API (or can I?). And it doesn't seem like I can use the frame API simultaneously with channel API.

ANY THOUGHTS/SUGGESTIONS.

THANK YOU EVERYBODY AHEAD OF TIME

BorisMoto
0 Kudos
Message 1 of 8
(4,845 Views)
You can use a mixture of CAN objects and frames, but it is not an easy thing to do. You would use CAN objects to to the CAN transmission, and CAN frames to do the receive, and they would share a common config. There are problems with doing this, including the fact that there are only a limited number of objects, and objects can NOT have the same CAN ID.

My suggestion is that if this all gets too confusing, you might just have to switch over to completely using CAN frame API's. There are a few examples on the NI website, including the one below (be sure to get all of the hyperlink).

http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4p_guid=E993D9B56C3D2BABE0340003BA230ECF&p_node=DZ59102&p_submitted=N&p_rank=&p_answer=
0 Kudos
Message 2 of 8
(4,807 Views)
Hello BorisMoto,

as you already describe in your subject, you want/need to use the CAN channel and CAN frame API simultaneously. This is not possible on one port. However, if you use a 2-port CAN card and run the channel API on one port and the frame API on the other (assuming both ports connected to the same network), you should be able to build your application as described.

-B2k
0 Kudos
Message 3 of 8
(4,803 Views)
Thank you, gentelmen, for your input.

DHuff, your link doesn't work. There seems to be something else that comes after the last "=" sign.
Also, by saying "CAN Objects" you mean the objects that are created with "ncConfigCANObj.vi", am I correct?

Also, is there a way to read an arbitrary CAN message from the network using Channel interface?

I just might have to switch completely to frame interface, but it will be such a pain in the neck to convert all the data into raw data manually.

Thank you once again for your help.

BorisMoto
0 Kudos
Message 4 of 8
(4,797 Views)
Yes, you are correct, the objects are created with ncConfigCANObj calls.
The example I was trying to point to is in the third party example code under the company of DISTek integration. Try this link.

example of send & receive using NI CAN frames

To answer your second question, you can read arbitrary frames off of the bus using Channel API's using the CAN Read.VI that will read the bus as a task.

You might want to look at the advanced channel pallette, it contains vi's to programatically configure the CAN channel tasks.
0 Kudos
Message 5 of 8
(4,792 Views)
Hello BorisMoto/dhuff,

you can not read an arbitrary CAN message from the network using Channel API. The Channel API only works on 'known' (already configured) messages and thus 'known' arbitration IDs. Unfortunately, there is no mode in the Channel API that allows to receive 'unknown' IDs.

-B2k
0 Kudos
Message 6 of 8
(4,785 Views)
Hello dhuff/B2K,

I looked at the advanced pallete for the channel API and it looks like, unfortunately, B2K is correct.
I can't use channel API to read a message with an "unknown" ID. This leaves me stuck with one of two choices:
--use two CAN ports on my card (one to read, one to write) connected to the same network
--use frame API for the whole application.

Thank you very much for your help, gentelmen.

BorisMoto
0 Kudos
Message 7 of 8
(4,783 Views)

hello dhuff,

We were searching for some CAN examples to send/ receive the data from a microcontroller. We found the example that you've shared in forum. Right now we're in validating phase for CAN drivers selection. We're using the example that you have provided with some modifications in our project. It is working fine. We could send and receive the CAN frames without any problems. We hope we can continue forward with this development.

 

Many thanks,

krishna.

 

0 Kudos
Message 8 of 8
(4,260 Views)