Unstable TTL pulse rate | LabJack
 

Unstable TTL pulse rate

2 posts / 0 new
Last post
fish
ivapl's picture
Unstable TTL pulse rate

Hi,

I am trying to send a 300 Hz TTL pulse signal. When I checked the signal on oscilloscope, the shape is fine but there is a fluctuation on the frequency that goes from 260 Hz - 400 Hz. I am just using this simple code in python to control the labjack:

dev = u3.U3() # Open first found U3
dev.configIO(FIOAnalog=0x0F)

dev.setDOState(ioNum=4, state=0)

dt = 26
while True:
    dev.setDOState(ioNum=4, state=0)
    dev.getFeedback(u3.WaitShort(dt))
    dev.setDOState(ioNum=4, state=1)
    dev.getFeedback(u3.WaitShort(dt))

LabJack Support
labjack support's picture
Each call in your while loop

Each call in your while loop has USB delay, which can fluctuate. Try combining those four calls into one Feedback call to limit USB communications and see if that helps to get it closer to 300 Hz.

#  ...
commands = [u3.BitStateWrite(4, 0), u3.WaitShort(dt), u3.BitStateWrite(4, 1), u3.WaitShort(dt)]
while True:
    d.getFeedback(commands)