Good morning,
i'm using t7 in order to get the value of the frequency of a signal (the range we're talking about is 30kHz-90kHz). I'm using the extended feature DIO "Frequency In". The setting i use is the following (through a Python script):
info = ljm.getHandleInfo(handle)
print("Opened a LabJack with Device type: %i, Connection type: %i,\n" \
"Serial number: %i, IP address: %s, Port: %i,\nMax bytes per MB: %i" % \
(info[0], info[1], info[2], ljm.numberToIP(info[3]), info[4], info[5]))
aNames = ["DIO_EF_CLOCK0_ENABLE","DIO_EF_CLOCK0_DIVISOR", "DIO_EF_CLOCK0_ROLL_VALUE","DIO0_EF_ENABLE","DIO0_EF_INDEX"]
aValues = [1,1,0,1,3]
numFrames = len(aNames)
results = ljm.eWriteNames(handle, numFrames, aNames, aValues)
The measurement is taken in a loop in order to have a set. This is a single measure that is repeated each time:
value = ljm.eReadName(handle, "DIO0_EF_READ_A")
value1 = ljm.eReadName(handle, "DIO0_EF_READ_B_F")
print("\nFreq = %f" % (value1))
As results i'm getting for a 90 kHz signal this set of results:
Freq = 90090.093750
Freq = 89988.750000
Freq = 89988.750000
Freq = 89988.750000
Freq = 90090.093750
Freq = 89988.750000
Freq = 89988.750000
Freq = 89988.750000
Freq = 89988.750000
Can i improve my measurement? Can i increase the accuracy of the results by changing the settings? In the average the error decrease but i'd like to improve my data at first. Am i not considering some factors?
To measure frequency the T7 is comparing the period to its internal 80 MHz clock. In this case the periods are: 89988.75 Hz = 11.1125 µs and 90090.09375 = 11.09999 µs. That's a difference of only 12.5 ns. 12.5 ns happens to be 1/80MHz, so that is the smallest difference that the T7 can resolve.
To get a better reading multiple periods will need to be averaged.
Edit: I think the best solution would be to use a logic counter or flip-flop to divide the frequency.
It's correct, anyway i changed approach: i use the T7 to read a transducer giving as output a frequency signal. Before doing this i used as input a wave generated from a Signal generator, to develop and set the script for the data aquisition. Now i use a different input, the PWM output of the board. The measures improved in accuracy and precision so it's necessary to consider the quality of the input used.
TLDR: consider also the input wave and their accuracy during the measurement