Electronic Design

Tachometer Measures Very Low Frequencies

The circuit shown in the figure is a three-digit tachometer that lets you measure low-frequency events recurring at intervals of 0.235 to 15 seconds--that is, from 4 to 255 rpm. Thus, it's suitable for those biomedical applications that measure the rate of low-frequency signals such as heartbeats, respiratory rates, ECG/EEG, and the speed of low-rpm motors or mechanisms.

A PIC16F872 MCU handles the tachometer function. The PIC senses the period of the input frequency (fin), computes the equivalent pulses per minute, and updates the LED displays accordingly. The input signal must be conditioned for 0 to 5 V dc, and the pulse width when the signal is high must be at least 4 µs.

The MCU solves the equation RPM = 60/T, where T is the period of the sensed input. The constant 60 represents the 60 seconds in a minute to give an equivalent readout of pulses or revolutions per minute (rpm). The time base for this circuit is supplied by the 32-kHz crystal (Epson C-001R32.768K-A ±20 ppm), which in turn triggers T1, the PIC's internal timer. Timer1 contains a programmable prescaler that's set to 1/8. This prescale generates a divided frequency of 4 kHz. Timer1 contains 16 bits, yielding a resolution of 0.00025 seconds (250 µs), and performs the period measurement.

Timer1 is enabled via software at the positive edge of the input signal on input RC2. When the next positive edge arrives, Timer1 is disabled. This way, Timer1 contains a binary count that corresponds to the period of the input signal. Because the resolution is 0.00025 seconds, we have to make three right shifts to get 0.25 seconds. So, our new rpm equation will be RPM = 60000/T.

The table shows how the rpm readings are obtained, starting from the counter (Timer1), which contains the period's reading. For example, if the PIC detects a signal whose period is 1 second, the counter reading will be equal to 1000 decimal because the internal frequency divider is set to 4. The resulting rpm reading for this signal must be equivalent to 60.

See the software routine to perform this task in this article's online version at www.elecdesign.com. It works as follows: The PIC monitors the input (RC2) waiting for a low-to-high transition. When a transition is detected, Timer1 is enabled by setting the bit TMR1ON.

The PIC then waits for the next low-to-high transition. When that happens, the PIC disables the bit TMR1ON to stop the counting. Now, the respective period reading resides in registers TMR1H and TMR1L.

To avoid having an out-of-range reading, we have to check the overflow bit called TMR1F. If this bit is set, it means that signal's period is too long to be measured. In this case, the program goes to label UNDF, which will display the message "OUF," or overflow. This indicates the input signal has a period higher than 16.384 seconds.

If there's no overflow, we have to verify that the period measurement is equal to or higher than 940 (equivalent to 255 rpm). If this reading is below 940, the program goes to label OVERF, which will display the message "00F." This indicates that the reading is above 255 rpm.

If the value is greater than 940, the reading will be divided by four using the routine DIVS, which works with two pairs of registers (ACCb and ACCa) that form two 16-bit numbers. To obtain the period, the formula is ACCb/ACCa = ACCb, and then the number 60,000 (EA60H) is divided by ACCb using the routine DIVS again. This gives us the rpm value in binary code, so we must convert it to BCD code.

To perform that operation, we transfer the reading to W and then call the routine BINBCD, which converts the binary reading to BCD code using the registers R0, R1, and R2 (where R2 is the most significant digit). Finally, each register is converted to a seven-segment code so that it can be shown on the LED display. Two computed tables perform the seven-segment operations, SEGM and SEGM2, where the last table handles the hundreds digit.

RPM VERSUS COUNTER READINGS
Counter Counter/4 = T 60000/T = RPM
940 235 255
1000 250 240
2000 500 120
4000 1000 60
50000 12500 5
65535 16384 4
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish