Sie sind auf Seite 1von 61

AUTOMATIC CAR PARKING SYSTEM USING 89C51 MICROCONTROLLER

The Project Automatic Car Parking System using 89C51 Microcontroller is an interesting project which uses 89C51 microcontroller as its brain. The project is designed for car parking.

The aim of this project is to atomize the car park for allowing the cars into the park. LCD is provided to display the information about the total number of cars that can be parked and the place free for parking. Two IR TX RX pairs are used in this project to identify the entry or exit of the cars into/out of park. These two IR TX RX pairs are arranged either side of the gate. The TX and RX are arranged face to face across the road so that the RX should get IR signal continuously.

Whenever the mains are switched on, the LCD displays the message parking space for 10 vehicles. The number indicates the maximum capacity of park in this project. Whenever a car comes in front of the gate, the IR signal gets disturbed and the microcontroller will open the gate by rotating the stepper motor. The gate will be closed only after the car leaves the second IR pair since the microcontroller should know whether the car left the gate or not. Now the microcontroller decrements the value of the count and displays it on LCD. In this way, the microcontroller decrements the count whenever the car leaves the park and displays it on LCD.

If the count reaches 0, i.e. if the park is completely filled, the microcontroller will display NO SPACE FOR PARKING on LCD. And now if any vehicle tries to enter the park, the gate will not be opened since there is no space. If any vehicle leaves the park, the controller will increment the count and allows the other vehicles for parking. This project uses regulated 5V, 500mA power supply. Unregulated 12V DC is used for relay. 7805 three terminal voltage regulator is used for voltage regulation. Bridge type full wave rectifier is used to rectify the ac out put of secondary of 230/12V step down transformer.

ENTRY SENSOR IR

EXIT SENSOR IR

89C51
CRYSTAL

ULN 2003 RESET CIRCUIT

STEPPER MOTOR 1

STEPPER MOTOR 1

Step down T/F

Bridge Rectifier

Filter Circuit

Regulator Power supply to all sections

Figure:1.1 Block Diagram: Automatic Car Parking System using 89C51 Microcontroller

DESCRIPTION

POWER SUPPLY: The input to the circuit is applied from the regulated power supply. The a.c. input i.e., 230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier. The output obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to remove any a.c components present even after rectification. Now, this voltage is given to a voltage regulator to obtain a pure constant dc voltage.

230V AC 50Hz

D.C Output

Step down transformer

Bridge Rectifier Filter Regulator

Figure 2.1: Power supply Transformer: Usually, DC voltages are required to operate various electronic equipment and these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus

the a.c input available at the mains supply i.e., 230V is to be brought down to the required voltage level. This is done by a transformer. Thus, a step down transformer is employed to decrease the voltage to a required level. Rectifier: The output from the transformer is fed to the rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full wave rectification. Filter: Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage. Voltage regulator: As the name itself implies, it regulates the input applied to it. A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. In this project, power supply of 5V and 12V are required. In order to obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first number 78 represents positive supply and the numbers 05, 12 represent the required output voltage levels.

MICROCONTROLLERS: Microprocessors and microcontrollers are widely used in embedded systems products. Microcontroller is a programmable device. A microcontroller has a CPU in addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a single chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in microcontrollers makes them ideal for many applications in which cost and space are critical. The Intel 8051 is a Harvard architecture, single chip microcontroller (C) which was developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s and early 1990s, but today it has largely been superseded by a vast range of enhanced devices with 8051-compatible processor cores that are manufactured by more than 20 independent manufacturers including Atmel, Infineon Technologies and Maxim Integrated Products. 8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU. 8051 is available in different memory types such as UV-EPROM, Flash and NVRAM. The microcontroller used in this project is AT89C51. Atmel Corporation introduced this 89C51 microcontroller. This microcontroller belongs to 8051 family. This microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM, two timers, one serial port and four ports (each 8-bits wide) all on a single chip. AT89C51 is Flash type 8051. The present project is implemented on Keil Uvision. In order to program the device, Proload tool has been used to burn the program onto the microcontroller. The features, pin description of the microcontroller and the software tools used are discussed in the following sections.

FEATURES OF AT89C51: 4K Bytes of Re-programmable Flash Memory. RAM is 128 bytes. 2.7V to 6V Operating Range. Fully Static Operation: 0 Hz to 24 MHz. Two-level Program Memory Lock. 128 x 8-bit Internal RAM. 32 Programmable I/O Lines. Two 16-bit Timer/Counters. Six Interrupt Sources. Programmable Serial UART Channel. Low-power Idle and Power-down Modes. Description: The AT89C51 is a low-voltage, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer, which provides a highly flexible and cost-effective solution to many embedded control applications. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode

stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The power-down mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.

Figure2.2: Pin diagram

PIN DESCRIPTION: Vcc Pin 40 provides supply voltage to the chip. The voltage source is +5V.

GND Pin 20 is the ground.

XTAL1 and XTAL2 The 8051 has an on-chip oscillator but requires an external clock to run it. Usually, a quartz crystal oscillator is connected to inputs XTAL1 (pin19) and XTAL2 (pin18). There are various speeds of 8051 family. Speed refers to the maximum oscillator frequency connected to XTAL. When the 8051 is connected to a crystal oscillator and is powered up, the frequency can be observed on the XTAL2 pin using the oscilloscope. RESET Pin9 is the reset pin. It is an input and is active high. Upon applying a high pulse to this pin, the microcontroller will reset and terminate all the activities. This is often referred to as a power-on reset. EA (External access) Pin 31 is EA. It is an active low signal. It is an input pin and must be connected to either Vcc or GND but it cannot be left unconnected. The 8051 family members all come with on-chip ROM to store programs. In such cases, the EA pin is connected to Vcc. If the code is stored on an external ROM, the EA pin must be connected to GND to indicate that the code is stored externally. PSEN (Program store enable) This is an output pin.

ALE (Address latch enable) This is an output pin and is active high.

Ports 0, 1, 2 and 3 The four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports upon RESET are configured as input, since P0-P3 have value FFH on them. Port 0(P0) Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data. ALE indicates if P0 has address or data. When ALE=0, it provides data D0-D7, but when ALE=1, it has address A0-A7. Therefore, ALE is used for demultiplexing address and data with the help of an internal latch. When there is no external memory connection, the pins of P0 must be connected to a 10K-ohm pull-up resistor. This is due to the fact that P0 is an open drain. With external pull-up resistors connected to P0, it can be used as a simple I/O, just like P1 and P2. But the ports P1, P2 and P3 do not need any pull-up resistors since they already have pull-up resistors internally. Upon reset, ports P1, P2 and P3 are configured as input ports. Port 1 and Port 2 With no external memory connection, both P1 and P2 are used as simple I/O. With external memory connections, port 2 must be used along with P0 to provide the 16-bit address for the external memory. Port 2 is designated as A8-A15 indicating its dual function. While P0 provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the address. Port 3

Port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as input or output. P3 does not need any pull-up resistors, the same as port 1 and port 2. Port 3 has an additional function of providing some extremely important signals such as interrupts.

Table: Port 3 Alternate Functions Machine cycle for the 8051 The CPU takes a certain number of clock cycles to execute an instruction. In the 8051 family, these clock cycles are referred to as machine cycles. The length of the machine cycle depends on the frequency of the crystal oscillator. The crystal oscillator, along with on-chip circuitry, provides the clock source for the 8051 CPU. The frequency can vary from 4 MHz to 30 MHz, depending upon the chip rating and manufacturer. But the exact frequency of 11.0592 MHz crystal oscillator is used to make the 8051 based system compatible with the serial port of the IBM PC. In the original version of 8051, one machine cycle lasts 12 oscillator periods. Therefore, to calculate the machine cycle for the 8051, the calculation is made as 1/12 of the crystal frequency and its inverse is taken.

SOFTWARES USED: KEIL COMPILER: Keil compiler is a software used where the machine language code is written and compiled. After compilation, the machine source code is converted into hex code which is to be dumped into the microcontroller for further processing. Keil compiler also supports C language code.

PROLOAD: Proload is a software which accepts only hex files. Once the machine code is converted into hex code, that hex code has to be dumped into the microcontroller and this is done by the Proload. Proload is a programmer which itself contains a microcontroller in it other than the one which is to be programmed. This microcontroller has a program in it written in such a way that it accepts the hex file from the keil compiler and dumps this hex file into the microcontroller which is to be programmed. As the proload programmer kit requires power supply to be operated, this power supply is given from the power supply circuit designed above. It should be noted that this programmer kit contains a power supply section in the board itself but in order to switch on that power supply, a source is required. Thus this is accomplished from the power supply board with an output of 12volts.

IR SECTION: WHAT IS INFRARED? Infrared is a energy radiation with a frequency below our eyes sensitivity, so we cannot seeit Even that we can not "see" sound frequencies, we know that it exist, we can listen them.

Even that we can not see or hear infrared, we can feel it at our skin temperature sensors. When you approach your hand to fire or warm element, you will "feel" the heat, but you can't see it. You can see the fire because it emits other types of radiation, visible to your eyes, but it also emits lots of infrared that you can only feel in your skin. INFRARED IN ELECTRONICS Infra-Red is interesting, because it is easily generated and doesn't suffer electromagnetic interference, so it is nicely used to communication and control, but it is not perfect, some other light emissions could contains infrared as well, and that can interfere in this communication. The sun is an example, since it emits a wide spectrum or radiation. The adventure of using lots of infra-red in TV/VCR remote controls and other applications, brought infra-red diodes (emitter and receivers) at very low cost at the market.

From now on you should think as infrared as just a "red" light. This light can means something to the receiver, the "on or off" radiation can transmit different meanings.Lots of things can generate infrared, anything that radiate heat do it, including out body, lamps, stove, oven, friction your hands together, even the hot water at the faucet. To allow a good communication using infra-red, and avoid those "fake" signals, it is imperative to use a "key" that can tell the receiver what is the real data transmitted and what is fake. As an analogy, looking eye naked to the night sky you can see hundreds of stars, but you can spot easily a far away airplane just by its flashing strobe light. That strobe light is the "key", the "coding" element that alerts us. Similar to the airplane at the night sky, our TV room may have hundreds of tinny IR sources, our body, the lamps around, even the hot cup of tea. A way to avoid all those other sources, is generating a key, like the flashing airplane. So, remote controls use to pulsate its infrared in a certain frequency. The IR receiver module at the TV, VCR or stereo "tunes" to this certain frequency and ignores all other IR received. The best frequency for the job is between 30 and 60kHz, the most used is around 36kHz IR GENERATION To generate a 36kHz pulsating infrared is quite easy, more difficult is to receive and identify this frequency. This is why some companies produce infrared receives, that contains the filters, decoding circuits and the output shaper, that delivers a square wave, meaning the existence or not of the 36kHz incoming pulsating infrared. It means that those 3 dollars small units, have an output pin that goes high (+5V) when there is a pulsating 36kHz infrared in front of it, and zero volts when there is not this radiation.

Figure :2.3 IR generation

A square wave of approximately 27uS (microseconds) injected at the base of a transistor, can drive an infrared LED to transmit this pulsating light wave. Upon its presence, the commercial receiver will switch its output to high level (+5V).If you can turn on and off this frequency at the transmitter, your receiver's output will indicate when the transmitter is on or off.

Those IR demodulators have inverted logic at its output, when a burst of IR is sensed it drives its output to low level, meaning logic level = 1. The TV, VCR, and Audio equipment manufacturers for long use infra-red at their remote controls. To avoid a Philips remote control to change channels in a Panasonic TV, they use different codification at the infrared, even that all of them use basically the same transmitted frequency, from 36 to 50kHz. So, all of them use a different combination of bits or how to code the transmitted data to avoid interference. RC-5 Various remote control systems are used in electronic equipment today. The RC5 control protocol is one of the most popular and is widely used to control numerous home appliances, entertainment systems and some industrial applications including utility consumption remote meter reading, contact-less apparatus control, telemetry data

transmission, and car security systems. Philips originally invented this protocol and virtually all Philips remotes use this protocol. Following is a description of the RC5. When the user pushes a button on the hand-held remote, the device is activated and sends modulated infrared light to transmit the command. The remote separates command data into packets. Each data packet consists of a 14-bit data word, which is repeated if the user continues to push the remote button. The data packet structure is as follows: 2 start bits, 1 control bit, 5 address bits, 6 command bits.

The start bits are always logic 1 and intended to calibrate the optical receiver automatic gain control loop. Next, is the control bit. This bit is inverted each time the user releases the remote button and is intended to differentiate situations when the user continues to hold the same button or presses it again. The next 5 bits are the address bits and select the destination device. A number of devices can use RC5 at the same time. To exclude possible interference, each must use a different address. The 6 command bits describe the actual command. As a result, a RC5 transmitter can send the 2048 unique commands. The transmitter shifts the data word, applies Manchester encoding and passes the created one-bit sequence to a control carrier frequency signal amplitude modulator. The amplitude modulated carrier signal is sent to the optical transmitter, which radiates the infrared light. In RC5 systems the carrier frequency has been set to 36 kHz. Figure below displays the RC5 protocol. The receiver performs the reverse function. The photo detector converts optical transmission into electric signals, filters it and executes amplitude demodulation. The receiver output bit stream can be used to decode the RC5 data word. This operation is done by the microprocessor typically, but complete hardware implementations are present on the market as well. Single-die optical receivers are being mass produced by a

number of companies such as Siemens, Temic, Sharp, Xiamen Hualian, Japanese Electric and others. Please note that the receiver output is inverted (log. 1 corresponds to illumination absence). IR RECEIVER Description The TSOP17.. series are miniaturized receivers for infrared remote control systems. PIN diode and preamplifier are assembled on lead frame, the epoxy package is designed as IR filter. The demodulated output signal can directly be decoded by a microprocessor. TSOP17.. is the standard IR remote control receiver series, supporting all major transmission codes. Features Photo detector and preamplifier in one package Internal filter for PCM frequency Improved shielding against electrical field disturbance TTL and CMOS compatibility Output active low Low power consumption High immunity against ambient light Continuous data transmission possible (up to 2400 bps) Suitable burst length .10 cycles/burst

figure :2.5 IR RECEIVER

figure :3.3 Suitable Data Format The circuit of the TSOP17 is designed in that way that unexpected output pulses due to noise or disturbance signals are avoided. A bandpassfilter, an integrator stage and an automatic gain control are used to suppress such disturbances. The distinguishing mark

between data signal and disturbance signal are carrier frequency, burst length and duty cycle. The data signal should fullfill the following condition: Carrier frequency should be close to center frequency of the bandpass (e.g. 38kHz). Burst length should be 10 cycles/burst or longer. After each burst which is between 10 cycles and 70 cycles a gap time of at least 14 cycles is necessary. For each burst which is longer than 1.8ms a corresponding gap time is necessary at some time in the data stream. This gap time should have at least same length as the burst. Up to 1400 short bursts per second can be received continuously. Some examples for suitable data format are: NEC Code, Toshiba Micom Format, Sharp Code, RC5 Code, RC6 Code, R2000 Code, Sony Format (SIRCS). When a disturbance signal is applied to the TSOP17.. it can still receive the data signal. However the sensitivity is reduced to that level that no unexpected pulses will occur. Some examples for such disturbance signals which are suppressed by the TSOP17 are: DC light (e.g. from tungsten bulb or sunlight) Continuous signal at 38 kHz or at any other frequency Signals from fluorescent lamps with electronic ballast (an example of the signal modulation is in the figure below).

figure :3.4

ULN2003 CURRENT DRIVER:

Fig: DIP 16 Package

The ULN2003 current driver is a high voltage, high current Darlington arrays each containing seven open collector Darlington pairs with common emitters. Each channel is rated at 500mA and can withstand peak currents of 600mA. Suppression diodes are included for inductive load driving and the inputs are pinned opposite the outputs to simplify board layout. These versatile devices are useful for driving a wide range of loads including solenoids, relays DC motors, LED displays filament lamps, thermal print heads and high power buffers. This chip is supplied in 16 pin plastic DIP packages with a copper lead frame to reduce thermal resistance.

Fig: Pin Connection This ULN2003 driver can drive seven relays at a time. The pins 8 and 9 provide ground and Vcc respectively. The working of ULN driver is as follows: It can accept seven inputs at a time and produces seven corresponding outputs. If the input to any one of the seven input pins is high, then the value at its corresponding output pin will be low, for example if the input at pin 6 is high, then the value at the corresponding output i.e., output at pin 11 will be low. Similarly if the input at a particular pin is low, then the corresponding output will be high.

One of the coil terminals of the relay will be connected to the output pin of the ULN driver. Thus in order to switch on the relay to operate any load, the output from the ULN driver (any one of the 7 outputs) should be low. Thus for the output to be low, the input applied at that corresponding input pin should be high. The input to the ULN driver is provided by the microcontroller. Thus the instruction required to operate the relay through the microcontroller is SETB PX.Y Where X is the port number (P0, P1, P2 and P3) And Y is the pin number of Port X. RELAY INTERFACING WITH THE MICROCONTROLLER:

AT 89C51 P1.0

1 2 3 4 5 6 7 8 Ground

U L N 2 0 0 3

16 15 14 13 12 11 10 9 Vcc LOAD

RELAY

Figure :4.4

STEPPER MOTOR:

Figure 5.1: Stepper motor

A stepper motor is a widely used device that translates electrical pulses into mechanical movement. The stepper motor is used for position control in applications such as disk drives, dot matrix printers and robotics. Stepper motors commonly have a permanent magnet rotor surrounded by a stator. The most common stepper motors have four stator windings that are paired with a center-tapped common. This type of stepper motor is commonly referred to as a fourphase or unipolar stepper motor. The center tap allows a change of current direction in each of the two coils when a winding is grounded, thereby resulting in a polarity change of the stator. The direction of the rotation is dictated by the stator poles. The stator poles are determined by the current sent through the wire coils. As the direction of the current is changed, the polarity is also changed causing the reverse motion of the rotor. It should be noted that while a conventional motor shaft runs freely, the stepper motor shaft moves in a fixed repeatable increment, which allows one to move it to a precise position. Thus, the stepper motor moves one step when the direction of current

flow in the field coil(s) changes, reversing the magnetic field of the stator poles. The difference between unipolar and bipolar motors lies in the may that this reversal is achieved.

Figure 5.2 : Stepper motor operation

Advantages: 1. The rotation angle of the motor is proportional to the input pulse. 2. The motor has full torque at standstill (if the windings are energized) 3. Precise positioning and repeatability of movement since good stepper motors have an accuracy of 3 5% of a step and this error is non cumulative from one step to the next. 4. Excellent response to starting/ stopping/reversing. 5. Very reliable since there are no contact brushes in the motor. Therefore the life of the motor is simply dependant on the life of the bearing. 6. The motors response to digital input pulses provides open-loop control, making the motor simpler and less costly to control.

7. It is possible to achieve very low speed synchronous rotation with a load that is directly coupled to the shaft. 8. A wide range of rotational speeds can be realized as the speed is proportional to the frequency of the input pulses. Disadvantages: 1. Resonances can occur if not properly controlled. 2. Not easy to operate at extremely high speeds. Open Loop Operation: One of the most significant advantages of a stepper motor is its ability to be accurately controlled in an open loop system. Open loop control means no feedback information about position is needed. This type of control eliminates the need for expensive sensing and feedback devices such as optical encoders.

Stepper Motor Types: There are three basic stepper motor types. They are : Variable-reluctance Permanent-magnet Hybrid Variable-reluctance (VR) This type of stepper motor has been around for a long time. It is probably the easiest to understand from a structural point of view. This type of motor consists of a soft iron multi-toothed rotor and a wound stator. When the stator windings are energized with DC current, the poles become magnetized. Rotation occurs when the rotor teeth are attracted to the energized stator poles.

Figure 5.3: Cross-section of a variable reluctance (VR) motor. Permanent Magnet (PM) The permanent magnet step motor is a low cost and low resolution type motor with typical step angles of 7.5 to 15. (48 24 steps/revolution) PM motors as the name implies have permanent magnets added to the motor structure. In this type of motor, the rotor does not have teeth . Instead the rotor is magnetized with alternating north and south poles situated in a straight line parallel to the rotor shaft. These magnetized rotor poles provide an increased magnetic flux intensity and because of this the PM motor exhibits improved torque characteristics when compared with the VR type.

PM stepper motor principle Figure : 5.4 Hybrid (HB)

Cross section of a hybrid stepper motor

The hybrid stepper motor is more expensive than the PM stepper motor but provides better performance with respect to step resolution, torque and speed. Typical step angles for the HB stepper motor range from 3.6 to 0.9 (100 400 steps per revolution). The hybrid stepper motor combines the best features of both the PM and VR type stepper motors. The rotor is multi-toothed like the VR motor and contains an axially magnetized concentric magnet around its shaft. The teeth on the rotor provide an even better path which helps guide the magnetic flux to preferred locations in the air gap. This further increases the detent, holding and dynamic torque characteristics of the motor when compared with both the VR and PM types. This motor type has some advantages such as very low inertia and a optimized magnetic flow path with no coupling between the two stator windings. These qualities are essential in some applications.

When to Use a Stepper Motor: A stepper motor can be a good choice whenever controlled movement is required. They can be used to advantage in applications where you need to control rotation angle, speed, position and synchronism. Because of the inherent advantages listed previously, stepper motors have found their place in many different applications. The Rotating Magnetic Field: When a phase winding of a stepper motor is energized with current a magnetic flux is developed in the stator. The direction of this flux is determined by the Right Hand Rule which states:

If the coil is grasped in the right hand with the fingers pointing in the direction of the current in the winding (the thumb is extended at a 90 angle to the fingers), then the thumb will point in the direction of the magnetic field. The below figure shows the magnetic flux path developed when phase B is energized with winding current in the direction shown. The rotor then aligns itself so that the flux opposition is minimized. In this case the motor would rotate clockwise so that its south pole aligns with the north pole of the stator B at position 2 and its north pole aligns with the south pole of stator B at position 6. To get the motor to rotate we can now see that we must provide a sequence of energizing the stator windings in such a fashion that provides a rotating magnetic flux field which the rotor follows due to magnetic attraction.

Figure :5.5: Magnetic flux path through a two-pole stepper motor with a lag between the rotor and stator. Torque Generation: The torque produced by a stepper motor depends on several factors. The step rate The drive current in the windings The drive design or type

In a stepper motor, a torque will be developed when the magnetic fluxes of the rotor and stator are displaced from each other. The stator is made up of a high permeability magnetic material. The presence of this high permeability material causes the magnetic flux to be confined for the most part to the paths defined by the stator structure. This serves to concentrate the flux at the stator poles. The torque output produced by the motor is proportional to the intensity of the magnetic flux generated when the winding is energized.

The basic relationship which defines the intensity of the magnetic flux is defined by: H = (N * i) / l where N = The number of winding turns i = current H = Magnetic field intensity l = Magnetic flux path length This relationship shows that the magnetic flux intensity and consequently the torque is proportional to the number of winding turns and the current and inversely proportional to the length of the magnetic flux path. Thus from this basic relationship it is concluded that the same frame size stepper motor could have very different torque output capabilities simply by changing the winding parameters. Step Angle Accuracy:

The main reason that the stepper motor gained such popularity as a positioning device is for its accuracy and repeatability. Typically stepper motors will have a step angle accuracy of 3 5% of one step. This error is also non cumulative from step to step. The accuracy of the stepper motor is mainly a function of the mechanical precision of its parts and assembly.

Figure 6.1: Positional accuracy of a stepper motor Torque versus Speed Characteristics: The torque versus speed characteristics are the key to selecting the right motor and drive method for a specific application. These characteristics are dependent upon (change with)the motor, excitation mode and type of driver or drive method.

Figure6.2: Torque versus speed characteristics

Single Step Response and Resonances: Stepper motors can often exhibit a phenomena referred to as resonance at certain step rates. This can be seen as a sudden loss or drop in torque at certain speeds which can result in missed steps or loss of synchronism. It occurs when the input step pulse rate coincides with the natural oscillation frequency of the rotor. Often there is a resonance area around the 100 200 pps region and also one in the high step pulse rate region. The resonance phenomena of a stepper motor comes from its basic construction and therefore it is not possible to eliminate it completely. It is also dependent upon the load conditions. It can be reduced by driving the motor in half or micro stepping modes.

Figure6.3: Single step response versus time Few Definitions related to stepper motor: 1. Step angle Step angle is associated with the internal construction of the motor, in particular the number of teeth on the stator and the rotor. The step angle is the minimum degree of rotation associated with a single step.

Step angle 0.72 1.8 2.0 2.5 5.0 7.5 15

Steps per Revolution 500 200 180 144 72 48 24

Fig: Stepper motor step angles

2. Steps per second and rpm relation The relation between rpm (revolutions per minute), steps per revolution and steps per second is as follows: Steps per second = (rpm*steps per revolution)/60 3. Motor speed: The motor speed, measured in steps per second (steps/sec) is a function of the switching rate. 4. Holding torque: The amount of torque, from an external source, required to break away the shaft from its holding position with the motor shaft standstill or zero rpm condition. Figure 6.4:STEPPER MOTOR INTERFACING WITH MICROCONTROLLER:

AT 89C51

P1.0 P1.1 P1.2 P1.3

1 2 3 4 5 6 7 8 Ground

U L N 2 0 0 3

16 15 14 13 12 11 10 9 Vcc STEPPER MOTOR

LIQUID CRYSTAL DISPLAY:

LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing LEDs (seven segment LEDs or other multi segment LEDs) because of the following reasons: 1. The declining prices of LCDs. 2. The ability to display numbers, characters and graphics. This is in contrast to LEDs, which are limited to numbers and a few characters. 3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep displaying the data. 4. Ease of programming for characters and graphics.

These components are specialized for being used with the microcontrollers, which means that they cannot be activated by standard IC circuits. They are used for writing different messages on a miniature LCD.

A model described here is for its low price and great possibilities most frequently used in practice. It is based on the HD44780 microcontroller ( Hitachi) and can display messages in two lines with 16 characters each . It displays all the alphabets, Greek letters, punctuation marks, mathematical symbols etc. In addition, it is possible to display symbols that user makes up on its own. Automatic shifting message on display (shift left

and right), appearance of the pointer, backlight etc. are considered as useful characteristics. Pins Functions There are pins along one side of the small printed board used for connection to the microcontroller. There are total of 14 pins marked with numbers (16 in case the background light is built in). Their function is described in the table below: Pin Number 1 2 3 4 Logic State -

Function Ground Power supply Contrast

Name Vss Vdd Vee RS

Description

Control of operating

R/W

6 7 8 9 10 11 12 13 14

E D0 D1 D2 D3 D4 D5 D6 D7

Data / commands

0V +5V 0 - Vdd D0 D7 are interpreted as 0 commands 1 D0 D7 are interpreted as data Write data (from controller to 0 LCD) 1 Read data (from LCD to controller) 0 Access to LCD disabled 1 Normal operating From 1 to Data/commands are transferred to 0 LCD 0/1 Bit 0 LSB 0/1 Bit 1 0/1 Bit 2 0/1 Bit 3 0/1 Bit 4 0/1 Bit 5 0/1 Bit 6 0/1 Bit 7 MSB

LCD screen: LCD screen consists of two lines with 16 characters each. Each character consists of 5x7 dot matrix. Contrast on display depends on the power supply voltage and whether messages are displayed in one or two lines. For that reason, variable voltage 0-Vdd is

applied on pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Some versions of displays have built in backlight (blue or green diodes). When used during operating, a resistor for current limitation should be used (like with any LE diode).

LCD Basic Commands All data transferred to LCD through outputs D0-D7 will be interpreted as commands or as data, which depends on logic state on pin RS: RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed. Built in processor addresses built in map of characters and displays corresponding symbols. Displaying position is determined by DDRAM address. This address is either previously defined or the address of previously transferred character is automatically incremented. RS = 0 - Bits D0 - D7 are commands which determine display mode. List of commands which LCD recognizes are given in the table below:

Command Clear display Cursor home Entry mode set Display on/off control Cursor/Display Shift Function set Set CGRAM address Set DDRAM address Read BUSY flag (BF) Write to CGRAM or DDRAM Read from CGRAM or DDRAM

RS RW D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 I/ 0 0 0 1 D 0 0 1 D U 0 1 D/C R/L x 1 DL N F x CGRAM address DDRAM address DDRAM address 0 0 0 0 0 0 1 x S B x x

Execution Time 1.64mS 1.64mS 40uS 40uS 40uS 40uS 40uS 40uS 40uS 40uS

0 0 0 0 0 0 0 0 0 1 1 BF

0 D7 D6 D5 D4 D3 D2 D1 D0 1 D7 D6 D5 D4 D3 D2 D1 D0

I/D 1 = Increment (by 1) 0 = Decrement (by 1) S 1 = Display shift on 0 = Display shift off D 1 = Display on 0 = Display off U 1 = Cursor on 0 = Cursor off B 1 = Cursor blink on 0 = Cursor blink off

R/L 1 = Shift right 0 = Shift left DL 1 = 8-bit interface 0 = 4-bit interface N 1 = Display in two lines 0 = Display in one line F 1 = Character format 5x10 dots 0 = Character format 5x7 dots D/C 1 = Display shift 0 = Cursor shift

LCD Connection Depending on how many lines are used for connection to the microcontroller, there are 8-bit and 4-bit LCD modes. The appropriate mode is determined at the beginning of the process in a phase called initialization. In the first case, the data are transferred through outputs D0-D7 as it has been already explained. In case of 4-bit LED mode, for the sake of saving valuable I/O pins of the microcontroller, there are only 4 higher bits (D4-D7) used for communication, while other may be left unconnected. Consequently, each data is sent to LCD in two steps: four higher bits are sent first (that normally would be sent through lines D4-D7), four lower bits are sent afterwards. With the help of initialization, LCD will correctly connect and interpret each data received. Besides, with regards to the fact that data are rarely read from LCD (data mainly are transferred from microcontroller to LCD) one more I/O pin may be saved by simple connecting R/W pin to the Ground. Such saving has its price. Even though message displaying will be normally performed, it will not be possible to read from busy flag since it is not possible to read from display.

LCD Initialization Once the power supply is turned on, LCD is automatically cleared. This process lasts for approximately 15mS. After that, display is ready to operate. The mode of operating is set by default. This means that: 1. Display is cleared 2. Mode DL = 1 Communication through 8-bit interface N = 0 Messages are displayed in one line F = 0 Character font 5 x 8 dots 3. Display/Cursor on/off D = 0 Display off U = 0 Cursor off B = 0 Cursor blink off 4. Character entry

ID = 1 Addresses on display are automatically incremented by 1 S = 0 Display shift off Automatic reset is mainly performed without any problems. Mainly but not always! If for any reason power supply voltage does not reach full value in the course of 10mS, display will start perform completely unpredictably. If voltage supply unit can not meet this condition or if it is needed to provide completely safe operating, the process of initialization by which a new reset enabling display to operate normally must be applied. Algorithm according to the initialization is being performed depends on whether connection to the microcontroller is through 4- or 8-bit interface. All left over to be done after that is to give basic commands and of course- to display messages.

Figure : Procedure on 8-bit initialization.

CONTRAST CONTROL: To have a clear view of the characters on the LCD, contrast should be adjusted. To adjust the contrast, the voltage should be varied. For this, a preset is used which can behave like a variable voltage device. As the voltage of this preset is varied, the contrast of the LCD can be adjusted.

Figure 7.1: Variable resistor

Potentiometer Variable resistors used as potentiometers have all three terminals connected. This arrangement is normally used to vary voltage, for example to set the switching point of a circuit with a sensor, or control the volume (loudness) in an amplifier circuit. If the terminals at the ends of the track are connected across the power supply, then the wiper terminal will provide a voltage which can be varied from zero up to the maximum of the supply.

Potentiometer Symbol

Presets These are miniature versions of the standard variable resistor. They are designed to be mounted directly onto the circuit board and adjusted only when the circuit is built. For example to set the frequency of an alarm tone or the sensitivity of a light-sensitive circuit. A small screwdriver or similar tool is required to adjust presets. Presets are much cheaper than standard variable resistors so they are sometimes used in projects where a standard variable resistor would normally be used. Multiturn presets are used where very precise adjustments must be made. The screw must be turned many times (10+) to move the slider from one end of the track to the other, giving very fine control.

Preset Symbol

LCD INTERFACING WITH THE MICROCONTROLLER:

LED INTERFACING: LED stands for Light Emitting Diode. Microcontroller port pins cannot drive these LEDs as these require high currents to switch on. Thus the positive terminal of LED is directly connected to Vcc, power supply and the negative terminal is connected to port pin through a current limiting resistor. Light-emitting diodes are elements for light signalization in electronics. They are manufactured in different shapes, colors and sizes. For their low price, low consumption and simple use, they have almost completely pushed aside other light sources- bulbs at

first place. They perform similar to common diodes with the difference that they emit light when current flows through them.

It is important to know that each diode will be immediately destroyed unless its current is limited. This means that a conductor must be connected in parallel to a diode. In order to correctly determine value of this conductor, it is necessary to know diodes voltage drop in forward direction, which depends on what material a diode is made of and what colour it is. Values typical for the most frequently used diodes are shown in table below: As seen, there are three main types of LEDs. Standard ones get ful brightness at current of 20mA. Low Current diodes get ful brightness at ten times lower current while Super Bright diodes produce more intensive light than Standard ones. Since the 8051 microcontrollers can provide only low input current and since their pins are configured as outputs when voltage level on them is equal to 0, direct connectining to LEDs is carried out as it is shown on figure (Low current LED, cathode is connected to output pin).

This current limiting resistor is connected to protect the port pins from sudden flow of high currents from the power supply. Thus in order to glow the LED, first there should be a current flow through the LED. In order to have a current flow, a voltage difference should exist between the LED terminals. To ensure the voltage difference between the terminals and as the positive terminal of LED is connected to power supply Vcc, the negative terminal has to be connected to ground. Thus this ground value is provided by the microcontroller port pin. This can be achieved by writing an instruction CLR P1.0. With this, the port pin P1.0 is initialized to zero and thus now a voltage difference is established between the LED terminals and accordingly, current flows and therefore the LED glows. LED and switches can be connected to any one of the four port pins.

Vcc P1.0

Figure7.2: LED Interfacing with the microcontroller In this project, four LEDS are used, two for each IR section. Red LED is to indicate that the gate is closed and Green LED to indicate the gate is opened.

Figure 7.3: Schematic diagram

WORKING PROCEDURE: Automatic car parking system using 89C51 microcontroller is an exclusive project which allows the cars to be parked in cellars based on the availability without the involvement of a human. In this project, two pairs of IR Transmitters and Receivers are used. One pair is placed at the entry gate and the other is placed at the gate used for leaving the cellar. Initially the information regarding the space for the vehicles will be displayed on LCD (Liquid Crystal Display). The operation of this system starts when a vehicle tries to park in the cellar. The IR pair placed at this gate detects the vehicle arriving at the entry gate as the vehicle will be interrupting the IR signal falling on to the IR receiver from the transmitter. Then the gate will be opened as this action is preprogrammed in the microcontroller and automatically the count will be decremented for allowing the vehicles to enter. This project provides space for a maximum of 4 vehicles to be parked. The opening and closing of the gate is controlled by the stepper motor. This gate remains open for some time allowing the vehicle to enter there and then closes automatically. The information about the space for the other vehicles will be continuously displayed on the LCD for the easy check of the other vehicles to enter into. Now the second IR pair starts working, i.e., when a vehicle wants to leave the place, the vehicle will be waiting at the exit gate then the vehicle will be interrupting the IR signal falling on to the IR receiver from the transmitter. Now the gate which is used for leaving the place opens and will remain open for some time allowing the vehicle to leave and the closes again and gets locked and the information will be updated on the LCD whenever a vehicle exits out from the cellar. The operation continues upto 10 vehicles if no vehicle left the cellar. i.e., the LCD display will be now NO SPACE FOR NEW VEHICLES unless a vehicle exits

out. Thus, this system will not allow another vehicle when there is no space in the cellar completely avoiding the man involvement and automising the control to allow the vehicles to be parked.

;***********SOURCE CODE**************************************** ;*************** CAR PARKING SYSTEM ***************** ;*************** WK-212 ***************** ;******************************************************** ; P3.6 AND P3.7 RECEIVERS OF ENTRY AND EXIT SENSORS RESP. ; P1.0,P1.1,P1.2 AND P1.3 STEPPER MOTOR A,B,C AND D COILS ; P2 LCD DATA PINS ; P3.0,P3.1 AND P3.2 ARE RS,R/W AND EN PINS OF LCD RESP.

ORG 00H SETB P3.6 SETB P3.7 MOV R6,#10 ; MAKING P3.6 AS I/P PIN ; MAKING P3.7 AS I/P PIN ; VEHICLE CAPACITY OF PARK

;******* LCD INITIALISATION **************************** MOV DPTR,#COMM BACK1 : CLR A MOVC A,@A+DPTR JZ NEXT ACALL COMN ACALL DELAY INC DPTR SJMP BACK1 ;****** LCD INITIAL MESSAGE DISPLAY NEXT : MOV DPTR,#MESG4 ACALL BACK2 ********************

ACALL DELAY1 MOV A,#0C0H ACALL COMN ACALL DELAY MOV DPTR,#MESG5 ACALL BACK2 ACALL FORDELAY ACALL FORDELAY MOV A,#01H ACALL COMN ACALL DELAY MOV A,#82H ACALL COMN ACALL DELAY MOV DPTR,#MESG6 ACALL BACK2 MOV A,#0C5H ACALL COMN ACALL DELAY MOV DPTR,#MESG7 ACALL BACK2 ACALL FORDELAY ACALL FORDELAY MOV A,#01H ACALL COMN ACALL DELAY MOV A,#81H ACALL COMN

ACALL DELAY MOV DPTR,#MESG ACALL BACK2 MOV A,#0C0H ACALL COMN ACALL DELAY MOV DPTR,#MESG1 ACALL BACK2 MOV A,#0C4H ACALL COMN ACALL DELAY MOV A,#'1' ACALL DATAWRT ACALL DELAY MOV A,#'0' ACALL DATAWRT ACALL DELAY ;*********** CHECKING FOR VEHICLE ENTRY OR EXIT ******** BACK : JNB P3.6,ENTRY JNB P3.7,EXIT SJMP BACK ;*********** OPENING THE GATE FOR VEHICLE ENTRY ******** ENTRY : MOV R7,#10 MOV A,#66

ACALL RUNACW DEC R6 MOV A,#0C4H ACALL COMN ACALL DELAY MOV A,R6 ANL A,#0F0H ORL A,#30H ACALL DATAWRT ACALL DELAY MOV A,#0C5H ACALL COMN ACALL DELAY MOV A,R6 ANL A,#0FH ORL A,#30H ACALL DATAWRT ACALL DELAY1 STAY : JNB P3.6,STAY ACALL DELAY1 STAY1 : JB P3.7,STAY1 STAY2 : JNB P3.7,STAY2 ACALL FORDELAY MOV R7,#10 MOV A,#66 ACALL RUNCW CJNE R6,#00,BACK MOV A,#01 ; FOR EXIT GATE HIGH TO LOW ; DISPLAYING CURRENT CAPACITY

ACALL DELAY1

ACALL COMN ACALL DELAY MOV A,#82H ACALL COMN ACALL DELAY MOV DPTR,#MESG2 ACALL BACK2 MOV A,#0C4H ACALL COMN ACALL DELAY MOV DPTR,#MESG3 ACALL BACK2 STAY4EXIT : JB P3.7,STAY4EXIT VEHICLE MOV A,#01 ACALL COMN ACALL DELAY MOV A,#81H ACALL COMN ACALL DELAY MOV DPTR,#MESG ACALL BACK2 MOV A,#0C0H ACALL COMN ACALL DELAY MOV DPTR,#MESG1 ACALL BACK2 ACALL DELAY ; WAITING FOR EXIT OF

EXIT : MOV R7,#10 MOV A,#66 ACALL RUNACW INC R6 MOV A,#0C4H ACALL COMN ACALL DELAY MOV A,R6 MOV B,#10 DIV AB ORL A,#30H ACALL DATAWRT ACALL DELAY MOV A,#0C5H ACALL COMN ACALL DELAY MOV A,B ORL A,#30H ACALL DATAWRT STAY3 : JNB P3.7,STAY3 ACALL DELAY1 STAY4 : JB P3.6,STAY4 STAY5 : JNB P3.6,STAY5 ACALL FORDELAY MOV R7,#10 MOV A,#66 ACALL RUNCW LJMP BACK

FORDELAY:ACALL DELAY2 ACALL DELAY2 ACALL DELAY2 ACALL DELAY2 ACALL DELAY2 ACALL DELAY2 ACALL DELAY2 ACALL DELAY2 ACALL DELAY2 ACALL DELAY2 ACALL DELAY2 RET RUNACW: CLR P1.0

SETB P1.1 SETB P1.2 CLR P1.3 ACALL DELAY1 CLR P3.0 SETB P3.1 SETB P3.2 CLR P3.3 ACALL DELAY1 SETB P1.0 SETB P1.1 CLR P1.2 CLR P1.3

ACALL DELAY1 SETB P3.0 SETB P3.1 CLR P3.2 CLR P3.3 ACALL DELAY1

SETB P1.0 CLR P1.1 CLR P1.2 SETB P1.3 ACALL DELAY1 SETB P3.0 CLR P3.1 CLR P3.2 SETB P3.3 ACALL DELAY1 CLR P1.0 CLR P1.1 SETB P1.2 SETB P1.3 ACALL DELAY1 CLR P3.0 CLR P3.1 SETB P3.2 SETB P3.3

ACALL DELAY1 DJNZ R7,RUNACW RET RUNCW: CLR P1.0 SETB P1.1 SETB P1.2 CLR P1.3 ACALL DELAY1 CLR P3.0 SETB P3.1 SETB P3.2 CLR P3.3 ACALL DELAY1 CLR P1.0 CLR P1.1 SETB P1.2 SETB P1.3 ACALL DELAY1 CLR P3.0 CLR P3.1 SETB P3.2 SETB P3.3 ACALL DELAY1 SETB P1.0 CLR P1.1

CLR P1.2 SETB P1.3 ACALL DELAY1 SETB P3.0 CLR P3.1 CLR P3.2 SETB P3.3 ACALL DELAY1 SETB P1.0 SETB P1.1 CLR P1.2 CLR P1.3 ACALL DELAY1 SETB P3.0 SETB P3.1 CLR P3.2 CLR P3.3 ACALL DELAY1 ; ; ; MOV P1,A RR A ACALL DELAY1 DJNZ R7,RUNCW RET COMN : MOV P2,A CLR P1.7 CLR P1.6 SETB P1.5

ACALL DELAY CLR P1.5 RET DATAWRT:MOV P2,A SETB P1.7 CLR P1.6 SETB P1.5 ACALL DELAY CLR P1.5 RET BACK2 : CLR A MOVC A,@A+DPTR JZ NEXT1 ACALL DATAWRT ACALL DELAY INC DPTR SJMP BACK2 NEXT1 : RET

DELAY : MOV R2,#20 HERE1 : MOV R3,#255 HERE2 : DJNZ R3,HERE2 DJNZ R2,HERE1 RET DELAY1: MOV R2,#40 HERE3 : MOV R3,#255 HERE4 : DJNZ R3,HERE4 DJNZ R2,HERE3

RET DELAY2: MOV R2,#255 HERE5 : MOV R3,#255 HERE6 : DJNZ R3,HERE6 DJNZ R2,HERE5 RET COMM : DB 38H,0CH,01,06,84H,00 MESG4 : DB "WIN KIT",0 MESG5 : DB "LEARNING IS FUN",0 MESG6 : DB "CAR PARKING",0 MESG7 : DB "SYSTEM",0 MESG : DB "PARKING SPACE",0 MESG1 : DB "FOR VEHICLES",0 MESG2 : DB "NO SPACE FOR",0 MESG3 : DB "PARKING",0 END

Das könnte Ihnen auch gefallen