0

for a few months I use python3 with pigpiod (version 71) at Raspberry Pi 3B+ to control some actuators (on/off) and LEDs (on/off/PWM). My dimming algorithm uses the command pi.set_PWM_dutycycle(pin, dc) all 0.025 Seconds to enable smooth dimming. Everything has been fine for a few days. After that, the following problem gradually occurs by certain pins:

  • The pin-state is 0. After the command pi.write(pin, 1) the pin-state is still 0. (unexpected)
  • [The pin-state is 0. After the command pi.write(pin, 0) the pin-state is still 0. (expected)]
  • The connected LED flickers while changing the dutycycle. In detail, when dimming from 0 to 255, up to about 150 everything is fine, then the pin-status changes with a frequency of approx. 1 Hz. (abnormal)

The problem occurs frequently on Raspberry Pis with a high number of pi.set_PWM_dutycycle(pin, dc) processes. It seems to me, the pins that are often dimmed by pi.set_PWM_dutycycle(pin, dc) are particularly often affected.

Today the problem occurred again: Pin 6 is affected and e.g. pin 12 is not (using BCM Numbers).

I did the following to confine the problem:

root@raspberry:/home/pi# pigs csi 7
root@raspberry:/home/pi# killall python3

Start python3 in shell:

root@raspberry:/home/pi# python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pigpio
>>> pi = pigpio.pi()
>>> pin = 6
>>> pi.set_mode(pin, pigpio.OUTPUT)
0
>>> pi.read(pin)
0
>>> pi.write(pin, 1)
0
>>> pi.read(pin)  # Should return "1"  [######## Here is the Problem visible ########]
0
>>> pi.write(pin, 0)
0
>>> pi.read(pin)
0
>>> otherPin = 12
>>> pi.set_mode(otherPin, pigpio.OUTPUT)
0
>>> pi.write(otherPin, 0)
0
>>> pi.read(otherPin)
0
>>> pi.write(otherPin, 1)
0
>>> pi.read(otherPin)  # Should return "1"
1
>>> pi.write(otherPin, 0)
0
>>> pi.read(otherPin)
0

The related log in /dev/pigerr shows the following:

root@raspberry:/home/pi# cat /dev/pigerr
2020-04-26 12:49:55 pthSocketThread: Connection accepted on socket 14
2020-04-26 12:49:55 pthSocketThread: SO_KEEPALIVE enabled on socket 14

2020-04-26 12:49:55 pthSocketThread: Connection accepted on socket 5
2020-04-26 12:49:55 pthSocketThread: SO_KEEPALIVE enabled on socket 5

2020-04-26 12:49:55 gpioRead_Bits_0_31:
2020-04-26 12:49:55 gpioNotifyOpenInBand: fd=5
2020-04-26 12:50:55 alertEmit: notification 0 (1 reports, 0-0)
2020-04-26 12:51:10 gpioSetMode: gpio=6 mode=1
2020-04-26 12:51:50 gpioRead: gpio=6
2020-04-26 12:51:55 alertEmit: notification 0 (1 reports, 1-1)
2020-04-26 12:52:04 gpioWrite: gpio=6 level=1
2020-04-26 12:52:18 gpioRead: gpio=6
2020-04-26 12:52:26 gpioWrite: gpio=6 level=0
2020-04-26 12:52:35 gpioRead: gpio=6
2020-04-26 12:52:55 alertEmit: notification 0 (1 reports, 2-2)
2020-04-26 12:53:55 alertEmit: notification 0 (1 reports, 3-3)
2020-04-26 12:54:18 gpioSetMode: gpio=12 mode=1
2020-04-26 12:54:27 gpioWrite: gpio=12 level=0
2020-04-26 12:54:38 gpioRead: gpio=12
2020-04-26 12:54:41 gpioWrite: gpio=12 level=1
2020-04-26 12:54:44 gpioRead: gpio=12
2020-04-26 12:54:49 gpioWrite: gpio=12 level=0
2020-04-26 12:54:55 alertEmit: notification 0 (1 reports, 4-4)
2020-04-26 12:54:56 gpioRead: gpio=12
2020-04-26 12:55:55 alertEmit: notification 0 (1 reports, 5-5)
2020-04-26 12:56:25 gpioTerminate:
2020-04-26 12:56:25 gpioTerminate: initialised, terminating
2020-04-26 12:56:25 initReleaseResources:
SIGHUP/SIGTERM received

This unexpected condition persists.

If you execute killall pigpiod and pigpiod and repeat the same test, everything is fine:

>>> import pigpio
>>> pi = pigpio.pi()
>>> pin = 6
>>> pi.set_mode(pin, pigpio.OUTPUT)
0
>>> pi.read(pin)
0
>>> pi.write(pin, 0)
0
>>> pi.read(pin)
0
>>> pi.write(pin, 1)
0
>>> pi.read(pin)
1
>>> pi.write(pin, 0)
0
>>> pi.read(pin)
0
>>>

and the related log:

root@raspberry:/home/pi# cat /dev/pigerr
2020-04-26 12:59:00 pthSocketThreadHandler: Socket 5 closed
2020-04-26 12:59:10 pthSocketThread: Connection accepted on socket 6
2020-04-26 12:59:10 pthSocketThread: SO_KEEPALIVE enabled on socket 6

2020-04-26 12:59:10 pthSocketThread: Connection accepted on socket 5
2020-04-26 12:59:10 pthSocketThread: SO_KEEPALIVE enabled on socket 5

2020-04-26 12:59:10 gpioRead_Bits_0_31:
2020-04-26 12:59:10 gpioNotifyOpenInBand: fd=5
2020-04-26 12:59:24 gpioSetMode: gpio=6 mode=1
2020-04-26 12:59:35 gpioRead: gpio=6
2020-04-26 13:00:02 gpioWrite: gpio=6 level=0
2020-04-26 13:00:07 gpioRead: gpio=6
2020-04-26 13:00:10 alertEmit: notification 0 (1 reports, 0-0)
2020-04-26 13:00:11 gpioWrite: gpio=6 level=1
2020-04-26 13:00:14 gpioRead: gpio=6
2020-04-26 13:00:17 gpioWrite: gpio=6 level=0
2020-04-26 13:00:19 gpioRead: gpio=6
2020-04-26 13:01:10 alertEmit: notification 0 (1 reports, 1-1)
2020-04-26 13:02:10 alertEmit: notification 0 (1 reports, 2-2)
2020-04-26 13:03:10 alertEmit: notification 0 (1 reports, 3-3)

After a few days, the above problem returns.

I have no idea where to look for the cause. Does anyone have an idea here?

  • You need to write a script which shows the problem and say how to run it to demonstrate the problem. E.g. run this script for 5 days and then notice that GPIO x is not set as expected. If you can create such a script I suggest you then raise an issue at github.com/joan2937/pigpio/issues – joan Apr 26 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.