LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ISO implementation using over NI CAN (Channel) - Issue sending same message different data multiple time

Hello All,

 

Am trying to implement ISO communication over NI's Channel API CAN.

 

ISO has same message header (29bit CAN) from one ECU to Other, the difference lies on the data.

Eg: ISO_EMS_2_IC (0x1F40F310) remains same, the data content represents Data Identifier, etc like in J1939 each Message (29bit CAN ID).

 

Am planning to implement using NI's CAN Channel API. The problem is, Same Message cannot be transmitted on different task. i.e....

Let say a J1939 message ETC1 with its channels are used as input to NI "Init Start" and create a task TaskRef01

ETC1[]=>InitStart=>TaskRef01    Now Write ChannelDataSet01[]to CAN using NI's WRITE

Similarly I did another Task but same message....

ETC1[]=>InitStart=>TaskRef02    Now Write ChannelDataSet02[]to CAN using NI's WRITE

 

It seems that ChannelDataSet02[] overrides ChannelDataSet01[], eventhough the TaskRef are different. I can see just one set of data being transmitted on Vector's CANALYZER by NI CAN Channel API.

 

Can some tell me how to overcome this? Meaning How to send two sets of Data sequentially back and forth periodically using NI CAN Channel API?

 

Thanks in advance!

 

Best Regards,

Imagineer

 

0 Kudos
Message 1 of 9
(2,854 Views)

Hi Imagineer,

 

If you want to write multiple channels of data from the same CAN port, you need to initialize them within the same CAN Init Start vi. There can only be one CAN task open on a CAN port at a time. If you want to actually alternate between the two sets of data, you would need to programmatically switch the two datasets that you are sending to the CAN Write VI, but still only initialize one CAN session. That way, you can send different sets of your channel data out over the same CAN session. You could also use the Continuous Write mode with an array full of multiple sets of data. This link explains the NI-CAN Channel API; there are also some examples on our website.

 

Also, if you're using hardware that supports NI-XNET, it is a newer and generally better driver for CAN applications, and I would recommend using it.

 

Best,

Dan N

Applications Engineer

National Instruments 

0 Kudos
Message 2 of 9
(2,836 Views)

Hello,

 

First, Thanks for your reply. For clarity, I have attached two scenarios. (UniqueMessages & SameMessages). Both cases there is neither any error nor any warnings from NI's CAN Channel API.

        In case of UniqueMessages, all messages are transmitted. I could verify that on CANALYZER

        In case of SameMessages, only one message is transmitted at 1s periodic interval. Have checked the Tas Reference Value, all are unique for each loop iteration. Also from timing it seems that the first Task created, is the only one which Transmits this message.

 

Next I tried sending same messages by setting different frequency at each loop iteration. This resulted in error after first iteration: NI-CAN:  (Hex 0xBFF62006) The object is already open in another application.  Solutions: Ensure that only one application at a time uses an object , and that you close all objects prior to exiting your application (don't use LabVIEW toolbar's Abort button).

 

Looks like NI Channel API's inter implementation limits user to one Task per message. I wish this was not the case, Now I have to programatically switch data and also programatically do Message Management 😞

0 Kudos
Message 3 of 9
(2,831 Views)

Since NI forum limits 3 attachments per post, so replying with another attachment.

0 Kudos
Message 4 of 9
(2,830 Views)

Hi Imagineer,

 

From the code that you've posted, it seems like you're initializing multiple tasks for each Channel that you are writing, which is not the ideal way to use NI-CAN. Instead, create one task with several channels, and then write all three of the channels at once using Task Write.

 

I think you should take a look at some of the NI-CAN examples as a reference for how the Channel API is supposed to be programmed. To find them, open up LabVIEW and go to Help>>Find Examples, and then go to Hardware Input and Output>>CAN>>NI-CAN>>Channel API. The example listed under Basic>>Single Sample Event Output shows how to programmatically change the data that you write out to multiple channels.

 

Best,

Dan N

Applications Engineer

National Instruments 

0 Kudos
Message 5 of 9
(2,802 Views)

I have tried using the example listed in NI knowledge base but it appears I am missing something

 

The example is listed in this link https://decibel.ni.com/content/docs/DOC-3666

 

 

If you look at the block diagram the VI is capable of pushing multiple messages to CAN at different rates.

 

The part I am a little confused with is the "Write to Data to Bus." section in the block diagram.

 

If you look at the front panel there is an Array called DataBytes which is set to 56, 11.

 

I guess my confusion is I am usure why this is set to these values and what do I need to change to add more CAN messages.

 

I am able to successfully push one CAN message on to the network but when I add another message I do not see it being pushed on to the network

 

I am using a PXI 8464 2 Port CAN interface. 

 

I am pushing the signals out of CAN0

 

I am monitoring the CAN signals on CAN1 through MAX by connecting CAN0 and CAN1 with NI's 2 Meter Can Cable (PN 192017A-02 CAN CABLE 2 Meter 4304 12506)

 

 

Any help would be appriciated

 

 

Tim
0 Kudos
Message 6 of 9
(2,768 Views)

Still looking for support with this problem.

Tim
0 Kudos
Message 7 of 9
(2,760 Views)

This is a fairly old example that you're looking at, and it's on the developer community, so it's not an official NI example. However, I believe that you need to add more data values to the "data bytes" array as you add additional messages that you want to be sent. I believe the data is expected to be in a Zx2 array, where "Z" is the number of messages you're sending. So if you're sending two messages, make the data bytes array a 2x2 array.

 

What you probably should do though is look through the example finder at some of the CAN examples there. Open the example finder (Help --> Find Examples), and then navigate to Hardware Input and Output --> CAN --> NI-CAN

 

Also, for future reference, it is better to create a new forum post than to reply to an old forum post, especially if you're question is only partially related to the forum post. You'll generally get more help if you create a new forum post.

Colden
0 Kudos
Message 8 of 9
(2,737 Views)

Thanks for the Input.

 

I have posted a new thread in regards to my questions about this particular VI.

 

I pretty much figured out that I needed to add another pair of values to the NX2. Array my question was really what values should I add and why are they originally set to 56 and 11.

 

 

Tim
0 Kudos
Message 9 of 9
(2,728 Views)