From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to transmit CAN frames cyclically inside a loop obeying the transmit data informed in DBC?

Solved!
Go to solution

Hello all!

 

I'm not sure if I do understand completely how the bellow situation behaves. I'm using LabVIEW 2014 and PXI 8513 card on Windows.

 

Reading NI-XNET Help I understood:

 

Cyclic Data: The data frame transmits in a cyclic (periodic) manner. The period is defined in the field "transmit data" in the CAN Frame Properties in the DBC file imported.

 

But how can the transmission time obey the transmit data informed in DBC file if I call the XNET Write VI into a loop with a wait inside? I'm not sure if I understand completely how it works into a while loop.

 

Watching the program below, how would the writing behave? 

 

NI Example.JPG

 

Whereas the loop contains a "wait until next ms multiple" of 100 and the signal frame selected from database (dbc) has a transmit time of 0,02 s (20 ms), how many times would be these frame transmitted in the first loop ?

 

If your answer is "Although the transmit time of the frame is 0,02 s in this case the writing will write only once", I've one more question: How could I keep a loop writing the frames obeying the frame transmit time of the dbc? Consider that I've signals selected of differents frames with differents transmit time.


thanks in advance!

0 Kudos
Message 1 of 2
(3,987 Views)
Solution
Accepted by topic author clebermarques

When you use the XNET Write with Single Point mode, it updates the value which will be transmitted according to the timing specified in the XNET database (DBC file). If you call multiple writes before the frame has been transmitted, only the last written value will go out over CAN.

 

If you look in the XNET help files under NI-XNET API for LabVIEW -> Sessions -> Session Modes, you'll find the information there, including an example of how it works.

 

In your example - if you've got a loop timing of 100ms but your cyclic message time is 1s, then you will only transmit the last 'written' value over CAN when the message cycle time comes around. If your loop timing is 100ms but your message time is 10ms, then you will transmit the same value 10 times (approximately...windows timing and all that).

 

In essence, your CAN frame transmission keeps running in the background according the timing you've specified in the DBC file but you can then update the values that are transmitted asynchronously using the Write Single-Point VI.

 

If you want to ensure the values transmitted are updated each time - you need to use the stream or queued mode and buffer your CAN frames for outputting. That, or you need to use an RT target which can update the data at a deterministic rate.


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 2 of 2
(3,981 Views)