CAN scanner

Have questions about a SparkFun product or board? This is the place to be.

Moderator: phalanx

Post Reply
User avatar
SebaS
Posts: 80
Joined: Mon May 22, 2006 10:02 am
Location: Argentina

CAN scanner

Post by SebaS » Thu Feb 12, 2009 9:19 am

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
[i]Sebastian M. Irazabal
Electronic Engineer
Rosario, Santa Fe - Argentina[/i]

The_Todd
Posts: 65
Joined: Wed Jan 02, 2008 12:31 am

Post by The_Todd » Thu Feb 12, 2009 11:53 am

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
SebaS
Posts: 80
Joined: Mon May 22, 2006 10:02 am
Location: Argentina

Post by SebaS » Fri Feb 13, 2009 6:47 am

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!!!
[i]Sebastian M. Irazabal
Electronic Engineer
Rosario, Santa Fe - Argentina[/i]

Shifted
Posts: 250
Joined: Sat Nov 24, 2007 10:46 pm
Location: Texas
Contact:

Post by Shifted » Fri Feb 13, 2009 7:21 am

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
SebaS
Posts: 80
Joined: Mon May 22, 2006 10:02 am
Location: Argentina

Post by SebaS » Mon Feb 16, 2009 5:42 am

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:
[i]Sebastian M. Irazabal
Electronic Engineer
Rosario, Santa Fe - Argentina[/i]

Shifted
Posts: 250
Joined: Sat Nov 24, 2007 10:46 pm
Location: Texas
Contact:

Post by Shifted » Mon Feb 16, 2009 6:35 am

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
SebaS
Posts: 80
Joined: Mon May 22, 2006 10:02 am
Location: Argentina

Post by SebaS » Tue Feb 17, 2009 5:03 pm

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!
[i]Sebastian M. Irazabal
Electronic Engineer
Rosario, Santa Fe - Argentina[/i]

jrsimma
Posts: 6
Joined: Sun Sep 19, 2010 7:36 pm

Re: CAN scanner

Post by jrsimma » Mon Oct 10, 2011 7:55 pm

Sebas:

We've done around 115 CAN designs. If you have questions, please feel free to ask. You can reach us at http://www.simmasoftware.com. We normally don't charge for advice, so feel free to ask.

BTW, we have new J1939/CAN/J1587/J1708 adapters: Wireless, USB, RS-232, and UART.

J1939 to RS-232
J1939 to USB
J1939 to WiFi
J1939 to UART

Thanks,

JR

ic3man5
Posts: 4
Joined: Thu Oct 13, 2011 1:25 am

Re: CAN scanner

Post by ic3man5 » Thu Oct 13, 2011 2:06 am

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.

Post Reply