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.

Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

switch to write CAN

Hi,
Does anyone know how to have a switch (boolean) that can control when & which messages to be written to the CAN BUS?
So I want to be able to control the time (using a switch) when I want to start writing the messages into the CAN BUS instead of keep writing continously. I have multiple messages on a while loop but I dont want to using all of them at the same time so instead i want to a have switch for each message that can control when I want to write the message.
Thank you
 
0 Kudos
Message 1 of 4
(3,657 Views)
Hi,

I’m not sure, if I understand you correctly. You currently configure both messages to periodically transmit at 1 Hz (sample rate input of the CAN InitStart VI). Additionally, the timed loop is also configured to execute every second.

If you change the sample rate of the CAN InitStart VIs to ‘0’, the CAN write calls will only transmit the message, when the CAN Write VI is called, thus, you could put a case structure around each CAN Write and select with a Boolean control whether to write the message or not.

Further more: The case structures with the CAN Start/Stop VIs are probably not that effective: When the VI starts, it takes the current state of the M201 and M202 control and based on their state the message is either enabled or not. Once LabVIEW executes the times loop, the state of the two controls is not re-evaluated and thus you cannot stop/restart the message while the VI runs.

Maybe your intention was to have them in the timed loop? If that is the case you should change the mode of the CAN InitStart VIs to ‘output recent’ as otherwise you’re passing data to the CAN Write with every loop, but in case the task is stopped the data is buffered and transmitted when the task is restarted. That would mean that upon staring the task old data is transmitted. The ‘output recent’ mode prevents that any data is buffered.
 
-B2k
Message 2 of 4
(3,649 Views)

Putting a case structure around each CAN Write and select with a Boolean proven to be effective,

thank you so much for your help

-bm-

0 Kudos
Message 3 of 4
(3,637 Views)
This is similiar to a question that I asked NI but have not yet received a response on.  So let me confirm what I understand from this thread.
Using Frame API.
There is no seperate hardware buffer where periodic commands (more than one) are stored.
If I use the periodic commands, I can only have one periodic interval, not one for each command.
If I have a mix of periodic commands and one off commands, then I am tasked with building the periodic buffering in code.
 
To have an idea:
Periodic commands
 
Arb ID  Data      Interval
174      81 01     1.2S
178      01          1.2S
678      03  FF    10.0S
 
Then be able to insert one time commands into the stream as needed.

Message Edited by Pana-man on 10-13-2005 11:14 AM


Paul
0 Kudos
Message 4 of 4
(3,567 Views)