Project Report on “CRASH PROTECTION ” SUBMITTED IN PARTIAL FULFILLMENT OF REQUIRED FOR B- TECH IN “Electronics & communication” under Punjab state board of technical education and industrial training Chandigarh Submitted by:-

RIMT (Mandi Gobindgarh)

Submitted To:- DEPARTMENT OF “ ELECTRONICS AND COMMUNICATION” RIMT- Near floating side, Mandi Gobindgarh. Punjab (147301)

1 ON CRASH PROTECTION

2 INDEX

SR. NO. CHAPTER NAME PAGE NO. 1 Acknowledgement 4 2 Introduction 5 3 Component List 6 4 Block Diagram Mechanical drawing and description Power Supply 12 6 Microcontroller 13 7 Circuit and working Advantage 32 11 Disadvantage 33 12 Application 34 13 Precaution 35

3 CHAPTER – 1 ACKNOWLEDGEMENT Many individual have proudly influenced us during our Studies (B.E) at RIMT ENGINEERING College,Mandi Gobindgarh and it is pleasure to acknowledge their guidance and support. At RIMT Polytechnic, We learned many things like the project training is mainly aimed at enabling the student to apply their theoretical knowledge to practical as "The theory is to know how and practical is to do how" and to appreciate the limitation of knowledge gained in the class room to practical situation and to appreciate the importance of discipline, punctuality, team work, sense of responsibility, money, value of time, dignity of labour. I will like to express my gratitude towards Mrs. Talwar who took keen interest in our project, who helped me in every possible way and is source of inspiration for all the group members. I would also like to thank Mr. Talwar (HOD), Electronics & Communication who motivated us to complete our project with enthusiasm and hard work.

Components:- Iron Strip Lenth-10 fit, depth-30mm and width-12mm Iron Strip Lenth- 2 fit, Depth-25mm and width-6mm

1. diode 4007 2 2. 1000uF, 25 V 1

4 3. 470uF, 16 V 1 4. 7805 1 5. LED 1 6. 470 ohm 1

1. 40 pin base 1 2. 12 Mhz 1 3. 22 pF 2 4. 89s52 1 5. 10uF, 10 V 1 6. 10K 1

1. 8 Pin base 2 2. 817 2 3. 1K 2 4. 470 ohm 2 5. 4.7 K 2 6. 547 2 7. 558 2 Bateery 2 Battery connecter 2 Motor Dc gear 2

PROCREDURE TO MAKE PROJECT:-

1. IDEA OF PROJECT

In this stage student select the topic of the project of the

project. It’s the main stage of project work.its the area where

talented students shows their innovative ideas. Innovative

students make project with a new idea then others. We

selected this project because we want to do something in with

5 our own hands. We drop idea because there was little bit

practical.

2. STUDY RAW MATERIAL AND LAYOUT DIAGRAM

In this section we collected the study Raw Material. We

searches about our project on

google.com,www.yahoo.com,www.msn.com and

www.ludhianaprojects.com. But we find many Layout and

theory Raw Materials for our project. We were not sure about

the Layout and Raw Material used in it. Because Layout

diagram available on the site were provided by students. So we

can really on them. Then we saw www.ludhianaprojects.com a

project help provider site. Its help us lot. They helped us lot in

our project. We find the proper layout Project of our project in

that site.

3. Trail TESTING OF MAIN PROJECT- Then we collect the Raw

Material of project. It was not a easy task. Because no shop in

our area have all parts used in projects. Then after collection of

Raw Material we test the projects working by temporary made

project.- step by step. Because we want to sure about the

6 Project. We checked it in different steps beacuuse it was a big

project and was not possible to check it in a single step.

4. COMPONENT MOUNTING- we have also some parts of

electronic circuit. So we kept the pcb for circuit with hole size

from 0.8mm yo 1 mm for leads of Raw Material. Then we insert

Raw Material according ton their pitches.

5. SODERING- Afgter mounting Raw Raw Material we solder the

Raw Raw Material ane by one. We kept the temperature of iron

at 250 degree to 400 degree. Because above this temperature

it can damage to component. We used general iron available in

the market of siron company. Its temperature was nearly 350

degree acc to company specifications. We used soldering wire

of 22 gauge with flux inbuilt.

6. Assembly of Project:- after making electronic circuit we make

mechanical portion. For this we take a base Board and after

this our first step is that we make iron work that is welding,

turning and etc. after this assembly of mechanical portion. After

making mechanical portion we connect electronic circuit to

make it automatic functions.

7 7. FINAL TESTING- After that we test the Project step by step .

and insert the ICs after testing the one portion of the Project an

then after other step by step. Its was tough work we tested

voltage across the compents with erepect to ground. And

current in series.

TROUBLSHOOTING- Then we tried to troubleshoot the errors in the project

8 CHAPTER –2 INTRODUCTION

In this project we use will control train with IR sensor. This sensor have transmitter and receiver and its working is based on the reflected rays. sensor will give signal to microcontroller . Microcontroller will give that data to relay drive circuit or H bride circuit. If H brude will good enough to give sufficient current to motors then we will use H- bridge circuit. If not then we will use relay circuit to operate motors. We will use opto-couplers in between micron roller and H bridge circuit. In this project we will control train with infrared in will be stopped. We will control auto stop function of moving train . In this project we will use IR sensor at the front of train. We can use more other sensor against IR sensor but it is less in cost so we use it. Normally we will provide supply to IR transmitter and it emits the frequency rays in invisible form. When any train or other thing will be in front of train then sensor will work and with the help of microcontroller motor supply will be disconnected . We will use 89c051 microcontroller for this function. We will give 9v supply to remote with 9v dc battery available in the market. We will use 7805 voltage regulator for 5v dc supply. For input to microcontroller there will be microswitches. There will be complementary push pull power amplifier after Microcontroller output. For that we will use 548 npn transistors 558 pnp. It will amplify data so that it will not destroy in the way. After that it will be amplify and led will convert that signal into phpt signal . On reciver end photodide will amplify that signal and will give it to microcontroller. Microcontroller will give

9 signal to optocoupler. Here optocoupler will worl as a isolator after that h bridge will amplify that signal and will give signal according to rxed signal

Automation requires precisely rotating motor which accelerates / decelerates very fast & stops at precise predetermined position without any error, and also has holding torque so that the motor-shaft position is maintained. AUTO CONTROLS make stepper motor controllers are based on H-bridge configuration with facility of having constant current supplied to the motor.

Stepper motor controllers are MOSFET based and utilize high voltage D.C. Supply at constant current mode. Hence, the stepper motor can run at higher speed up to 1000 rpm and above. Stepper motor controllers can achieve the acceleration of 100 m/Sec2. to zero speed to stop the motor from running speed, with rated torque. The time of Acc & Dec. will vary as per the load and GD2 of the load to overcome inertia force.

Basic:- COMPONENTS DIODE When a p-type semi conductor is suitably joined to an n-type semi conductor, the contact surface so formed is called p-junction. A p-n junction is known as semi conductor diode. It is known as crystal diode since it is grown out of a crystal. A semi conductor diode has two terminals. It conducts only when it is formed biased i.e. when terminal connected with arrowhead is at higher potential than the

10 terminal connected to the bar. However, when it is reversed biased, practically it does not conduct any current through it.

ZENER DIODE A specially designed silicon diode, which is optimized, to operate in the breakdown region is known as Zener diode. The ordinary rectifier and small signal diodes are never intentionally operated in the breakdown region s known because this may damage them. On the other hand Zener diodes are only operated in the breakdown region. Therefore, Zener diodes are cryptically designed to have a sharp breakdown voltage. By varying the doping levels of silicon diode, a manufacturer can produce Zener diode with breakdown voltages from about 2 to 200V.

RESISTORS Resistor is a component, used to limit the amount of current or divide the voltage in an electronic circuit. The ability of a resistor to oppose the current is called resistance R is Ohm. Each resistor has two main characteristics i.e. its resistance (R) in ohms and its power rating in watts (W). the resistors having wide range of

11 resistance ( from a fraction of an ohm to many mega ohms ) are available. The power rating may be as lower 1/10 W to as high a several hundred watts. The value of R is selected to obtain a desired current I or voltage drop IR in the circuit. At the same time wattage of the resistor is to select so that it can dissipate the heat losses without overheating itself.

12 CAPACITORS The two conducting plates separated by an insulating material (called dielectric) from a capacitor. The basic purpose of the capacitor is to store the charge. The capacity of a capacitor to store per unit potential difference is called its capacitance. The unit of capacitance of farads ( F ). A capacitor is a component, which offers low impedance to AC but very high. Impedance ( resistance ) to DC. In most of the electronic circuits, a capacitor has dc voltage applied, combined with a much smaller AC signal voltage. The usual function of the capacitor is to block DC voltage but pass the AC signal voltage, by means of charging and discharging. These application include coupling, bypassing for AC signal.

13 TRANSISTORS A semiconductor device consisting of two p-n junctions formed by a special technique is adopted to form a transistor either p-type or n-type semi conductors between a pair of opposite types is a transistor. There are two types of transistors: PNP transistor & NPN transistor.

RELAY Working of relay or two-way switch is of same type. The only difference is that the two-way switches is operated manually but relay works on magnetic field. In relay one coil is used to produce magnetic power. When voltage is induced in coils magnetic field is produced. The terminals connected to magnetic coils are connected to base plate switches on and off points of relay. Coil is made on iron core by this electromagnetic field. The two points of coil on which voltages are given are put at outer base plate of relay and the relay is made on iron stand and stretched by the ‘spring is kept b/w the two points of switch. A and B is a coil. The pole D is connected to the switch C, when there is no supply to the coil. This condition is known as normal connection (N/C). but when the supply is given to the coil, the core of coil becomes electromagnetic pole and connects the pole D with switch E. in this

14 condition switch E is known as orderly connection (O/C).When the supply is off. The core of supply is demagnetized; resulting in reconnection of pole D with switch C. relay can operate on AC as well as DC. There are many types of relays such as; 1. Many relays control only one phase i.e. have only one on/off contact. 2. Many relays can control two phase or both phase and neutral.

ON/OFF SWITCH It makes the supply or total fluctuations of the switches ON/OFF. NEON INDICATING LAMP When the switch is made on this neon lamp gives light to indicate that the main switch is made on. When it does not give any light this indicate that switch is off. TRANSFORMER A transformer is just similar in appearance to an indicator. Basically, it consists of two coils having the same core. The coil to which supply is connected, is called primary winding and the coil to which load is connected, is called secondary winding. When an AC supply is applied to primary an e.m.f. is induced in the secondary side. Thus, transformer is a static device, which transfers power from one to other circuit.

15 Depending upon the number of turns on the secondary and primary side, a transformer may be step up or step down. In electronics circuits, the transformers, which are generally used, are known as power transformers, o/p transformers and intermediate frequency transformers.

LEDs

Light Emitting Diodes (LEDs)

Colours | Sizes and shapes | Resistor value | LEDs in series | LED data | Flashing | Displays

Example: Circuit symbol:

Function LEDs emit light when an electric current passes through them.

Connecting and soldering LEDs must be connected the correct way round, the diagram may be labelled a or + for anode and k or - for cathode (yes, it really is k, not c, for cathode!). The cathode is the short lead and there may be a slight flat on the body of round LEDs. If you can see inside the LED the cathode is the larger electrode (but this is not an official identification method).

LEDs can be damaged by heat when soldering, but the risk is small unless you are very slow. No special precautions are needed for soldering most

16 LEDs.

Testing an LED Never connect an LED directly to a battery or power supply! It will be destroyed almost instantly because too much current will pass through and burn it out.

LEDs must have a resistor in series to limit the current to a safe value, for quick testing purposes a 1k resistor is suitable for most LEDs if your supply voltage is 12V or less. Remember to connect the LED the correct way round!

For an accurate value please see Calculating an LED resistor value below.

Colours of LEDs LEDs are available in red, orange, amber, yellow, green, blue and white. Blue and white LEDs are much more expensive than the other colours.

The colour of an LED is determined by the semiconductor material, not by the colouring of the 'package' (the plastic body). LEDs of all colours are available in uncoloured packages which may be diffused (milky) or clear (often described as 'water clear'). The coloured packages are also available as diffused (the standard type) or transparent.

Tri-colour LEDs The most popular type of tri-colour LED has a red and a green LED combined in one package with three leads. They are called tri-colour because mixed red and green light appears to be yellow and this is produced when both the red and green LEDs are on.

The diagram shows the construction of a tri-colour LED. Note the different lengths of the three leads. The centre lead (k) is the common cathode for both LEDs, the outer leads (a1 and a2) are the anodes to the LEDs allowing each one to be lit separately, or both together to give the third colour.

17 Bi-colour LEDs A bi-colour LED has two LEDs wired in 'inverse parallel' (one forwards, one backwards) combined in one package with two leads. Only one of the LEDs can be lit at one time and they are less useful than the tri-colour LEDs described above.

LED Clip

Photograph © Rapid Electronics

Sizes, Shapes and Viewing angles of LEDs LEDs are available in a wide variety of sizes and shapes. The 'standard' LED has a round cross-section of 5mm diameter and this is probably the best type for general use, but 3mm round LEDs are also popular.

Round cross-section LEDs are frequently used and they are very easy to install on boxes by drilling a hole of the LED diameter, adding a spot of glue will help to hold the LED if necessary. LED clips are also available to secure LEDs in holes. Other cross-section shapes include square, rectangular and triangular.

As well as a variety of colours, sizes and shapes, LEDs also vary in their viewing angle. This tells you how much the beam of light spreads out. Standard LEDs have a viewing angle of 60° but others have a narrow beam of 30° or less.

Rapid Electronics stock a wide selection of LEDs and their catalogue is a good guide to the range available.

Calculating an LED resistor value An LED must have a resistor connected in series to limit the current through the LED, otherwise it will burn out almost instantly.

The resistor value, R is given by:

18 R = (VS - VL) / I

VS = supply voltage VL = LED voltage (usually 2V, but 4V for blue and white LEDs) I = LED current (e.g. 20mA), this must be less than the maximum permitted

If the calculated value is not available choose the nearest standard resistor value which is greater, so that the current will be a little less than you chose. In fact you may wish to choose a greater resistor value to reduce the current (to increase battery life for example) but this will make the LED less bright.

For example

If the supply voltage VS = 9V, and you have a red LED (VL = 2V), requiring a current I = 20mA = 0.020A, R = (9V - 2V) / 0.02A = 350 , so choose 390 (the nearest standard value which is greater).

Working out the LED resistor formula using Ohm's law Ohm's law says that the resistance of the resistor, R = V/I, where:

V = voltage across the resistor (= VS - VL in this case) I = the current through the resistor

So R = (VS - VL) / I

For more information on the calculations please see the Ohm's Law page.

Connecting LEDs in series If you wish to have several LEDs on at the same time it may be possible to connect them in series. This prolongs battery life by lighting several LEDs with the same current as just one LED.

All the LEDs connected in series pass the same current so it is best if they are all the

19 same type. The power supply must have sufficient voltage to provide about 2V for each LED (4V for blue and white) plus at least another 2V for the resistor. To work out a value for the resistor you must add up all the LED voltages and use this for VL.

Example calculations: A red, a yellow and a green LED in series need a supply voltage of at least 3 × 2V + 2V = 8V, so a 9V battery would be ideal.

VL = 2V + 2V + 2V = 6V (the three LED voltages added up). If the supply voltage VS is 9V and the current I must be 15mA = 0.015A, Resistor R = (VS - VL) / I = (9 - 6) / 0.015 = 3 / 0.015 = 200 , so choose R = 220 (the nearest standard value which is greater).

Avoid connecting LEDs in parallel! Connecting several LEDs in parallel with just one resistor shared between them is generally not a good idea.

If the LEDs require slightly different voltages only the lowest voltage LED will light and it may be destroyed by the larger current flowing through it. Although identical LEDs can be successfully connected in parallel with one resistor this rarely offers any useful benefit because resistors are very cheap and the current used is the same as connecting the LEDs individually. If LEDs are in parallel each one should have its own resistor.

Reading a table of technical data for LEDs Suppliers' catalogues usually include tables of technical data for components such as LEDs. These tables contain a good deal of useful information in a compact form but they can be difficult to understand if you are not familiar with the abbreviations used.

The table below shows typical technical data for some 5mm diameter round LEDs with diffused packages (plastic bodies). Only three columns are

20 important and these are shown in bold. Please see below for explanations of the quantities.

IF VF VF VR Luminous Viewing Type Colour Wavelength max. typ. max. max. intensity angle 5mcd @ Standard Red 30mA 1.7V 2.1V 5V 60° 660nm 10mA Bright 80mcd @ Standard 30mA 2.0V 2.5V 5V 60° 625nm red 10mA 32mcd @ Standard Yellow 30mA 2.1V 2.5V 5V 60° 590nm 10mA 32mcd @ Standard Green 25mA 2.2V 2.5V 5V 60° 565nm 10mA High 60mcd @ Blue 30mA 4.5V 5.5V 5V 50° 430nm intensity 20mA Super 500mcd @ Red 30mA 1.85V 2.5V 5V 60° 660nm bright 20mA Low 5mcd @ Red 30mA 1.7V 2.0V 5V 60° 625nm current 2mA

IF max. Maximum forward current, forward just means with the LED connected correctly.

VF typ. Typical forward voltage, VL in the LED resistor calculation. This is about 2V, except for blue and white LEDs for which it is about 4V.

VF max. Maximum forward voltage.

VR max. Maximum reverse voltage You can ignore this for LEDs connected the correct way round. Luminous Brightness of the LED at the given current, mcd = intensity millicandela. Viewing angle Standard LEDs have a viewing angle of 60°, others emit a narrower beam of about 30°. Wavelength The peak wavelength of the light emitted, this determines the colour of the LED. nm = nanometer.

21 Flashing LEDs Flashing LEDs look like ordinary LEDs but they contain an integrated circuit (IC) as well as the LED itself. The IC flashes the LED at a low frequency, typically 3Hz (3 flashes per second). They are designed to be connected directly to a supply, usually 9 - 12V, and no series resistor is required. Their flash frequency is fixed so their use is limited and you may prefer to build your own circuit to flash an ordinary LED, for example our Flashing LED project which uses a 555 astable circuit.

LED Displays LED displays are packages of many LEDs arranged in a pattern, the most familiar pattern being the 7-segment displays for showing numbers (digits 0- 9). The pictures below illustrate some of the popular designs:

Bargraph 7-segment Starburst Dot matrix Photographs © Rapid Electronics

Pin connections of LED displays There are many types of LED display and a supplier's catalogue should be consulted for the pin connections. The diagram on the right shows an example from the Rapid Electronics catalogue. Like many 7-segment displays, this example is available in two versions: Common Anode (SA) with all the LED anodes connected together and Pin connections diagram Common Cathode (SC) with all the cathodes © Rapid Electronics connected together. Letters a-g refer to the 7 segments, A/C is the common anode or cathode as appropriate (on 2 pins). Note that some pins are not present (NP) but their position is still numbered.

22 Also see: Display Drivers.

MOTOR:-

An electric motor converts electrical energy into mechanical energy. The reverse task, that of converting mechanical energy into electrical energy, is accomplished by a generator or dynamo. Traction motors used on locomotives often perform both tasks if the locomotive is equipped with dynamic brakes. Electric motors are found in household appliances such as fans, exhaust fans, fridges, washing machines, pool pumps and fan-forced ovens.

Most electric motors work by electromagnetism, but motors based on other electromechanical phenomena, such as electrostatic forces and the piezoelectric effect, also exist. The fundamental principle upon which electromagnetic motors are based is that there is a mechanical force on any current-carrying wire contained within a magnetic field. The force is described by the Lorentz force law and is perpendicular to both the wire and the magnetic field. Most magnetic motors are rotary, but linear motors also exist. In a rotary motor, the rotating part (usually on the inside) is called the rotor, and the stationary part is called the stator. The rotor rotates because the wires and magnetic field are arranged so that a torque is developed about the rotor's axis. The motor contains electromagnets that are wound on a frame. Though this frame is often called the armature, that term is often erroneously applied. Correctly, the armature is that part of the motor across

23 which the input voltage is supplied. Depending upon the design of the machine, either the rotor or the stator can serve as the armature.

A simple DC electric motor. When the coil is powered, a magnetic field is generated around the armature. The left side of the armature is pushed away from the left magnet and drawn toward the right, causing rotation.

BLOCK DIAGRAM:-

24 Power supply

Sensors Programmable Photodiode or Motor control IC photo circuit 89c51 transistors

DC Motors

Wheels of the Train

Mechanical Portion:-

Track for train

25 Train

Wheel system

A wheel is a device that allows heavy objects to be moved easily through rotating on an axle through its center, facilitating movement or transportation while supporting a load, or performing labor in machines. Common examples found in transport applications. A wheel, together with an axle, overcomes friction by facilitating motion by rolling. In order for wheels to rotate, a moment needs to be applied to the wheel about its axis, either by way of gravity, or by application of another external force. More generally the term is also used for other circular objects that rotate or turn, such as a ship's wheel, steering wheel and flywheel

Timeline

26 

Bronze Age disk wheel as depicted on the Standard of Ur (ca. 2500 BC)

Classical Greek four-spoked chariot-wheel (as a Linear B glyph), in use from the 15th century BC. Hittite and Egyptian chariots tended to have six spokes, Iron Age Assyrian ones eight.

Bronze Age "wheel pendants" of the Urnfield culture (ca. 1200 BC), found in Zürich (Swiss National Museum)

An Early Iron Age spoked wheel from Choqa Zanbil (ca. 1000 BC, National Museum of Iran)

27 Wheel of the Etruscan chariot (ca. 530 BC)

The classic spoked wheel with hub and iron rim, in use from about 500 BC (Iron Age Europe) until the 20th century AD

Penny-farthing bicycle (1882)

Modern motorcycle alloy wheel with inflatable tire and disc brake

Michelin's "Tweel" airless tyre (2005)

[edit] Mechanics and function

The wheel is a device that enables efficient movement of an object across a surface where there is a force pressing the object to the surface. Common examples are a cart pulled by a horse, and the rollers on an aircraft flap mechanism.

28 Wheels are used in conjunction with axles, either the wheel turns on the axle, or the axle turns in the object body. The mechanics are the same in either case.

The low resistance to motion (compared to dragging) is explained as follows (refer to friction):

 the normal force at the sliding interface is the same.  the sliding distance is reduced for a given distance of travel.  the coefficient of friction at the interface is usually lower.

Bearings are used to help reduce friction at the interface. In the simplest and oldest case the bearing is just a round hole through which the axle passes (a "plain bearing").

Example:

 If a 100 kg object is dragged for 10 m along a surface with the coefficient of friction μ = 0.5, the normal force is 981 N and the work done (required energy) is (work=force x distance) 981 × 0.5 × 10 = 4905 joules.  Now give the object 4 wheels. The normal force between the 4 wheels and axles is the same (in total) 981 N. Assume, for wood, μ = 0.25, and say the wheel diameter is 1000 mm and axle diameter is 50 mm. So while the object still moves 10 m the sliding frictional surfaces only slide over each other a distance of 0.5 m. The work done is 981 × 0.25 × 0.5 = 123 joules; the friction is reduced to 1/40 of that of dragging.

Additional energy is lost from the wheel-to-road interface. This is termed rolling resistance which is predominantly a deformation loss.

A wheel can also offer advantages in traversing irregular surfaces if the wheel radius is sufficiently large compared to the irregularities.

The wheel alone is not a machine, but when attached to an axle in conjunction with bearing, it forms the wheel and axle, one of the simple machines. A driven wheel is an example of a wheel and axle. Note that wheels pre-date driven wheels by about 6000 years.

[edit] Stability

29 Static stability of a wheeled vehicle

For unarticulated wheels, climbing obstacles will cause the body of the vehicle to rotate. If the rotation angle is too high, the vehicle will become statically unstable and tip over. At high speeds, a vehicle can become dynamically unstable, able to be tipped over by an obstacle smaller than its static stability limit. Without articulation, this can be an impossible position from which to recover.

For front-to-back stability, the maximum height of an obstacle which an unarticulated wheeled vehicle can climb is a function of the wheelbase and the horizontal and vertical position of the center of mass (CM).

The critical angle is the angle at which the center of mass of the vehicle begins to pass outside of the contact points of the wheels. Past the critical angle, the reaction forces at the wheels can no longer counteract the moment created by the vehicle's weight, and the vehicle will tip over. At the critical angle, the vehicle is marginally stable. The critical angle θcrit can be found by solving the equation:

where

xcm is the horizontal distance (on level terrain) of the center of mass from the lower axle; and

ycm is the vertical distance (on level terrain) of the center of mass from lower axle.

30 The maximum height h of an obstacle can thus be found by the equation:

where w is the wheelbase.

Gear system:- Gears

A gear is a component within a transmission device that transmits rotational force to another gear or device. A gear is different from a pulley in that a gear is a round wheel which has linkages ("teeth" or "cogs") that mesh with other gear teeth, allowing force to be fully transferred without slippage. Depending on their construction and arrangement, geared devices can transmit forces at different speeds, torques, or in a different direction, from the power source. Gears are a very useful simple machine. The most common situation is for a gear to mesh with another gear, but a gear can mesh with any device having compatible teeth, such as linear moving racks. A gear's most important feature is that gears of unequal sizes (diameters) can be combined to produce a mechanical advantage, so that the rotational speed and torque of the second gear are different from that of the first. In the context of a particular machine, the term "gear" also refers to one particular arrangement of gears among other arrangements (such as "first gear"). Such arrangements are often given as a ratio, using the number of teeth or gear diameter as units. The term "gear" is also used in non-geared devices which perform equivalent tasks:

31 "...broadly speaking, a gear refers to a ratio of engine shaft speed to driveshaft speed. Although CVTs change this ratio without using a set of planetary gears, they are still described as having low and high "gears" for the sake of

General

The smaller gear in a pair is often called the pinion; the larger, either the gear, or the wheel.

Mechanical advantage

The interlocking of the teeth in a pair of meshing gears means that their circumferences necessarily move at the same rate of linear motion (eg., metres per second, or feet per minute). Since rotational speed (eg. measured in revolutions per second, revolutions per minute, or radians per second) is proportional to a wheel's circumferential speed divided by its radius, we see that the larger the radius of a gear, the slower will be its rotational speed, when meshed with a gear of given size and speed. The same conclusion can also be reached by a different analytical process: counting teeth. Since the teeth of two meshing gears are locked in a one to one correspondence, when all of the teeth of the smaller gear have passed the point where the gears meet -- ie., when the smaller gear has made one revolution -- not all of the teeth of the larger gear will have passed that point -- the larger gear will have made less than one revolution. The smaller gear makes more revolutions in a given period of time; it turns faster. The speed ratio is simply the reciprocal ratio of the numbers of teeth on the two gears.

32 (Speed A * Number of teeth A) = (Speed B * Number of teeth B)

This ratio is known as the gear ratio.

The torque ratio can be determined by considering the force that a tooth of one gear exerts on a tooth of the other gear. Consider two teeth in contact at a point on the line joining the shaft axes of the two gears. In general, the force will have both a radial and a circumferential component. The radial component can be ignored: it merely causes a sideways push on the shaft and does not contribute to turning. The circumferential component causes turning. The torque is equal to the circumferential component of the force times radius. Thus we see that the larger gear experiences greater torque; the smaller gear less. The torque ratio is equal to the ratio of the radii. This is exactly the inverse of the case with the velocity ratio. Higher torque implies lower velocity and vice versa. The fact that the torque ratio is the inverse of the velocity ratio could also be inferred from the law of conservation of energy. Here we have been neglecting the effect of friction on the torque ratio. The velocity ratio is truly given by the tooth or size ratio, but friction will cause the torque ratio to be actually somewhat less than the inverse of the velocity ratio.

In the above discussion we have made mention of the gear "radius". Since a gear is not a proper circle but a roughened circle, it does not have a radius. However, in a pair of meshing gears, each may be considered to have an effective radius, called the pitch radius, the pitch radii being such that smooth wheels of those radii would produce the same velocity ratio that the gears actually produce. The pitch radius can

33 be considered sort of an "average" radius of the gear, somewhere between the outside radius of the gear and the radius at the base of the teeth.

The issue of pitch radius brings up the fact that the point on a gear tooth where it makes contact with a tooth on the mating gear varies during the time the pair of teeth are engaged; also the direction of force may vary. As a result, the velocity ratio (and torque ratio) is not, actually, in general, constant, if one considers the situation in detail, over the course of the period of engagement of a single pair of teeth. The velocity and torque ratios given at the beginning of this section are valid only "in bulk" -- as long-term averages; the values at some particular position of the teeth may be different.

It is in fact possible to choose tooth shapes that will result in the velocity ratio also being absolutely constant -- in the short term as well as the long term. In good quality gears this is usually done, since velocity ratio fluctuations cause undue vibration, and put additional stress on the teeth, which can cause tooth breakage under heavy loads at high speed. Constant velocity ratio may also be desirable for precision in instrumentation gearing, clocks and watches. The involute tooth shape is one that results in a constant velocity ratio, and is the most commonly used of such shapes today.

Comparison with other drive mechanisms

The definite velocity ratio which results from having teeth gives gears an advantage over other drives (such as traction drives and V-belts) in

34 precision machines such as watches that depend upon an exact velocity ratio. In cases where driver and follower are in close proximity gears also have an advantage over other drives in the reduced number of parts required; the downside is that gears are more expensive to manufacture and their lubrication requirements may impose a higher operating cost.

The automobile transmission allows selection between gears to give various mechanical advantages.

Spur gears Spur gears are the simplest, and probably most common, type of gear. Their general form is a cylinder or disk. The teeth project radially, and with these "straight-cut gears", the leading edges of the teeth are aligned parallel to the axis of rotation. These gears can only mesh correctly if they are fitted to parallel axles.[2]

Helical gears

Intermeshing gears in motion

Unlike most gears, an internal gear (shown here) does not cause direction reversal.

35 Helical gears from a Meccano construction set.

Helical gears offer a refinement over spur gears. The leading edges of the teeth are not parallel to the axis of rotation, but are set at an angle. Since the gear is curved, this angling causes the tooth shape to be a segment of a helix. The angled teeth engage more gradually than do spur gear teeth. This causes helical gears to run more smoothly and quietly than spur gears. Helical gears also offer the possibility of using non-parallel shafts. A pair of helical gears can be meshed in two ways: with shafts oriented at either the sum or the difference of the helix angles of the gears. These configurations are referred to as parallel or crossed, respectively. The parallel configuration is the more mechanically sound. In it, the helices of a pair of meshing teeth meet at a common tangent, and the contact between the tooth surfaces will, generally, be a curve extending some distance across their face widths. In the crossed configuration, the helices do not meet tangentially, and only point contact is achieved between tooth surfaces. Because of the small area of contact, crossed helical gears can only be used with light loads.

36 Quite commonly, helical gears come in pairs where the helix angle of one is the negative of the helix angle of the other; such a pair might also be referred to as having a right handed helix and a left handed helix of equal angles. If such a pair is meshed in the 'parallel' mode, the two equal but opposite angles add to zero: the angle between shafts is zero -- that is, the shafts are parallel. If the pair is meshed in the 'crossed' mode, the angle between shafts will be twice the absolute value of either helix angle.

Note that 'parallel' helical gears need not have parallel shafts -- this only occurs if their helix angles are equal but opposite. The 'parallel' in 'parallel helical gears' must refer, if anything, to the (quasi) parallelism of the teeth, not to the shaft orientation.

As mentioned at the start of this section, helical gears operate more smoothly than do spur gears. With parallel helical gears, each pair of teeth first make contact at a single point at one side of the gear wheel; a moving curve of contact then grows gradually across the tooth face. It may span the entire width of the tooth for a time. Finally, it recedes until the teeth break contact at a single point on the opposite side of the wheel. Thus force is taken up and released gradually. With spur gears, the situation is quite different. When a pair of teeth meet, they immediately make line contact across their entire width. This causes impact stress and noise. Spur gears make a characteristic whine at high speeds and can not take as much torque as helical gears because their teeth are receiving impact blows. Whereas spur gears are used for low speed applications and those situations where noise control is not a problem, the use of helical gears is indicated when the application

37 involves high speeds, large power transmission, or where noise abatement is important. The speed is considered to be high when the pitch line velocity (that is, the circumferential velocity) exceeds 5000 ft/min.[3] A disadvantage of helical gears is a resultant thrust along the axis of the gear, which needs to be accommodated by appropriate thrust bearings, and a greater degree of sliding friction between the meshing teeth, often addressed with specific additives in the lubricant.

[edit] Double helical gears

Double helical gears, invented by André Citroën and also known as herringbone gears, overcome the problem of axial thrust presented by 'single' helical gears by having teeth that set in a 'V' shape. Each gear in a double helical gear can be thought of as two standard, but mirror image, helical gears stacked. This cancels out the thrust since each half of the gear thrusts in the opposite direction. They can be directly interchanged with spur gears without any need for different bearings.

Where the oppositely angled teeth meet in the middle of a herringbone gear, the alignment may be such that tooth tip meets tooth tip, or the alignment may be staggered, so that tooth tip meets tooth trough. The latter type of alignment results in what is known as a Wuest type herringbone gear.

With the older method of fabrication, herringbone gears had a central channel separating the two oppositely-angled courses of teeth. This was necessary to permit the shaving tool to run out of the groove. The

38 development of the Sykes gear shaper now makes it possible to have continuous teeth, with no central gap.

Bevel gears

Bevel gear used to lift floodgate by means of central screw. Main article: Bevel gear

Bevel gears are essentially conically shaped, although the actual gear does not extend all the way to the vertex (tip) of the cone that bounds it. With two bevel gears in mesh, the vertices of their two cones lie on a single point, and the shaft axes also intersect at that point. The angle between the shafts can be anything except zero or 180 degrees. Bevel gears with equal numbers of teeth and shaft axes at 90 degrees are called miter gears.

The teeth of a bevel gear may be straight-cut as with spur gears, or they may be cut in a variety of other shapes. 'Spiral bevel gears' have teeth that are both curved along their (the tooth's) length; and set at an angle, analogously to the way helical gear teeth are set at an angle compared to spur gear teeth. 'Zero bevel gears' have teeth which are curved along their length, but not angled. Spiral bevel gears have the same advantages and disadvantages relative to their straight-cut cousins as helical gears do to spur gears. Straight bevel gears are generally used

39 only at speeds below 5 m/s (1000 ft/min), or, for small gears, 1000 r.p.m.

[4]

Crown gear

A crown gear

A crown gear or contrate gear is a particular form of bevel gear whose teeth project at right angles to the plane of the wheel; in their orientation the teeth resemble the points on a crown. A crown gear can only mesh accurately with another bevel gear, although crown gears are sometimes seen meshing with spur gears. A crown gear is also sometimes meshed with an escapement such as found in mechanical clocks.

[edit] Hypoid gears Main article: Hypoid Hypoid gears resemble spiral bevel gears, except that the shaft axes are offset, not intersecting. The pitch surfaces appear conical but, to compensate for the offset shaft, are in fact hyperboloids of revolution. [citation needed] Hypoid gears are almost always designed to operate with shafts at 90 degrees. Depending on which side the shaft is offset to, relative to the angling of the teeth, contact between hypoid gear teeth may be even smoother and more gradual than with spiral bevel gear teeth. Also, the pinion can be designed with fewer teeth than a spiral bevel pinion, with the result that gear ratios of 60:1 and higher are "entirely feasible" using a single set of hypoid gears.[5]

40 Worm gear

A worm and gear from a Meccano construction set Main article: Worm gear A worm is a gear that resembles a screw. It is a species of helical gear, but its helix angle is usually somewhat large(ie., somewhat close to 90 degrees) and its body is usually fairly long in the axial direction; and it is these attributes which give it its screw like qualities. A worm is usually meshed with an ordinary looking, disk-shaped gear, which is called the "gear", the "wheel", the "worm gear", or the "worm wheel". The prime feature of a worm-and-gear set is that it allows the attainment of a high gear ratio with few parts, in a small space. Helical gears are, in practice, limited to gear ratios of 10:1 and under; worm gear sets commonly have gear ratios between 10:1 and 100:1, and occasionally 500:1.[6] In worm-and-gear sets, where the worm's helix angle is large, the sliding action between teeth can be considerable, and the resulting frictional loss causes the efficiency of the drive to be usually less than 90 percent, sometimes less than 50 percent, which is far less than other types of gears.

41 The distinction between a worm and a helical gear is made when at least one tooth persists for a full 360 degree turn around the helix. If this occurs, it is a 'worm'; if not, it is a 'helical gear'. A worm may have as few as one tooth. If that tooth persists for several turns around the helix, the worm will appear, superficially, to have more than one tooth, but what one in fact sees is the same tooth reappearing at intervals along the length of the worm. The usual screw nomenclature applies: a one- toothed worm is called "single thread" or "single start"; a worm with more than one tooth is called "multiple thread" or "multiple start".

We should note that the helix angle of a worm is not usually specified. Instead, the lead angle, which is equal to 90 degrees minus the helix angle, is given.

In a worm-and-gear set, the worm can always drive the gear. However, if the gear attempts to drive the worm, it may or may not succeed. Particularly if the lead angle is small, the gear's teeth may simply lock against the worm's teeth, because the force component circumferential to the worm is not sufficient to overcome friction. Whether this will happen depends on a function of several parameters; however, an approximate rule is that if the tangent of the lead angle is greater than the coefficient of friction, the gear will not lock.[8] Worm-and-gear sets that do lock in the above manner are called "self locking". The self locking feature can be an advantage, as for instance when it is desired to set the position of a mechanism by turning the worm and then have the mechanism hold that position. An example of this is the tuning mechanism on some types of stringed instruments.

42 If the gear in a worm-and-gear set is an ordinary helical gear only point contact between teeth will be achieved.[9] If medium to high power transmission is desired, the tooth shape of the gear is modified to achieve more intimate contact with the worm thread. A noticeable feature of most such gears is that the tooth tops are concave, so that the gear partly envelopes the worm. A further development is to make the worm concave (viewed from the side, perpendicular to its axis) so that it partly envelopes the gear as well; this is called a cone-drive or Hindley worm.

Helical and Worm Hand,

A right hand helical gear or right hand worm is one in which the teeth twist clockwise as they recede from an observer looking along the axis. The designations, right hand and left hand, are the same as in the long established practice for screw threads, both external and internal. Two external helical gears operating on parallel axes must be of opposite hand. An internal helical gear and its pinion must be of the same hand.

A left hand helical gear or left hand worm is one in which the teeth twist counterclockwise as they recede from an observer looking along the axis.[11]

43 Rack and pinion

Rack and pinion animation Main article: Rack and pinion

A rack is a toothed bar or rod that can be thought of as a sector gear with an infinitely large radius of curvature. Torque can be converted to linear force by meshing a rack with a pinion: the pinion turns; the rack moves in a straight line. Such a mechanism is used in automobiles to convert the rotation of the steering wheel into the left-to-right motion of the tie rod(s). Racks also feature in the theory of gear geometry, where, for instance, the tooth shape of an interchangeable set of gears may be specified for the rack (infinite radius), and the tooth shapes for gears of particular actual radii then derived from that.

[edit] External vs. internal gears An external gear is one with the teeth formed on the outer surface of a cylinder or cone. Conversely, an internal gear is one with the teeth formed on the inner surface of a cylinder or cone. For bevel gears, an internal gear is one with the pitch angle exceeding 90 degrees.

Electronic Portion

44 CHAPTER – 5 POWER SUPPLY DIAGRAM WITH FOUR DIODE

WORKING All most all types of electronics circuit need a source of DC supply for their operation. As that can be obtained by storage cell are very expensive and convenient but have advantage of being portable and ripple fraction however their current is low and voltage are low so they need frequency replacement so to overcome this we have converted our AC 220V to different less voltage output in our circuit we have use two types of supplies. One is 6V and other is 12V. By using step-down transformer we have step-down double AC and by using two diodes we have converted AC into DC. And filtering by 10000uF capacitor. We have regulator it by regulator IC and thus taking O/P regulated DC supply for 12V. We have use 7812 regulating IC respectively.

45 Receiver TSop Photo Modules for PCM Remote Control Systems Available types for different carrier frequencies Type fo Type fo TSOP1730 30 kHz TSOP1733 33 kHz TSOP1736 36 kHz TSOP1737 36.7 kHz TSOP1738 38 kHz TSOP1740 40 kHz TSOP1756 56 kHz

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. 94 8691 GND

46 VS OUT 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 Block Diagram

TSOP17.. Vishay Telefunken Rev. 10, 02-Apr-01 www.vishay.com Document Number 82030 2 (7) Absolute Maximum Ratings

47 Basic Characteristics Tamb = 25_C

Application Circuit

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.

48 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 neccessary. 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, R–2000 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 occure. 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 38kHz or at any other frequency Signals from fluorescent lamps with electronic ballast (an example of the signal modulation is in the figure below). 0 5 10 15 20 time [ms] IR Signal from Fluorescent Lamp with low Modulation

49 CHAPTER – 6 MICROCONTROLLER

WELCOME TO THE WORLD OF THE MICROCONTROLLERS.

Look around. Notice the smart “intelligent” systems? Be it the T.V, washing machines, video games, telephones, automobiles, aero planes, power systems, or any application having a LED or a LCD as a user interface, the control is likely to be in the hands of a micro controller!

Measure and control, that’s where the micro controller is at its best.

Micro controllers are here to stay. Going by the current trend, it is obvious that micro controllers will be playing bigger and bigger roles in the different activities of our lives.

These embedded chips are very small, but are designed to replace components much bigger and bulky In size. They process information very intelligently and efficiently. They sense the environment around them. The signals they gather are tuned into digital data that streams through tributaries of circuit lines at the speed of light. Inside the microprocessor collates and calculators. The software has middling intelligence. Then in a split second, the processed streams are shoved out.

What is the primary difference between a microprocessor and a micro controller?

Unlike the microprocessor, the micro controller can be considered to be a true “Computer on a chip”.

In addition to the various features like the ALU, PC, SP and registers found on a microprocessor, the micro controller also incorporates features like the ROM, RAM, Ports, timers, clock circuits, counters, reset functions etc.

50 While the microprocessor is more a general-purpose device, used for read, write and calculations on data, the micro controller, in addition to the above functions also controls the environment.

89S52 micro controller

The 89S52

The 89S52 developed and launched in the early 80`s, is one of the most popular micro controller in use today. It has a reasonably large amount of built in ROM and RAM. In addition it has the ability to access external memory.

The generic term `8x51` is used to define the device. The value of x defining the kind of ROM, i.e. x=0, indicates none, x=3, indicates mask ROM, x=7, indicates EPROM and x=9 indicates EEPROM or Flash.

A note on ROM

51 The early 89S52, namely the 8031 was designed without any ROM. This device could run only with external memory connected to it. Subsequent developments lead to the development of the PROM or the programmable ROM. This type had the disadvantage of being highly unreliable.

The next in line, was the EPROM or Erasable Programmable ROM. These devices used ultraviolet light erasable memory cells. Thus a program could be loaded, tested and erased using ultra violet rays. A new program could then be loaded again.

An improved EPROM was the EEPROM or the electrically erasable PROM. This does not require ultra violet rays, and memory can be cleared using circuits within the chip itself.

Finally there is the FLASH, which is an improvement over the EEPROM. While the terms EEPROM and flash are sometimes used interchangeably, the difference lies in the fact that flash erases the complete memory at one stroke, and not act on the individual cells. This results in reducing the time for erasure.

Different microcontrollers in market.

 PIC One of the famous microcontrollers used in the industries. It is based on RISC Architecture which makes the microcontroller process faster than other microcontroller.

 INTEL These are the first to manufacture microcontrollers. These are not as sophisticated other microcontrollers but still the easiest one to learn.

 ATMEL Atmel’s AVR microcontrollers are one of the most powerful in the embedded industry. This is the only microcontroller having 1kb of ram even the entry stage. But it is unfortunate that in India we are unable to find this kind of microcontroller.

52 Intel 89S52

Intel 89S52 is CISC architecture which is easy to program in assembly language and also has a good support for High level languages.

The memory of the microcontroller can be extended up to 68K.

This microcontroller is one of the easiest microcontrollers to learn.

The 89S52 microcontroller is in the field for more than 20 years. There are lots of books and study materials are readily available for 89S52.

Derivatives

The best thing done by Intel is to give the designs of the 89S52 microcontroller to everyone. So it is not the fact that Intel is the only manufacture for the 89S52 there more than 20 manufactures, with each of minimum 20 models. Literally there are hundreds of models of 89S52 microcontroller available in market to choose. Some of the major manufactures of 89S52 are

 Atmel

 Philips

Philips The Philips‘s 89S52 derivatives has more number of features than in any microcontroller. The costs of the Philips microcontrollers are higher than the Atmel’s which makes us to choose Atmel more often than Philips

53 Dallas Dallas has made many revolutions in the semiconductor market. Dallas’s 89S52 derivative is the fastest one in the market. It works 3 times as fast as a 89S52 can process. But we are unable to get more in India.

Atmel These people were the one to master the flash devices. They are the cheapest microcontroller available in the market. Atmel’s even introduced a 20pin variant of 89S52 named 2051. The Atmel’s 89S52 derivatives can be got in India less than 70 rupees. There are lots of cheap programmers available in India for Atmel. So it is always good for students to stick with 89S52 when you learn a new microcontroller.

The 89S52 doesn’t have any special feature than other microcontroller. The only feature is that it is easy to learn. Architecture makes us to know about the hardware features of the microcontroller. The features of the 89S52 are

. 8K Bytes of Flash Memory . 256 x 8-Bit Internal RAM . Fully Static Operation: 1 MHz to 24 MHz . 32 Programmable I/O Lines . Two 16-Bit Timer/Counters . Six Interrupt Sources (5 Vectored) . Programmable Serial Channel . Low Power Idle and Power Down Modes

The 89S52 has a 8-Bit CPU that means it is able to process 8 bit of data at a time. 89S52 has 235 instructions. Some of the important registers and their functions are

Let’s now move on to a practical example. We shall work on a simple practical application and using the example as a base, shall explore the various features of the 89S52 microcontroller.

54 Consider an electric circuit as follows,

The positive side (+ve) of the battery is connected to one side of a switch. The other side of the switch is connected to a bulb or LED (Light Emitting Diode). The bulb is then connected to a resistor, and the other end of the resistor is connected to the negative (-ve) side of the battery.

When the switch is closed or ‘switched on’ the bulb glows. When the switch is open or ‘switched off’ the bulb goes off

If you are instructed to put the switch on and off every 30 seconds, how would you do it? Obviously you would keep looking at your watch and every time the second hand crosses 30 seconds you would keep turning the switch on and off.

Imagine if you had to do this action consistently for a full day. Do you think you would be able to do it? Now if you had to do this for a month, a year??

No way, you would say!

The next step would be, then to make it automatic. This is where we use the Microcontroller.

But if the action has to take place every 30 seconds, how will the microcontroller keep track of time?

Execution time

Look at the following instruction, clr p1.0

55 This is an assembly language instruction. It means we are instructing the microcontroller to put a value of ‘zero’ in bit zero of port one. This instruction is equivalent to telling the microcontroller to switch on the bulb. The instruction then to instruct the microcontroller to switch off the bulb is,

Set p1.0

This instructs the microcontroller to put a value of ‘one’ in bit zero of port one.

Don’t worry about what bit zero and port one means. We shall learn it in more detail as we proceed.

There are a set of well defined instructions, which are used while communicating with the microcontroller. Each of these instructions requires a standard number of cycles to execute. The cycle could be one or more in number.

How is this time then calculated?

The speed with which a microcontroller executes instructions is determined by what is known as the crystal speed. A crystal is a component connected externally to the microcontroller. The crystal has different values, and some of the used values are 6MHZ, 10MHZ, and 11.059 MHz etc. Thus a 10MHZ crystal would pulse at the rate of 10,000,000 times per second.

The time is calculated using the formula

No of cycles per second = Crystal frequency in HZ / 12.

For a 10MHZ crystal the number of cycles would be,

56 10,000,000/12=833333.33333 cycles.

This means that in one second, the microcontroller would execute 833333.33333 cycles.

Therefore for one cycle, what would be the time? Try it out.

The instruction clr p1.0 would use one cycle to execute. Similarly, the instruction setb p1.0 also uses one cycle.

So go ahead and calculate what would be the number of cycles required to be executed to get a time of 30 seconds!

Getting back to our bulb example, all we would need to do is to instruct the microcontroller to carry out some instructions equivalent to a period of 30 seconds, like counting from zero upwards, then switch on the bulb, carry out instructions equivalent to 30 seconds and switch off the bulb.

Just put the whole thing in a loop, and you have a never ending on-off sequence.

Let us now have a look at the features of the 89S52 core, keeping the above example as a reference,

1. 8-bit CPU.( Consisting of the ‘A’ and ‘B’ registers)

Most of the transactions within the microcontroller are carried out through the ‘A’ register, also known as the Accumulator. In addition all arithmetic functions are carried out generally in the ‘A’ register. There is another register known as the ‘B’ register, which is used exclusively for multiplication and division.

Thus an 8-bit notation would indicate that the maximum value that can be input into these registers is ‘11111111’. Puzzled?

The value is not decimal 111, 11,111! It represents a binary number, having an equivalent value of ‘FF’ in Hexadecimal and a value of 255 in decimal.

We shall read in more detail on the different numbering systems namely the

57 Binary and Hexadecimal system in our next module.

2. 8K on-chip ROM

Once you have written out the instructions for the microcontroller, where do you put these instructions?

Obviously you would like these instructions to be safe, and not get deleted or changed during execution. Hence you would load it into the ‘ROM’

The size of the program you write is bound to vary depending on the application, and the number of lines. The 89S52 microcontroller gives you space to load up to 8K of program size into the internal ROM.

8K, that’s all? Well just wait. You would be surprised at the amount of stuff you can load in this 8K of space.

Of course you could always extend the space by connecting to 68K of external ROM if required.

3. 256 bytes on-chip RAM

This is the space provided for executing the program in terms of moving data, storing data etc.

4. 32 I/O lines. (Four- 8 bit ports, labeled P0, P1, P2, P3)

In our bulb example, we used the notation p1.0. This means bit zero of port one. One bit controls one bulb.

Thus port one would have 8 bits. There are a total of four ports named p0, p1, p2, p3, giving a total of 32 lines. These lines can be used both as input or output.

5. Two 16 bit timers / counters.

A microcontroller normally executes one instruction at a time. However certain applications would require that some event has to be tracked independent of the main program.

58 The manufacturers have provided a solution, by providing two timers. These timers execute in the background independent of the main program. Once the required time has been reached, (remember the time calculations described above?), they can trigger a branch in the main program.

These timers can also be used as counters, so that they can count the number of events, and on reaching the required count, can cause a branch in the main program.

6. Full Duplex serial data receiver / transmitter.

The 89S52 microcontroller is capable of communicating with external devices like the PC etc. Here data is sent in the form of bytes, at predefined speeds, also known as baud rates.

The transmission is serial, in the sense, one bit at a time

7. 5- interrupt sources with two priority levels (Two external and three internal)

During the discussion on the timers, we had indicated that the timers can trigger a branch in the main program. However, what would we do in case we would like the microcontroller to take the branch, and then return back to the main program, without having to constantly check whether the required time / count has been reached?

This is where the interrupts come into play. These can be set to either the timers, or to some external events. Whenever the background program has reached the required criteria in terms of time or count or an external event, the branch is taken, and on completion of the branch, the control returns to the main program.

Priority levels indicate which interrupt is more important, and needs to be executed first in case two interrupts occur at the same time.

8. On-chip clock oscillator.

This represents the oscillator circuits within the microcontroller. Thus the

59 hardware is reduced to just simply connecting an external crystal, to achieve the required pulsing rate.

Description The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications. Features • Compatible with MCS-51™ Products • 4K Bytes of In-System Reprogrammable Flash Memory – Endurance: 1,000 Write/Erase Cycles • Fully Static Operation: 0 Hz to 24 MHz • Three-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 Channel • Low-power Idle and Power-down Modes

PIN Diagram of 89S52

60 61 62 Pin Description VCC Supply voltage. GND Ground. Port 0 Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 may also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. In this mode P0 has internal pullups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pullups are required during program verification. Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 1 also receives the low-order address bytes during Flash programming and verification. Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pullups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pullups and can bPort 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, it uses strong internal pullups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the

63 contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups. Port 3 also serves the functions of various special features of the AT89S52 as listed below: Port Pin Alternate Functions P3.0 RXD (serial input port) P3.1 TXD (serial output port) P3.2 INT0 (external interrupt 0) P3.3 INT1 (external interrupt 1) P3.4 T0 (timer 0 external input) P3.5 T1 (timer 1 external input) P3.6 WR (external data memory write strobe) P3.7 RD (external data memory read strobe) Port 3 also receives some control signals for Flash programming and verification. RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. ALE/PROG Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, pulse is skipped during each access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no

64 effect if the microcontroller is in external execution mode. PSEN Program Store Enable is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier. that one ALEunconnected while XTAL1 is driven as shown in Figure 2. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed

CHAPTER – 7 Motor Drive Circuit

65 Working :-

In this we use two optocouplers and four transistors ( two NPN and Two PNP). Circuit of transistor is known as H- Bridge circuit.

Optocoupler:-

Pin No. 1 of both ICs are connected with positive supply and Pin No. 2 of both ICs are connrcted with the output of Microcontroller. Pin no. 4 of ICs are connected with supply throught a 470 ohm resistance and Pin No. 3 is grounded. Pin No. 1 & 2 contains LED and Pin No. 3 & 4 Contain receiver for detecting the light of LED and it works as a Transistors.

H-Bridge Circuit:-

We use two npn and two pnp diodes. Collector of pnp diodes are connected with negative supply and collector of npn diodes are connected with positive supply. Base of one npn and one pnp is connected with the pin no. 4 of 1st optocoupler through a 1 K resistance. Base of other transistor are connected

66 with the pin 4 of 2nd IC. Now emitter of one pair of different transistors are connected with one terminal of motor and 2nd terminal of motor is connected with other transisitor’s emitter.

Working:-

Inb the normal condition microcontroller gives the high output to pin no. 2 of both ICs and pin no. 1 is already connected with positive supply so both LEDs will not work hence voltage on both pairs of transistors will be high. Due high on both pair H-Bridge circuit will not work. Now one IR sensor will ground the input of Microcontroller hence one pin of microcontroller goes to low at output. So due to this pin no.2 of one IC will go to low and one high. Low pin of one IC glow the LED hence receiver of one IC will hence it will ground the positive supply so voltage at the base of one pair transistor will be low.So for low voltage one pnp transistor will work and gives the low voltage to motor at one point and at this time for high voltage at the other pair npn transistor will work and it gives the high voltage to motor at 2nd point so mpotor will rotate in one direction.

In 2nd condition 2nd IR sensor will work hence pin no 2 of second IC becomes low and of 1st Ic becomes high. So second IC will work like first IC and First Ic will Work like second IC which was in First condition. So due to this voltage polarity at the both pairs of base of all Tarnsistors gets changes and other left transistor will work. So they will change the polarity of motor hence motor will rotate and opposite direction.

Reset Circuitry:

As soon as you give the power supply the 8051 doesn’t start. You need to restart for the microcontroller to start. Restarting the microcontroller is nothing but giving a Logic 1 to the reset pin at least for the 2 clock pulses.

67 So it is good to go for a small circuit which can provide the 2 clock pulses as soon as the microcontroller is powered.

This is not a big circuit we are just using a capacitor to charge the microcontroller and again discharging via resistor.

Crystals

68 Crystals provide the synchronization of the internal function and to the peripherals. Whenever ever we are using crystals we need to put the capacitor behind it to make it free from noises. It is good to go for a 33pf capacitor.

We can also resonators instead of costly crystal which are low cost and external capacitor can be avoided.

But the frequency of the resonators varies a lot. And it is strictly not advised when used for communications projects.

Using Keil C.

There is nothing much different from the Turbo C we used and Keil C we are going to use. The only difference is that we need to change the header file of the microcontroller we are going to use.

69 #include

Here in the above code I was using At89c51 so I am including this file for compiling.

After including the file we must declare main function and start writing the code.

#include void main() { int i; while(1){ for (i = 0;i< 9000;i++) P1_1=0; for (i = 0;i< 9000;i++) P1_1=1; } }

DC Motor

70 These are the motors that are commonly found in the toys and the tape recorders. These motors change the direction of rotation by changing the polarity. Most chips can't pass enough current or voltage to spin a motor.

Also, motors tend to be electrically noisy (spikes) and can slam power back into the control lines when the motor direction or speed is changed.

Specialized circuits (motor drivers) have been developed to supply motors with power and to isolate the other ICs from electrical problems. These circuits can be designed such that they can be completely separate boards, reusable from project to project.

A very popular circuit for driving DC motors (ordinary or gearhead) is called an H-bridge. It's called that because it looks like the capital letter 'H' on classic schematics. The great ability of an H-bridge circuit is that the motor can be driven forward or backward at any speed, optionally using a completely independent power source.

The H-Bridge Circuit

71 This circuit known as the H-bridge (named for its topological similarity to the letter "H") is commonly used to drive motors. In this circuit two of four transistors are selectively enabled to control current flow through a motor.

72 opposite pair of transistors (Transistor One and Transistor Three) is enabled, allowing current to flow through the motor. The other pair is disabled, and can be thought of as out of the circuit.

By determining which pair of transistors is enabled, current can be made to flow in either of the two directions through the motor. Because permanent- magnet motors reverse their direction of turn when the current flow is reversed, this circuit allows bidirectional control of the motor.

The H-Bridge with Enable Circuitry

73 It should be clear that one would never want to enable Transistors One and

Two or Transistors Three and Four simultaneously. This would cause current to flow from Power + to Power - through the transistors, and not the motors, at the maximum current-handling capacity of either the power supply or the transistors. This usually results in failure of the H-Bridge. To prevent the possibility of this failure, enable circuitry as depicted in Figure is typically used.

In this circuit, the internal inverters ensure that the vertical pairs of transistors are never enabled simultaneously. The Enable input determines

74 whether or not the whole circuit is operational. If this input is false, then none of the transistors are enabled, and the motor is free to coast to a stop.

By turning on the Enable input and controlling the two Direction inputs, the motor can be made to turn in either direction.

Note that if both direction inputs are the same state (either true or false) and the circuit is enabled, both terminals will be brought to the same voltage

(Power + or Power - , respectively). This operation will actively brake the motor, due to a property of motors known as back emf, in which a motor that is turning generates a voltage counter to its rotation. When both terminals of the motor are brought to the same electrical potential, the back emf causes resistance to the motor's rotation.

Stepper motors

Stepper motors are special kind of heavy duty motors having 2 or 4 coils.

The motors will be stepping each time when it get the pulse. As there are many coils in the motors we need to energize the coils in a specific sequence for the rotation of the motor. These motors are mostly used in heavy machines. The figure shown below consists of a 4 coil stepper motor and the arrow mark will rotate when the coils are energized in the sequence.

75 Unlike DC motors stepper motors can be turned accurately for the given degrees.

Servo motors

Servo motors unlike the stepper motor it has to be controlled by the timing signal. This motor has only one coil. It is mostly used in train s for its lightweight and low power consumption. The servo motors can also be accurately rotated by the making the control signal of the servo motor high for a specific time period. Actually the servo motor will be having 3 wires where 2 are for power supply and another one is for the control signal.

Driving the servomotors is so simple that you need to make the control

76 signal high for the specific amount of time. The width of the pulse determines the output position of the shaft

Object Detection

Detecting objects without whiskers doesn’t require anything as sophisticated as machine vision. Some train s use RADAR or SONAR (sometimes called

SODAR when used in air instead of water). An even simpler system is to use infrared light to illuminate the train ’s path and determine when the light reflects off an object.The IR illuminators and detectors are readily available and inexpensive.

Infrared As Headlights

The infrared object detection system we’ll build on the Bot is like a car’s headlights in several respects. When the light from a car’s headlights reflects off obstacles, your eyes detect the obstacles and your brain processes them and makes your body guide the car accordingly. We will be using infrared

LEDs for headlights. They emit infrared, and in some cases, the infrared reflects off objects and bounces back in the direction of the detecter. The

77 eyes of the Bot( mobile) are the infrared detectors. The infrared detectors send signals to the Microcontroller indicating whether or not they detect infrared reflected off an object. The brain of the Bot, the microcontroller makes decisions and operates the motors based on this sensor input.

CHAPTER - 9

78 CIRCUIT DIAGRAM

79 WORKING First of all we give a 12 volt supply to the train then power supply circuit will convert it in 5 volt which is required for microcontroller and all parts of circuit. this supply goes to microcontroller. Positive voltage at 40 no. pin and 20 no. is connected with Ground. We give a 5 volt supply at pin no. 9 for reset purpose through a reset circuit. Reset circuit is constructed by 10uF capacitor and 10 K resistance. Pin no, 18 and 19 is connected with 12 Mhz crystal oscillator and 2 ceramic capacitor respected the ground. Now we use a TSOP 1738 of which pin no. 1 is connected with GND and 2nd pin is connected with Positive 5 volt. It gives output at pin no. 3 which is connected with P3.3 which receives the data in serial form. After this programming works and gives output at port 2. Port 2 is connected with motor circuit. One motor circuit is connected with P2.0 and P2.1 and second motor is connected with P2.2 and P2.3. for forward direction MCU gives low at P2.0 and P2.2 and high at other two pins. Due to this both motors will rotate in same direction. To understand this functioning of motors above working of motor circuit is descrived. For reverse direction P2.1 and P2.3 goes low and respectively P2.0 and P2.2 goes high so both motors will rotate same but in different direction as that of previous direction. For left or right turning of train we give low signal at Pin no. P2.0 and P2.3 or P2.1 and P2.2. due to this both motors will rotate in opposite direction hence train will turn in one direction. To control the function of stop we use IR transmitter and receiver at front of Train. IR transmitter is connected with 5 volt supply through a 100 ohm resitance permanently. IR receiver used as a switching circuit for microcontroller. First of all we provide 5 volt supply at P1.0 through 10 k resistor and also we connect IR reciver at this pin without any resistance. So

80 when receiver detect the rays ( which are reflected by other train In the front of main train) provide low signal to the microcontroller. So its starts its programming working and provide high signal at all pins of motor circuit and that happen motor get stop. To movement of this train we use wheels direct with motor or in some situations gears are used with motor and wheel to create torque and speed of train .

Programming

/

*************************************************************

********ir train new modified

*************************************************************

*********/

VAR1 equ r7 ;Temporary Variable

TEMP equ 10H ;Temp variable

COUNT equ 11H ;Count

ADDR equ 12H ;Device address

CMD equ 13H ;Command

FLIP bit 00H ;Flip bit

81 TOG bit 01H ;Temp bit for flip

IR equ P3.3 ;IR Receiver connected to this pin

SW1 equ P2.0 ;Switch 1 connected here

SW2 equ P2.1 ;Switch 2 connected here

SW3 equ P2.2 ;Switch 3 connected here

SW4 equ P2.3 ;Switch 4 connected here

SW5 equ P2.4 ;Switch 5 connected here

SW6 equ P2.5 ;Switch 6 connected here

SW7 equ P2.6 ;Switch 7 connected here

SW8 equ P2.7 ;Switch 8 connected here

SWport equ P1 ;Port at which switches are connected

org 00H ;Start of prog

main: nop

fcmd:

82 nvalid: ljmp main valid: ;Key press check clr a mov c,FLIP rlc a mov TEMP,a clr a mov c,TOG rlc a cjne a,TEMP,valid1 sjmp nvalid valid1: mov c,FLIP mov TOG,c mov a,CMD clr c cjne a,#1,skip1 ;Check for SW1

acall moto1

83 ljmp main isset1: clr SW1 ljmp main moto1: clr p2.0 setb p2.1 clr p2.2 setb p2.3 acall delay

acall delay setb p2.0 setb p2.1

setb p2.2 setb p2.3 ret skip1: cjne a,#2,skip2 ;Check for SW2

84 acall moto2 ljmp main isset2: clr SW2 ljmp main moto2: setb p2.0 clr p2.1 setb p2.2 clr p2.3 acall delay acall delay

setb p2.0 setb p2.1 setb p2.2 setb p2.3

ret

85 skip2: cjne a,#3,skip3 ;Check for SW3 acall moto3 ljmp main isset3: clr SW3 ljmp main

moto3: clr p2.0 setb p2.1 setb p2.2 clr p2.3 acall delay acall delay setb p2.0 setb p2.1 setb p2.2 setb p2.3

86 ret skip3: cjne a,#4,skip4 ;Check for SW4 acall moto4 ljmp main isset4: clr SW4 ljmp main moto4: setb p2.0 clr p2.1 clr p2.2 setb p2.3 acall delay acall delay setb p2.2 setb p2.3 setb p2.0 setb p2.1

87 ret skip4: cjne a,#5,skip5 ;Check for SW5 acall moto5 ljmp main isset5: clr SW5 ljmp main moto5: setb p2.4 clr p2.5 acall delay

setb p2.4 setb p2.5

ret skip5: cjne a,#6,skip6 ;Check for SW6

88 acall moto6 ljmp main isset6: clr SW6 ljmp main moto6: clr p2.4 setb p2.5 acall delay

setb p2.4 setb p2.5

ret skip6: cjne a,#7,skip7 ;Check for SW7 jb SW7,isset7 setb SW7 ljmp main isset7:

89 clr SW7 ljmp main skip7: cjne a,#8,skip8 ;Check for SW8 jb SW8,isset8 setb SW8 ljmp main isset8: clr SW8 ljmp main skip8: cjne a,#0CH,exit ;Check for all switches mov SWport,#00H ljmp main exit: ljmp main delay: acall delay1 acall delay1 acall delay1

90 acall delay1 acall delay1

ret delay1:

MOV R6,#255

AGAIN22: MOV R7,#255

BACK22: DJNZ R7,BACK22

DJNZ R6,AGAIN22

RET

END ;End of program

91 CHAPTER – 10 ADVANTAGES

92 CHAPTER – 11 DISADVANTAGES

CHAPTER – 12 APPLICATION

93 CHAPTER – 13 PRECAUTIONS 1. According to circuit all the different components for their services, ability. 2. During soldering on the PCB, one should be very careful regarding short circuit, dry units, etc. 3. Components direction especially electrolytic capacitor, transistor, must be kept in mind for their actual position.

94 4. Put each and every component on the PCB according their actual position. 5. Proper care must be taken by solders on transistor so that these are not to be damaged due to leakage of current. 6. Put each and every component of the same value on the PCB as per diagram.

Bibliography: www.ludhianaprojects.com/train ics http://www.sciencejoywagon.com/physicszone/lesson/otherpub/wfendt/el ectricmotor.htm

95 96 97 98 99