U3 Timer reset not working in Python 2.7 | LabJack
 

U3 Timer reset not working in Python 2.7

3 posts / 0 new
Last post
Brian
aparanoidbw's picture
U3 Timer reset not working in Python 2.7

Edited for formatting

I've tried searching the forums and google, and I still cant get this to work.

I'm trying to reset the timer every so often so I don't have these huge numbers.  I'm using U3 Labjack, with the python 2.7 library.

Attached are my atttempts.  Also code below

Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>>> import u3
>>> dev = u3.U3()
>>> dev.reset(True)
>>> dev.configIO(NumberOfTimersEnabled = 1)
{'NumberOfTimersEnabled': 1, 'TimerCounterPinOffset': 4, 'DAC1Enable': 0, 'FIOAnalog': 0, 'EIOAnalog': 0, 'TimerCounterConfig': 65, 'EnableCounter1': False, 'EnableCounter0': False}
>>> dev.getFeedback(u3.Timer0())
[160794122]
>>> dev.getFeedback(u3.Timer(timer = 0))
[192106954]
>>> dev.getFeedback(u3.Timer(timer = 0, Value = 0))
[224845482]
>>> dev.getFeedback(u3.Timer(timer = 0, Value = 0))
[230366378]
>>> dev.getFeedback(u3.Timer(timer = 0, Value = 0, UpdateRest = True))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'UpdateRest'
>>> dev.getFeedback(u3.Timer(timer = 0, Value = 0, UpdateReset = True))
[286179735]
>>> dev.getFeedback(u3.Timer(timer = 0, Value = 0, UpdateReset = True))
[292600972]
>>> dev.getFeedback(u3.Timer0(Value = 0, UpdateReset = True))
[336233891]
>>> dev.getFeedback(u3.Timer0(Value = 0, UpdateReset = True))
[340177169]
>>> dev.getFeedback(u3.Timer0(UpdateReset = True))
[375781204]
>>> dev.getFeedback(u3.Timer0(UpdateReset = True))
[379435376]
>>> dev.getFeedback(u3.Timer0(Value = 0))
[418480080]
>>> dev.getFeedback(u3.Timer0(Value = 0))
[423833158]

 

no matter what I try, the timer keeps counting up.

Also if someone could explain the timer output in further detail, it would be appreciated.  Using the code in sreenshot, when I sleep for 1 second and request another timer count, I'm getting a difference of about 4,001,000.  Although the default clock speed is 48mHz.  I don't understand why I'm getting 4 million, when there are 48 million cycles per second.

I'm not using any special timer divisors or anything, just default specs.

File Attachment: 
LabJack Support
labjack support's picture
Looking at your code, system

Looking at your code, system timer low (mode 10) is being used since the mode is not set. It is the default timer. This timer can't be reset and is free-running at a 4 MHz frequency. So the 4 million difference per second is correct. That mode is documented here:

https://labjack.com/support/datasheets/u3/hardware-description/timers-co...

If you want to use a different timer mode, use TimerConfig before your Timer calls to configure the mode. Timers and its modes are documented here:

https://labjack.com/support/datasheets/u3/hardware-description/timers-co...

Brian
aparanoidbw's picture
excellent, I'm a little

excellent, I'm a little embarrased that I only saw the clock base 48mHz (default) in Table 2.9-1, but not the System timer low read (default mode) in Table 2.9-1.

Thanks for the help, I'll continue to play around with the Timer modes.