LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having trouble writing CAN Frames reliably

I've attached the VI that I use to write to the bus. When I use the VI by itself, it works every time, but when I include it in a program, it will fail to write about half of the time. I've even tried putting it in a For loop and writing the frame multiple times with a wait in each iteration, but it will still fail. I have Echo enabled, and I've read that the is a built-in function in CAN that will write the frames over and over until a node acknowledges the frame, but this doesn't seem to happen.

 

In my database I have the transmit frequency set to 100 ms, which matches what it is transmitted at. I also have all of my frame data type set as event (and not cyclic because I could never get that to work).

 

0 Kudos
Message 1 of 5
(535 Views)

Here is a copy saved for Labview 18.0.

0 Kudos
Message 2 of 5
(533 Views)

Also, another thing that I just noticed is that everything works just fine with writing to the bus when I have the bus monitor open using the same CAN interface.

0 Kudos
Message 3 of 5
(521 Views)

Try to debug with NI-XNET Bus Monitor

Enable Bus Error Frames and see if there are any error frames.

NI-XNET Troubleshooting Guide  is useful as well.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 4 of 5
(518 Views)

Ok, so apparently this was a simple issue of timing. I added 1 second waits between the create session, write frame, and XNET Clear.

0 Kudos
Message 5 of 5
(479 Views)