# CAN-based EV control system initial release



## DJBecker (Nov 3, 2010)

I've created a project on Google Code named 'obd2-instruments'

http://code.google.com/p/obd2-instruments/

This project contains multiple subsystem, all with a common theme of automotive CAN bus code that runs on common microcontrollers.

Unlike most code out there, this isn't a OBD2 reader or gauge display. It is a CAN bus communication and reporting system, that includes the car side of OBD2 reporting.

The Cougar EV controller add-on OBD2 code is there, unchanged from an early January snapshot.

There are more recent versions for both the AVR (e.g. Arduino hardware, and the Cougar hardware) and the STM32.

The AVR version supports multiple chips. Our first motor controller used an Arduino Mega1280 board, which soon added a MCP2515 CAN controller. At that point I rewrote our firmware to be partially compatible with the Cougar config structure in the hope that the CAN interface code would be useful for Cougar users.

I later added a driver for the CAN controller built into the AT90CAN32 series, although that is untested and there is no GPIO setup code for those chips.

The STM32 version started with our use of the STM32VLDiscovery board. We wired up a MCP2515 controller, since I had known-working code. (That was supposed to be easy, but we lost a few *days* to chip bugs that made that specific SPI port unusable.) I added support for the '103 and '105 chips once our controller PC board was fabricated.http://ecomodder.com/forum/editpost.php?do=editpost&p=247427


----------



## Jaesin (Mar 6, 2011)

That's awesome. Thanks for sharing. Where can we learn more about your controller?


----------



## bjfreeman (Dec 7, 2011)

I ran accross your code when researching.


```
/* Set Rx filter.  The reset defaults are used, enabling only filter
     * 0.
     * This filter accepts the following standard (non-extended) IDs
     *  0x420 our arbitrary operating ID for internal messages
     *  0x7DF the OBD functional (e.g. hailing/broadcast) ID
     *  0x7e0 this specific controller's OBD ID (possible 0x7e0..7e7).
     */
```
do you plan to suipport the extended Can 2.0A/B


----------



## DJBecker (Nov 3, 2010)

Jaesin said:


> That's awesome. Thanks for sharing. Where can we learn more about your controller?


I should update the code on those pages. We've been doing the development in a private SVN repository to accommodate some additional check-ins.

I've discussed the design quite a bit over on ecomodder, but it's easily missed among the thousands of posts.

http://ecomodder.com/forum/showthre...44v-motor-controller-6404-138.html#post279642

http://ecomodder.com/forum/showthre...44v-motor-controller-6404-138.html#post279671

http://ecomodder.com/forum/showthre...44v-motor-controller-6404-138.html#post279281

Here is one with the layout of our gate driver board:
http://ecomodder.com/forum/showthre...44v-motor-controller-6404-120.html#post238466

http://www.diyelectriccar.com/forums/showpost.php?p=249541&postcount=53


----------

