LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble writing to CAN

Solved!
Go to solution

Hello,

 

I am working with a prototype vehicle and I need to write to the CAN network if possible.  I am using an NI USB-8473 CAN interface, which I believe only supports NI-CAN, so I am attempting to work with those blocks.  The attached code is based off of a few different examples I have seen online, but I am by no means an expert.

 

I am able to read other channels from the CAN network very consistently (if I change the desired ID for the ncReadNet VI), but when I try to read the channel on which the ncWriteNet VI should be transmitting, I see all zeros.

 

I have tried several different combinations of options for the NI-CAN blocks, but nothing seems to work.  Any advice you all might be able to give would be much appreciated.

 

Thanks!

Addison A.

0 Kudos
Message 1 of 5
(3,038 Views)

I'm no expert at CAN communications (except I know it is probably not two cans and a string), but I do know that NI has about 40 million CAN examples.  Just look under Help --> Find Examples... and then search for CAN.  Hopefully this will help you to get started.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 5
(2,999 Views)
Solution
Accepted by topic author Kanogul

Correct me if I'm wrong, but you want to read the CAN message that you send out, with the same hardware? 

 

For a general configuration of the hardware, that is not possible. 

On hardware level, the CAN transceiver has two queues, one for read and one for write. 

When the transceiver is writing on the CAN bus, it is not receiving anything, and therefor not storing the send message in the read queue. 

But you can configure the hardware to store the send message in the read queue, that is called Echo. 

The attribute Self Reception? for the NI CAN hardware lets you set the echo function. 

You need the use the ncSetAttr.vi to set this attribute. 

Message 3 of 5
(2,972 Views)

Oh boy do I have a lot to say about CAN.  If you're interested in learning more you can checkout my (on going) blog series.

 

So correct me if I'm wrong but what you are looking for is to see that the data you are writing actually is being written and you are doing that by reading back your data.  This only works if you have echo enabled on the hardware.  What this typically does is for every frame successfully sent, the frame will be added to the read queue.  On XNet this is called Echo, and on NI-CAN this is Self Reception.  Keep in mind due to how CAN works frames you write only get truly written when there is another device on the bus to acknowledge it was written.  So if you write a frame with echo (or self reception) turned on, the read will only have that frame if another device on the bus is powered and read it.

 

Also agree with others to start with some NI examples.  The Transmit Receive Same Port found in Help >> Find Examples is a perfect starting point, and is mentioned in Part 3 of my blog series.

 

Oh and in the future you may find more support for CAN related discussions on the Automotive subforum.

Message 4 of 5
(2,962 Views)

OK thanks, dkfire and Hooovahh!

 

Clearly I have a lot more to learn about CAN.  This is really the first time I've worked with it extensively, so I appreciate the suggestions.

 

I was able to enable echo and see that my message was being received by another device on the network.  (I've attached the new VI just for reference.)  Now on to the next problem, as I always say.  Thanks again!

 

-Addison A.

0 Kudos
Message 5 of 5
(2,957 Views)