Serial Monitor from EMF Camp Badge

I love the classic serial interface. Partly because it is so simple, and partly because of nostalgic memories from my youth when they were ubiquitous (well unless you had some fancy test-gear with GP-IO). A lot of my projects have a serial bus or two in them somewhere.

Occasionally I want to monitor what is happening on a serial interface to help debug a project. There are a few ways to do this. I can get my scope out and enable the serial decode. Or, I can wire-in a serial to USB convertor and monitor the data on a PC. But I can find both these options a bit fiddly to setup. For a while I've been wanting some kind of pocket-sized serial monitor that can connect to a serial interface and locally display the ASCII and Hex data.

When I needed to do some fairly complex debugging on Lunar Lander I knew a serial monitor would be very useful, so that gave me the impetus to make one. I've had a platform in mind for this project for a while. I don't like having bits of hardware hanging around turning into e-waste so I like to try and find uses for event badges and other computer boards that I acquire. For this project I picked the Tilda Mke from EMF Camp 2014 as the platform. It's a nice size and has a reasonable collection of buttons. The 128x64 black and white display is perhaps a bit small, but OK. It's Arduino compatible, so fits with workflows that I already know well. Best of all, it has a battery so the monitor can work without a PSU if needed.


Tilda Mke Badge


For this kind of embedded project I like to get close to the hardware, and have very little patience for learning about platforms and frameworks. So, off the bat I wiped the original RTOS-lite type environment off the badge and went straight to programming it natively like an Arduino. That might have been a bit rash, but it worked in the end. There were a couple of gottchas that I needed to work through. The files provided for the Arduino IDE for the badge were no longer compatible with the current IDE version. I think some odd manifest files are missing. I eventually just used the Arduino Due configuration and #defined in the program any extra definitions I needed that weren't in that.

A bigger challenge was getting the display fully working. I used the U8G2 library, but the actual display on the badge doesn't correspond 100% to any of the pre-defined types in the library. I could get stuff appearing on the display OK, but the contrast was very low leading me to suspect that the voltages or timings weren't set right. Not having much patience to learn how to work frameworks properly, I eventually took a pre-defined display type that worked OK, and then extended the display configuration sequence from the EMF Camp software and manually wrote the right values to the driver registers while still using U8G2 to do everything else.


Writing to the display


The software development was in my usual style: write something very simple (flashing an LED when data is received) and them keep adding functionality until it does what I want. It's very incremental, and not pretty, but it works for me. The screen is big enough to get 10 lines of 8 characters per line (in HEX and ASCII) - so the whole screen is equivalent to one 80 character line if you want to think about it like that! The badge is quite well provided with RAM though, so there is a big buffer and scrolling function to go back and see stuff that's gone off the display.

One of the nice things about this project is it is, of course, very hackable. When doing debugging for Lunar Lander I wanted to look for specific character sequences - no problem to modify the software to spot those and send a signal on a GPIO to trigger a scope, or to store the special sequences in a separate buffer for study.

The badge is a 3.3V system, and I still tend to work a lot with 5V logic, so I wanted some input protection. The obvious choice to to use a zener diode as a voltage limit. It turns out though, that low voltage zeners have terrible performance - the "knee" is more of a gentle curve (see below). Of course you read this stuff in text-books, but it's not until you actually come to practical example that it really hits home. I ended up using a forward-biased white LED instead which had much better performance in this application.


Zener Diode Curve



Input Schematic


The project really needed a case which was a good job for the 3D printer. I really like the visual design of the badge (and the 2 layer circuit board routing is impressive) so I wanted to keep that as a feature. The main problem is that the power switch is a tiny surface-mount slider on the BACK of the board. In a commercial project there would be a plastic leaver to interface to that and protrude through the case. You probably could achieve that with a 3D print, but it would be complicated to design and need trial and error. After a bit of contemplation I left a notch in the case to allow you to reach the switch from behind. It's a bit quirky, but I like the look and it works OK. It's interesting to compare my case to the one someone produced in 2014. The quality of 3D prints has come on a lot - mostly I think due to better slicing algorithms and control systems.

Once I got everything together I hit a snag - the serial monitor didn't work with some inputs - it looked like there was something else trying to drive the serial input to the microcontroller. After a lot of head scratching I realized that the IoT module on the badge was also connected to the serial line. If you are going to build this yourself then it is vitally important to remove the tiny resistors R5 and R6 near the IoT module to disconnect it from the serial lines.


Completed Monitor


Overall this is a nice tool, and something I think I will want to use a lot. I like the reuse of the old badge and the visual design (though I could/should have made the case a bit thinner). It does occasionally get a bit out of sync and read data wrong. I suspect this is just the voltage limit circuit not producing very good edges. Some nice enhancements would be to put some better input signal processing, and to use the secondary serial ports on the microcontroller rather than the primary one which is also used for programing and USB.

For those few who have a Tilda Mke badge (or want to make their own version with an Arduino Due), here are the files, warts and all: