Rasberry PI 3+/ Python App Mystery

I do not know what is going on, I am getting multi-interupted hits without an interrupted signal.

I am using the following schematic (LM555) to debounce a pushbutton. The output signal is extremely clean (no noise).

The code works great, but sometimes I get multiple interruptions; like the interrupt function is stuck in an endless loop. As you can see, there is no loop in the function. I do not know what is happening. I have to recyle the app to stop mystery.

def Push_Button_Function(channel):

#	global override
#	override = 1
    x=1

#Debug Point
    print('>>>PUSH BOTTON DETECTED <<<')

    #Next disable the button interrup so we do not have a interrupt while runing the function code
    GPIO.remove_event_detect(pushButton_Pin)
    statusbar.config(text="Push Button Detected")
    Disable_Buttons()
    
#First turn off the Ready LED
    Set_Ready_LED_Off()

    print("Telling controler the intensity value")
    
    GPIO.output(IntensitySelect_Pins,Task_Num[intensity_options.get()])
    
    print("Calling Run Task")
    
    Run_Task()
    
    print(" Back in Push Button Function")

#Wait for push button to be realsed
    while GPIO.input(pushButton_Pin):
        pass
             
    Set_Ready_LED_On()        

# Renabling the push botton interuot
    print(" Reinabling Push Buttom interupt")
    
# Renable push botton interrup so we do not have a interrupt while runing the function code
    GPIO.add_event_detect(pushButton_Pin,GPIO.RISING ,callback = Push_Button_Function) 

    statusbar.config(text="Ready")
    
    Restore_Buttons()
    
    print("Push Botton function exiting")
    print("^^^^^^^^^^^^^^^^^^^^")


Thank you for sharing your wisdom with me :smiley: :smiley: :smiley:

Does this:

GPIO.remove_event_detect(pushButton_Pin)

really play nicely with this?:

    while GPIO.input(pushButton_Pin):
        pass

This is a loop.

Is this managing a GUI? If so, the loop that busy-waits for button release is probably not what you want.

If I were doing this, I would keep the GPIO event detection permanently active, but then have a check at the top of the function to determine whether to activate or not. This would be relatively easy to debug, as you could put a print() above that check.

The GPIO.remove_event_detect(pushButton_Pin) line of code is already in the function.

I do not understand what you’re saying>>>

really play nicely with this?:

   while GPIO.input(pushButton_Pin):
       pass

Hello,

it might be a design problem. 15 uFcapacitor value is a rather large value for the purpose of filtering out a toggle signal from a simple switch. Instead, use 1 uF in parallel with a 0.1 uF. Remove the 10 Ohm resistor. All this does is keep the voltage at a non-zero value - not what you want. Replace it with a piece of wire (a trace). Also remember that a capacitor holds charge. 15 uF will hold a lot of charge relative to the the purpose for this simple applicaton (you might see this value in the output of a small power supply). The larger the charge, the more time that is needed to discharge a capacitor. Now, when you press the toggle switch, the R6 resistor limits the amount of discharge current that is allowed. Unless you hold the toggle switch for a relatively long time for the capacitor to fully discharge, it will never reach the desired LOW value to trigger your IC pin.

For R5, change the value from 330 to ~4.7 kOhm.

Note:

  1. 5V / 330 = 15 mA
  2. 5V / 4.7 k = 1 mA

I’m not sure about the circuit. Are you sure that’s wired as monostable and not as astable?

You have the threshold and trigger wired together, which looks like the astable configuration.

The monostable configuration doesn’t wire them together.

555 timer IC - Wikipedia

As for the 555, I am using the internal flip-flop to control the output. I am not using in astable or monostable mode Since the 555 is a 5V logic, I can not use its output pin signal because it would blow the Raspberry GPIO input pin. So, I am using the open collector discharge transistor with a 10K pull-up resistor.

I will try your suggested circuit to see if it helps.

Here is the entire Python App Code( a Dropbox link)

It works great except for this random interrupt triggering, which requires a reboot of the app to stop these interrupt triggerings. I checked the 555 output is working correctly and is very clean. So I do not think it is a hardcore problem but a software problem. is like retrigering it self.

One more thing:
I can not attach my DVM to test points because it caused the code to fail!! Why is this happening, or is it a normal thing?

It appears that you either have a loose connection, cold solder, or micro hair crack in a component (capacitor / resistor) somewhere. I would start by doing a solder touch up to all of the components. Make sure you use solder flux where you perform the solder touch up so that the solder flows smoothly. Without it, there is potential for cold solder. I recommend investing in a Carson type magnifier which can help inspecting boards for improper soldering. You can go to Amazon and enter this number in its search bar: B00BUGYKPE. It will help you catch things that your eyeballs may miss.

Note that under normal circumstances, putting a voltmeter probe on a test point should not affect a circuit since the output impedance of a voltmeter is typically in the range of 1 MOhm.

Recap:

  1. Make the circuit modifications as I pointed out in my previous post (I use the same circuit for one of my boards and it works as expected). The capacitors should be ceramic type.
  2. Make the solder touch ups / troubleshootig checks that I have just metioned in this post.
  3. Once you have verified that you have a working circuit, then I would move on to verifying the SW.

Good luck.

I just bread baord you curciut. Your circuit is almost like mine except for the values and the removal of the 10-ohm resistor.

I see you’re running the RC junction to the trigger pin (which sets the flip-flop) but not the threshold pin. So how does the flip-flop get reseted when the button is released?

I never stated not to connect it to the other pin. I just included the Trigger pin because it was the closest pin on the schematic provided. Note that I am not an LMC555 component connoisseur. I will leave it up to you to do your research as to its proper operation and required connections.

I did not intend to insult you..Sorry for my bad wording.

I am redoing the PCB with your mod.

Again, thank you for sharing your wisdom with me.

No insult taken actually. :wink:

Looks like a nice project that you’re working on.

Good luck with troubleshooting it.

… also make sure your grounds are solid EVERYWHERE.

fyi …

I did a quick check of your schematic again. It is clearly missing the bypass capacitors from Vcc to GND on the LMC555 timer.

Per its datasheet, in the Power Supply Recommendations section, it states the following:

... the minimum recommended is 0.1 μF in parallel with 1-μF electrolytic. Place the bypass capacitors as close as possible to the LMC555 and minimize the trace length.

My project is a stepper motor app. Since Python can not hold or provide the required microsecond ( shortest step time 16 microseconds) timing for proper stepping, I had to use a logic controller (Itsy Bitsy 32u4 3v). This Python app is a GUI app, so the user can select 1 of 17 possible stepper patterns. When the user selects a pattern, the GUI code sets the GPIO pins that tell the logic controller what pattern was selected. Once the GPIO pins are set to the proper values, the GUI sets the run GPIO pin high, telling the logic controller to run the task. The GUI and logic controller code works great and without any errors, including the interrupts. Then, out of the blue, this interrupt mystery pops up. Needing an app restart to stop this mystery and return to normal operation.

I have another mystery with the home sensors, but these sensors are not connected to Rasberry but with the logic controller.

I will add the bypass caps, as you pointed out.

What is the U1 IC part number?

U1 is the logic controller (Itsy Bitsy 32u4 3v).

Per the schematic from this user guide, they recommend having a 10 uF cap in parallel with a 1 uF capacitor. That’s about right. That is what I have for one of my designs:

Like I stated before, any time that you’re going to be using an IC in your design (that goes for any part actually), the first thing that you want to do is to start reading its datasheet. This will help you to understand its strenghs and limitations and whether or not if it is suited for your application. For ICs, in this particular case, is to determine the required bypass capacitor recommended values.

220/10 = 22 times greater than the largest recommended value capacitor for this IC.

The IC that the itsy-bitsy-32u4 uses is the ATMEGA32U4. If you reference its datasheet, they have a power supply with output capacitors of 10 uF and 1 uF.

Moral of the story: read the documentation.

what type caps are they (ceramic or electrolytic)?

From previous post:

The 0.1 uF cap can be ceramic. Thee 1 uF cap needs to be electrolytic type. But I would also add a 10 uF cap as well.