User avatar
TerryC65
Posts: 202
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

GPIO Pins seem to have no Oomph

Wed Mar 15, 2017 4:24 pm

Hi,

My project is using simple MOSFET circuits to drive a couple of solenoids. When I tested the system nothing worked. I have a simple Arduino based scope, so I wrote a very simple ON-OFF looping program and removed the 'Signal' connection (the GPIO line) from one of the MOSFETs and had a look at the levels, I could see the signal switching between 0 and approx 2.75 V.

This surprised me, because I had previously used the same MOSFET circuit to drive power LEDs with a PWM signal and got 3.3 V, but that project used a Pi Zero and this Project is using a Pi 3. I then ran my simple program on my old Pi 2 (which I had previously used to integrate my PWM code) and got the same result. When I restored the Signal connection to the MOSFET I/P, the pulses disappeared.

Finally, I tried driving a simple LED circuit directly from the GPIO pin and the LED failed to light. I also tried the same test, with a different GPIO pin with the same result.

The program is running on a fully up to date Raspbian Jessie with Pixel and I am using Python 2.7 and the latest RPi.GPIO library to switch the O/Ps.

I vaguely remember seeing something somewhere about the possibility of limiting the O/P current of the pins pro-grammatically, but cannot find that page anymore. Did I dream it? If not, is it possible that my copy of Raspbian has become misconfigured?

User avatar
Burngate
Posts: 6329
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: GPIO Pins seem to have no Oomph

Wed Mar 15, 2017 7:00 pm

Have a look / Google for Gert van Loo's document entitled GPIO pads control, errata (or something like)
It gives the magic runes to change the GPIO current capabilities.

The minimum they can be set to is 2mA, so with appropriate resistor it should light a LED. If it won't, then something may be broken.

User avatar
TerryC65
Posts: 202
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: GPIO Pins seem to have no Oomph

Wed Mar 15, 2017 7:29 pm

Burngate wrote:Have a look / Google for Gert van Loo's document entitled GPIO pads control, errata (or something like)
It gives the magic runes to change the GPIO current capabilities.
Thanks. I found that. If I've understood what it is telling me, the setting is achieved by writing to a register. It seems unlikely that has happened accidentally, since I only use Python and very simple C.
Burngate wrote:The minimum they can be set to is 2mA, so with appropriate resistor it should light a LED. If it won't, then something may be broken.
That was my first thought; but two completely separate Pis which have never been connected to the same external wiring? That's what made me think of the drive current setting, since I used the same SD Card in both.

Having said that, I can see how the drive current capability for a pin could be considerably reduced if one or more of the internal BCM drivers has been damaged. Again though, I tried my test with a pin that hadn't been used for anything else in any of my projects, with the same result, so I'm still uncertain what is going on.

User avatar
joan
Posts: 14995
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO Pins seem to have no Oomph

Wed Mar 15, 2017 8:17 pm

Have you double checked the pins you are using?

https://pinout.xyz/

RPi.GPIO lets you select pin numbering (BOARD) or GPIO numbering (BCM).

User avatar
TerryC65
Posts: 202
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: GPIO Pins seem to have no Oomph

Wed Mar 15, 2017 8:22 pm

joan wrote:Have you double checked the pins you are using?

RPi.GPIO lets you select pin numbering (BOARD) or GPIO numbering (BCM).
Triple and quadruple. I'm using BCM numbering so GPIO 17 is on Board pin 11. Also I have observed the pins pulsing and the pulses stop when loaded.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13218
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: GPIO Pins seem to have no Oomph

Wed Mar 15, 2017 9:14 pm

The GPIO logic of all SoC's, from PI1 (and zero) to PI 3 are identical!
So that isn't where the problem can be.
I get the feeling that there is a mistake somewhere, where you don't switch the output high or low but instead as low or as input with a weak pullup (50K). You could try to add a stronger pullup (say 2K2) to see what happens.

any GPIO programmed to output a 1, should output close to 3V3, unless very heavy loaded, say < 1K.
Normally drive strength is never changed by any library (AFAIK).

User avatar
TerryC65
Posts: 202
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: GPIO Pins seem to have no Oomph

Thu Mar 16, 2017 7:39 am

mahjongg wrote:I get the feeling that there is a mistake somewhere, where you don't switch the output high or low but instead as low or as input with a weak pullup (50K). You could try to add a stronger pullup (say 2K2) to see what happens.
I'm not sure that I understand what you mean when you say 'adding a stronger pullup'. I have used resistors on all my inputs, but I don't believe it is normal to pull up or down an output; the load does that.

Here is the code that I'm using for the test system:

Code: Select all

#!/usr/bin/env python 2.7

import time
import RPi.GPIO as GPIO

################################### Setup GPIO  ######################################

GPIO.setmode(GPIO.BCM)

GPIO.setup(7, GPIO.OUT) 
GPIO.setup(18, GPIO.OUT)
GPIO.setup(7, GPIO.LOW)
GPIO.setup(18, GPIO.LOW)


def strike_hammers():
    while True:
            GPIO.setup(7, GPIO.HIGH)
            print 'Left Solenoid On'
            time.sleep(1)
            GPIO.setup(7, GPIO.LOW)
            print 'Left Solenoid Off'
            time.sleep(1)
            GPIO.setup(18, GPIO.HIGH)
            print 'Right Solenoid On'
            time.sleep(1)
            GPIO.setup(18, GPIO.LOW)
            print 'Right Solenoid Off'
            time.sleep(1)


################# Main Program Begins Here  #################
strike_hammers()
A reasonable example of the circuit that I'm using for the test system may be found at: https://thepihut.com/blogs/raspberry-pi ... -gpio-pins. Obviously, my circuit includes two LEDs and therefore two GPIO pins and I have tried different pins to confirm that the problem seems to be across the board.

The code was copied from my project and modified to add the loop and create square waves.

PiGraham
Posts: 4022
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: GPIO Pins seem to have no Oomph

Thu Mar 16, 2017 7:46 am

TerryC65 wrote:
mahjongg wrote:I get the feeling that there is a mistake somewhere, where you don't switch the output high or low but instead as low or as input with a weak pullup (50K). You could try to add a stronger pullup (say 2K2) to see what happens.
I'm not sure that I understand what you mean when you say 'adding a stronger pullup'. I have used resistors on all my inputs, but I don't believe it is normal to pull up or down an output; the load does that.
Your load is a MOSFET gate, which behaves as a capacitor. You need a resistor to discharge that capacitance and turn off the device when not driven. One way to look at that is as the input of the MOSFET needs a pull-down.
What is your circuit? What MOSFET are you using.

User avatar
TerryC65
Posts: 202
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: GPIO Pins seem to have no Oomph

Thu Mar 16, 2017 7:50 am

PiGraham wrote:Your load is a MOSFET gate, which behaves as a capacitor. You need a resistor to discharge that capacitance and turn off the device when not driven. One way to look at that is as the input of the MOSFET needs a pull-down.
What is your circuit? What MOSFET are you using.
Yes it is in my project, but not in the test circuit that I pointed you at in my previous post. Had it worked in the test circuit and not in my project, I would have had a different problem.

In any case, this MOSFET Driver circuit has previously worked to generate PWM, as I mentioned originally.

PiGraham
Posts: 4022
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: GPIO Pins seem to have no Oomph

Thu Mar 16, 2017 9:23 am

Is your code really this?

Code: Select all

GPIO.setup(7, GPIO.HIGH)
I think you need this:

Code: Select all

GPIO.output(7, GPIO.HIGH)
That could explain what you are seeing, where you are switching between input and output mode instead of turning an output on and off.

User avatar
TerryC65
Posts: 202
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: GPIO Pins seem to have no Oomph

Thu Mar 16, 2017 9:32 am

PiGraham wrote:I think you need this:

Code: Select all

GPIO.output(7, GPIO.HIGH)
That could explain what you are seeing, where you are switching between input and output mode instead of turning an output on and off.
Crumbs! How did it ever give me pulses when the pin wasn't loaded! Thanks for pointing out my dumb mistake.

User avatar
davidcoton
Posts: 5148
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: GPIO Pins seem to have no Oomph

Thu Mar 16, 2017 2:07 pm

TerryC65 wrote: How did it ever give me pulses when the pin wasn't loaded!
Because the input state will float to wherever the stray capacitance and resistance thinks appropriate. Often somewhere mid-range. While in output state it will be either high or low. So you will see a switching voltage, but no current (or "Oomph", to use the technical term).
Location: 345th cell on the right of the 210th row of L2 cache

Return to “Troubleshooting”