Close

Trying to establish comms

A project log for Audible CAN-bus alarm

Monitor vehicle signals and beep when something's wrong

andrew-bolinAndrew Bolin 03/11/2017 at 07:030 Comments

Well my attempts at using the SparkFun library came up short.

Found this one instead: https://github.com/franksmicro/Arduino/tree/master/libraries/MCP2515

Initially had a lot of trouble because the SparkFun library used the same file names - my code would compile fine, but just crash the Arduino. Deleted the SparkFun library and things improved.

Now I at least have some SPI data going across to the MCP2515. I've written a minimal test on the Arduino (just reads the vehicle speed and rpm), but it didn't work on my car. I'm not 100% sure that my car even does speak CAN on its OBD port, but I am 98% confident...

Looking at the CAN H & L pins on the scope, H is moving between 2.33 & 3.94V, L is doing the inverse between 2.33 & 0.70V, which seems within spec. Not sure if it's doing the right speed though, the pulses I'm seeing look more like 250kHz than the 500kHz I was expecting.

Next steps: Try setting different speeds, check CAN on logic analyser or USB dongle

Edit: My speed woes are due to my cheap board using an 8MHz crystal. Need to study the MCP2515 datasheet to see if it can do 500kbps with an 8MHz clock, or swap in a 16MHz crystal.

Discussions