Thursday, 30 November 2023

Pimoroni Yukon - Interfacing a Raspberry Pi to an Micro-controller running Micropython

I've been working on testing some new pre-release modular robotics hardware from Pimoroni. The Yukon board.


I am planning to build my Pi Wars robot around this, which means I need a way to talk to a Micro-python board from a Raspberry Pi. It would be really neat to be able to do this over the USB lead. This board is not a HAT, so needs powering via USB. I thought it would be great to use the USB port on the Pi to power the Yukon board, and for communication between the two.

This opened up a rabbit hole of learning. First to work out how to send data over USB serial from Python on the Pi, and how to read the data in Micropython on a connected micro-controller. I discovered that certain byte values get changed (line ending conversions) and that some kill the micro-python program (the same way pressing the 'stop' button in the Thonny IDE does). I learned how to disable this feature in micropython, and then how difficult it is to get control back when main.py auto-runs on power up and turns off the ability of the IDE to intercept and stop the program!

To avoid these problems I decided to hex encode each byte I wanted to send, so it is sent as a pair of bytes represented by ASCII characters which are safe to send. This topic raised some interest on social media, so I cleaned up the example and made it run on a vanilla Raspberry Pi Pico board. You can find the code on github.com/Footleg/rpi-pico/tree/main/micropython/serial_comms_over_usb

Saturday, 11 November 2023

Developing a small robot as a code test platform

I have learned from previous experience in the Pi Wars robotics competition how important it is to get testing code early. So rather than working on the physical build of my robot, I have been working on programming robotics code around areas which are new to me. I was already developing a small robot for STEM outreach events, based around the Inventor HAT mini board from Pimoroni.

This board supports encoder motors, something I have not developed code for previously. I wanted more feedback from my robot to better control it autonomously. Encoders enable you to read the speed of rotation of your motors, and count how many rotations they have made. This makes speed control possible, and distance travelled to be tracked. All my previous robots have been manual control only, so this was all new for me. I also added and IMU, which would enable measuring the orientation of the robot. This makes accurate turns possible.

The triangular tracked robot I was already developing is a little too small for Pi Wars, but the code developed on it should be portable to my competition robot once I have that built. I wrote a hardware abstraction interface so that my code talks to an interface which is independent of the specific hardware it is running on. I converted my manual control robot program from my STEM event robots to use the interface, creating this Universal Robot project on Github.

Saturday, 30 September 2023

Pi Wars 2024 - The Beginning

Hard to believe it is almost 5 years since my last Pi Wars blog entry. Since I last entered as a competitor in 2019, I have mentored school teams each year the competition has run, and so decided not to enter myself after discovering just how much work that was in 2019! This year my plans to run another after school robotics club fell through when the Computer Science teacher I worked with last time left the school. So I thought I should enter again myself. I've built quite a few robots over the years since my last time, so I've been promoted to the 'veterans' category this time around. I just need a name and an idea now!

With the entry deadline fast approaching, I decided the most visually exciting robot I could think of would use 4 RC tracks in the place of wheels on a 4 'wheeled' rocker-bogie suspension. I've had these tracks in the parts box for a while, intending to build a robot out of them.


So that's the idea. In keeping with the theme 'Disaster Zone', I needed a robot name. So I decided on:

Team name: Footleg Robotics

Robot name: Ragnarök Rescue


Just as I had decided to enter, my daughter told me she was going to enter as a young person team with a school friend, and wanted me to be their team mentor. So here I am again, entering myself, and mentoring a young persons team at the same time. Will I never learn?