measuring rpm

Recommended Posts


I want to measure the rpm of a stirring device for one of my machines. I am trying to use a timer to do this.

I have attached the transducer to port EI00 which is channel 8, and therefore my timer offset is 8.

I have the following sequence.


include("C:\program files\labjack\drivers\labjackud.h")

while (1)

1) AddRequest(0, LJ_ioPUT_CONFIG, LJ_chTIMER_COUNTER_PIN_OFFSET, 8, 0, 0)

2) AddRequest(0, LJ_ioPUT_TIMER_MODE,0, LJ_tmRISINGEDGES32, 0, 0)

3) AddRequest(0, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_BASE, LJ_tc48MHZ_DIV, 0, 0)

4) AddRequest(0, LJ_ioPUT_CONFIG, LJ_chTIMER_CLOCK_DIVISOR, 48, 0, 0)

5) AddRequest(0, LJ_ioPUT_CONFIG, LJ_chNUMBER_TIMERS_ENABLED, 1, 0, 0)



I have some basic questions first:

on line 2 : after MODE, it wants me to specify Timer that a zero if I have only one enabled? ALso, what is the difference between using RISINGEDGES or FALLINGEDGES? DO I have to use both?

on line 5 : is the 1 correct after enabled?

Next I made a channel called timer to read my data. For I/O type i said timer and for channel number it won't let me put 8, so I put 0. Is this correct?

I then made a variable value component to read timer[0] and I don't get any data coming out.

Thanks for all your help.

Link to comment
Share on other sites

First, and I hate to pass things off, but any questions related to the AddRequest() parameters really should go to LabJack. We pass through all these things directly to their driver, largely so that as they add cool new features, we immediately support them. However since its their driver, its best to ask them these sort of questions as they are the experts.

That said...:

1) you don't want all this config in a while() loop. You only need to do it once. Just remove the while() and endwhile

2) If you have one timer enabled, then it starts at 0, so 0 is correct. The pin offset doesn't affect the numbering of the timers, just where 0 is located.

3) I don't know the specific difference between rising and falling edges, but would assume that one is looking at the upward slope and the other the downward. You should use one or the other

4) line 5, yes, 1 is correct, but I think this line might need to be before line 2

5) Timer channel: always starts from 0. Again the pin offset only changes where the input is, not the numbering.

Link to comment
Share on other sites


I am trying to do something similar in that I want to measure RPM's using the Period In Timer. My RPM sensor signal varies from 1-200Hz... 0.1-1V.

My input is set to FIO04, otherwise, I have the same script set up just like buttons has above, but keep getting the following error.

D0050:01:0016 LabJack Device #1 error: Request made on pin not properly configured for analog/digital

My LOCAL-Channels channel is set to: Timer, channel 0, Timing 0.5, ...

At some point the timer seemed to work, but the output was in the 10s and 100s millions if I remember correctly. The question I have, is what units is the timer output in and do the units vary depending on the timer clock frequency and divisor number?

I have attached my .ctl file for reference.


Thank you.

Link to comment
Share on other sites

You get the error because with a pin offset of 4, the Timer and A to D channels you have point to the same pin. You can't do this. If you want to read the period and A to D you will have to use two inputs and jumper them together.

As for units: the period in timer units I believe are in clock cycles, though really you should ask the LabJack folks. If it is clock cycles, then if you want actual frequency (hz) or time units, it will depend on the clock frequency and divisor.

Link to comment
Share on other sites


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