Romi / Windows 10 IoT
Posted: January 25, 2021
This is a project using Pololu's Romi robot connected to a Raspberry Pi 3 running Microsoft's Windows 10 IoT operating system instead of Linux. The original plan was to write all the code in C# to get practice with .NET, but that didn't end up working out very well (explained below). Oddly, I bet if I used Linux on the RPI3 and Mono I could have done the whole thing in C# no problem.
The RPI3 code opens a UDP socket and takes commands that look similar to the language LOGO: FD <count>, BK <count>, LT <count>, and RT <count>. The count is related to ticks on the motor encoders.
Related Projects @mikekohn.net
The original idea was to have it draw a pentagram around the candle, but inaccuracies in the wheels made that too difficult. Probably should have used the gyros / accelerometer on the board to keep it straight. The laptop window on the left shows an SSH connection to the Windows 10 IoT system. The window on the right shows the pattern.txt command file being sent to the Raspberry Pi using nc (netcat). https://youtu.be/gwt_OjWb_hA
The core of this project is the Pololu Romi robot kit. The parts used here are the Romi chassis, two motors, two wheels, two casters, and the control board (ATmega32U4 based). Headers had to be soldered on to get access to UART TX/RX, GND, Battery Input, and 5v output. There is a socket on the board which can connect directly to a Raspberry Pi, but I didn't end up using it.
After assembling the Romi, the next step was to write some firmware and get it loaded onto the control board. The firmware basically ripped off from my Apple IIe Robot project and modified for the ATmega32U4 chip and Romi board. The code is uploaded with avrdude after pushing RESET twice. The source code is available below and assembles with naken_asm.
The firmware on the Romi control board basically takes a single character plus a binary number. The characters are f, b, l, and r (forward, back, left right) so f and the letter A (65) would tell the motors to spin forward for 65 * scale ticks of the encoders on the motors.
Now the Raspberry Pi part. I had been sitting on this project for a while because I originally wanted to do it using Windows 10 IoT on a Raspberry Pi 3 with C# using developing code with Mono. Then I ended up getting a free Microsoft Azsphere board and wanted to make it all work using their Azure Cloud. After a while of screwing with their Azure tools and then having to worry they were going to charge my credit card, I decided life's too short and went back to Windows 10 IoT. Unfortunately, Mono doesn't seem to be an option (other than a simple HelloWorld.cs) so I tried C# using their UWP API. I was having a rough time with their tools for that so I again said "life's too short" and just wrote the code in C. To make the board fit better on the Romi chassis I tried to get it to boot on an RPI Zero W, but it seems Windows IoT doesn't work on that board.
The source code (also available below) is pretty much just some simple C socket code along with some fairly typical Windows COM port code. The UDP code wasn't working at first, it seems there's a command that has to be run to open up the firewall in Windows 10 IoT:
Another problem was figuring out the name of the COM port to open up. It appears the name is:
I found that online. There were a couple commands I ran, one was supposed to say the name of the COM device and the second turns off debugging on the COM port (not sure if the second one is actually needed, but I'll post it here in case anyone else stumbles on this page having trouble with Windows IoT UART):
With the motor_control.exe program running on the Raspberry Pi,
to pass commands to it by loading a text file called pattern.txt:
And passing it over UDP to the motor_control.exe with:
I found working with Windows 10 IoT pretty interesting. Where running Linux on a Raspberry Pi turns it into a computer (it has a login, can compile software, has a full desktop) Windows 10 IoT treats it more like a device. When it boots there is a screen that has some information, a mouse pointer, keyboard input in areas, and an awkward command prompt. The interface is a bit sluggish. There's also a web interface with lots of information and the ability to set things up. It's possible to ssh into it (username Administrator) and run software on the console. I was able to compile a simple HelloWorld.cs and scp it to the device and run it from the console, but as soon as I added UDP code it would bomb out with an error about missing libraries.
Installing Windows IoT on an SD card is also a bit awkward since it seems to require Microsoft tools to install on a Windows system. After that there is a flash.ffu file that can be installed with some of their tools, or converted to a standard .img file that can be dd'd under Linux using an ffu2img.py3 Python script.
The picture above shows the Raspberry Pi 3 connected to the Romi control board. The LiPo battery is connected to the battery port and the red / black wires from the Romi supply +5v and Gnd to pins 4 and 6 of the Raspberry Pi. The RXD1 UART pin is connected with a green wire to UART0 TX (pin 8) on the Raspberry Pi and the TXD1 UART pin is connected with a yellow wire to UART0 RX (pin 10) on the Raspberry Pi.
Copyright 1997-2021 - Michael Kohn