Close

The home stretch

A project log for Interactive Color LED grid with IR touch sensing

My wife wanted some hardware to program with processing. I wanted to design some PCBs

engunneerengunneer 07/13/2016 at 02:360 Comments

(June 2016)

I finally decided that the sparkfun level convertor was to blame for the bad clock bits. Yes, I know the clock wasn't even going through the level convertor, but the data was. I removed the PCB with prejudice. As I mentioned before, the shift registers are fine with 3.3V control signals, so I just needed to change the remaining two signals to the right voltage. The serial feedback from the shift registers was taken care of by a simple 5V->3.3V voltage divider. The speeds I'm talking about are not going to mind this at all.

The WS2812 remained as the last signal that needed a boost. As you can find many places online, there are standard ways as well as tricks for boosting the voltage up, ranging from a transistor to using a WS2812 powered off of a slightly lower supply rail to act as a buffer. I considered using a LM339 that was spare on my PCB anyway, but knew there must be something simpler. I found a comment to that last linked post that mentioned an unusual method that sounded just wrong, but was actually really clever. When you look at the schematic (falstad simulator), it feels wrong because it would seem that the data is flowing backwards through the diode. In reality, it is, or more accurately, the electrons that aren't the data are being pulled into the Teensy through the diode. The square wave generator in the link represents the Teensy output, and the 100k resistor represents the high impedance input of a WS2812. I used a 1N4148 and a 1k resistor from stock.

With the new Teensy to board interface done (only requiring 3 passives and a diode!), the test code worked! All that remains is to get the serial interface working on both ends in both directions.

The 12Mbps connection works seamlessly, as advertised. Processing, however, seemed to have issues keeping up with large amounts of data coming in the serial port. Originally, I had a scheme where the 6 byte packet sending color data to each color cell would cause the hardware to generate a 4 byte packet of return data (X, Y, touched, [255]), resulting in 900 return bytes per frame. After that, I had it set up such that any LED write to the last pixel would generate a packet of 225 bytes of data back to Processing, plus a [255] stop byte (226 bytes per frame). To minimize the packet size of touch data coming back over the serial port, I decided to pack the 225 bits of data into bytes, such that each segment of 5 cells was stored in a byte, so each of the 9 boards would be represented in 5 bytes. The resulting 46 byte per frame packet is still not as small as it could be, but is small enough to do the job. In contrast, the LED writing data is 1350 bytes per frame.

In debugging this mode, I set up a fixed target (my logic analyzer, now free from debugging the clock glitches) with the teensy only test code, and then switched to the serial enabled code to get the serial packets for debugging. This picture was taken so I could verify that the bits I was unpacking matched with the pixel positions I thought they did.

once the order of packing and unpacking the bits was settled, I was able to uncomment the processing code that was set to highlight any pixel being touched in green, and any untouched in blue.

The screen to the right shows processing's internal representation of the hardware, which works even if the hardware is not present so that Erica can write code without dragging around the assembly. I was able to get the processing refresh rate well above 50 Hz, so the motion and responsiveness is very smooth. I currently have the sensors set to pick up objects in the 0-5cm range. I also just noticed that you can see the IR transmitters glowing in that image because of the IR sensitivity of my cell phone camera.

The next step is getting a diffuser in front, and having the touch sensors still work. I did experiments earlier with a polypropylene cutting board that showed promise, and some poking online shows that white polycarbonate should still be transparent to IR, but can act as the diffuser in the visible range. I also experimented with using clear PVC walls in between the cells to give a little more definition to each cell, and to reduce cross-talk in the IR sensing department, which looked promising.

Discussions