timer nightmare


Recommended Posts

Hi All

I'm a complete newby to LabJack, have a U3-HV. Acquiring analog and digital data seems fairly straightforward, but TIMERS? All I want to do is use a timer to output on a named channel, the frequency of an incoming square wave on a digital channel. the frequency is low, max 3hz.

I have tried the samples, tried adapting the samples, but I cannot make any sense of it.

Could some kind soul who knows their way around these things do me a real solid and write a simple .ctl to do what I describe above? It must be only 5 minutes work to someone in the know but I am missing something fundamental and its driving me NUTS. Once I have that, it'll all make sense.....hopefully...

thanks, OB

Link to comment
Share on other sites

You are polling the digital channel? If so, it'd be much easier to simply set the output of a digital channel based on the input by adding this line in the input channel's event:

digOut = digIn[0]

where digIn is the name of your input, and digOut the name of your output. This will echo the input to the output.

Link to comment
Share on other sites

..and then what? But thanks for the response nonetheless...

I think you vastly over-estimate my understanding of this no-doubt excellent piece of kit, but the initial barrier to doing ANYTHING concerning timers seems insurmountable. I've looked at the TimerFrequencyout.ctl and can't see why you would need 2 timers to measure the frequency of one square wave. And whatś with this obsession with PWM I see with any documentation concerning timers? Again, there is a key piece I seem to be missing.

Tell you what, I'll trawl through the vast numbers of other questions undoubtedly posed on this topic, and come back and try to ask a question that does not insult your vast experience.

Or you could just give me hand up and tell me how to set it up.

thanks, OB

Link to comment
Share on other sites

I'm sorry, but I still do not know what you are trying to do. As such, I do not want to spend a lot of time giving you an explanation for something you don't want.

Truthfully, I think LabJack is going to be better suited to answer these questions as your questions are very hardware specific. As I've said many times in this forum, the DAQFactory LabJack driver is basically a wrapper for the LabJack UD provided by LabJack, and they really are the best source for support for their devices for things that are device specific like how to use Timers. I expect they will reply to this forum, but like me, they'd like more detail on what you are trying to do.

But maybe its just me: do you just want to read the frequency of a square wave and display it? Your use of the word "output" and "channel" made me think you wanted to then take that value and send it out another channel, basically replicating the wave form, or perhaps outputting an analog voltage proportional to the frequency.

Link to comment
Share on other sites

You did mention using a timer to output something (timers have input and output modes), and it originally sounded like you wanted to poll an input signal and output it in some output channel, but I think you are saying you simply want to use a timer input to measure frequency?

I've looked at the TimerFrequencyout.ctl and can't see why you would need 2 timers to measure the frequency of one square wave. And whatś with this obsession with PWM I see with any documentation concerning timers?

The closest example I see in /LJGuideSamples is TimerFreqOut.ctl. That is not a bad example for you, but to avoid some confusion I would look at TimerPeriodIn.ctl instead.

In examples demonstrating an input timer you will often see that a PWM output timer is also enabled. This gives you a nice known signal to connect to the input timer to see if it is measuring correctly.

So, assuming you just want to measure a frequency, I suggest using 32-bit period measurement mode 2:

http://labjack.com/support/u3/users-guide/2.9.1.3

Also refer to the following to help understand what you see in the DAQFactory script:

http://labjack.com/support/u3/users-guide/4.3.6

In DAQFactory, you can look at the example TimerPeriodIn.ctl:

http://labjack.com/support/ud/df-lj-app-guide/10

I have gone ahead and made a new simpler example called "Simple Period32 Example.ctl" and posted it at labjack.com:

http://labjack.com/support/ud/examples/daqfactory

Link to comment
Share on other sites

Thanks guys. I will digest this.

What I am trying to do is take a digital input from a reed switch pickup on the pedal crank of an exercise bike and use that to generate a rpm value. There is also an analog signal from a loadcell (Wheatstone bridge) measuring braking force on the flywheel of the bike and these signals plus heartrate from another gadget will be used in a excel to generate power, expended effort and other statistics.

Why don't you buy an exercise bike with all this stuff fitted I hear you say. Well, I have this Labjack thing........

Link to comment
Share on other sites

Section 2.8.1.3 is about mechanical switch inputs and mentions bounce:

http://labjack.com/support/u3/users-guide/2.8.1.3

See the labjack.com forum topic #1105 for a general discussion of frequency measurement:

http://forums.labjack.com/index.php?showtopic=1105

Do you have an instrumentation amp for your bridge? The LJTick-InAmp is good and also provides the excitation.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.