Ground and GPIO backwards?


12 posts
by abishur » Tue Jul 03, 2012 11:28 pm
So let's start with the basics:

1) My leads on the multimeter are connected correctly (they're not backwards ;-))

2) When I measure the voltage between the ground pin and the 3v3 pin I get 3v3, when I measure between the 5v and ground pins I get 5v (well close enough ;-))

Here's the issue when I set one of the GPIO to be an output and measure between that pin and ground I get a -3v3! (when I write a zero I get zero) If I wire my circuit such that the ground is positive and the GPIO is negative it works fine. (The GPIO in question is GPIO 4, broadcom name is pin 23)

Does anyone know what could be causing this?
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4326
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by jojopi » Wed Jul 04, 2012 1:10 am
If you keep the black meter lead at ground (either header P1 pin 6, or more conveniently TP2) at all times, then everything you probe with the red lead should have a positive (or zero) voltage. I do not believe that your Pi could be creating negative voltages, or that it would still work if it did.
User avatar
Posts: 2131
Joined: Tue Oct 11, 2011 8:38 pm
by abishur » Wed Jul 04, 2012 1:41 am
Okay so very annoyingly I reset my pi and it's not doing it anymore :evil:

Most people would be happy by this, but I don't like how it randomly did this, and the fact that now I can't reproduce the issue. I mean I haven't touched a *single* item on my test setup pictured here

Image

You can ignore the opto-isolator at the bottom, the important thing is that when I did the initial test the red wire was attached to GPIO 23 and the black wire to Ground as depicted from the wiki here

Image

So when I set my pin high it should have enabled the corresponding pin on the ULN2003 darlington transistor array. (For those interested, the flow on the right side goes +5v -> resistor -> LED -> ULN2003).

It did not.

When I made the red wire plug into the negative rail, and the black wire the positive rail it immediately worked. I tested this with my multimeter and can 100% accurately report that for whatever reason it was backwards. I'm fully aware which pin is ground and how to use a multimeter, sorry if this sounds defensive or aggressive, I'm mostly just pissed that a reset cleared the issue :x
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4326
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by jojopi » Wed Jul 04, 2012 3:06 am
Your circuit appears correct. (Assuming that the LED anode is in the same breadboard node as the resistor — it is hard to tell in the picture. And that you are aware you have very limited noise margin in the high state — ULN2003 needs up to 3V on-state input.) The fact that the circuit behaviour matched the multimeter also seems to rule out any issue with the meter's display. I am afraid I still do not believe that you connected the GPIO to the breadboard in the sense you thought you did, however.

If a GPIO was at -3.3V relative to ground, then it would have been 6.6V below the 3.3V rail, and 8.3V below 5V. But the Pi is powered from 5V only and uses common-negative linear regulators (for everything expect the core). It is impossible for these devices to produce an output that is higher than their input, or lower than ground. And the board would not function at all if any voltages were significantly wrong.
User avatar
Posts: 2131
Joined: Tue Oct 11, 2011 8:38 pm
by Grumpy Mike » Wed Jul 04, 2012 2:50 pm
That happens some times. Not getting -3V3 from a pin, thinking you have got a result when you haven't.

There is no way you can get -3V3 from your GPIO pin, it is as simple as that.

As to what the real situation was is now hard to tell because it is not reproducible. The most likely explanation is that you did not have it wired like you think you did. It has happened to me on more than one occasion, you get a result that you think is impossible, check it and find yes it was impossible. It is the way the brain works, its all part of being human.

Also it is not beyond the bounds of possibility that you have an intermittent fault on the display board of your meter.
User avatar
Posts: 791
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
by abishur » Wed Jul 04, 2012 3:17 pm
I know that the pi can't produce those values, but not only did my company provided, just calibrated, professional grade multimeter say the -3v3 when connected normally, the circuit itself corroborated this. I've made painstakingly sure to change nothing on the circuit except where the positive and negative leads plug into my board (which is to say I left the jumper on the GPIO pins, and moved only where they connected to my breadboard).

Before the reset the circuit would only work with the GPIO acting as ground and the ground acting as 3v3. It was weird but it worked. After the reset, the circuit was no longer working. I swapped only where the jumpers plugged into the breadboard. You can see the circuit itself in the photo (and yes the red wire is the anode for the LED ;-) ) red wire went from GPIO 23 to + rail, green jumper went from plus to pin 1 of uln2003, blue jumper goes from pin 8 (ground) to - rail, black wire goes from - rail to ground. On the high side my white wire went from 5V to the + rail, jumper trough a 330 ohm resistor to the LED's anode, LED's cathode connects to pin 16. When GPIO 23 goes high it completes the circuit allowing voltage to flow through the LED.

It's a *painfully* simple circuit that would not work before the reset without the red wire (GPIO 23) being plugged into the - rail and the black wire (ground) into the + rail. After the reset it wouldn't work again until I returned the wires to their original locations.

I'm sorry for harping on this so much, but I want to make it explicitly clear that I fully ruled out user error (in so far as the circuit is designed at any rate). I've yet to remove the jumpers from the GPIO pins to the breadboard from the GPIO. I did all my testing through the wires. It's literally impossible for me to have connected to the wrong GPIO and then fixed it latter because I'm still connected to the original GPIO! ;-)

I also get the fact that it's impossible for the pi to put out -3v3, so we're faced with two impossibilities and while I'm also prone to believe that the impossibility that relies on the infallibility of a man is the one to put your money on for having actually made a mistake, I can also fully confirm that it was working before a reset, I reset, it didn't work, I swapped nothing more than the + and - rails to what they should have been all along and it worked again and my multimeter confirmed a +3v3 from pin 23 to ground. :?
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4326
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by abishur » Wed Jul 04, 2012 3:20 pm
side note, rather than saying I got -3v3 from the GPIO, is it possible that I had done something that was causing the GPIO to act as an input rather than an output and was getting a reverse voltage of 3v3 through the ground?
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4326
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by Grumpy Mike » Wed Jul 04, 2012 3:36 pm
abishur wrote:side note, rather than saying I got -3v3 from the GPIO, is it possible that I had done something that was causing the GPIO to act as an input rather than an output and was getting a reverse voltage of 3v3 through the ground?


I can't see how that would have worked either.

Many many years ago, I was working on a circuit at the lab at my University. It worked, I took some measurements with the scope, checked that the pulses did what I wanted them to in the larger system I was working on and went home for the weekend. On Monday morning I found I would not work and finally tracked it down to a wiring fault. There was a wire connected to the wrong pin. With the wiring as it was there was no way it could have possibly produced the results I saw on the Friday night. Short of a goblin rewiring it over the weekend I have no other explanation of the two situations.
Looks like the goblin has been round again. ;)
User avatar
Posts: 791
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
by abishur » Wed Jul 04, 2012 3:44 pm
Grumpy Mike wrote:Looks like the goblin has been round again. ;)


My goblin might have fur

Image
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4326
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by selsinork » Wed Jul 04, 2012 4:33 pm
abishur wrote:My goblin might have fur

Did you feed it after midnight ?
;)
Posts: 151
Joined: Mon Apr 16, 2012 8:31 am
by abishur » Wed Jul 04, 2012 5:23 pm
selsinork wrote:
abishur wrote:My goblin might have fur

Did you feed it after midnight ?
;)


I know that old man told me not to when I got her, but I just don't see what harm that could have caused!

I like how the photo I took made her look big, but she's actually a bit of a runt, 2 years old and weighs around 8 pounds, a very tiny cat.
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4326
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by AndrewS » Wed Jul 04, 2012 6:14 pm
abishur wrote:
selsinork wrote:
abishur wrote:My goblin might have fur

Did you feed it after midnight ? ;)

I like how the photo I took made her look big, but she's actually a bit of a runt, 2 years old and weighs around 8 pounds, a very tiny cat.

So, small paws, ideal for messing about with breadboards ;)
User avatar
Posts: 3626
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK