Dear Ben,
Thank your for your great work! I have been successfully using your rpi.GPIO for some time now.
Now, however, I'm seeing some strange behaviour whenever I try to change the duty cycle of a PWM output. The system crashes instantly and reboots. No error or exception is shown.
Some time ago I had no problems with the code. Unfortuately I can not tell when it startet to behave strange. I did a full update to the current releases and still the same.
Here my setup:
Raspberry Pi 3 Model B Plus Rev 1.3
Raspbian 10 BUSTER, 4.19.118-v7+
PYTHON 3.7.3
rpi.gpio 0.7.0
Find here some code I used to reproduce the behaviour:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #!/usr/bin/env python # -*- coding: utf-8 -*- import RPi.GPIO as gpio from time import sleep if __name__ == '__main__': gpio.setmode(gpio.BCM) gpio_valve1 = 16 # Set as output initial high for low active output gpio.setup(gpio_valve1, gpio.OUT, initial=gpio.HIGH) valve1 = gpio.PWM(gpio_valve1, 10) # Init valve with 100% duty cycle valve1.start(100) # Change duty cycle to 50 valve1.ChangeDutyCycle(50) # <<<< freeze and reboot happens here sleep(1) # Change frequency to 20 Hz valve1.ChangeFrequency(20) sleep(1) # Change duty cycle to 80 valve1.ChangeDutyCycle(80) |
Please give me instructions which logging to perform on my side to analyse the issue.
Regards,
Chris
Update:
Seems it is not the packet but rather the raspi itself. As a test I plugged the sd card in another raspi 3B+ and it runs like a charm.
Still it would be interesting why only the ChangeDutyCyle() causes a reset but not the other code...
Thank you
Sounds like you may have a borderline power problem with your circuit using close to what a GPIO pin or power supply can handle. Using too much current for GPIO can starve the SOC of power causing reboots.
Last edit: Ben Croston 2020-06-27
Hmm, actually I don't think so. I'm using the output as sink with 8mA and a optocoupler as load. The optocoupler also prevents hazardous voltage spikes from the connected valves.
I assume it's some ESD issue.
Dear Ben,
omg, after two month of smooth operation I encouter the same problems again. The new Pi shows the same behaviour. ChangeDutyCycle(0) leads to a sudden system reboot.
I checked the pins capacitive load (30pF of optocopuler input) and the powersupply. Both look good. This device certainly has no ESD damage.
In the /var/log/syslog and .../kern I see no issues. Can you give me some hints for futher debuggin?
Cheers,
Christian
UPDATE: System reboots in also if any of the ouputs is used as regular GPIO.output().
I ordered new RPIs to check for spikes caused by the inductive valves - after optocoupler and driver MOSFET...
Found the failure. It was a defect solenoid in my load circuitry. Puhh...