Page 1 of 1

Detect negative voltage on GPIO?

Posted: Sun Dec 01, 2019 9:50 pm
by Drop_C
Hi,
the question is probably pretty dumb, but I just can't get my head around it:
I need to detect change of a touch sensor (TTP223 IC), which gives a constant signal
when it's touched and drops to ground when it's not touched.
I tried a simple RC circuit which gives me a signal when it's touched, which slowly
drops to ground again. When the sensor is not touched any more the capacitor discharges
and gives me a negative signal. Can I detect that with a GPIO pin too? Or will that
actually even damage the raspberry? Or is it possible to turn the negative voltage into
a positive? Tried that using transistors, diode bridges (rectifier), but couldn't figure it
out. Rectifier would work if I'd had positive and negative source, but I only have
positive and ground. Hope someone can give me a hint... Thanks!

Re: Detect negative voltage on GPIO?

Posted: Sun Dec 01, 2019 10:38 pm
by DougieLawson
If you feed a negative voltage (with respect to the GND pins on your RPi) into a GPIO you'll soon be spending £35 for a new RPi.

Re: Detect negative voltage on GPIO?

Posted: Sun Dec 01, 2019 10:48 pm
by PeterO
Convert your 0 to 5V to a 0 to 3.3V signal to protect the Pi, then use a "detect change" feature of one of the gpio libraries to tell you when it changes state.
Capacitively coupling a digital signal to a gpio pin is always going to be a bad idea !
PeterO

PS:

Looking at the data sheet that device can be run from 3.3V anyway, so do that an just connect the Q pin directly to a gpio pin and use a "state change" like
http://abyz.me.uk/rpi/pigpio/cif.html#gpioSetAlertFunc to detect the changes of state.

PeterO

Re: Detect negative voltage on GPIO?

Posted: Sun Dec 01, 2019 10:53 pm
by Mortimer
Surely it would be far easier to feed the output signal (Q) of the chip to your GPIO as is, and let your software work out when the state of the GPIO changes from low to high and high to low?

Re: Detect negative voltage on GPIO?

Posted: Mon Dec 02, 2019 8:46 am
by Drop_C
Thanks. Luckily I haven't tried yet to feed the negative voltage to a gpio :-)
I should have mentioned, I have a whole row of these touch sensors, and I only
need to detect the change in any one of them. In order to save some gpio pins,
I thought I could electronically change there constant on/off state into a change
signal and this way combine the whole row of touch sensors to provide one signal.
But looks like I need a gpio pin for each single sensor then. Will probably need
a couple of MCP23017 gpio expanders then. And lots of wiring... (it's basically
an 8x8 grid of these sensors).

Re: Detect negative voltage on GPIO?

Posted: Mon Dec 02, 2019 9:03 am
by PeterO
In which case, use the "interrupt on change" feature of the 23017s and connect the interrupt pins directly to gpio pins and use a detect change on those pins.
Or you could even connect the 8 interrupt pins to another 23017, set that to interrupt on change and connect that one's interrupt pin to a gpio pin.

PeterO

Re: Detect negative voltage on GPIO?

Posted: Mon Dec 02, 2019 9:29 am
by Drop_C
That's interesting. I'll try that. Thank you very much!