11-07-2021 08:37 PM
Dear all
I use python write an ci counter read code
my input frequency is fixed at 20Khz and i use while loop to get counter every 0.1 sec
but the conter is not fixed number
There will be a two-digit jump
for example 1421 →1421 →1423 →1421 →1428 →1425 →1426 →1421 ........
how can i get fix counter ?
CT = 0
while (tCT >0):
tCT = NI.read() //NI is function task.ci_channels.add_ci_count_edges_chan('Dev1/ctr0').ci_count_edges_term = 'PFI0'
print(str(thCT-CT))
CT = tCT
time.sleep(0.1)
thanks all
11-07-2021 09:25 PM - edited 11-07-2021 09:33 PM
I think it's not a problem with the counter but with the execution of the Python program, your python program does not execute "exactly" at 100ms intervals.
Software execution times are not guaranteed by OS and hence the difference is counter readback values are the variation in OS execution time of your loop.
Edit - counters being an HW are the most precise you can get given the reference clock is the best you can get