Robotic R&D: FPGA and ML Pipelines

We've made progress in replicating a high-precision robotic arm (from Haddington Dynamics) since last April.

Before moving forward, let me recap the functional components of our robotic joint (with feedback and high precision):

  • processor sends controlling impulses to a motor driver;
  • motor driver modulates high-voltage electrical current to rotate a stepper motor;
  • motor spins a speed reducer gear;
  • an optical encoder (a wheel with slits that pass through a pair of IR light beams) translates angular position of a motor into a pair of voltage-modulated signals;
  • optical interface board captures voltage levels, drops some noise and feeds it to the analog-to-digital converter from which the processor could read.

In April we had the following goals in mind:

  • switch from 3D-printed cycloidal speed reducer to a 3D-printed planetary gear;
  • design and print an optical encoder to match the new gear;
  • print and solder an optical interface board, replacing a tangling mess of wires on the breadboard;
  • switch processing from Arduino Uno to a MiniZed Dev board (ARM+FPGA);
  • switch from L293D-based stepper motor driver to A4988.

All these goals are complete now. In addition to that, there is an emerging environment and tooling for moving forward with machine learning in this project.

Optical Interface

Initially our optical interface was just a mess of wires, capacitors and resistors on a bread-board.

Based on the original schematics from the Haddington Dynamics, I eventually managed to finish the routing and get a PCB design that looked correct.

JLCPCB has a good reputation for printing out circuit boards, so that's where we placed the order: 5 boards and one SMT stencil (helps to apply solder paste).

optical board pcb

Within the next couple of months we received the necessary parts and "good enough" equipment, then destroyed a practice board while learning SMT soldering with a heat gun.

As it turns out, soldering, per se, is easy. The tricky part is in placing solder paste and sticking little chips without accidentally scattering everything across the table and the floor.

optical board soldered

Planetary Speed Reducer

Aigiz printed a planetary speed reducer (from an existing design) that used airsoft balls as bearings.

planetary speed reducer

We designed an optical encoder in Fusion 360 to fit this speed reducer. It was modular to allow rapid iterations without reprinting everything all the time.

optical encoder design

After connecting everything together we got an optical encoder with good repeatability but low precision. Arduino Uno controlled it at this point.

optical encoder

That's when the data started flowing in.

ML Pipelines

Getting the design to work involved fiddling with different elements: capacitors, resistors and micro-stepping. Somewhere along the way a collection of data samples started getting out of control.

multiple trace files

At this point, it made sense to pause and invest effort in setting up the necessary software tooling. Just like most software projects, having the right tools could reduce toil and enable steady iteration rythm.

By a coincidence, two peculiar things happened at this time, helping to shape this tooling:

So after throwing a bunch of Post-It notes on the wall, I've hacked together a minimally usable environment for organizing datasets in Jupyter:

machine learning pipelines in Jupyter

This environment stores and structures datasets, models and notebooks in an opinionated way, associating metadata with every bit of information and state change. This makes dependencies and relations explicit, helping with versioning, documentation and collaboration.

machine learning pipelines UI

MiniZed FPGA

Somewhere along the way, a MiniZed FPGA finally arrived. It took some time to make sense of the toolchain and board details. Eventually (after multiple failed attempts and banging of my head on the desk), ARM Cortex-A9, Artix-7 Programmable logic, Xilinx Analog-to-Digital converter and our own mess of wires started working together (in a naive way).

Here is how our design looks at this stage:

PL logic

This upgrade allowed us to replace Arduino Uno, while increasing sampling precision (11 bits) and frequency (10k-100k samples per second).

naive FPGA design

Next Steps

For the next month, I'll be traveling with my family, away from the hardware. I will make advantage of it by focusing on the software:

  • migrate ML Pipelines environment to event-sourced design (to evolve design without worrying about data schema upgrades);
  • explore programmable logic in a simulated environment for absolute positioning (with Verilator);
  • explore models for compensating jitter in the speed reducer (perhaps, even give a try to hashed perceptron in PL).

Meanwhile in Ufa, Aigiz will be working on a new design of the speed reducer gear.

- by .