1
\$\begingroup\$

(I have already read this question.)

I am looking to make a musical instrument with a series of capacitive buttons in a grid of 17x4 buttons, with a length of about two feet and a width of three inches. Due to (A) the number of buttons and (B) the mechanical design of the instrument I am hesitant to use a microcontroller. I will have a microcontroller at one end of the grid to process the touches, but finding a MCU with 68 leftover GPIOs is hard enough, let alone 68 timers. Much like in the linked question, off-the-shelf ICs created for capacitive sensing are much to slow for my purposes. The ideal solution will have a latency of less than 1 ms.

I was thinking of using some sort of oscillator whose frequency can be affected by the capacitance of my finger, along with some sort of counter, but that leaves me with a very serious multiplexing problem. I don't have a lot of space--68 counters seems like a lot of counters, and regardless, that still leaves me with the same problem, counters outputting pulses that a microcontroller needs to analyze.

\$\endgroup\$
4
  • 6
    \$\begingroup\$ Back in the 80s, microcontrollers were running at few MHz and had only a couple of timers, yet they managed to make e.g. 61 key synths that are velocity sensitive with 1 or 2 timers. You have 100x the horsepower and more timers, but you don't need a hardware timer per key just like in the 80's. Also capacitive touch sensors are slow, because they need the time for multiple readings to reliably detect small capacitance changes of e.g. finger while still being able to ignore small changes in capacitance due to humidity. \$\endgroup\$ Commented Jul 7, 2023 at 5:26
  • \$\begingroup\$ Can you please provide a cutout drawing of the physical sensor areas? I have problems to imagine a useful grid of 17 x 4 sensors arranged in a two feet x three inches area. \$\endgroup\$ Commented Jul 7, 2023 at 13:51
  • \$\begingroup\$ I'm taking some inspiration from this. The 17x4 buttons is the fretboard. I can't really put too much inside the next without compromising the structural integrity, so ideally every 2 frets (4 strings each) would have their own sensor, which would all get multiplexed (rounding up to 18 isn't a problem). \$\endgroup\$ Commented Jul 7, 2023 at 20:24
  • 1
    \$\begingroup\$ Of course what you ask can be done, but the same reasons why you say you don't want to use a microcontroller might push me toward using a microcontroller. You might reconsider. \$\endgroup\$ Commented May 7 at 13:34

4 Answers 4

2
\$\begingroup\$

You might be surprised by how few GPIOs are used in e.g. contactless touch screens - they detect fingers using a sparse grid of X and Y wires - simplified - a finger is detected near 2 or more "X" axis wires then detect finger near 2 or more "Y" axis wires.

Basically the proximity of a nearby finger changes the capacitance to free space of a wire , and the microcontroller cycles driving lines and switching them to an ADC to measure the way the wires charge and discharge over time to measure the capacitance.

So a grid of 8x8 wires might be able to detect a finger in more than 64 positions relative to the wires.

Some microcontrollers e.g. STM32L152 family have convenient analog multiplexers and switches designed for touch switch driving.

It may be simpler to consider continue using a Theremin style approach to musical instrument interface .. You dont need 68 oscillators, your finger affects several at a time, so maybe 10 oscillators (but then there is "injection locking" where they will mostly run at the same frequency because they can "see" each other.. )

Or find a resistive touch screen monitor from some old point of sale terminal that has not been destroyed by the users, and the resistive touch screen sensors are easier as you only use four wires to drive them ..

Or use a camera or two that looks across the keyboard, works out where your fingers are.

Or use a matrix of infrared beams that your finger interrupts (like my old Sony E-Reader touch screen : one LED is "seen" by several receivers on the other side of the screen, a finger or a stylus gets in the way of the path of the infrared to one or more receivers. Change the LED thats switched on and the pattern of shadows moves.)

\$\endgroup\$
1
\$\begingroup\$

For a large amount of capacitive sensors, that must be read a high speed, D-flipflops can be used. This is an example circuit for 8 inputs:

schematic

simulate this circuit – Schematic created using CircuitLab

A clock of 10..100 kHz can be provided by a MCU or separate generator. This signal is buffered by NOT1 and drives the D inputs of the flipflops via resistors. The resistors in combination with the sensor capacitance introduce a variable signal delay.

The clock signal is also delayed by the combination of R9 and C1. This is the reference delay, which will be compared with the sensor delay.

With low capacitance at a sensor input the high signal will be at the flipflop input before the rising edge of M_CLK, so HIGH is sampled and stored.

With a high capacitance however the high signal is too late, the flipflop stores LOW.

If the MCU wants to read the stored sensor values it pulls /MCU_READ low and reads the flopflop outputs. A LOW represents a sensor touch. The logic may be inverted by adding another inverter behind NOT1 if needed.

Multiple blocks of this circuit may share the MCLK and the DRV signal, so the inverters are only used once. If more than 4 blocks are used a separate DRV signal derived from CLK1 is required.

All blocks can share the same 8 MCU inputs, just separate /MCU_READ signals are required, probably created by a 74HCT138 DEMUX.

I tested this using 5 V logic, but assume it will work with 3.3 V as well.

If CLK1 is generated by the MCU I recommend to read the flipflops when CLK1 is high (-> M_CLK low). I tested sampling rates up to 250 kHz.

At a very noisy environment it is useful to take multiple samples.

This is just an ON/OFF detector. If analog values are required, one must generate DRV and M_CLK separate with variable delay between the rising edges, and test, at which delay the values change.

\$\endgroup\$
1
\$\begingroup\$

68 timers and GPIOs I’m not so sure about, but 64 high-functionality smart GPIO pins is very much a solved problem.

Parallax Propeller 2 (P2X8C4M64P) chip has all of that. It has identical I/O on each pin, so you got 64 8-bit DACs, ADCs, comparators, complex double timers, so on and so forth. Stick two of them and it will do just about anything you need and then some. It’s a very powerful part. There are a couple of lower-cost carrier boards for it.

Development, in a pinch, can be done without any special software. It comes with a FORTH interpreter in the internal boot ROM if you feel adventurous :) It’s a perfect pastime if all you got is a bit of power, a serial terminal, a notebook (paper kind), P2, and time to pass in a cabin in the mountains :)

\$\endgroup\$
0
\$\begingroup\$

You don't need to use a microcontroller, there are stand-alone touch sensors available.

Or if you you want to build your own, instead of measuring frequency, measure an analogue property like power consumption, or amplitude.

schematic

simulate this circuit – Schematic created using CircuitLab

74lvc1g08 under 5c in quantity. almost as cheap as the transistor.

Obvously don't use a pot but instead choose the apropriate resistor for the sensitivity you want, which will depend on the capacitance of your touch pads.

125Khz chosen because it's an ISM band. Emitted radiatrion can be reduced by using half inverting and half non-inverting gates,

\$\endgroup\$
4
  • \$\begingroup\$ Most off-the-shelf touch sensors have an unacceptably high latency. \$\endgroup\$ Commented Jul 7, 2023 at 21:37
  • \$\begingroup\$ How do you guarantee that Vee of the OR gate doesn't exceed 0.5 V? Most transistors have a turn-on Vbe of around 0.7 V. Seems like you would destroy the gate before the transistor even turns on. \$\endgroup\$ Commented Jul 8, 2023 at 14:32
  • \$\begingroup\$ Not stated above the square wave doesn't go to 0V to 5V only to about 1v to 5v , Vee of the or gate is kept low by the 10K (or whatever resistance is suitable there - which will depend on the capacitive load the gate is driving) \$\endgroup\$ Commented Jul 10, 2023 at 21:37
  • \$\begingroup\$ I'm not understanding what you think could destroy the gate (unless you were thinking of the clock signal flowing below VEE, adding some resistance between the gate and the touch pad will reduce emitted noise too. how much depends on the sensitivity needed. \$\endgroup\$ Commented Jul 18, 2023 at 5:10

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.