m3pi preparation
Before you start using the mbed with your Pololu 3pi, you need to program the on board AVR with Pololu's "Serial Slave" example.
The easiest way is to use the binaries as described below. If you want to build your own then there are great instructions on at www.pololu.com with some handy links at m3pi-Development
The Easy Way¶
To do this the easy way you simply need to temporarily repurpose your mbed Microcontroller to be an AVR ISP programmer by using Aaron Berks mbedAVR programmer. This enables an AVR binary dragged onto mbed LocalFileSystem to be be programmed into the AVR over SPI - drag and drop programming for AVR :-)
You will need :
- m3pi AVR Programmer
- Program.zip - Contains "program.avr" - the file the ISP programmer looks for on the LocalFileSystem
The mbed AVR programmer only takes .bin files currently. As the mbed microcontroller would try to load a .bin file into the mbed itself, I have opted for the .avr extension.
AVR Studio generates .hex files, but there are many HEX2BIN converters available.
Lastly, the programmer will delete the binary once it has been programmed. This behavior can be prevented by removed the following line from the main.cpp
#define DELETE_BINARY 1
Setting up your hardware¶
The hardware connections between the mbed and the 3pi are simple. On the 3pi side, there is just a standard 6 way AVR ISP header :
The connection to mbed is straight forward.
AVR ISP | mbed |
1 MISO | p6 |
2 VCC | VOUT |
3 SCK | p7 |
4 MOSI | p5 |
5 nRST | p8 |
6 GND | GND |
As I am doing quite a lot of 3pi reflashing at the moment, I made myself a little breakout board on strip board, with a mbed socket and a 6 way AVR socket.
The Hard Way¶
To start working with the 3pi, you'll need to complete the following steps (or similar). Download and install a toolchain? How quaint ;-)
Seriously though there is plenty of help at the Software resources area on the Pololu site.
- Download and install AVR Studio
- Download and install WinAVR (avr-gcc compiler)
- Download and install Pololu AVR library and examples
- Get a copy of HEX2BIN - the output of AVR Studio is hex files, Aarons AVR910 implementation only works with binary files.
- Build (and convert to binary) the 3pi Slave example.
To help get through all of this, there is this Getting Started document from Pololu.
Once you're up and running, the Resources area for the Pololu 3pi contains a wealth of great stuff.