es journal

Upload: kunaldoshi

Post on 18-Jan-2016

213 views

Category:

Documents


0 download

DESCRIPTION

Msc ES Journal

TRANSCRIPT

Sr NoTitleDateSign

1BLINKING LED

2INTERFACING ANALOG-TO-DIGITAL CONVERTERS

3THE STEPPER MOTOR INTERFACE

4INTERFACING LCDs

5SERIAL DATA COMMUNICATION

6TRAFFIC LIGHT SIMULATOR

7ELEVATOR SIMULATOR

INTERFACING ANALOG-TO-DIGITAL CONVERTERSAnalog-to-digital Converters accept analog inputs such as light, temperature etc. and convert them to a digital form. The ADC0808/0809 used here uses successive approximation as a conversion techniqueand has 8 input channels from where it can access 8 analog signals.The timing Diagram shown below illustratesthe conversion sequence as follows:1> Place analog input on any desired channel.2> Place address of the selected input channel on address lines ADD A, ADD B &ADD C.3> Latch the input address using ALE (Address Latch Enable) singal.4> Apply START pulse, commanding the ADCto start conversion.5> Wait for the EOC (End of Converstion) signal to become Low and then High informing that the conversion from analog to digital is complete.6> Enable the Output by making OE line High.7> Read in the digital data from ADCs output lines.In the circuit presented here, we are taking voltage as an analog input from a pot of 10K ohms. Weare using port P1 for reading in the converted digital data and port P3 for control lines. We have chosenIN2 as an input channel using statements (CLR ADD_A, SETB ADD_B and CLR ADD_C). A preset isused to set the Vref+ to a desired value. If we set the Vref+ to 2.56 V then we get a convinient step size of10 mV. We vary the analog input voltage to the ADC by rotating the pot. Since the output of ADC isconnected to port P1, we can see the digital outptu on bi-color LEDs connected to P1. The clock for ADCis derived by dividing frequency of XTAL2 pin of the crystal by IC 4040, the Binary Counter. We aretaking only one sample at a time so that observation can be made easily. Hence after every sample, wechange the analog input voltage by rotating the pot, making sure that the input voltage does not exceed2.56V; because this is an 8-bit ADC and the maximum digital output can expect is 255. Use Multimeterto measure this voltage (There is an orange coloured socket provided on the ADC interface for thispurpose). Then press RESET buttons so that program reexecutes. The convereted digital output can thenbe observed on bi-color LEDs of port P1. To convert the digital value observed on the LEDs, useWindows calculator in Scientific mode.In calculator -> View ->Scientific. Select Bin, then feed 1s and 0s displayed on P1 starting fromMSB. Then click Dec to convert the result to decimal. Compare the input voltage with the digital outputvoltage. They should be almost equal. For example, if the input analog voltage is 1.9V (=1900 mV), thenthe digital output will be approximately 190 (=1900/10). For next sample, vary the pot and press RESETbutton.

INTERFACING PROGRAM FOR ANALOG-TO-DIGITAL CONVERTERS

#include #include #define IN_PORT P1 //#define ON 1#define OFF 0sbit ADDR_A = P3^3; //sbit ADDR_B = P3^1; //sbit ADDR_C = P3^0; //sbit ALE = P3^4;sbit OE = P3^5;sbit START = P3^6;sbit EOC = P3^7;unsigned char nop;void main( void ){IN_PORT = 0xff; // make as inputEOC = 1;ALE = 0;START = 0;OE = 0;//// while(1) // infinite loop// {ADDR_C = 0;ADDR_B = 1;ADDR_A = 0;nop++; ALE = 1;nop++; START = 1;nop++; ALE = 0;START = 0;while(EOC) {_nop_();}while(!EOC) {_nop_();}OE = 1;for (;;);// } //end of while} // end of main

THE STEPPER MOTOR INTERFACE

It is often desirable in an application to accurately position a load or device. Conventional DC orAC motors are ill-suited in such cases because it is difficult to determine the exact position of the load,motor speed, or how much total movement has been produced; unless external positioning sensors,encoders and controlling devices are used. In such applications, using stepper motor is a better option.Stepper motor is an electromechanical device which converts electrical pulses into discrete mechanicalmovements.

Features of Stepper Motor:1. Angle of rotation is proportional to the number of input pulses.2. Speed is proportional to the frequency of input pulses.3. Bi-directional Operation.4. Open-loop system. No position feedback is required.5. Non-cumulative positioning error.6. Excellent low speed and high torque characteristics. No need for gear reduction.7. Holding torque when energized.8. Absence of brushes for longer trouble free life.

Disadvantages of Stepper Motor:1. Resonance can occur if not systematically controlled.2. Canonotbe used for applications demanding extremly high speed.3. If torque is exceeded beyoun limit, all knowledge of position is lost.4. Produces much less torque as compared to that produced by DC/AC motor of comparable size.5. Expensive.

In the scheme presented here, only lower order 4 lines of port P1 are used in the interface. A number00110011 is placed on port P1 and rotated right when motor is to be rotated in clockwise directionand rotated left when motor is to rotated in anticlockwise direction. A delay is necessary betweensteps.If we use a stepper motor with step angle of 1.8 degrees, then 200 steps will cause a one completerotation (1.8 X 200 = 360).

THE INTERFACING PROGRAM

#include sbit SW = P2^7;voidMSDelay(unsigned int value);void main()// Start of main() function{P1 = 0x00;SW = 1; // Initialize Port 1 as Output Portwhile(1) // Infinite Loop{if (SW == 0){P1 = 0X66;MSDelay(50);P1 = 0XCC;MSDelay(50);P1 = 0X99;MSDelay(50);P1 = 0X33;MSDelay(50);}else{P1 = 0X66;MSDelay(50);P1 = 0X33;MSDelay(50);P1 = 0X99;MSDelay(50);P1 = 0XCC;MSDelay(50);}}}voidMSDelay(unsigned int value){unsignedint x, y;for (x=0;x