Hi all,
I am trying to use a Pi to control GPIB instruments. I have an Arduino mega 2560 acting as a serial to gpib converter taking care of the gpib side of things; no problems there. I want to communicate with the Arduino via infrared LED's and receivers (I have a hardware solution to the 38KHz carrier wave), with the Pi just out-putting 1, 2 and 3 millisecond pulses over a GPIO pin.
The problem I am coming across is that the length of the pulse from the pi occasionally doubles or even triples in size. Most of the time it is reasonably consistent but about 0.6% of my pulses have this phenomenon; I think it may be caused by the Pi CPU doing other things in the background. Is there a way to specify the Pi to dedicate itself to just one program?
I am running Raspian, but have looked into RiscOS pi (didn't get on with it). I would prefer to be able to write the IR protocols in python. An extract of my code is below, (it may be that the time.sleep() function is not the correct tool for the job?):
#-----------------------------------------------------------------
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(26, GPIO.OUT, initial = GPIO.LOW)
def no_ms_pulse(): # seperator for other pulses
time.sleep(0.0018)
def low_bit():
GPIO.output(26, GPIO.LOW)
time.sleep(0.0008)
GPIO.output(26, GPIO.LOW)
no_ms_pulse()
def one_ms_pulse():
GPIO.output(26, GPIO.HIGH)
time.sleep(0.0008)
GPIO.output(26, GPIO.LOW)
no_ms_pulse()
def two_ms_pulse():
GPIO.output(26, GPIO.HIGH)
time.sleep(0.0018)
GPIO.output(26, GPIO.LOW)
no_ms_pulse()
def three_ms_pulse():
GPIO.output(26, GPIO.HIGH)
time.sleep(0.0029)
GPIO.output(26, GPIO.LOW)
no_ms_pulse()
#--------------------------------------------------------------------
Any thoughts would be appreciated!