Wed May 29, 2013 11:41 am
A salutary tale of triggering video with a pressure pad using a Raspberry Pi for the interactive theatre production, "
Memory Dealer" -
Tarim
- Foolhardiness
Set GPIO for pin 5 to be an edge triggered input with internal pull-up using Gordon Henderson's wiringPi program.
Hook up the pressure pad (a simple make/break switch) to pin 5 and ground.
This fails and leaves the Pi in a state where it will only boot into the emergency kernel mode with a "Greetings from standalone Raspberry Pi" message - even with nothing connected to the GPIO header. 
- Investigation
It seems the floor is metal (it looks more like an innocent set of tiles but a multimeter reveals it conducts!) Also, the pressure pad has an extra set of connectors underneath ... with bare wires.
At one point, I touch the wire between the pressure pad and pin 5 and feel a slight electric tingle.
I've "blown" the GPIO for pin 5 so the Pi thinks it's permanently grounded and does what it should - which is boot into "safe mode".
- Perplexity
But how did I knacker that GPIO? Surely the metal floor will just ground pin 5 even with nothing on the pressure pad and the pull-up resistor will stop too much current flowing?
- Contemplation
Do all the GPIO pins get initialised to inputs on power up? (What happens to the TXD output GPIO on pin 8?) The internal pull-up resistor is software switched - so is it possible that pin 5 doesn't have one while it is booting? But that would mean pin 5 is floating - so sometimes Pis would boot into safe mode for no apparent reason.
- Realisation
The USB power supply has no ground - the Pi's ground is floating compared to the metal floor - I could have pulled pin 5 to all sorts of random voltages. This might also explain the tingling - it's probably more than 3.3v. (Thanks Bristol Hackspace for the discussion.)
- Resolution
Borrow another Pi (didn't tell Tom and Duncan I'd blown up the last one).
Hook up the Pi ground to the earth pin on a mains plug (remove live and neutral pins altogether - just in case).
Insert a buffer chip (CD4050) with an external pull-up resistor (about 20K) for good measure between Pi and pressure pad.
Yippee - one pressure pad triggered video.
- Afterthoughts
Must experiment with avoid_safe_mode=1 in /boot/config.txt to see if I can make that other Pi boot. Wonder if the other GPIO pins are ok?
I like the CD4050 (another great recommendation from John Honniball). Given a 3.3v supply; it will do level conversion from TTL 5v down to 3.3v as well as protect the Pi's GPIOs.
@Tarim8