Firmware Design

Firmware Design

The BrickPi is powered by a microcontroller based on Arduino.  It has a very similar circuit to the Arduino Uno, using an ATMEGA328 as the central “brain” to control the motors, count encoder values, and read sensors.

General Overview

The BrickPi receives commands and requests from the Raspberry Pi over Serial.   The BrickPi is setup as a serial slave.  After initialization, the BrickPi acts on commands from the Raspberry Pi.

The BrickPi firmware must be loaded through ISP pins; no USB connection is available for programming.  There are two separate ISP programming footprints on the board.

Each ATMEGA328 is addressed in the EEPROM, which allows them to share a serial line to and from the Raspberry Pi.

The firmware constantly runs in a loop, updating the motor values, encoder values, LED values, and sensor values in the void loop() function.  This loop is interrupted for serial calls from the Raspberry Pi.

The Code

The latest code is kept in our Github Repository for BrickPi.  You can get the entire project in one full swoop there!

An Open Invitation to Copy, Hack, or Improve

We would love for you to copy this, on your own project or to make the BrickPi firmware better.  Here’s our Our Github Repository.  Just let us know what you’re up to!

Go forth!