SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
User avatar
By SebaS
#66013
Hello everybody, I'm back!

Now with a question... Have any of you ever work with CAN (Controller Area Network)? I've got a lot of doubts about it...

I'm working with a MCF51JM128 Freescale, it has a msCAN module...

One of my questions is about Identifiers... I want to plug the MCU, with a CAN Interface, to a CAN bus (from a car) and read EVERITHING... As I don't know about car's Protocol, I don't know the identifiers it uses.. So I want to setup the CAN bus so it won't check the identifier...

And if anyone could guide me through this project, maybe recommend me some bibliography or give me any advice it would be HUGELY appreciatted..

The CAN bus really shocked me, it's harder than I expected...

Well, thanks in advance, guys!

And please, one more time, excuse my English
By The_Todd
#66026
I work with CAN quite a bit, and think it is a great architecture. I do mostly custom implementations using my own protocol, but have done work with J1939 which is the CAN standard on industrial vehicles, and CANopen, but never with domestic cars (which I believe you are referring to, i.e. Toyota...)

By simply plugging your MCU into the CAN bus and setting it to the right frequency (varies by manufacturer) you can read all messages on the bus, and given some documentation, subsequently decode them.

The U.S. requires CAN bus on all new cars made after 2008, however, I don't think there is a standard communication protocol between manufacturers so you will have to obtain the specific documentation from them.

What car manufacturer did you have in mind?

Todd
User avatar
By SebaS
#66109
Hi Todd!

Well, I'd like to make an universal scanner... I know its ambicious, but I'd like to try it.

The problem is that I don't have a clue about mfgs protocols or speed.

But I'm still learning how to work with CAN, can you pass me or give me an idea of where to get some documentation (tutorial o guide) in order to learn CAN?

Some of the protocol used in cars are J1939 and OBD-II... But I can't find technical information about them, I mean, how to decode them.

Any help would be great!

Thanks!!!
By Shifted
#66114
If you want to make a universal scanner, make it easy on yourself, buy a chip that does it:

http://www.elmelectronics.com/obdic.html

They have chips that decode all 5 protocols, not all vehicle's are CAN, it's only been mandated since 2005. The other protocols are VPW, PWM, ISO-91410-2, ISO-14230-4 and CAN. Which one you need to use depends greatly on the car you connect it to. The ELM can "auto negotiate" with the vehicle's data bus to find the correct connection speed. All you need to do then is to talk RS232 to the ELM and send simple text commands. Take a look at the ELM323 datasheet to find more information about how to query the vehicles data bus.

The other problem you'll have is you can't get "all" the parameters without some inside knowledge of the manufacturer's implementation. OBD is only a specification for how vehicles need to respond to certain diagnostic tests and basic information (RPM, Speed, some sensor values). To know all the data that's available you need the manufacturer's information.

If you are looking to try to reprogram the ECU through the port, then each manufacturer is allowed it's own implementation of a protection scheme. This can also vary from vehicle to vehicle, for example on a Chevrolet Camaro LS1 you request a Seed, to which you need to respond with a Key. The Key is a 2 byte hex number that must be generated from the Seed and sent back in a specific period of time, get it wrong 3 times and the ECU locks you out for a period of 30 minutes.
User avatar
By SebaS
#66295
Thanks for the info Shifted!

I was not sure about wich were the other protocols, now your reply clearifies me that. The problem with those chips is that if I want an universal scanner I'll need to buy the 5 of them, place it in one board and make them work all together... So I was thinking in developnig and application software for each protocol. so it would all be inside the uC.

About those five protocols.. I thought they all were protocols that run over CAN, but now I think I was mistaken, right?

Thanks again, I hope you can help me through this project.

Have a nice day
:wink:
By Shifted
#66300
Right, none of them are CAN except CAN itself. VPW uses variable pulse width signals, PWM uses pulse width modulation, KWP yet another type, etc. These all require different hardware schemes to connect to and talk to the vehicle.
User avatar
By SebaS
#66481
I've been reading and I've found out that since 2008 most (not to say all) cars would be equipped with CAN bus, so I guess I'll only focus on that.

In the Wikipedia I found the OBD-II PIDs and an explanation on how does the protocol works:

Let's say that we want to know the speed of the car, then the querry would be (please correct me if I'm wrong)

0x07 0xDF 0x02 0x01 0x0D 0x00 0x00 0x00 0x00 0x00

0x07 0xDF - ECU ADDRESS
0x02 - Additional data bytes (the next 2 bytes)
0x01 - Show Current Data
0x0D - Vehicle Speed

The Last 5 0x00 are not implemented

My questions are:

1- Is the ECU ADDRESS the CAN ID? (I guess the answer is yes)... Because 0x7DF are 11bits, so that would be the 11-bit header... Does anybody know what would be the 29-bit header?

2 -That Address (0x7DF) is standard right?

Thanks to all of you!
By ic3man5
#134574
Look at figure 2 in this datasheet: http://www.cl.cam.ac.uk/research/srg/HA ... /an713.pdf

The identifier is usually the ECU but it can be anything (It's used more in my eyes as a way to "Identify" what type of data bits your going to expect)

I'd say 99% of CAN messages are standard and not extended. Most networks are 500K baud. If you don't set the baudrate correctly, you'll crash the bus. You also need 120ohms of termination between High and Low lines at the start and end of the network (60ohm total).

Look at an OBD2 Pinout to see which networks a car has.

Some vehicles have 'gateways' that filter the CAN messages at the OBD2 port, you can get around this by hooking up before the gateway.

Hope this helps.