# Tachometer

5,458

14

9

Posted

## Introduction: Tachometer

My project here is a Tachometer controlled by MSP430 microcontroller , I am documenting my process because while designing this tachometer I appreciated every resource on the interface of msp430 and LCD 16x2 I could find.

## Step 1: Description

A tachometer is

basically a revolution counter, then this is an instrument measuring the rotation speed of a shaft or disk(the device usually displays the revolutions per minute (RPM)), as we will see in a DC motor.

If we want to display the speed where, we could use a diferent optoelectronic devices, in my case I choose a LCD (liquid-crystal display), and for the measuring I take the MSP430G2553, let's see

## Step 2: Components

Fig 1.2

1-LCD lcm161602aA

2-MSP430G2553

3-resistor (30k,20k,220,150)ohm and potentiometer 1.5k ohm

5-DC motor

6- Lithium batteries 3.7 V

7-Wires

Software : Code composer studio V5

## Step 3: ​Circuits

There are three important circuits for our tachometer there are: IR Transmitter and receiver, motor dc, and msp430 lcd interface, (please see first the sensor IR)

DC Motor

Consist in 3-5V dc motor with a rectangular acrylic piece (black acrylic) on his shaft, this piece is not symmetric, I mean it has just one long side. How big is the piece? see Fig. 1.4 ,dont worry about the two motors, that we really need is how to put the acrylic piece on the shaft(rotor), The piece have to block the light between the emitter and receiver.

Fig. 1.4

IR Sensor (IR Transmitter and receiver)

The emitter always going to send a IR signal to the receiver that in normal state is receiving almost all IR light from emitter(As we see on Fig. 1.5),except when the acrylic piece is right in the middle, when this happen the signal in receiver will change.

Fig.1.5

Emitter is connected to vcc and continue to gnd through a 150 ohm resistor(Fig 1.3), the receiver is connected to vcc and continue to ground through a pull down resistor (20k ohm) (Fig 1.3), when is not obstacle between the emitter and the receiver the signal on P1.1 is the voltage vcc minus receiver voltage (usually 0.7 volts), then P1.1 signal will be a high, a ‘1’logic ,when is an obstacle P1.1 signal is grounded, is ‘0’ logic.

Then we need to read the zeros, it means we will count the zeros, because the signal is zero when the acrylic piece pass between the receiver and emitte; Fig. 1.6 show the output of the IR sensor when the motor is working

Fig. 1.6 a. P1.1 signal b.DC motor working,notice that the acrylic peace is passing through the sensor.

Here is when the microcontroller start a counter that counts the times that P1.1 is zero, it is simple like a polling the pin and plus a unit to some variable, the program actually use a interrupt of falling edge to star the count in an interval of 0.25 second.the next part of code show the variable “count” increment every time that is a falling edge, “count” t is a unsigned int,and is clear when pass 0.25 seconds, after this the count is multiplied for 240 for obtain the speed of on minute, (0.25s*240=60s) then(“count”*240=rpm ), it could be seen in the file.

// port interrupt routine

#pragma vector = PORT1_VECTOR

__interrupt void PUERTO_P1 (void) {

count =count+1;

P1IFG=0X00; //clear the interrupt flag

}

Code example.

## Step 4: Msp430 Lcd Interface

Msp430 Lcd Interface

The Fig 1.3 show the conextions, just in casetha you don’t unsertand here is the pin assignation

MSP430 LCD

P2.0 RS

P2.1 EN

P2.2 XX

P2.3 XX

P2.4 D4

P2.5 D5

P2.6 D6

P2.7 D7

Sorry for my redaction and a spanish-speaking and also sorry for video,but a friend remove the working video.As you will see the rpm counter stops because the motor is moving far away from sensor.

You could find the other of pins here http://www.sigmaelectronica.net/manuals/LCM1602A....

and the code here https://app.box.com/s/b3ua61b8yxickd0mwcwsw36lmurmrc5l

## Recommendations

• ### 3D CAM and CNC Class

333 Enrolled

• ### Science of Cooking

We have a be nice policy.

## Questions

can i get code for tachometer...........

Sorry about that,here is, look https://app.box.com/s/b3ua61b8yxickd0mwcwsw36lmurmrc5l

The url is not working. Can you update it? Thx.

Hey! Nice work. Could you tell me the maximum value of rpm that can be measured on this tachometer with a fair level of accuracy?

As you see in my program (see link) has two ISR one by digital port and the other by time, the firts recieve the signal from the IR sensor, and plus one to the "rpm" variable, the program do this in intervals of time sets by the timer(the second isr), then if you set the timer for high time you have a high level of a accuracy, in my case the time was a second, after this a funtion multiplies the number of count by 60. The other way is mesauring the PWM of the IR signal, it is better, works like a digital frequency meter, sorry for answers to late, and by my english, I'm a spanish speaker.Have some extra question?, just ask me.

Interesting! Thanks for sharing!

You're welcome!