../micromouse-1

Micromouse Project Chronicles

Micromouse is a competition where the goal is to build a "mouse" that can find its way to the center of the maze it is put into using only the sensors and computing power on its body. I discovered this from a Veritasium video about the topic and thought "I could do that!". Since then, I've sunk a lot of hours into researching, prototyping, and building this.

The entire goal of this project was to make some educated guesses as to what I can do, then revise from how components perform in practice. I decided early on to use some brushless DC motors1. I picked some drone motors because they seemed comparable to the high RPM brushed motors that are usually used for small robots, but are significantly cheaper, more efficient, and can have higher torque if given the right current.

In my research, I saw many people used cheap infrared proximity sensors to detect walls. I liked the idea, but thought it would be silly to not have the ability to precisely measure position relative to other variables. Because of this, I bought the VL53L4CD time-of-flight sensor from ST Microelectronics. It shoots an infrared laser and has a microcontroller that measures the time it takes to bounce back. This distance sensor seemed like it would be able to accurately detect walls and give me a bit more precision. I have another blog post from when I ended up writing my own library for it here

I decided I could pick some components early on using educated guesses and update them with better guesstimates later from how they perform. This is how I settled on picking basically the cheapest ESC offered by RaceDayQuads. I messed with them for weeks and ended up accidentally frying one. Before that happened, I updated a driver for the DShot drone ESC protocol to add support for bidirectional DShot. My university classes were so boring that I learned assembly in my dorm to write state machine code for my RP2040 chip. The RP2040's Programmable In/Out (PIO) state machines are quite useful for writing simple code to send very specific digital data without dedicated hardware or having to pause the main thread to bitbang in real time.

While researching and troubleshooting DShot, I learned that I was missing out on Field-Oriented Control. If sinusoidal currents are applied to the 3 phases, the motor wastes less energy creating magnetic fields in the wrong directions when spinning. I also didn't have very transparent knowledge about the current consumption and rotational speeds from those ESCs. This led to me buying some ESC devkits from ST. The G431B-ESC1 is super convenient because it is a reference design from a company that sells chips. That means it has proper documentation and PCB SCHEMATICS!! It doesn't, however, come with very good libraries, because I couldn't figure out the ST Motor Control Workbench. I ended up discovering, then using the STM32duino Arduino drivers to run a script that uses the SimpleFOC library.

Because I was tinkering with a devkit, there was no overcurrent protection whatsoever. I needed to keep eyes on the current alongside any other variables. I didn't want to spend an exorbitant amount of money on a current clamp or differential probe, so I ended up learning Ohm's Law before taking Physics 2: Electricity and Magnetism, and added a current shunt resistor in series with the circuit. I measured out the resistor using my friend's current limiting power supply, calibrating it to have 0.01Ω of resistance. Because the resistor (≈20cm of 22awg wire) has a known resistance, the voltage drop across it shows the amount of current flowing through the circuit. Conveniently, my 1980s analog oscilloscope has an add function that lets me add a negative value of probe 1 to probe 2. That let me measure the voltage drop and show it on a graph, leading to approximately ten millivolts of voltage drop per amp of current.

TO BE CONTINUED...


Future me note when proofreading/editing this on 2024-05-12: I had no idea how large this project was going to turn out to be. I've been writing a motor controller library because of how expensive the prebuilt solutions are. I ended up getting something to possibly work, but because I hadn't taken Physics 2: E & M at the time, I ended up setting a parameter wrong and fried an ESC. Now that my university classes are over, I think I have enough time and knowledge to resume this project in the near future


1

calling this a DC motor is quite a misleading. They are DC in the sense that their controllers are powered by direct current, but the controllers modulate 3-phase AC current to magnetize the poles.