Touch Me Four Times

May 21st, 2019 5 min read

It’s been a few months since I’ve finished my MusiCubes Controller. And although most of the controller works perfect, there is one issue that is still bugging me: the false positives of the touch sensors. Time to fix this!

Originally I tried to solve this issue by taking some counter measures in the software:

  • Touches when no music was playing were ignored.
  • Touches shorter than 50ms were ignored.

And although this solved most of the false positives, it still wasn’t perfect. Mainly the volume down button was triggered every once in a while, resulting in a mute state after a few hours of playing. Also the fact that I couldn’t turn the volume all the way down before starting the music was a minor inconvenience as well. A modified touch system should solve this.

image

I originally added one plate of brass on each side of the the MusiCubes tray to handle the touches on the designated surface. The plates of brass were 40x30 mm, allowing me to touch the designates surface anywhere I wanted.

The Solution

The idea is to split up the touch surfaces in 4 sections each. Since I am using the MPR121 Proximity Capacitive Touch Sensor Controller which has 12 touch sensing inputs, connecting these four sections doesn’t require any extra electronics.

Whenever the MPR121 reports a touch, I’ll count the number of active touch surfaces. By setting a threshold of a minimum of 2 surfaces, false positives on one of the touch surfaces will be ignored.

Let’s start cutting up the original brass plates!

I had used some hot glue to mount the brass plates to the MDF. A small screwdriver and a bit of force aloud me to pry of the glue and remove the plates. Removing the glue from the plates and cleaning them up was very a satisfying job.

image

Cutting the pieces of brass up into four sections was an easy job for my Dremel multitool, so soon enough I ended up with 8 small brass plates.

image

With an overdose of hot glue, I glued the four pieces back in place, making sure the four pieces didn’t touch. The hot glue is a perfect isolator for this!

image

Next I connected four pieces on both sides to their respective MPR121 sensors. Note to self: next time solder the wires to the plates before glueing them in place, because the soldering heat melts the glue.

And with this modification done, it’s time to modify the code.

To quickly count the number of active fields, I added a method to my TouchManager:

uint8_t TouchManager::activeFields(uint8_t sensorIndex) {
  uint16_t state = _sensors[sensorIndex].touched();
  uint8_t count = 0;
  while (state) {
    count += state & 0x1;
    state >>= 1;
  }
  return count;
}

If the number of active fields is above the threshold, I handle the touch like I did in the previous version. For the full modification of the code, check out this commit on GitHub.

The Big Discovery

To test if this works, I added some logging to report the false positives. Which brought me to my big discovery: the false positives of the sensors were completely gone! It turns out the false positives where caused by the fact that the original brass plates were to large. With four small plates, the MPR121 was much more reliable. As a matter of fact, I haven’t had a single false positive in two weeks time! The issue was completely gone! Even though the touch surface is still as large. Awesome!

Because of this, I didn’t need a threshold of 2 touched surfaces. In stead I can just respond to any touch detection. And because there aren’t any false positives anymore, I can enable the tough controls even when there isn’t any music playing.

Victory!

Turn Down The Heat

And with the touch changes, the hardware of the MusiCubes is almost perfect. Almost. Unfortunately there still was one minor issue. The system is powered with a Micro USB power supply, directly into the NodeMCU USB connection. This means that the Neopixels are powered over the same connection.

Unfortunately the USB power goes trough a diode on the NodeMCU board, to prevent any power going into the USB port. But this means the 1 amps that are necessary for the NeoPixels flow through that diode as well. It works, but the diode gets hot. Too hot.

image

To fix this, I added an external USB connector that directly feeds the 5V into the Neopixel power lines, as well as the the NodeMCU. The tiny diode no longer has to deal with the power hungry LEDs.

image

And with this change, all of the issues are solved!

image

The MusiCubes controller really turned out to be a perfect companion to my Sonos sound system. Starting and stopping the music is so simple that even my 3 year old son casually controls the music from time to time. It took a while to convince him to play something else then Disney’s Moana music though …

Loading comments …
©2021 - MichaelTeeuw.nl