LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I update CAN messages being transmitted as a periodic waveform?

I am using NI-CAN 1.5 to transmit CAN messages with a CAN Object using the "Transmit Periodic Waveform" communication type. The CAN card I am using is a dual port PXI-8461.

I wish to update the waveform message(s) but am running into problems. I configure the CAN Object with a write buffer size of 2 and then start transmitting 2 messages with one message going out every 500ms. These 2 messages are correctly getting placed on the bus. To update the messages, I successfully stop the CAN Object and attempt to write new data into the write buffer. This is where I am running into problems. The ncWrite VI is failing with an error of 0xBFF62008 (Write Queue Overflow).

Upon further
inspection, I noticed that when I stopped the Object and there was only 1 of 2 messages pending, I could successfully write one time; however, the second write would fail with the same error. If 2 messages were pending, neither write would be successful. I need to be able to update both messages. I thought maybe I could use the ncWait VI to wait for the write queue to empty and then write in 2 new messages; however, this will not work since the ncWait VI never returns before a timeout occurs in "Transmit Periodic Waveform" communication type. Either 2 or 1 messages are always pending so it never sees that the card is ready for new data.

I looked in the Programmer's Reference Manual, and this is the procedure recommended. (A bit different, but I tried it and came up with the same results.) The Reference Manual claims ncWrite replaces the oldest data in the queue on page 3-30, but on page 2-40 it says ncWrite returns an error when called on a full queue.

Does anyone see anyt
hing that I'm doing wrong or have an alternate way to accomplish what I want? Thanks for your help.
0 Kudos
Message 1 of 5
(3,087 Views)
Hello-

The transmit waveform mode will probably not actually clear or update the buffer after it has been written to. Instead, use ncWriteObj and transmit data periodically. There is a knowledge base that gives an example of this: (http://www.ni.com/cgi-bin/search/search.cgi?scope=knowledgebase&query=290BCFDB).

Randy Solomonson
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(3,087 Views)
I can't use Transmit Data Periodically because I need to alternate between two data sets with same ArbID. Transmit Data Periodically rewrites only the last data when it reaches the end of the buffer instead of rewriting the entire buffer. The Programmer's Reference Manual clearly states how to do what I'm trying to do but this method does not work. Why? I need to be able to update the periodic waveform on the fly. Have you gotten this to work? I think this may actually be a bug in NI-CAN or the manual needs to be modified to correctly state that a periodic waveform cannot be updated. Thanks for your help.
0 Kudos
Message 3 of 5
(3,087 Views)
The "Transmit Periodic Waveform" section (pg 3-30) of the NI-CAN Programmer's Reference states, "Use this configuration to transmit a fixed sequence of CAN data frames over and over, one CAN data frame every period."

The words "fixed sequence" denote that it was not intended to change as the program runs. I appolgize if this was not clear. Any suggestions for improvement to the documentation can be emailed to support@ni.com.

If those two data sets do not change at run-time, they could be merged together. For example, make the buffer the size of both data sets added together. Start by Writing the first element of set one, then the first element of set two, then the second element of set one, then the second element of set two, etc.


Randy Solomonson
Application Engineer
National Instruments
0 Kudos
Message 4 of 5
(3,087 Views)
Note step 5 under the "Transmit Periodic Waveform" section on page 3-30 in the NI-CAN Programmer's Reference. It says new waveform data can be provided when the CAN Object is stopped. It also says that if the queue is full, the oldest data will be replaced. This is not true because some of the data in the buffer is never seen as old/stale, therefore, NI-CAN won't allow it to be overwritten.
0 Kudos
Message 5 of 5
(3,087 Views)