Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

LV: Sending "sync message" for getting synchronous CAN acquistion

Solved!
Go to solution

Hello @ all

 

 

First of all: My knowledge about the CAN bus in general is not so good, so excuse a possible unprecise problem description.

 

My task is to read out CAN messages of devices. This works fine for devices that send their messages "stand-alone" with a fixed repetition rate (here: 100Hz).

But other devices do not send their messages with such a repetition rate. They send their message only until they come in an overflow (here: after 150ms). I´ve heard that I have to send a "sync message" to the devices to get their message. That means, that I have to send the sync message with 100 Hz to get the 100 Hz acquistion.

 

My question: How should I have to program such a bidirectional CAN transfer? Of course, I can send one sync message and read the answer. But what to do when I want to read for example 10000 messages? I don´t want to trigger it by software due to the timer accuracy.

Do I just have to start the "CAN read.vi" and the "CAN write.vi" parallel? Or is there any possibility to start the write.vi and the read.vi at a fixed time, to get both functions parallel?

 

 

Tanks so far.

0 Kudos
Message 1 of 4
(7,152 Views)
Solution
Accepted by topic author LittleJoe198

Hi LittleJoe198,

 

I'm not quite sure what exactly the problem is. I only know "sync messages" in context of CANopen. But your question indicates that you are using the frame API. Maybe you mean sending remote frames?

 

You could use CAN objects to transmit data periodically using hardware timing (only supported on PCI/PXI/PCMCIA CAN cards). Take a look at the LabVIEW example finder (Category Hardware Input and Output > CAN > Frame API > Basic), "CAN Transmit - periodic.vi".

 

It is no problem sending and receiving on the same port, see example "Transmit Receive same Port.vi".

 

You should also take a look at the CAN Hardware and Software manual (START > Programs > National Instruments > NI-CAN).

 

 What type of CAN hardware are you using?

 

Let me know if you have further questions.

 

Regards,

Andreas Stark
LabVIEW Lead @ Rocket Factory Augsburg
0 Kudos
Message 2 of 4
(7,136 Views)

Hi AndreasS

 

Thank you so far.

My hardware is the PXI-8464 card.

 

I had the chance to look and test the two posted examples. They seem to work fine. I will insert them into my application. Well, I am not happy about the timer solution in this VIs: The timing (100Hz) of the read and write operation is done by software polling (10ms timer in a while loop). I hoped to find a solution, where the timing is done by hardware. But the timer seems to work good enough for my application.

 

Thank you very much

0 Kudos
Message 3 of 4
(7,120 Views)

Hi LittleJoe198,

 

I'm glad you got it running. 

 

You are right about the Transmit  Receive same port example, timing is done in software using the wait function.

But the other example (CAN Transmit - periodic) sends the data periodically using hardware timing - specified by the control "Period (ms)". In this case a CAN object is used. Your card supports CAN Objects, so it is very easy to use hardware timing. Take a closer look at your CAN Hardware and Software Manual page 10-19 ff.

"Transmit Data by Call, Receive by Call Using Remote
Period specifies a minimum interval between subsequent
transmissions. Even if ncWriteObj.vi is called very frequently,
frames are transmitted on the network at a rate no more than
Period. "

 Let me know if you have further questions using CAN Objects.

 

Regards,

Andreas Stark
LabVIEW Lead @ Rocket Factory Augsburg
0 Kudos
Message 4 of 4
(7,118 Views)