Hello everyone,
I'm currently working on a personal project but I encounter a difficulty which as kept my mind for almost a week now ! Here is the problem :
I have a LED which can blink two different ways. A rapid blink (10hz) and a slow blink (5hz). I want to identify what is the blinking state of my LED (using my Ue9).
To ensure that, I want to measure the time between two rising edges on the input digital signal. In fact, If this time equals 0.4s then I will know that my LED is blinking slowly. At the opposite, if this time equals 0.2s I will know that my LED is blinking quickly.
How can I perform this, and how does it work on Ue9 ?
Thanks for your answer.
I suggest you use a timer configured for 32-bit Period Measurement Input:
https://labjack.com/support/datasheets/ue9/hardware-description/timers-c...
Thanks for your answer.
Do you have some code examples that you could send to me ?
I understand the solution but I still have some difficulties to implement it...
Please note that I'm using my Ue9 with Ride (python) on a Linux station.
James.
Do you have access to a Windows computer? It is good to do an initial test with the test panel in LJControlPanel. There you can enable the timer and see if it reads the period of your signal correctly.
Someone else here will follow up about Python on Linux.
Our LabJackPython download contains our UE9 Python interface and some examples here:
https://labjack.com/support/software/examples/ud/labjackpython
Here's a quick example with 32-bit Period Measurement Input Rising Edge (derived from the PWM-looping.py example):
from time import sleep
import ue9
#Timer related Modbus register addresses.
#The Modbus map with all registers can be found here:
# https://labjack.com/support/software/api/modbus/ud-modbus
TIMER_CLOCK = 7000
TIMER_DIVISOR = 7002
NUM_TIMERS_ENABLED = 50501
TIMER0_CONFIG = 7100
TIMER1_CONFIG = 7102
TIMER0 = 7200
TIMER1 = 7202
# Open the LabJack.
d = ue9.UE9()
#Timer clock and mode numbers can be found here:
# https://labjack.com/support/datasheets/ue9/hardware-description/timers-c...
# Set the timer clock base to system clock (48 MHz) with divisor of 2.
# This will set the timer clock to 24 MHz (TimerClockBase/divisor)
d.writeRegister(TIMER_CLOCK, 1) #1 = 48 MHz (System)
d.writeRegister(TIMER_DIVISOR, 2)
# Enable 1 timer (Timer 0). Timer 0 will be on FIO0.
d.writeRegister(NUM_TIMERS_ENABLED, 1)
# Configure timer0 for 32-bit Period Measurement Input, Rising Edge (mode 2).
d.writeRegister(TIMER0_CONFIG, [2, 0]) #[mode, value]
# Getting 10 readings from timer 0 every 1 second.
for i in range(10):
print d.readRegister(TIMER0)
sleep(1.0)
# Close the device.
d.close