Jon's Place

Sunday, December 30, 2018

MicroDrone, and other stuff

Well, its been a long time since I did a real post here - over a year. 2018 is winding down, and I'm working on a couple new robots. I also have some life news.

I started working as a Senior Software Engineer at Google in May, working out of the Kitchener (Waterloo) office. I'm working on a nice mix of hardware and software, with a bit of machine learning thrown in. Lots of cool stuff happening at Google, and I'm enjoying it immensely.

I'm working on a completely new version of Seeker 2x, my newest autonomous mini-sumo robot. I've got a new 4-layer PCB built, and I'm just waiting on a stencil so I can populate one to test it. I had to do another new board because I'm completely re-doing the chassis, and the old one wouldn't fit.

I've also just recently decided to start working on a small autonomous indoor quadcopter drone, which I'm calling MicroDrone. The plan is to use a custom MicroPython board for the flight controller, and a Raspberry Pi Zero W for higher level control. I'm using brushless motors and props from a DJI Spark drone (since MicroDrone is pretty much the same size).

I'm 3D printing the entire chassis, using ABS for now. I'm going to order a new nozzle for my printer so I can print carbon-fiber-reinforced ABS material.

I'll be using laser time-of-flight range sensors on all six sides (front, back, left, right, top, bottom), and I'll be using a down-facing camera connected to the pi zero to do stuff like optical flow-based odometry. In the picture above you can see the two large holes in front of the battery at the bottom - the one next to the battery is for one of the laser sensors, and the one in front is for the down-facing camera.

The flight controller PCB will have a cortex M4 32-bit ARM chip running MicroPython, and a BNO055 9-axis IMU for flight stabilization. The camera and the laser sensors will be connected to the Raspberry Pi Zero,  which will be running Tiny Core Linux.

Saturday, March 31, 2018

Moved the blog

I've moved the blog to a new domain, since I sold a short time ago.

The new domain is:

Hopefully I'll be posting some new stuff shortly...

Thursday, September 7, 2017

Asset Science & Robotics

I got laid off from Mozilla about a year and a half ago (shortly after my last blog post). I ended up going back to the same place I was working before I joined Mozilla, a small start-up called Asset Science. They were originally going to (re)-hire me to work on their software, but after seeing my workshop and some of my projects, they decided the time was ripe to build a robotics solution for testing mobile phones.

So, for the past year and a half, I've been designing and building a simple, low-cost, robotics solution for doing automated testing of mobile phones. The first set of production prototypes will debut at the Mobile World Congress show in San Francisco next week.

Here's a slick professionally done video showing it off:

I'll probably post more details after the show.

Sunday, February 14, 2016

Roz - Raspberry Pi

Its been a while since I posted here - life has been busy. The first revision of the power board had a couple issues, so we ended up doing a second revision. This second revision works great.

Power Board Revision 2

I 3D printed a mount for Roz so I could fasten both the power board and a raspberry pi 2. I also picked up a 2.8" touchscreen LCD from Adafruit, and also a spy camera (also from Adafruit). You can see the camera in the picture below - it is on the end of a long gold-colored flat cable, just in front of the head.


The raspberry pi 2 has a wifi module, and an Espruino Pico, which has been re-flashed with MicroPython. The pico is acting as a bus forwarder for the Bioloid bus, which contains the 14 servos, and the power board (which is also a device on the bus).

The screen will allow me to display status, and run debug routines, choose missions, and in general give me visibility into what's happening. The camera (which isn't mounted yet) will allow me to run SimpleCV, and thus add vision-based capabilities to Roz. I'll be designing and printing a new head for Roz to include the camera mount.

The other thing you can see in Roz's head is a LIDAR Lite, which is essentially a laser-based range sensor. I backed the company on their original crowd-funding campaign, and this seemed like a reasonable place to use it.

Having the power board allows me to hot-switch from battery power to wall power and back again, which is essential in my opinion for using an OS-based computer on a robot. I would have liked to incorporate a 3-cell charger into the board as well, but that will have to wait until version 2.

Sunday, January 3, 2016

Roz - Power Board

So my brother Dave and I have been designing a new power management and distribution board for Roz and his walker. Dave bought a 6-legged bioloid walker from Trossen Robotics, and we'll be sharing code and hardware on our projects.

Its very close to being sent off to the board house to get made. Here's what the schematic looks like:

Roz - Power Board Schematic

 And this is the PCB layout:

Roz - Power Board PCB

The PCB will be 80mm x 42mm. If you want to take a closer look, you can find the design files in my github account. We use Kicad for all PCB design.

This board has a number of nice features. You can plug in wall power (12 volts) and it automatically switches to use that to power the robot instead of the battery. When you unplug wall power, it automatically switches back to battery without missing a beat. It will also monitor the voltage in each cell of the battery (we use Lithium Polymer 3-cell battery packs).

The main power on/off switch is actually a push-button (which can be remotely mounted). Push and hold it for more than 500 milliseconds and the circuit powers up. Push and hold (while powered up) for more than 2 seconds and the circuit powers down. Of course, its all programmable, using the 32-bit ARM Cortex M4 chip onboard, running MicroPython (of course, what else?)

The board provides a five amp/five volt regulator, to power a raspberry pi. On Roz, I'll be using a raspberry pi 2, along with a 320 x 240 touch screen LCD panel display. Both of these were purchased from BC Robotics, and I definitely recommend them as a distributor for Pololu and Adafruit stuff if you live in Canada.

The microcontroller (an STM32F401) will also be a device on the bioloid bus, and so can be queried from the pi like the AX-12 servos. This will allow the pi to shut down power to the entire system, as well as monitor power. The microcontroller has an extra four general purpose I/O ports (which can be digital or analog), as well as an I2C port, an SPI port, and a UART. All of the ports have jumpers to allow either five volts or 3.3 volts to power whatever is plugged in.

Designing, prototyping, and building this board has been a lot of fun. I'll report back here once I get the actual bare board back from manufacturing.

Wednesday, December 2, 2015

Roz - Obstacle Scanning

I wrote up a simple scanning routine for Roz that does a 120 degree scan using the front-facing GP2D12 sensor, gathering a result every 40 ms (basically the update rate of the sensor). The scan takes one second, so the resolution ended up being five degrees.

Here's a quick video of the scan itself:

Here's the output of the scanning routine:

>>> import sonarTest
Total time:  1000
[6.369501, 6.369501, 6.354494, 6.622461, 7.411738, 8.793456, 10.49099, 12.54209, 12.52528, 15.2174, 19.15718, 23.08899, 29.92357, 38.45215, 49.59524, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]

Groups:  [(15, 24)]

Max Group:  (15, 24)
Center of Max Group:  618
Center Angle:  31

The scan routine, after running, analyzes the results, looking for areas where there are no obstacles. Each contiguous area gets grouped together, and it finds the "widest" obstacle free area, and then points the robot's head towards the center of that area at the very end.

Here's a plot of the scan:

I've included scan line numbers in the plot for reference. The wall shows up nicely in the plot.

In the actual obstacle avoidance routine I've written using this, Roz rotates his body to that final direction, and then continues walking.

The obstacle scanner code is here:

and the place where I use it is:

I use body inverse kinematics to move Roz's body forwards while scanning. This has the effect of turning the main leg servos back, so the legs aren't in the way of the head as it does its scan.

I'm planning on designing and building a new head eventually, that will replace the front GP2D12 range finder with a LIDAR-lite sensor. I backed their original crowd-funding campaign, so I have one. While that sensor is major overkill in terms of capabilities, the really important thing is it can sample at 250 Hz, which is 10x faster than the GP2D12. This will allow me to get one-degree resolution scans.

I plan on using this capability for more than just finding the way out of tight corners. I eventually want to use it to help choose which direction is best to walk in, and to do a limited amount of localized mapping.

Monday, November 30, 2015

Roz Walks Again

So two years ago, you might remember I ported Roz to run in Python on a BeagleBone Black. I really like Python, but I figured out that I'm not so happy having a small simple robot running an OS. Basically, its major overkill, and it introduces a lot of problems that aren't really easy to solve, some involving trying to keep it running so you don't have to wait multiple minutes for booting.

Anyways, over the past couple weeks, my brother Dave got MicroPython talking to Bioloid servos directly, without needing an interface board, much like he did with an AVR way back when.

This was really a watershed moment for me, since it meant that I could program Roz in Python, but not have to deal with an OS on the robot.

I quickly designed and 3D printed a new head for Roz, one that was much smaller and simpler than the old one, still containing 3 IR range sensors, but also containing one of my custom uCee MicroPython boards.

Roz Standing

This works really well, as it turns out. I ported the regular Python code to MicroPython (which wasn't that much work), and got everything working nicely again. Here's a simple video showing Roz walking around again.

This is just the beginning. Now that I have a robot with reasonably robust hardware, I can start working on the programming side of things to hopefully add some interesting behavior. The current code can be found on my GitHub account, but of course it is a work in progress.

Friday, October 23, 2015

CNC Milling

As some of you probably remember, I have a Sherline CNC milling machine. It hasn't had much use in the last five years, but sometimes you really need to make robot parts out of metal instead of 3D printing them in plastic.
My Sherline CNC Mill
I needed some new parts machined for Seeker 2x, so I decided it was time to haul out my mill, and get it running again. The last time I used it, I was controlling it from an old laptop I bought in 2000 (a 1 GHz Pentium 3) using Mach 3 through the parallel port. I decided I wanted something a little more modern, so I started researching options. It turns out that the Xylotex control box I used was simply a power supply and a stepper control board to handle 3 axes, using the normal step/dir control pins for each axis.
Xylotex CNC 3-Axis Control Box
So, with a lot of research and discussions with my brother, I ended up installing GRBL on an Arduino Uno I had in one of my drawers. I wanted to use ChiliPeppr for my GUI, and since my desktop is on the other side of my office from the mill, I decided to use a Raspberry Pi 2 that I had to run the serial port json server, so it could sit over on the desk next to the mill, and give access to the mill over the network.
I soldered together a custom 7-wire cable to connect my Arduino to the stepper board, set up the Rpi with the server, and plugged everything in. Amazingly, it all works seamlessly. Next post will talk about the software I use to get from CAD models to G-Code.

Wednesday, October 14, 2015

Seeker 2x Running MicroPython

My new boards came in today, ordered from Dangerous Prototypes. I ordered the boards on October 6, and they arrived at my door on October 14, which is amazing. The best part was the cost, the boards (10 copies of one board) were $10, plus $20 for 2-day shipping. Definitely worth it.
Seeker 2x new PCB

The idea is I'm stripping all the old electronics out of Seeker 2x, and I'm going to be replacing the insides with this new board, which contains:

I always had big software plans for Seeker 2x, but I really don't like programming in C, so I never got around to actually doing more than a bare minimum. Now that I'll be able to use Python to code things, I'm hoping I can do some much more advanced tricks.
Seeker 2x
I'm also really excited to play with the new 9-axis IMU chip. For $16, you get a full nine-axis sensor package together with an onboard Cortex M0 ARM chip running real time (100 Hz) sensor fusion. A few years ago, that combination would have come on a big board and cost over $1000.

Tuesday, September 22, 2015

Two Old Warriors

I moved to London Ontario this past summer, and one of the perks of moving to a city is having a local hackerspace. unLab is a neat place, with an interesting cast of regulars who show up every Thursday night. I have more stuff and better tools for the most part at home, but for me a hackerspace is all about the people you get to interact with.

Anyways, this coming weekend (September 26/27) is Doors Open London, and I'll be at the unLab all day on Saturday, talking to people and showing a couple of my robots.

Yes, Seeker 2 and Seeker 2x are coming out of retirement, and will spend the day going head to head.

Seeker 2 and Seeker 2x Face Off
Should be a lot of fun...

Monday, January 19, 2015

Work Stuff

Some of you might be interested in the stuff I am doing at my day job (Mozilla - been working for them for two years now).

In general, I'm building tools for measuring power consumption on FirefoxOS phones. Those tools include hardware and software components. I did a post a little over a year ago, when I first started working on power stuff.

This year, I'm building a new version of the battery harness, one that is portable. The idea is, you attach it to your phone, and spend the day wandering around, doing whatever it is that you do, and all the while the battery harness is logging power usage data to a micro SD card.

I assume the people reading this are more interested in how it all works, so I'll dive down into the details now.

The battery harness basically pulls the battery out of the phone, and provides a secure mechanical adapter to power the phone from the battery, while allowing the positive line to be intercepted, between the battery and the phone. This shunt goes to the ammeter (a custom board that I designed and built), and the ammeter measures voltage drop across a resistor to get instantaneous current.

Normally, the ammeter is in a small 3D printed box, and is connected to a PC view a USB cable. There is an AVR on the ammeter running some custom C code, and it sends power usage data over this USB cable to a Python application running on the host PC. With this new portable harness, I mounted the ammeter directly to the harness, and mounted a Sparkfun OpenLog board under it, connected to the debug hardware serial port on the ammeter (which normally isn't used). You can see these pieces on the following pictures:

Portable Harness with Ammeter

Bottom of Portable Harness, with OpenLog Board

You can also see a small Pololu Voltage Regulator board tucked in there in the second picture. It is a step-up/step-down regulator, and produces a steady 5 volts from anything between 2.7 and 11.8 volts.

Normally the ammeter is powered from the host PC over USB, but with this setup there is no host PC. We can't power it from the phone, because that will interfere with the power consumption measurements. So I got another little single cell 850 mAh Lipo battery from Sparkfun, and mounted it where the phone battery would normally go. It provides 5 volts (using the regulator) to power both the ammeter and the logging board.

Here's what it looks like together:

Portable Battery Harness
I designed and 3D printed a cover, so you could put the whole assembly into your pocket without electrocuting yourself or damaging the electronics. In the above picture, the cover is on the left, and contains an on/off power switch, a charge port (for the small lipo battery), and a neat little turning catch to hold it in position.

Here's what it looks like put together:

Portable Battery Harness with Cover
It make the phone somewhat thicker of course, but it allows you to still use all the features of the phone (including the camera) while measuring power consumption.

Here's a picture with the power switch on. The three LEDs are on the ammeter - green is power, red is a flashing heartbeat, and yellow is an indicator for a software switch on the ammeter. The OpenLog board has a small blue LED, but you can't really see it in the picture.

Portable Battery Harness - Powered Up
There is still a lot of work to do on this - the charging system is not ideal, and I'd like to integrate it better, I also need to write some software on the phone itself, so it logs specific events (like "Took a picture") that can be correlated with the power log. I also need to figure out a way to monitor the voltage on the small LiPo, so I don't accidentally drop its voltage down below 3.0 volts (which can cause permanent damage to these batteries).

Friday, January 16, 2015

Arduino Robot

So, its been quite a while since I last posted here. Sorry, haven't been working on anything robotics related in a couple months. Today I got a robot in the mail from a contest I won over at Diigiit Robotics. This is the first robot I've owned (other than bioloid kits) that I didn't design & build from scratch myself.

Not sure what I'm going to do with it, but you never know...

Wednesday, October 15, 2014

NanoSeeker v2.1 Populated Board

So I built a board tonight, and its working (after removing and rotating one of the h-bridge chips I put on backwards). I've validated that micropython works on it, and I can turn on and off the four LEDs. I've also successfully paired my cell phone with the bluetooth module on the board, so I'm pretty happy about that.

Tomorrow I'll test more of the functionality, making sure that everything works.

NanoSeeker v2.1 PCB Populated

Here's a picture of the entire sub, with the PCB attached.

NanoSeeker v2.1
The hole in the top of the nosecone is where the pressure/depth sensor will go.

New PCB Arrived

So the new PCB from DirtyPCB's arrived today!

It looks awesome, and I like the black color. Here's a picture of the top and bottom of the board, followed by a side-by-side of the previous yellow board with this new one. The only real difference is the bluetooth module footprint (and the color).

Top and bottom of new PCB

New PCB next to previous version
So I'm pretty happy about this - I'll see about getting this board populated tonight after work.

Thursday, September 25, 2014

NanoSeeker v2.0 PCB - Time for a redo!

I made a couple mistakes with this new board for NanoSeeker. One mistake was recoverable - I forgot to include a power line on the schematic going to the IMU chip, so I had to solder a wire in place to provide that. Ugly, but it ends up being usable.

NanoSeeker v2.0 PCB, with power wire for IMU

The second mistake was not recoverable. I chose a bluetooth module strictly based on its size, assuming it would work like other bluetooth modules I've used in the past. The module I chose, the BLE113 from BlueGiga, is a bluetooth 4.0 module, and is pretty much useless out of the box. You have to program it in order for it to be useful, which means you have to have some sort of programming interface designed into your board. Okay for a manufacturer who is going to build thousands of boards - not okay for a hobby-level board that is a one-off.

I found a nice, small module made by ST (same company that makes the MCU chip I'm using), that is bluetooth 3.0, and supports SPP out of the box. The module part number is SPBT2632C2A. I got a couple of them from Digikey, and I'm going to ensure that it works before I do anything else.

So, I'm redoing the board, and replacing the old bluetooth module with this new one. I've also made sure to add a power drop to the IMU. I'm going to try a new PCB place ( - they have similar prices but much better shipping options that SeeedStudio, who I used for the last board run.

Sunday, August 31, 2014

NanoSeeker v2.0 PCB Running

So, this morning I populated one of my new boards, and hand-soldered a few of the through-hole parts needed for it to run...

NanoSeeker v2.0 PCB, Populated
Here's a video with a very simple script running, cycling the four LEDs on the board:

The script is from this page:

leds = [pyb.LED(i) for i in range(1,5)]
n = 0
while True:
  n = (n + 1) % 4
I'll be testing the individual parts on this board over the next little while...

Tuesday, August 26, 2014

NanoSeeker - PCB

So, its been three and a half weeks, and my new board showed up today. So hopefully in the next few days I'll get a chance to build one, and see if it works.
NanoSeeker v2 PCB
These boards were ordered from SeeedStudio.

Friday, August 1, 2014

NanoSeeker - New Board

I've been working over the past couple weeks on the design of the new board for NanoSeeker, and its done now, and sent off to SeeedStudio for manufacturing.

Here's the schematic:

NanoSeeker v2.0 Schematic
The layout was difficult, because the board is only 26mm wide:

NanoSeeker v2.0 PCB - Top & Bottom

NanoSeeker v2.0 PCB - Top Only
The board is going to be done in yellow, which I think is a nice color for an underwater vehicle. Since the shell is clear, it will all be on display. I'm having a surface mount stencil made by OSH Stencils.

I'm again using one of the awesome Pololu 3.3 volt switching up/down voltage regulators to provide power for everything, from the 180 mAh 7.4 volt Lipo battery.

While I'm waiting for the new board to arrive (will be ~4 weeks), I'll work on getting some of the mechanical parts together (dive plane/rudder plus linear actuators), as well as getting started on some of the software that will be needed on the sub.

Friday, July 18, 2014

NanoSeeker Version 2

So, its been quite a while since I last posted here. I spent most of April and May traveling, including going to Maker Faire in San Mateo, and JSConf in Florida. While I was at JSConf, I ran into some of the guys from OpenROV, and we immediately starting talking about ROVs and AUVs. I had brought NanoSeeker with me, just to show to anyone who was interested, and we found out completely accidentally that the battery holder tubes for an OpenROV are exactly the right size to make a transparent shell for NanoSeeker.

NanoSeeker with a clear shell
Eric Stackpole, one of the founders of OpenROV, gave me a spare one they had with them, and I immediately started thinking about what I could do with a new version of NanoSeeker. I built the first version of NanoSeeker in 2009, and a lot has changed in the home-brew electronics space since then.

I decided right off the bat that it should run MicroPython (and thus use an STM32F405 as the processor), and incorporate a full 9-axis IMU, as well as a depth sensor and a speed sensor. I started working on the CAD model, and got it to the point where it was ready to be printed. I bought my own material cartridge for the 3D printer I use for work, so over the past week I printed the parts I would need.

NanoSeeker v2, beside the old v1
I need to find another o-ring that is the right size, and of course I need to completely redesign the electronics, but I think this is going to work out nicely. I'm going to include a bluetooth module on the board, which will allow me to update the python scripts driving it while it is on the bench, without having to open it up.

I'm really looking forward to having a micro AUV that I can program in a reasonable language, without having to go through a lot of crazy hoops.

Friday, February 14, 2014

MicroPython Board With a Crystal, and a New Motor Driver Board

So, I ordered a few of the crystals Damien used on the official MicroPython board, and although physically it isn't a perfect fit, it works, so I now have a nice clean board.

I also got rid of the orange LED, and replaced it with a proper blue LED (I didn't have any of those left when I put the board together). So, everything is as it should be, and is working nicely.

I also ordered a couple new motor driver boards, and have one hooked up now - it is working great. uCee will be back together again shortly, driving around with my custom MicroPython board (all the videos shown up until now were with the Teensy 3.1 running MicroPython).

New Motor Driver Board
Things are back to working, which is a good thing. I'll be bringing uCee (along with Roz) to PyCon in April in Montreal, since both robots are powered by Python.