Timer count register reset | LabJack
 

Timer count register reset

5 posts / 0 new
Last post
M.Eider
M.Eider's picture
Timer count register reset

Hi,

is there a way to reset a Timer's count register within the U3-LV?

I have configured Timer 0 to PWM and Timer 1 to TIMERSTOP at 28 Hz, which means I want to create a specific amount of pulses that must have the same length. Unfortunately it seems that Timer 0 is keeping its last count value when it's disabled by Timer 1, so the length of the first pulse always varies from the desired value, when both Timers are restarted.

I have added the curves of three outcomes measured by my oscilloscope and a screenshot of the VI I haved used in LabVIEW, which is based on the "U3 PWM16 and Duty Cycle.vi" Demo.

Thanks in advance!

File Attachment: 
LabJack Support
labjack support's picture
There are a couple things to

There are a couple things to try here:

1) Set the direction and state of the IO line prior to starting the PWM. The PWM output will go high and low based on when the timer rolls and when it matches a specified value. By changing the default state I think we can avoid partial pulses. I am not sure if the default state should be high or low.

2) All the timer features share a timer clock. So you can turn off the timer clock, reset the individual modules then reenable the clock.

Let us know how it goes.

M.Eider
M.Eider's picture
Thanks for the hintsI've

Thanks for the hints
I've tried setting the digital pin level with "eDO" and also disabling the timers with "eTC sb" prior to my configuration (I placed everything within the while-loop), but this didn't work either. How can the pin direction be changed and timer clock be disabled in LabVIEW?

I've also tried to set both timers as "TIMERSTOP". This sets the internal counting register to zero, but after my configuration the timer counting register again takes on a random value
Greetings,
M.Eider

LabJack Support
labjack support's picture
I am having a tough time

I am having a tough time figuring out what is going on. Internally the U3 is comparing the value passed as the "Timer Value" to an internal counter. When the count matches the PWM output is set high. When the counter overflows from 65535 to zero the PWM output is set low. A command to start the PWM may be received while the counter is higher or lower than the match value, And the line may be high or low when the PWM is started. So we have four combinations of initial line value and whether the update occurred while the counter is higher or lower than the match. In no combination doesn't anything unexpected happen. Would you please repeat your test without anything connected to the U3 except a scope?

Also, make sure your firmware is up to date. If not, the update utility is LJSelfUpgrade under Programs->LabJack.

M.Eider
M.Eider's picture
Ok I think I've found the

Ok I think I've found the problem. As you supposed to disconnect the U3 from the other circuitry, the impulse generation now works fine with the VI from the first post.

Maybe I'll add an impedance converter to the PWM ouput and check the current which is drawn by the additional circuit. Perhaps there's a wrong connection in my wiring.

Thanks for the help!