Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

error logging with a usb-8473 high speed can interface

I posted the following under a different sub-forum... I was pointed to posting it here...

 

 

I wrote an application that monitors data from a board - mostly status of the board. I am using the NI USB-8473 High-Speed CAN Interface. My application consists of a while loop that writes a request every 100 milliseconds and another while loop that reads every 20 milliseconds. When it reads it parses the data accordingly. This program is suppose to log errors on the BUS. I am currently using the ncGetAttr.vi and reading Transmitt Error Counter and Receive Error Counter, but I am not sure if these two are the ones that I need. I noticed that if I run the application and then disconnect one of the interfaces (not the usb cable connected to my computer, but disconnect the computer that's responding to my requests) this number goes up until it hits 128 and then it stays. If I reconnect the interface, that number starts going down back to 0. It looks like all it is doing is keeping track of the frames I sent that were not read by the other computer (or board).

I have made it so if this number returned is ever greater than 0, then I increment an error counter. I still have to add more logic, because when I reconnect the interface this numbers goes back to 0. 

 

Do any of you guys have any experience with this interface? Is there a better way to log errors?  

 

 

I then added this to the post...

 

 

Let me add to my OP then. I found some examples in teh Find Examples section, but I can't get them to run, because I

am missing some dependencies I guess...

 

There is a few things these guys are using in the example... such as when Initializing the CAN interface, they set the flags

Log Bus Errors and Log Tranceiver Faults, but then I can't follow the example anymore... 

 

When I set this flags, how do I then read the errors?

 

 

 

I'll attach a picture of what I see right now, but the whole thing is broken so it won't run...

 

Please help... 

0 Kudos
Message 1 of 7
(7,938 Views)

Hi carspidey!

 

The example code in the attached picture is for the 985x series of CAN interfaces. Those modules can only be programmed through the NI LabVIEW FPGA module; you probably don't have that module installed and thus all wires are broken.

The feature set (hardware and software) of the NI 985x CAN modules differs from the one for the NI USB-8473, so that example is not a good one to look at.

 


carspidey wrote:

I noticed that if I run the application and then disconnect one of the interfaces (not the usb cable connected to my computer, but disconnect the computer that's responding to my requests) this number goes up until it hits 128 and then it stays. If I reconnect the interface, that number starts going down back to 0. It looks like all it is doing is keeping track of the frames I sent that were not read by the other computer (or board).


 

The behavior that you are describing is expected behavior of the CAN protocol. Transmission attempts that are not acknowledged, increase the error counter by 8, once the counter reaches 128 it stops there (CAN error passive). Other failures may increase the error counter even further, until 255 (CAN bus off). Every sucessful transmission decreases the counter again. For more details on this take a look at the NI-CAN Hardware and Software Manual

 

There is a nother option for you to use with the NI USB-8473 CAN interface: Try the  "Log Bus Errors?" attribute (described in the above mentioned NI-CAN manual). That attribute is also used in the "CAN Receive Error Frames.vi" example which ships with the NI-CAN driver software. That example may be a good starting point for more experiments with the different CAN bus errors

 

-B2k

Message 2 of 7
(7,918 Views)

The behavior that you are describing is expected behavior of the CAN protocol.

 

Since this is expected behaviour, then I can use this as a source of an error counter right? What do you think?

But you also said that if it reaches 255, then it means the bus is off... meaning a BIG error right?

 

I did look at the CAN Receive Error Frames, but I don't understand it... I mean... I understand what it does to an extent... 

 

I don't need to read the error frame... I just want to log errors while my program is running... 

 

Like I mentioned before... My program has to while loops... one writes every 100mills, and the other loop reads every 20 millis...

I would like to show the # of Tx errors and Rx errors that occured during a 20 minute, 50 min, a couple days, a month, etc.  run (if any)...

 

Just a side question as I look at this vi... do we really need the start action there..???

 

THanks... 

0 Kudos
Message 3 of 7
(7,906 Views)

Just a side question as I look at this vi... do we really need the start action there..???

 

I just went through the manual... and if we have the START ON OPEN flag then we don't need it there...

 

Sorry about that...

0 Kudos
Message 4 of 7
(7,904 Views)

carspidey wrote:

Just a side question as I look at this vi... do we really need the start action there..???

 

I just went through the manual... and if we have the START ON OPEN flag then we don't need it there...

 

Sorry about that...


 

Hi carspidey!

 

Yes, we need to. You cannot set the "Log Bus Error?" or "Log Transceiver Fault?" attributes when the interface is already running (you would get an error in that case). That's why the config cluster of the ncCOnfigCANNet.vi has the START ON OPEN flag set to "FALSE"

 

-B2k

0 Kudos
Message 5 of 7
(7,900 Views)

When I set both flags, how can I determine when an error occurs?

Can I sepate this errors in two categories? Tx Errors and Rx Errors?

 

Thanks...

0 Kudos
Message 6 of 7
(7,835 Views)

Hi Carspidey,

 

Take a look at the detailed help for the “Log Bus Errors?” attribute for the ncSetAttr.vi in the CAN Receive Errors VI that B2k suggests. Looking at the help for that attribute you can see that the logged errors show up as messages. You could then parse those messages as the help document explains.

Matt
Applications Engineer
National Instruments
0 Kudos
Message 7 of 7
(7,807 Views)