Friday, January 31, 2014

USB Serial Monitor

Lately, I've been working with USB Serial devices, and I've discovered that many serial programs don't like it when the serial device is disconnected.

So I decided to write my own little monitor program in python. It hooks into pyudev to get the add/remove notifications when usb devices are plugged in or removed (so currently it only works under linux).

Source code can be found here. It requires pyudev version 0.16 or newer.

If you run:
./usb-ser-mon.py -l
it will show you the currently connected devices.

USB Serial Device with vendor 'Teensyduino' serial '21973' found @/dev/ttyACM1
USB Serial Device with vendor 'Prolific_Technology_Inc.' found @/dev/ttyUSB0
USB Serial Device with vendor 'STMicroelectronics' serial '00000000050C' found @/dev/ttyACM0
If you want to connect with the STM device (an STM32FDISCOVERY board in this situation), then you might do:

1247 >./usb-ser-mon.py -n Teensy
USB Serial device with vendor 'Teensyduino' serial '21973' connected @/dev/ttyACM1

>>>
In the previous example the Teensy was already connected. If I unplug and replug the Teensy device then I'd see:


USB Serial device @ /dev/ttyACM1  disconnected.

Waiting for USB Serial Device with vendor 'Teensy' ...
USB Serial device with vendor 'Teensyduino' serial '21973' connected @/dev/ttyACM1
Done executing '/src/main.py'
Micro Python for Teensy 3.1
Type "help()" for more information.
>>>
You only need to use as many characters as are required to uniquely identify a device, so I could use:
./usb-ser-mon.py -n STM
to connect to the Discovery board.

Sunday, January 19, 2014

MicroPython running on a Teensy 3.1 controlling a DragonTail

I signed up for the MicroPython Kickstarter with the idea that it would be cool to use python for low-level control of a robot.

While I'm waiting for the MicroPython board to arrive, I started to play with a Teensy 3.1, which is a small 32-bit ARM based controller with 256K of flash and 64K of RAM.

I decided to try to port MicroPython to run on the teensy, and most of my progress so far has been checked into the MicroPython github repoitory.

Wanting to see a robot running MicroPython, I put together the Solarbotics DragonTail Deluxe Kit along with the Electronics Bundle, but I replaced the Arduino controller with the Teensy 3.1.

Here's a photo of the bot:




An this is a closeup of the Teensy 3.1 Breakout I whipped up:


The header strips are GVS (Ground-Voltage-Signal). The outermost row is ground, the middle row is 5v, and the inside row is signal. Since most of the signals on the top side (relative to the picture) are analog, I made the ground on that side be AGND. The jumper just to the left of green LED allows me to connect the digital ground through to the analog ground if I need to. The small green board in the bottom right is a DC-DC Switching Regulator I got on eBay.

I put a short video of the bot running on YouTube.

The python source running under MicroPython can be found in my DragonTail github repository.