We just returned from ten days away on Salt Spring Island doing not a lot. It was one of those holidays where we didn’t have any plans except to relax, drink some wine, read some books, and enjoy ourselves. Except that I kept myself busy with a couple of electronics projects and my ever-expanding library of robotics-related code.
I’ve become really interested in using the Controller Area Network technology to have multiple processors communicating together. While researching the options I found this project: CAN-CAN. I liked the simplicity of using the Microchip MCP2515 and it’s less expensive than using one of the Atmel processors with built-in CAN support. And this project really made it easy, I starting thinking it was something I could probably do. So I did! Here is the schematic for my version.
My first project used two separate ATMega8 processors talking to each other over a CAN bus. I read through the source code from the original project but figured I could build my own version, integrated into my own library of code for my robots. I made a number of improvements, making it easier to configure for different hardware. The main program sends a short text string from one processor to the other, where the case is reversed (uppercase to lowercase and vice versa) and a reply is sent back. Here is a picture of what it looks like in action on the screen.
I spent part of my holiday cleaning up the code and implementing interrupt-driven TX and RX. The fun didn’t stop there though. I wrote a second program that “sniffs” the CAN bus and pretty-prints out each message. This has turned out to be very useful while developing other programs with the library (more on this later).
I’ve packaged up my entire library plus these two demonstration programs and made it available for download here. There isn’t a lot of instructions but I’ll probably try to put together something in the future (maybe my next holiday?).