11-09-2009 01:47 AM
I recently purchased a USB-8473 & USB-8742. These CAN interfaces were purchased in order to allow us to connect a PC to a vehicle and analyze the vehicle's CAN-BUS signals.
It was only after purchase that I discovered that neither of these interfaces come with a matching 9-pin D-SUB cable. While reading through the documentation that came on CD, I noted the relevant sections entitled "Cabling Requirements for High-Speed CAN" and "Cabling Requirements for Low-Speed/Fault-Tolerant CAN." In regards to the High-Speed version (USB-8473), the documentation seems to be saying I need to add a 120-ohm resistor (1/4W rated) between CAN_H and CAN_L on the D-SUB cable. But is this really true?
I was further confused after reading through a Philips TJA1040 App-Note on this subject. Pages 11-13 of that Application Note talk about "stub nodes." Philips appears to be recommending weak termination on even stub nodes. Or are they recommending that stub node termination merely to improve the EMC behavior? At any rate, I assume that attaching one of my NI CAN USB interfaces to a vehicle's CAN socket would essentially be "attaching a stub node"?
My fundamental question to this forum is simple: how do I properly make cables for my two USB adapters to work as expected in my application? Do I even need to worry about termination at all if I keep the cable length to 1-meter? And could I then use the same D-SUB cable on both the HI & LO speed CAN interfaces? (Note: currently, automotive CAN speeds do not exceed 500kb/s.)
Yet another question...
The NI CAN USB documentation talks about "V-" being the "CAN reference ground." I assume this is an INPUT to the NI CAN USB interface, such that I would need to connect it to "body earth ground" (grounded metal parts) in the car?
Thank you.
11-09-2009 04:46 PM
Hello,
I'd suggest taking a look at this KnowledgeBase for a description on how to terminate the CAN bus in various situations. You'll have to do a few calculations to determine if you can use the same cable for high and low speed applications. This KnowledgeBase describes some symptoms of improper CAN termination that you may run into if your bus isn't terminated properly.
V- refers to the CAN reference ground, like you said. This terminal will have to be connected to whatever ground your CAN bus is using. It may be different from the body earth ground in the car, so you may want to doublecheck how the rest of your network is set up.
11-09-2009 06:42 PM
Justin, I certainly appreciate your prompt reply.
Prior to reading your post, I had spent about 3 hours yesterday, pouring over the "NI-CAN Hardware and Software Manual.pdf" that came on CD, packaged with the CAN USB interfaces I purchased. I specifically focused Chapter 4 "Connectors and Cables." It contains the same content as the first KnowledgeBase page you recommended to me, but with additional details that the KnowledgeBase page doesn't have. Even so, I still had questions so I posted here yesterday.
You see, your KnowledgeBase article and Chapter 4 of your documentation give only a limited amount of very general information about termination, and none of that information appears to be specific to "automotive" applications. Your information basically says, "for HI-SPEED, make sure there's a 120-ohm resistance and the ENDS of the CAN wire pair." But my question yesterday went beyond that. You see, I am assuming that the CAN-BUS inside most any car (cars that have CAN) is properly terminated. Meaning, the block of CAN plugs you see on a Mercedes or the OBDII connector you have on a Toyota, would access the CAN wire pair "IN-BETWEEN" the two 120-ohm resistances that are factory-installed in the car. Going under that basic assumption (which I believe is sound), would not adding a CAN device on a car (such as adding an NI USB CAN interface) essentially be "adding a stub node"? If so, the Philips App Note PDF I referred you to in my post yesterday is relevant as it describes DIFFERENT termination for stub nodes. And that is why I felt your documentation could be misleading insofar as it doesn't specifically mention "stub nodes" even though Figure 4-3 in your documentation shows two of them between two 120-ohm resistances. Or is your documentation basically saying that what we should put 120-ohm resistances on stub-nodes too, in addition to the 120-ohm resistances that go at each end of the CAN wire pair?
From what I gather from researching this on the net is that a stub node running at 1Mb/s needs to be 30cm in length or shorter while at 500kb/s it could be up to 1m long. Yet other information I have read says that very short stub-nodes don't need any termination at all in many cases -- which, if true, would mean we could run the USB-8473 with an unterminated cable (which is not covered at all in your documentation). So I don't really know what is true and what is not here, hence my post here in hopes of finding someone knowledgeable about automotive CAN networks who could lead me by the hand in the right direction.
Further thoughts and advice would be greatly appreciated.
Thank you.
11-10-2009 01:09 PM
First of all, if you are operating in a vehicle and you do not plan to transmit on the bus, you need to place the unit in "Listen only" mode. Under the Frame API you can find this as a setting (set "Listen Only" to True) for the ncSetAttr.vi in the CAN>Frame>Advanced palette. If you do not you may end up waiting 24 hours for the car to be able to restart if you accidently transmit on the network.
Secondly, if you are keeping your cables short and you are connecting at the ODBII port you do not need termination on high speed (1Mbps, 500Kbps) networks. By short I mean less than a meter. The specification is for 0.3 meters but it is very conservative and in the modern environment is usually not needed. If you start seeing errors in the ECC register, or "stuff bit" errors, you need to terminate the stub.
Other than that, don't expect much in the way of CAN bus traffic at the ODBII connector other than the mandated (in the US) messaging for diagnostics. If you need to monitor vehicle message traffic you will have to find another place to tap into the vehicle network. The ODBII cnnector is usually protected from "accidents" by a vehicle gateway module which limits the traffic to what is needed for simple maintenance work.
Bill
11-10-2009 06:34 PM
Bill, I am grateful for your experienced feedback on interfacing with automotive CAN networks using the NI tools and for your clear guidance on using the associated NI software. Please forgive me, but I a few more questions for you:
1) I will be using the NI interfaces (USB-847x) on many different cars equipped with CAN. It is easiest to connect the V- (on the NI interfaces) to the ground in the OBDII plug, but would you recommend doing that? If not, what other convenient V- connection would you suggest? (Most Toyotas and other cars with OBDII have both +12v and GND in the OBDII.)
2) Per your comments above, I basically could build a single cable of less than 1-meter length for use with either of my USB-847x interfaces. And if I get errors (as you describe) on HI-SPEED CAN, would I then simply add a 120-ohm resistor between CAN_H and CAN_L, or should I use weaker termination (different value of resistance)? And would the size of that terminating resistor be different when connecting at the OBDII plug versus connecting at another CAN point in the vehicle (e.g., the place where you mentioned that I could read the complete set of CAN message signals)?
3) When I am connecting to LO-SPEED CAN in the car, from what I have read in the NI documentation it seems that I would need to use the internal termination of the USB-8472 at all times (with no termination on the cable, of course). In chapter 4 under "Software Selectable Termination" it talks about a choice of either 5k-ohm or 1k-ohm. But when connecting to the vehicle's CAN via the OBDII or another point, which termination setting would you recommend?
I greatly appreciate your time, Bill.
—James
11-12-2009 08:06 AM
James: I am happy to be able to help.
Regarding your questions:
1. Connect pin 3 (V-) of the 8473 to Pin 5 (signal ground) of the OBDII. If Pin 5 is not populated use Pin 4 (chassis ground) of the ODBII port or vehicle ground. You have to have a ground or signal ground reference for the CAN transceiver or else the signal could drift from the center and that may cause all kinds of interesting phenomena, especially when viewed with a scope. I've pulled my hair a lot on that one. And, of course, you will connect the 8473 Pin 2 (CAN_L) to pin 14 of the OBDII (if your vehicle has it on that pin - not all manufacturers comply) and the 8473 pin 7 (CAN_H) to pin 6 of the OBDII (same caveat as CAN_L). As we in Detroit have been known to say, "Your milage may vary" when it comes to using the OBDII port.
2. If you see message errors add a 120 ohm resistor across pins 2 & 7. No other value is recommended for use on high speed CAN. If you add a cable stub to a CAN bus somewhere else in the vehicle, add it as close to the connector for an ECU on the bus and keep the stub length short (inches or cms). No termination to your 1 meter cable to your 8473 should be necessary if lengths are kept short and you connect to the added short stub. Again, if you experience errors, add the 120 ohm resistor as above.
3. If you are connecting to low speed two wire or "Fault Tolerant" CAN (non GMLAN) I cannot say for sure what to do. GMLAN (so called "single-wire" CAN) does not require termination. This is where a good oscilliscope comes in handy. If you are using the 8472 I would defer to NI's experience and try one of the two values provided, no matter where you connect.
I hope this helps.
Bill
11-12-2009 07:19 PM
Bill, once again, a thousand thanks for your experienced input on CAN termination in automotive applications. You tips about OBDII are extremely helpful. And I believe I am square now on HI-SPEED: with a short cable (<1m) we can most often forgo any additional termination, but if we have problems we simply attach a 120-ohm resistance (1/4W rated) across the CAN wire pair. Got it.
Bill_in_Detroit wrote:If you are connecting to low speed two wire or "Fault Tolerant" CAN (non GMLAN) I cannot say for sure what to do... This is where a good oscilliscope comes in handy. If you are using the 8472 I would defer to NI's experience and try one of the two values provided, no matter where you connect.
Justin_E, in light of Bill's comment it appears that I am once again in need of your opinion about the 8472. I am going to assume you have not chimed in due to your not having experience with connections made to automotive CAN networks. But perhaps someone else at NI would have some helpful comments to supplement what Bill has said about low speed "Fault Tolerant" termination requirements in a vehicle?
Bill, you mentioned use of a scope to determine whether my CAN wires are properly terminated. But what specifically do I need to be looking for with the scope?
Please now allow me to offer some explanation as to why I am getting into such detail about this. You see, until now we have not been using any professional tools (like the NI USB CAN interfaces) to take CAN data from cars. We have been using a proprietary tool created by a company who supplies us with their CAN technology for car alarm use. But that proprietary tool has been a huge headache to us because the data we read out from a given vehicle's CAN is sometimes not readable by our supplier's engineers. (The engineers are looking for which CAN codes control things like parking lights on, ignition on, door open, door locking with PKE, etc.).
Because of the problems with our proprietary CAN reader, we purchased the 8472 and 8473 products from NI in hopes of taking "error free" data readings from new cars that currently don't work with our existing CAN controllers. Reading through the NI documentation about resistive termination made me worry about the likelihood of errors. If we don't properly terminate the CAN wires, we may get errors and not know it (I am assuming) which means we are back to the same headache we had with our old proprietary CAN reader tool. This is why I am so desperately trying to determine how to connect our 8472 and 8473 to the car such that we get the data with no errors.
I look forward to your further comments.
Many thanks,
James
11-13-2009 06:43 AM
James:
In response to what you would look for using a scope:
High Speed CAN is a differential voltage logic system. When the signal is recessive, the signals on CAN_H and CAN_L are roughly equivalent at a value of about 2.5 volts DC relative to ground. When the signal goes dominant, the CAN_H rises to about 3.5 volts DC and the CAN_L drops to about 1.5 volts DC, giving a net differential voltage of about 2.0 volts DC during the dominant bit. A discussion of this and about termination can be found in the Microchip document number AN228 which can be found at this link -> CAN Physical Layer.
What you would look for with a scope is that the voltages can be clearly seen at these levels during message traffic. Most of the problems that I have seen have shown up pretty quickly on a scope. First of all, you should use a scope with sufficient bandwidth so you can actually see the bit levels change. If termination is incorrect, you will not be able to get a lock on a message as the reflected signals will overwrite each other to some degree and the signal will look like noise to a large extent. For high speed CAN at 500 Kbps, if you set your scope in the 2 or 5 us range you should be able to see the bits clearly.
Good luck with your project. There are other tools on the market that may work better for your purpose than trying to write something on your own, but as this is the NI forum I won't go into that here without first clearing it with NI.
Bill
11-15-2009 10:28 PM
Bill, thank you again for your helpful reply.
In some ways I feel that I've gotten in thoroughly over my head here with these NI CAN USB interfaces. While pondering on the meaning of the last paragraph of your recent post that talked about "write something on your own," I re-read page 4-14 of the NI documentation that talked about Software Selectable Termination (USB-8472s only). It says:
"The USB-8472 and USB-872s feature a software selectable bus termination resistors, allowing the user to adjust the overall network termination through an API call."
Not being a programmer at all, I don't know clearly what this means. But it appears that some kind of "programming" is required in light of your own comment about "write something on your own."
Prior to purchasing these interfaces I asked NI a lot of questions about what I would need. I was led to believe that the software included with the interfaces would be sufficient for my job of reading automotive CAN signals. (I also had it in my mind that I would get all the cables I would need too; but as this thread indicates, that is not the case.) Anyway, for the life of me, I don't see how I can activate this 5k-ohm or 1k-ohm termination via the "MAX" driver software that comes on CD with the USB-8472/USB-8473 interfaces that I purchased.
I can see the checkbox marked "Listen Only" in the "Bus Monitor" of MAX (which is something you recommended I use in an earlier post here). But I don't see how to do "an API call" to activate or otherwise select the appropriate onboard termination of the 8472. How does one go about doing that?
Thank you,
James
11-16-2009 06:44 AM
James:
I am sorry to hear that you are still experiencing difficulties overcoming the learning curve of a new communication technology. It also appears the Sales Engineer you spoke to about the interface and software capabilities may have misunderstood your needs and overstated the ease of use of the products. There is an add on package that NI sells that may save you a lot of time, the Automotive Diagnostic Command Set, but it is $829.00 if you have a LabVIEW FUll Development System license. I haven't had the opportunity to use the product but have seen it demonstrated and it looks like it would be capable of doing what you need. It may not directly solve your problem, but it should take care of getting you up and running, then you can modify the code to meet your needs. You might be able under the circumstances to get NI to let you have a temporary license to evaluate the software for your needs. Talk to your local Sales Engineer about that.
But back to your original question, on page 10-113 and 10-114 of the "NI-CAN Hardware and Software Manual" (installed when you install the NI-CAN drivers) it refers to the ncSetAttrib.vi that you need to call before starting to read CAN messages from the network. There is a section under help when you drop the vi on your wiring diagram that explains what the attributes are under "Termination" (0 for 1.11 k ohm - default,and 1 for 4.99 k ohm). This only applies to the 8472 and 8472s. I have not tried to set this up in MAX so I can't say whether it can be done from there. It seems to me that it should be something that can be done in MAX and if it can't I suggest putting in a support request to NI so they fix it. I do personally own a 8473 but that doesn't help answer your question about the 8472 since MAX is "smart" enough to limit functionality offered to only that which applies to the referenced attached hardware. The MAX help provides no insights, either, as under the Port Properties dialog it should allow setting but there is no mention in MAX help. Your best bet may be to contact your local sales engineer and bring this to his or her attention. I'm sure NI doesn't want unsatisfied customers, that's not good for sales no matter how big a company gets.
If I get some time later this week I will look further into this with my own 8473 to see what options are presented in MAX.
Bill