8 replies [Last post]
josh
Offline
Joined: 2010-02-10

Ask away. We try to answer quickly.


    Summary

Q: Will the Mechanic CAN Library work?

A: Yes, with the modification attached below "config.h" for Mechanic Library tweak to work with Macchina.

AttachmentSize
config.h1.42 KB
Alfaa
Offline
Joined: 2014-05-14

Do you know if it will work off the shelf with the Mechanic CAN library? (located here: https://code.google.com/p/mechanic/)

The first thing I need to do with it is set it up as a CAN sniffer to get some codes from the internal CAN bus in my car. Writing libraries isn't exactly my forte, so I need to use other options.

EDIT: Oh, and the first bus I need to sniff is only 100kbps, which not too many libraries support, unfortunately.

josh
Offline
Joined: 2010-02-10

I took a look at the mechanic library - very cool! It should work just fine since Macchina is pretty much an Arduino Mega with an MCP2515 CAN shield on one board (plus other obd2 protocols and a few other things).

We should be able to add a couple #define statements to the top of the code to change the pin assignments for CS and the INT to match Macchina. We mapped some of the MCP2515 pins to unused pins on the Atmega2560 so to reduce interference with shields.

I'll verify it works and post that chunk of code up here once we know it works well..

josh
Offline
Joined: 2010-02-10

We were able to get the Mechanic CAN library working with a small tweak. I ran the "selftest" sketch and it worked fine. Since we have the CS and CAN INT lines running to different pins on the ATMEGA2560 (we used some pins not used on the Arduino-mega to avoid conflicts with other shields) we need to change the "configs.h" file to reflect those pin assignments.

Chip select is connected to PE2, INT is on PE4, and we are using external interrupt 6, so change "config.h" lines as follows:

// Arduino Mega 1280 or Mega 2560

#define P_MOSI B,2
#define P_MISO B,3
#define P_SCK B,1

#define MCP2515_CS E,2
#define MCP2515_INT E,6

#define CAN_INT 6

OR just replace the existing "config.h" file with this:

http://rechargecar.com/sites/default/files/config.h

A Dog IRL
Offline
Joined: 2014-05-14

Are there libraries that we can use that support KWP2000/ISO14230 and ISO9141? I'm having a lot of trouble figuring out where to start on my car using KWP2000.

Alfaa
Offline
Joined: 2014-05-14

This isn't what you're looking for, but I thought I'd add to the discussion that this library (https://github.com/matsekberg/j1850decoder) works VERY well for j1850 VPW (the single wire interface).

It works with regular Arduino pins, so it's not Macchina specific, but it's still very useful regardless.

Unfortunately, it looks like the car that I tested only uses j1850 VPW for what looks like the convenience bus. There doesn't seem to be any engine information that we could see.

There is a second bus in the car that is ISO9141, but I haven't found any libraries or code that might make developing for the Macchina any easier, so we're stuck at the moment.

A Dog IRL
Offline
Joined: 2014-05-14

Currently reading through this: https://www.cs.purdue.edu/homes/millerrv/Ryan_Miller/Projects/Entries/20...

It seems to be a pretty simple and unclear write up of KWP2000 interfacing, but it's still something to help understand it more.

Also bookmarked https://github.com/stanleyhuangyc/ArduinoOBD but this seems to be using a proprietary cable that the guy sells.

chaserutkowski
Offline
Joined: 2015-03-10

Where should I get started with ISO9141?

Has anyone found any libraries we can build off of?

I've been reading lots about ISO9141 but I'm not sure where to start at this point. It seems we are going to have to make our own library.

josh
Offline
Joined: 2010-02-10

Very happy to hear that you are starting to look at ISO9141 library dev! We did find a library to start working from and described a little bit towards the end of this thread:

http://rechargecar.com/forums/general/obd2-library-status

Here is the link to that code: https://code.google.com/p/avrobdii/

Macchina 1.1 uses the UART hardware interface to connect to the ISO9141 circuit. We decided to made a small modification to these boards so that all the data inversion would happen in the circuit to make the code a little easier. In other words, using a 1.1 board with the hardware modification should be the quickest way to get something going since you won't need to worry about timing.

We'll post up some information about the details of the hardware modification here soon.

Let us know if you run into any issues. Thank you!