Close

moti v0.3 firmware overview

A project log for Moti, a smart servo

Moti is a smart servo that simplifies the design of intricate robots.

nicholas-stedmanNicholas Stedman 08/20/2014 at 23:500 Comments

Moti's firmware is written as an extensive Arduino library. I use Sublime as my primary editor, and just use the Arduino IDE to compile the a simple sketch, which is then loaded onto each Moti. The sketch looks like this:

You can add your own code in loop(), but Moti.update() has to execute once per loop, and the longer between updates, the poorer it Moti will function. The update itself takes 500 microseconds (on average).

Currently the firmware takes up 68% of flash memory, but that will come down significantly as the latest hardware revisions are factored in. Soon, I’ll add a flowchart that demonstrates how methods relate, but for the moment let me briefly describe it. There’s a main loop that checks the communication port for commands, such as “move 720º degrees Clockwise at 30 rpm“ or "read sensor 2”. Then the loop executes the appropriate methods, which is often updating the position. That consists of checking the current position of the motor. If there’s a difference, then it moves until it gets there. That’s basically it!

In previous versions the firmware was written as a single file. While it wasn’t as bad as you’d think, it’s clearly not ideal. With new hardware forcing a major revision of the firmware, I am taking this opportunity to overhaul it. I’ve been working my way through this awesome book to learn best practices (hopefully I'm getting it right). Now here’s the firmware breakdown:

Discussions