8051/AT89S52 based RPM meter using Mouse Encoder

Problem Definition:
The task at hand was to create an RPM meter using AT89S52 microcontroller that displays the generated RPM count.

Life Cycle of a Microcontroller Project:
It was important for us to have a general idea of the steps that are followed to realize a project, from the very beginning of an idea to the very end of project completion.

The figure below shows the steps that were followed by us after we settled on the choice of our project in the 'brain storming' part. It was imperative for us to imagine how it could be implemented from the hardware point of view, before we passed on to the programming phase, because programming is much more flexible than the hardware design. In other words, we started by designing the hardware, then worked on the programming while taking in consideration the eventual constraints imposed by the hardware design.

The hardware design includes all the aspects of the electronic connections between Microcontroller and other devices, like the compatibility of the voltage levels, or the required number of pins, etc.

After completion of the hardware, we diverted our attention towards the programming phase. When the first program was developed, the HEX file was generated by the compiler, and was sent to the 'program memory' of the microcontroller. Eventual errors were corrected and performance was enhanced gradually, taking in account the famous rule which states that

Any project never works the first time; at least it does not work as you expect it to do.”

Hardware Design:

Click to enlarge.


Module 1 – Devices:
This section contains the devices that are connected externally. In our case there is only a small DC motor of rating 5V. It is basically used to drive the mouse encoder that generates the revolutions.

Module 2 – Input:
This section implements a small ball mouse rotary encoder that is being driven by the DC motor. The amount of revolutions depends upon how fast the DC motor spins the encoder. These analog revolutions result in a difference in voltage at the input of the Comparator IC LM324 that basically compares and converts the voltage difference into pulses of 0’s and 1’s. This data is fed into the microcontroller 89S52 that calculates the RPM Count.

Module 3 – Output:
The generated RPM needs to be displayed on and output device. But before that it is fed to the Buffer IC 74LS245 by the microcontroller that boosts the current. It is further connected to the PC screen via parallel port interfacing.

Each of the above component will be discussed in different sections of the blog. Lets take a quick overview of Software execution of the above project.

Component Discussion
The RPM meter project consists of the following main components. Click to see the details please.
SOFTWARE DESIGN:
This section deals with the software aspects of out project. The coding required in this project was a mixture of C languae and Assembly language. For that we used the Turbo C and KEIL uVision Softwares.

From the C program to the machine language:
The C source code is very high level language, meaning that it is far from being at the base level of the machine language that can be executed by a processor. This machine language is basically just zero's and one's and is written in Hexadecimal format, that why they are called HEX files.There are several types of HEX files.

Diagram below shows that to convert a C program to machine language, it takes several steps depending on the tool that is used, however, the main idea is to produce a HEX file at the end. This HEX file will be then transferred to the hardware to write every byte of data at the appropriate place in the EEPROM of the 89S52.

Program Flow Chart 
Assembly Code for RMP meter using Mouse Encoder

ORG 0000H



LJMP MAIN


ORG 0030h

MAIN:



MOV TMOD, #15h


MOV P1,#00H


UP:


SETB P1.0


MOV R0,#01FH


OUTER_DE: MOV R1,#0FFH


INNER_DE: DJNZ R1,INNER_DE


DJNZ R0,OUTER_DE

MOV TH1,#00H


MOV TL1,#00H


MOV R3,#02H
 MOV TH0,#0FFH


mov TL0,#0FFh


mov P2,#00h


CLR P1.0


SETB TR0
 NEXT: MOV A,TL0


CJNE A,#00H, NEXT

SETB TR1

WAIT: JNB TF1,WAIT


CLR TF1


DJNZ R3,WAIT


CLR TR1


CLR TR0


CLR TF1

MOV A,TL0


MOV P2,A


LJMP up

END

C code for parallal port Interfacing

#include



#include


#include

#define data_in 0x378


#define status 0x37A

#define x 25


void main()


{ clrscr();


unsigned char data;


float rev=0.0;


float rpm=0.0;

outportb(status,0x20);

while(1)


{

gotoxy(x,15);


printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");


gotoxy(x,16);


printf("º ROTATION SPEED METER º");


gotoxy(x,17);


printf("ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹");


gotoxy(x,18);


printf("º º");


gotoxy(x,19);


printf("º %7d RPM º",int(rpm));


gotoxy(x,20);


printf("º º");

gotoxy(x,21);


printf("º º");


gotoxy(x,22);


printf("º %7d rad/s º",int((2*(22/7)*rpm)/60));


gotoxy(x,23);


printf("º º");


gotoxy(x,24);


printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");

data= inportb(data_in);


//data=0x01;


rev=(data/45.0);


rpm=(rev*457.77);




}
}

Certificate of ownership:


This is to certify that this project report “ RPM Meter Using Mouse Encoder ”


is the bonafide work of “ Mr.Ahmed Fawad, Mr. M.Asif, Mr. Azeez Ahmed and Mr. M. Zohaib Arif ” of class “ V – OPS/EL – B ” who carried out the project work under my supervision.


Prof. Nazeer Alam
H.O.D ELECTRONICS

Prof. Ikram Rasool Qureshi
SUPERVISOR

16:02 | Posted in , , | Read More »

MATLAB Simulink Model of Music Equalizer using DSK 6713

What is Music Equalizer ?
Music equalizers are devices or software used for amplifying and attenuating predetermined frequency bands. Every music system, including some portable systems as well as professional stereo systems typically has an equalizer to equalize the audio data. Older system has analog equalizer which was tuned manually, but now a day’s digital music equalizer is very common. The advantage of digital equalizer is that we can store the preset gains of frequencies as desired and can be used in future by just pressing button. An audio equalizer typically will adjust the energy levels of the audio data in one or more different frequency bands in order to change the characteristics of the audio data. The equalizer may generate equalized audio data that may then be converted into analog data so that sound may be generated by a sound generating device, such as a speaker or headphone. The center frequencies for the various filters are distributed across an overall bandwidth having an upper and lower boundary. In general, the analog equalizer includes a combination of a simulated inductor and a bridging amplifier which are constructed of operational amplifiers whereas digital equalizer are made with software and processed by digital signal processor. The same has been accomplished on DSK 6713

Block Diagram of Music Equalizer



Audio Input: The Audio input can be taken from any music player. Mobile phone music player is used as the music input which is feed to DSK 6713 kit through line in connector. Mono channel is used for simplicity.    
                                                                                                                           
Analog to Digital Conversion: DSK 6713 has the built in A/D converter which converts the analog input signal into digital signal so that digital processing can be done on the input. The sampling frequency is set to 48kHz. Word length is 16-bit, scaling is normalized and samples per frame are 64. Refer to the diagram below :-                                                     
               

Low and Band Pass Filters for Music Equalizer: Filters are used for separating the signal   of different frequencies. One low pass and six band pass filters are designed in MATLAB’s tool, FDATOOL, for filtering seven different bands of frequencies. IIR filters are faster than the FIR filter and give smoother amplitude response as compare to FIR filters. So, IIR filters are used. The key to filters the music correctly is that filter’s cut off frequencies must overlap. The cut off frequencies of all filters are given in table below.       
Preset Band Gains for Equalizer:  Music effects are produced simply by changing the gains of separated signals of different frequencies. For example, the bass effect is achieved by increasing the gain of lower frequency signals. Preset Band Gain block consists of the 4 set of preset gain which produces Flat, Rock, Bass and Opera Effects. Gain setting for Bass effect is shown below.



Preset Selector: Dip switches on the DSK-6713 are used for preset selection. Zero indexing is used so that normal (flat) preset is selected when no button is pressed. Led on the Kit indicates the preset selection. Parameters of DIP switches are set as shown in figure.


Signal Adder: Signal adder combines all separated signals of different frequencies after completing the processing. Simple adder is used for this purpose.
Digital to Analog Conversion: After the combining, the signal is converted in analog. This is done by DSK 6713 built in D/A converter. The sampling frequency of the A/D and D/A should be same for better output.

SIMULINK MODEL FOR MUSIC EQUALIZER ON DSK 6713

You can download the simulink model for the above equalizer from the link given below, however the snapshot of our working simulink model is given below :

Download Simulink Model for Music Equalizer here. In case of any problem. feel free to contact at homeofgadgets@yahoo.com

Important Note: This term project of Digital Signal Processing is supervised by Assistant Professor S K Hasnain and is the property of the following students of Pakistan Navy Engineering College (NUST).
  1. Ahmed Fawad
  2. Waseem Ahmed
  3. Aziz Ahmed
  4. Arslan Amin Dhoraji Wala
For queries please contact at  homeofgadgets@yahoo.com 

10:34 | Posted in , , , , | Read More »

Labels

Recently Commented

Recently Added