Close

Dynamic sensing

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/21/2016 at 03:110 Comments

What I'd really like to do is the full dynamic depth sensing. The idea is simple enough - vary the DAC voltage that is used as the threshold sent to all boards, and then capture what the voltage level was when the touch was first seen. I think this means sweeping from near to far. Since the IR sensors read closer to 0V when near, this should be an increasing voltage sweep. For this to be effective, I would want to get as many measurements as possible between frames of display.

The starting point is to measure what the current refresh time is, and then see how fast I can make it. The WS2812 output is fairly fixed, as I need to send out 225*24 bits at the ~800kHz data rate. A quick measure on the scope shows that the LED output takes about 7ms, and that I start sending a new frame every 9.5ms. This implies that the IR only takes 2.5ms to read, but was also measured with no serial data going.

In the touch interface, I have a hard coded constant #defined that sets the delay used in us between each bang of the bit banging, as well as some extra delay between each set of 32 bits to help me count bits on the scope. I reduced all of these to a single microsecond each, shaving 750 us off the reading cycle.

I tried to measure the time needed for serial communication, but found it hard to capture on the scope. It seemed to be only a few ms, so let's call it 6ms. If I want a ~30 Hz refresh rate, I get 33ms for each frame. With 7ms for display, and 6ms for serial, i have 20ms remaining for touch sensing shenanigans. At 2ms each, I should be able to get 10 readings in. 8 is a nice binary number, and I may need a little more headroom for serial, since I now will need to be returning 1 byte for every 1-2 cells vs the older 1 byte for every 5 cells. I think I'll use 0 to indicate "not touched" and 7 to indicate "close range". I will start with a hand tuned array of sense threshold voltages to try to get a linear response.

The #define TESTING flag allows the Teensy full control over the display instead of asking for serial input. I made a quick Green (far) to Red (near) gradient using this Gradient Maker. The resulting 7 step gradient (I did HSV through yellow) was applied to the 7 distances. I arbitrarily chose steps of 200 analog counts, which are steps of 160mV. Here's a video of the new feature in action:

Keep in mind that the first three boards are the only ones hooked to the DAC so far. I will need to increase the strength of the pull up resistor on the output of the LM339 to have enough current to supply all 9 boards.

In the future, I could consider having a calibrated distance offset for each cell to help reduce variation. The center cell of each board tends to sense sooner than the rest as you approach.

Discussions