Decoding Tachometer Signals Using CompactRIO and LabVIEW FPGA
Overview
Tachometers are widely used in industrial applications to measure the angular speed of rotating machinery. In most industrial settings, a simple quadratue encoder is not feasible to integrate into a heavy industrial application – a tachometer is a very good alternative. Typical sensors that are used are proximity, magnetic or inductive sensors. These sensors are relatively inexpensive and rugged and can be easily mounted and used as a part of a tachometer system, to get the rpm of any rotating object. The sensors output a voltage whose frequency will increase proportionally with speed.
A good example where a tachometer can be used is to determine the speed of the rollers in large rolling mills. In this type of application the rpm of each motor is measured and compared to set points. A servo system will increase or decrease the motor speed to keep the rollers at the correct rpm.
Tachometers are also used in wind mills, where they are used to monitor the speed of the fans. This enables engineers to perform preventive maintenance on very expensive gear boxes by continuous monitoring of rpms of the rotating machinery. In most of these industrial applications, mounting of either a quadrature encoder or an optical sensor becomes impossible due to the size of the machinery involved.
Table of Contents
Tachometer Sensors and Signals
Most common tachometer sensors, output an AC voltage whose frequency is directly proportional to the speed of the rotating machinery. The output signal as illustrated in figure 1 is a distorted AC waveform, with each peak voltage representing the teeth of the rotating shaft.
The rpm of the rotating object can be calculated using the formula
Because of the uniqueness of the output signal from the sensor, custom signal conditioning and expensive hardware becomes a necessity to perform analysis and decode the signal at high speeds.
NI CompactRIO can be used to directly connect to an industrial tachometer sensor to measure the angular speed of rotating machinery, thus eliminating expensive custom signal conditioning hardware.

CompactRIO is a low cost, high performance system which performs the functions of both the custom signal conditioning hardware along with the data acquisition, thereby saving both money and time.
CompactRIO Analog Input Module for Tachometer Measurement
| I/O Module | Channels | Resolution (bits) | Sampling Rate (S/s) | Simultaneous Sampling | Signal Input Range | Isolation |
| cRIO-9221 | 8 SE | 12 | 800 k | No | ±60 V | Yes |
| cRIO-9215 | 4 DIFF | 16 | 100 k per channel | Yes | ±10 V | No |
| cRIO-9201 | 8 SE | 12 | 500 k | No | ±10 V | Yes |
The Operating Instructions and detailed specifications can be obtained from ‘CompactRIO Operating Instructions Manual’ of each module. For a step by step procedure of setting up the hardware, refer to ‘Getting Results with CompactRIO and LabVIEW’ linked below.
Application Development
The application will be divided into two segments – LabVIEW FPGA Development and LabVIEW Real-Time Development. The acquisition of the waveform and the calculation of time interval between successive rising edges are done on the FPGA. The Real-Time host will then take the time interval and converts to an RPM value.
LabVIEW FPGA Application Development
Acquire the Tach Sensor Signals
Change the LabVIEW execution target to your FPGA device. This will launch the embedded Project Manager. Start a new project and configure the CompactRIO hardware. Now on the block diagram of a new VI place the Analog Input VI from the FPGA Device I/O palette. Double click the Analog Input VI to configure the channel to acquire from the sensor.
The cRIO-9215 module was used in this example, but any high speed CompactRIO analog input module could be used.
Calculate Time Between Tachometer Pulses
Depending on whether the sensor used has a notch or teeth, we would look for the falling or the rising edge respectively. Depending on specifications of the sensor used, a suitable threshold voltage is decided. When the voltage goes above this threshold voltage, the timer is started. A Hysteresis is also incorporated to make sure that the timer is not triggered by the threshold crossings of the signal due to noise as against a true threshold crossing. Figure 6 clearly shows how incorporating threshold would make the system more robust.

Fig 5: Block Diagram of the top level FPGA VI: Tach RPM_FPGA.vi

Fig 6: Rising Edge interpretation by the FPGA Code
There are two states to start with – Check Threshold and Check Hysteresis. A 32 bit timer is used to get the time between two rising edges – defined as crossing the specified threshold voltage. As soon as a rising edge ‘event’ occurs, the value of the 32 bit timer is loaded into the shift register.
Initially, the code starts in ‘Check Threshold’ state where the analog input signal is constantly checked to see if it has crossed the threshold. Once it has crossed the specified threshold, an event is said to have occurred storing the value of the timer in a shift register at that instant. Following this step, the code goes to ‘Check Hysteresis’ state where we switch the boolean value of the event to false and start to check whether the signal has fallen below the hysteresis value specified. Once we have ascertained that the input signal has dropped below the hysteresis value, we again start looking for threshold crossing. This is done to switch the value of the event back to true which would get the value of the timer at that instant. The previous value of timer stored is now subtracted

Fig 8: Block Diagram of Check Hysteresis_FPGA.vi showing ‘Check Threshold’ State

Fig 9: Block Diagram of Check Hysteresis_FPGA.vi showing ‘Check Hysteresis’ State
with the present value to get time between two rising edges. The whole process is repeated to get continuous reading of the rpm of the rotating object in question.
LabVIEW Real-Time Development
The LabVIEW Real-Time VI runs on the controller and communicates with the FPGA VI. The calculations to convert the ‘Tach Period’ in usec/pulse to RPM are also done by the Real-Time VI.

[+] Enlarge Image
Fig10: Block Diagram of the LabVIEW Real-Time VI – Tach RPM_RT Host.vi – showing RT-FPGA communication
Calculate the rpm
The time output from the FPGA code is in microseconds and hence is converted to seconds and an inverse is taken to get the frequency of rising edges. The result is then divided by the number of teeth present in the sensor, to get the number of rotations that the object has made and this result is multiplied by 60 to get the rotations per minute which is our end result.
The LabVIEW FPGA module and CompactRIO can be used to easily create custom hardware, replacing expensive hardware that would have been required. CompactRIO is extremely flexible because you can at any time modify the code to fit your changing needs without buying additional hardware. Another major advantage of CompactRIO is that it can be used for control as well as acquisition. You could easily take this tachometer analysis code and integrate it with digital control in CompactRIO to perform high-speed industrial machine monitoring and control in a single CompactRIO embedded system.
CompactRIO Example Code
See Also:
Example Program: Decoding Tachometer Signals Using CompactRIO and LabVIEW FPGA
Related Links:
Getting Results with CompactRIO and LabVIEW
CompactRIO cRIO-9201/9221 Operating Instructions
CompactRIO cRIO-9215 Operating Instructions
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).




