1

I have a Pi NoIR camera setup to take a still image every 60 seconds with a Python3 script. This is set to run for about 12 hours from 7pm to 7am. This setup worked as intended without any problems. I then added a IR LED flash that is controlled by GPIO pin 17(BCM). Originally this just turned on and off. However, since changing the code to run the pin at 50% PWM I get the following error after a few hours of execution:

picamera.exc.PiCameraRuntimeError: Timed out waiting for capture to end

I've tried my original script again and it runs without error. The error only seems to occur when I use PWM.

Here is my code:

import time
import picamera
import datetime
import RPi.GPIO as GPIO

def capture_frame(_still):
#Record time and date
strNow = dtCurrent.strftime("%Y_%m_%d_%H_%M_%S")
dbdate = dtCurrent.strftime("%Y-%m-%d")
dbtime = dtCurrent.strftime("%H:%M:%S")

#Configure flash pin
flash = GPIO.PWM(17,120)

with picamera.PiCamera() as cam:
    cam.resolution = (640, 480)
    cam.annotate_text = strNow
    #GPIO.output(17, 1)
    flash.start(50)
    time.sleep(1)
    cam.capture('/home/pi/monitor/images/{0:4d}.jpg' . format(still), resize=(480, 360))
    cam.close()
    #GPIO.output(17, 0)
    flash.stop()
0

It's probably a bug in RPi.GPIO brought to light because of the way you are using the PWM functions. Check to see if it's a known issue at http://sourceforge.net/p/raspberry-gpio-python/tickets/ and perhaps raise an issue.

Rather than flash.start(50) and flash.stop()
try using flash.ChangeDutyCycle(50.0) and flash.ChangeDutyCycle(0.0)

  • GPIO ticket #94 This explains everything very nicley. My error occured at around 360 to 380 images taken. I shall use flash.ChangeDutyCycle instead. – gruffymax Dec 28 '15 at 12:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.