Drop_C
Posts: 6
Joined: Sat Nov 22, 2014 10:00 am

Detect negative voltage on GPIO?

Sun Dec 01, 2019 9:50 pm

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!
Attachments
Schematic_test3_Sheet-1_20191201212846.png
Schematic_test3_Sheet-1_20191201212846.png (9.42 KiB) Viewed 257 times
1575235601907.png
1575235601907.png (39.16 KiB) Viewed 257 times

User avatar
DougieLawson
Posts: 36578
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Detect negative voltage on GPIO?

Sun Dec 01, 2019 10:38 pm

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
PeterO
Posts: 5152
Joined: Sun Jul 22, 2012 4:14 pm

Re: Detect negative voltage on GPIO?

Sun Dec 01, 2019 10:48 pm

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
Last edited by PeterO on Sun Dec 01, 2019 11:13 pm, edited 1 time in total.
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
Mortimer
Posts: 924
Joined: Sun Jun 10, 2012 3:57 pm

Re: Detect negative voltage on GPIO?

Sun Dec 01, 2019 10:53 pm

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?
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

Drop_C
Posts: 6
Joined: Sat Nov 22, 2014 10:00 am

Re: Detect negative voltage on GPIO?

Mon Dec 02, 2019 8:46 am

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).

User avatar
PeterO
Posts: 5152
Joined: Sun Jul 22, 2012 4:14 pm

Re: Detect negative voltage on GPIO?

Mon Dec 02, 2019 9:03 am

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
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Drop_C
Posts: 6
Joined: Sat Nov 22, 2014 10:00 am

Re: Detect negative voltage on GPIO?

Mon Dec 02, 2019 9:29 am

That's interesting. I'll try that. Thank you very much!

Return to “Other projects”