Emma_Jir
Posts: 23
Joined: Wed Nov 29, 2017 11:13 am

Interrupt on a GPIO Pin

Sun Dec 31, 2017 11:57 am

Hello,

I've been using a script that wait's for a falling_edge on a GPIO Pin. The pin is pulled up to high (by the script, not physical) by default and pulled to ground over a low resistor by a button (COM-00097). It works fine but i've heard that when using components like above polling would be a better solution scince the microelectronics could take damage so i have following questions:

1)Is it generally safe to use the GPIO-Pins like described in the setup?

2)What is the maximum current a circuit should draw when using interupt?
Due to serveral functions the script distinguishes between a short signal an a one-second period the button is pushed. Could a current for one second do any harm to the chipset on long term?

Thank you in advance.

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

Re: Interrupt on a GPIO Pin

Sun Dec 31, 2017 12:10 pm

I don't know what was meant by polling may be better. It would make no difference to the electrical connections or the current consumption.

When set as an input the GPIO won't be drawing any significant current, perhaps in the microamp region.

Emma_Jir
Posts: 23
Joined: Wed Nov 29, 2017 11:13 am

Re: Interrupt on a GPIO Pin

Sun Dec 31, 2017 12:30 pm

joan wrote:
Sun Dec 31, 2017 12:10 pm
I don't know what was meant by polling may be better. It would make no difference to the electrical connections or the current consumption.

When set as an input the GPIO won't be drawing any significant current, perhaps in the microamp region.
I don't know, due to complicated circustances components can be damaged scince there is no clear edge rather than a weird slope when using components like buttons. I don't know the english terminus for it but it heightens the risk of damage as i understand.

The pin is set as Input Pin but i think i have 70 mA when short circuiting the button. The resistor is 270 ohm.

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

Re: Interrupt on a GPIO Pin

Sun Dec 31, 2017 12:41 pm

Emma_Jir wrote:
Sun Dec 31, 2017 12:30 pm
joan wrote:
Sun Dec 31, 2017 12:10 pm
I don't know what was meant by polling may be better. It would make no difference to the electrical connections or the current consumption.

When set as an input the GPIO won't be drawing any significant current, perhaps in the microamp region.
I don't know, due to complicated circustances components can be damaged scince there is no clear edge rather than a weird slope when using components like buttons. I don't know the english terminus for it but it heightens the risk of damage as i understand.

The pin is set as Input Pin but i think i have 70 mA when short circuiting the poles. The resistor is 270 ohm.
Please post your circuit, or a photo of your setup. 70mA is not consistent with pulling down through 270 ohms, indeed the current should be limited by the internal pull-up to a much lower value.

Apart from that, as Joan says there is no risk of damage from using edge-detect interrupts rather than polling. There is a risk that it won't work well (switch bounce can cause multiple interrupts), but that can be fixed.
Note that Joan wrote the pigpio system so she knows more about GPIO interfacing than most of us.
Signature retired

Emma_Jir
Posts: 23
Joined: Wed Nov 29, 2017 11:13 am

Re: Interrupt on a GPIO Pin

Sun Dec 31, 2017 12:50 pm

davidcoton wrote:
Sun Dec 31, 2017 12:41 pm
Please post your circuit, or a photo of your setup. 70mA is not consistent with pulling down through 270 ohms, indeed the current should be limited by the internal pull-up to a much lower value.

Apart from that, as Joan says there is no risk of damage from using edge-detect interrupts rather than polling. There is a risk that it won't work well (switch bounce can cause multiple interrupts), but that can be fixed.
Note that Joan wrote the pigpio system so she knows more about GPIO interfacing than most of us.
The circuit is simple:

[pin 13] -------------------------------------#######
# button #
[pin9(gnd)]---------[260Ohm]----------#######


Thank you for the quick answer. I think i misread the display and the current is lower. I have had no issues with multiple interrupts using this setup so far, maybe it's just quality components.

So there is no risk that the internal resistor might fail (and 270 Ohm are sufficient)?
And: is it safe to use different components like a toggle-switch for other purposes? Or should i consider using a latch or something?
Last edited by Emma_Jir on Sun Dec 31, 2017 1:01 pm, edited 1 time in total.

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

Re: Interrupt on a GPIO Pin

Sun Dec 31, 2017 1:01 pm

Emma_Jir wrote:
Sun Dec 31, 2017 12:50 pm
So there is no risk that the internal resistor might fail (and 270 Ohm are sufficient)?
If the internal resistor fails, you have bigger problems than the current on tthe GPIO. You don't actually need an external resistor, in fact if it gets too large, you won't pull the voltage down far enoughn to trigger the interrupt (or a "0" from polling, for that matter).
Emma_Jir wrote:
Sun Dec 31, 2017 12:50 pm
And: is it safe to use different components like a toggle-switch for other purposes? Or should i consider using a latch or something?
As long as you don't apply 5V to the GPIO pins, or short out either the 3V3 or 5V supply, connecting almost any switch to a GPIO input is safe.
Signature retired

Emma_Jir
Posts: 23
Joined: Wed Nov 29, 2017 11:13 am

Re: Interrupt on a GPIO Pin

Sun Dec 31, 2017 1:11 pm

Ok thank you so far. I have one more question regarding this topic peripherally, if not i can open a different thread and mark this one as solved:

on the python-gpio-module is there a way to wait for interrupts on two pins at the same time (like a logic or)?

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

Re: Interrupt on a GPIO Pin

Sun Dec 31, 2017 1:20 pm

Emma_Jir wrote:
Sun Dec 31, 2017 1:11 pm

on the python-gpio-module is there a way to wait for interrupts on two pins at the same time (like a logic or)?
Interrupts are like children. You don't wait for them, they just break in on whatever you are (or are not) doing.
Look up the documentation for you GPIO package, usually the lower level handler will determine which GPIO caused the interrupt and will call your handler for that GPIO. There will be some parameter when you set up an interrupt handler that determines which GPIO it responds to. You can set up interrupt handlers for as many different GPIOs as you like.
Signature retired

Return to “Beginners”