The Ultimate Remote is Dead. Long Live the Ultimate Remote 2.0

In late 2015 I built a piece of assistive technology that I called my Ultimate Remote. The device was an infrared remote for controlling my TV and cable box. It also had infrared mouse control for my computers. There were also limited keyboard commands mostly arrow keys, enter key, backspace and some control keys for doing cut-and-paste. Finally it was a Bluetooth device for doing accessibility switch control on my iPhone. I wrote about it in this blog post from January 2016.

The Ultimate Remote Control and Why I Built It


The core of it was an Adafruit Micro BLE device which was discontinued shortly after I purchased it. Adafruit replaced it with the Adafruit Feather 32u4 BLE. The Micro BLE also had an ATMega32u4 which is one of my favorite 8-bit processors.

The display was a monochrome 1.3 inch 128×64 OLED graphic display. It also contained one of my infrared I/O boards although it only did output. I didn’t really need to read any IR codes. On the end of a long wire were three lever micro switches that I would hold in my right hand to control the device.

The device served me well for well over a year. It was critical to me during my recent hospital stay where I was on a ventilator and could not talk. I used the switch control to type notepad messages on my iPhone and communicate with the nurses and doctors. You can read about that adventure here.

Pray That They Listen to the Man with No Voice

The micro switches have always been the weakest link in my devices. I have to use switches that have a feather touch to them and that means they are very fragile. The switches get knocked around quite a bit and so it was inevitable that one of them would break. About a week ago one of the switches failed and we had to replace them.

I had planned for many months to rebuild the entire device. I had used up all of the program memory in the device and could not add any new features or any new IR commands. I did not have codes installed for my Blu-ray player and there wasn’t any room left. In fact one time I had tried to recompile the code and because one of the included libraries had been updated, the code wouldn’t fit anymore. I don’t know if it was the Bluetooth BLE library or the graphics display library but something changed. I had to go through my code and try to free up some space by eliminating some error messages or shortening other messages. I finally got it to recompile but the writing was on the wall that I needed to upgrade.

The obvious choice was to use a new Adafruit Feather M0 BLE. Instead of the traditional 8-bit 32u4 running at 16 MHz with 32K flash memory and 2.5K RAM, I would have a 32-bit ARM Cortex M0+ running at 48 MHz, with 256K flash memory and 32K of RAM. The main problem was that my infrared library IRLib did not support these newer 32-bit ARM processors.

I had just recently spent weeks researching the new processor and converting my infrared library to support the newer chips. The timing and frequency modulation portions of my IR code are extremely dependent on the internal timers of the processor and that is very hardware dependent. I had to learn a whole new system of timers and PWM frequency control to rewrite the code. Fortunately I got it running just in time.

Although I had the infrared code working on the new processor, and had a Feather M0 BLE available to build a new device, it should not have been necessary to rush the new device into construction. All we had to do was repair the old remote by replacing the micro switches. I already had another set of switches assembled in anticipation of building the new remote. All we had to do was cut the cable on the old one, splice in the new cable and everything would be fine.

Dad decided that rather than having a stiff, unsightly splice in the middle of my cable, he would open up the box, unsolder the old cable and solder on the new cable. He ended up completely disassembling everything to get at the wires that needed replacing. I appreciated that he would go to that trouble even though this device was going to get replaced probably in a month or two. Unfortunately this was a bad decision.



Above are photos of the interior of my original ultimate remote. As you can see the wiring is pretty complicated. Unfortunately I only have about four different colors of wires available so we had to use the same color wires for different purposes. For example there are multiple green wires used for different purposes. After replacing the cable to the micro switches, dad tried to plug everything back in the way it was. We plugged in the device and I tried pushing the buttons but nothing would happen. In the course of trying to figure out what was wrong he touched one of the infrared LEDs and discovered that it was very nearly becoming more red than infra. It was too hot to touch. Although we did not get a visit from the infamous “Blue Smoke Monster”, if we had left it connected very long we would’ve had at least smoke and possibly fire as well.

It didn’t take us long to find out that the culprit was 2 green wires that had been crossed. We fixed the wiring and plugged it back in. No heat this time. The device worked intermittently for about five minutes and then quit working altogether. It was obvious that we had burned out the IR LED at least and possibly the transistors driving them.

Fortunately I had sufficient parts to build a new IR output board so we spent the next afternoon building it and installing it. It would not work either! One of the problems we were facing was that we had assembled and disassembled the box many times. I had been using small gauge stranded wire with silicone insulation. That is very flexible and made it easy to route the wires in a tiny box. However several of these wires were soldered into through hole locations on the circuit boards. Right at the point where they are soldered in, they are extremely susceptible to breaking if they are bent back and forth too many times. A better solution would have been to put a header pin in the hole. Then we could solder the stranded wire onto the pin and cover it with a piece of heat shrink tubing. At this point it was too late to do that.

We tried repeatedly to diagnose the problem with the new IR board but every time we fixed one thing, something else would break. There was also the possibility that we had damaged the Adafruit Micro BLE board itself. As I mentioned earlier, that board has been discontinued so there was no possibility of replacing it. After two full afternoons of working on it, I decided to throw in the towel and put all of our efforts into building the completely new device that had been planning for months.

I had all of the necessary parts. The new device would have a much larger 2.4 inch TFT color graphics display instead of the 1.3 inch monochrome OLED. This device also features a resistive touchscreen however I don’t have any use for that feature. It also includes a slot for an SD memory card. I may come up with a future use for that.

One of the nice things about the Feather Wing TFT board is that the feather board plugs into a socket in the backside. You don’t have to run wires from the main processor to the display board. However one of the disadvantages is that there is only one power and one ground pin on the device. So I was going to have to cut up a little piece of prototype board to make a power and a ground bus. This would bring in power from the outside, connected to the Feather and display boards, and run power to the infrared board. Similarly I needed ground wires to all of those parts plus a ground wire for the micro switches. We also needed to solder a jumper so that I can turn the backlight of the display off and on. There is a solder pad available but you have to jumper it to one of your Feather pins.

Although the Feather boards have a built-in battery connector and a battery charging circuit, I decided to power the device from an external 5v battery source. My old Ultimate Remote was a 5v device throughout while the Feather system runs on 3.3v. In the old system I had a short cable with a barrel jack running from the remote into a battery pack I call a Printy Boost. The Printy Boost is a device which I designed for the Adafruit Learning System as seen here. The Printy Boost also provides extended battery life to power my iPhone. So rather than have a separate battery for the remote and for the iPhone backup power I decided I would stick with the old system and run a cable from the Printy Boost into the remote just like I did before. Rather than connect to the +3.3v pin I connected to me “USB” pin which was the same as powering it through the USB cable at 5v.

There are some differences between the Feather TFT board and the old monochrome OLED graphics board so I had to tinker with the software to get things to run. Most of it was compatible because Most of the Boards operate on the Adafruit Graphics library but there are still differences. Once I had display software converted I tried using the device. Unfortunately it didn’t work again! You would think I would be more careful about crossed wires after the previous fiasco. It turns out we had the infrared I/O board wired backwards. I had drawn the wiring diagram looking at the front side of the IR board. That means on the right 2 pins are power and ground. Then moving to the left you skip one pin and the next one is the IR output. However the way the board is oriented in the device, the backside of the board is facing upwards. We wired it with power and ground on the right but that was wrong. Fortunately this just meant that the power lines were going to the receiver pins which were not being used in this application. So nothing burned out. We reversed the wiring and everything worked fine.

The final step was to design a 3D printed enclosure for the device. That took another afternoon or so.

We mounted the TFT display into the lid of the box using black nylon plastic screws and nuts out of this kit sold by Adafruit. They are really handy because they are selected to fit in the 0.1 inches diameter mounting holes used in most Adafruit boards. When that box of screws was first added to the Adafruit catalog I knew I would need them someday and purchased it right away. They work perfectly so it was a great purchase.

The rest of the box is held together by 5/8 inch sheet metal screws. I like using sheet metal screws because they have a pointy end that taps really well into 3D printed PLA plastic. Here are some more photos of the completed project.



There are still lots of software tweaks I have to implement. It takes longer to erase a 320×240 color display than it does to erase a 128×64 monochrome display. The monochrome device required you to call a “display” method to update the display after writing to it. The new color device updates as you write to it. The result is you can see the screen update where the old one would update instantly. I think the updates actually slow down the entire process a little bit. So I’m going to have to optimize the code so that it only updates the screen when absolutely necessary and only does it in small pieces. In the old system it was easy to just erase everything and redraw it from scratch every time but that won’t work very well in the new system.

Of course I also have to add all the features I’ve been wanting to add but didn’t have sufficient memory under the old system. I have to add all the codes for my Blu-ray player and there are some additional keyboard codes that I want to add. I may end up implementing an entire keyboard system so that I can type anything using IR codes. I’ve developed a special protocol for my IR library that allows me to use any mouse or keyboard commands possible. I’ve only been using a fraction of that capability.

One other difference between the old and new system involves the power output of the IR board. When I originally designed my infrared I/O board I ran the LEDs with no current limiting resistors. Because the LEDs are only intermittently running (assuming you don’t cross your wires), it’s safe to put more than 1 amp through them. But my experience is that sometimes USB power can’t supply enough power when that current spikes during transmission. So I’ve added some 33 ohms current limiting resistors in line with the LEDs on the latest version of my infrared I/O board. The old device did not have these resistors but it ran well because it was powered by a battery pack rather than a USB plug. Now that I’ve worked with the new remote I’m realizing it doesn’t have the power of the old one. I’m going to try shorting across those resistors and see if it helps.

I still have fond memories of my original Ultimate Remote. It served me well for over a year and was literarily a lifesaver while I was in the hospital. But I’m also looking forward to the new things I will be able to do with the new improved Ultimate Remote 2.0.

Afterward: After I completed the project I presented it on the weekly Adafruit Show-and-Tell. I was the first guest in the video below.

IRLib 2.02 Increases Support for SAMD 21

A few weeks ago we released IRLib 2.01 with preliminary support for SAMD 21 processors such as used in Arduino Zero and Adafruit Feather M0 boards. Then initial release had many hardcoded values. For example output was only available on pin 9 and the timer interrupt for the 50 µs receiver class was hardcoded to use TC3.

In our latest release IRLib 2.02 you now can use any available PWM pin on your platform for output by editing values in IRLibProtocols/IRLibSAMD21.h

You can now also choose to use TC4 or TC5 to drive the hardware interrupt for the 50 µs receiver class.

Both sending and receiving use GCLK0. Note that typically GCLK0-GCLK3 are reserved for internal Arduino infrastructure use however we are using GCLK0 with its default clock source of 48 MHz and a divisor of 1. Because we are not modifying those defaults, it is safe to use. That allows you complete freedom to use GCLK4-GCLK7 for other purposes.

The code has been tested on Arduino Zero, Arduino M0 Pro, and Adafruit Feather M0 BLE boards successfully.

The code is available now on GitHub at https://github.com/cyborg5/IRLib2

3D Printed 6 Piece Star Puzzle

When I was a child I used to enjoy playing with little puzzles. One of my favorites was a 6 piece star-shaped cube that I thought was particularly clever in its design. I decided I would try to 3D print one of those puzzles. Before going to the trouble of designing it myself I decided I would look on Thingiverse to see if someone had already created it.

This particular puzzle was available in several versions including this one on the right.
However it wasn’t exactly like the one I remembered. All of them that I found on Thingiverse had six identical pieces. I also saw some YouTube videos on how to assemble such a puzzle. It looked to me like it did not stick together very well.

The puzzle that I remembered also had 6 pieces but they were of three different types. Three of the pieces were identical to the ones in the Thingiverse models. Two of them were similar but they had a notch cut out. The final piece was completely solid and would be slid into place to lock everything together at the end.

So I made a modified version of the model linked above. I had to do a little tweaking to get the tolerances right but it turned out okay.

You can download my modified puzzle on Thingiverse at https://www.thingiverse.com/thing:2160633

Here is a photo of my completed puzzle.

Here is a photo of the individual pieces. I refer to the pieces as “part 1”, “part 2” and “part 3”. That designates how many of each of the pieces there are. That means there are three copies of “part 3” and so on.

Here is how to assemble the pieces. Start with a piece 3 in this orientation.

Add another piece 3 vertically on the right side.

Add the final piece 3 vertically on the left side.

Place a piece 2 horizontally across the back with the notch on top.

Place the other piece 2 horizontally across the front with the notch on top.

Slide the final piece into place from the front in a hole left by the notches.

Many thanks to by HotIceT for the original design. My piece 3 is identical to his and the other pieces were derived from that by modifying the STL files in Blender 3D.

Modifying the “Pause at Height” Cura Plugin for Printrbot Plus

Recently I did some 3D printing objects as a kind of diorama that I photographed for my 2016 Christmas card. One of the objects was this sign saying “Emmanuel – God Is with Us”. The background or base of the object was printed in brown filament and the raised lettering was printed in white filament. I use a single extruder Printrbot Metal Plus.

The trick to printing this is to print the brown portion, get the printer to pause while you change filaments, and then print the white lettering raised above it. I’m using Cura 15.04 which is the most recent version that can be easily configured for Printrbot. It has a plugin called “Pause at Height” that is designed to allow you to do just what I want. You pick a Z height at which the printhead is retracted and paused while you swap the filaments.

If you open Cura and click on the “Plugins” tab you will see the following:

There are two plugins installed by default. The one we are interested in is Pause at Height. You click on the plugin and then click on the tiny down arrow at the bottom of the window and a dialog will appear that allows you to set the parameters for the plugin. It will look like this…

It gives you a series of parameters that you can fill out. Then when you print your object, theoretically the printer will pause and allow you to change filaments. Unfortunately the Printrbot Metal Plus does not have any sort of control panel so there’s no way to resume the print once you’ve paused. I tried using the plugin anyway just to see what would happen. At the proper point in the print, the printhead retracts back and to the side as it’s supposed to. But rather than pausing, it immediately goes back where it left off and begins printing.

If you look at the lower left corner of the plugin screen you will see a button that says “Open plugin location”. If you click on that button here’s what the folder looks like in Windows Explorer.

You can see the plugins are actually Python programs that have a .py extension. We want to look at the one named “pauseAtZ.py”. We will open it up in our favorite text editor and take a look around. If you look at the code at approximately line 104 you will see this

#Move the head away
f.write("G1 X%f Y%f F9000\n" % (parkX, parkY))

#Disable the E steppers
f.write("M84 E0\n")
#Wait till the user continues printing
f.write("M0\n")
#Push the filament back, and retract again, the properly primes the nozzle when changing filament.
f.write("G1 E%f F6000\n" % (retractAmount))
f.write("G1 E-%f F6000\n" % (retractAmount))

It appears that this Python script is reading and writing your G-code looking for the proper place to do the pause. Then it inserts additional G-code to do the retraction and the actual pause. The important line is line number 110 which inserts the G-code command “M0”. This is a stop command as described here
http://www.reprap.org/wiki/G-code#M0:_Stop_or_Unconditional_stop
Apparently the firmware in the Printrbot Metal Plus does not recognize that particular G-code. There are other G-code options that we can substitute.

Using your text editor, do a “save as” and give it a different filename with a .py extension and save it in the same folder as the original. Modify line number 110 to read as follows

f.write("G4 S30\n")

The “G4” command is described here
http://www.reprap.org/wiki/G-code#G4:_Dwell
It causes a 30 second pause. I found that this gives me sufficient time to withdraw the original filament, replace it with a different color, and force some of the new filament through the nozzle to flush out the old color.

There is one other change you should make in that file. On the very first line it reads:

#Name: Pause at height

This is the name that appears in the plugin tab of Cura. You should change this name to something like

#Name: My Modified Pause

so that you can distinguish it from the original plugin.

I made those changes, selected the modified plugin and it worked perfectly. You have to play around with the preview slicing to determine what level you need to set for the pause. You might try printing a small test piece if your object is extremely large.