Sie sind auf Seite 1von 71

A Mini Project on

WIRELESS STEPPER MOTOR CONTROL USING IR COMMUNICATION Submitted in partial fulfillment of the requirement for the award of the degree of
Bachelor of Technology in

ELECTRICAL & ELECTRONICS ENGINEERING


Presented by P.Reddy Thejaswini S.Shama C.Jaya Teja J.Kalyan Kumar D.Kavitha ( 08691A0234) (08691A0239) (08691A0213) (08691A0214) (08691A0216)

Under the esteemed guidance of

Mr.C.Kamal Basha

M.E.(Ph.D)

Associate Professor, Department of EEE

DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING MADANAPALLE INSTITUTE OF TECHNOLOGY AND SCIENCE
(Affiliated to Jawaharlal Nehru Technology of University,Anantapur) PB.No.14, Angallu, Madanapalle, Chittoor (Dist),A.P.

MADANAPALLE INSTITUTE OF TECHNOLOGY & SCIENCE


Madanapalle
Department Of Electrical and Electronics Engineering BONAFIED CERTIFICATE This is to certify that this mini project entitled

WIRELESS STEPPER MOTOR CONTROL USING IR COMMUNICATION


is a bonafied work done BY

P.Reddy Thejaswini S.Shama C.Jaya Teja J.Kalyan Kumar D.Kavitha

( 08691A0234) (08691A0239) (08691A0213) (08691A0214) (08691A0216)

Under our guidance & supervision, in partial fulfillment of the requirement for the award of the degree of Bachelor of Technology in Electrical & Electronics Engineering in Madanapalle Institute of Technology and Science, Madanapalle, affiliated to Jawaharlal Nehru Technology University, Anantapur during the academic year 2011-2012. C. Kamal Basha M.E. (Ph.D) Associate Professor of the department Electrical & Electronics Engineering MITS, Madanapalle Submitted for the university examination held on: Dr. C.Sasikala Ph.D Head of the Department Electrical & Electronics Engineering MITS, Madanapalle

EXTERNAL EXAMINER

ACKNOWLEDGEMENT
We feel great pleasure while submitting the project report titled
WIRELESS STEPPER MOTOR CONTROL USING IR COMMUNICATION.

We express our gratitude and esteemed regards to our project guide

Mr.C.Kamal Basha

M.E, (Ph.D) Department of Electrical & Electronic Engineering, for

providing us invaluable gratitude & inspiration in carrying out our project studies. His constant support & encouragement enabled us to complete this work successfully. We take immense pleasure in conveying our sincere thanks to Dr.C.Sasikala
M.E.Ph.D Head of the department of Electrical & Electronics Engineering.

We extend our special thanks to the principal Dr.Sreenivasulu Reddy M.E. Ph.D and the management who supported us in working of the project. We convey our thanks to our beloved parents & our faculty who helped us directly or indirectly in bringing this project successfully.

P.ReddyThejaswini S.Shama C.Jaya Teja J.Kalyan Kumar D.Kavitha

(08691A0234) (08691A0239) (08691A0213) (08691A0214) (08691A0216)

ABSTRACT
Every system is automated in order to face new challenges in the present day situation. Automated systems have less manual operations, so that the flexibility, reliabilities are high and accurate. Hence every field prefers automated control systems. Especially in the field of electronics automated systems are doing better performance.

The goal of the project is to develop a system, which uses IR technology to control the speed and direction of stepper motor. This project is designed around a microcontroller which forms the control unit of the project. There are several applications with dc motors in our daily life. Obviously there exists many applications where there might be a need to control the speed of dc motors. There exist many ways of controlling the speed and direction of stepper motor. Of the available ones, PWM technique is the most efficient one and the same technique is used here in this project. According to this project the person who wants to control the speed and direction of stepper motor is given with a remote. By pressing the keys available on the remote the speed of the stepper motor direction is varied. This is realized with the help of microcontroller.

CONTENTS CHAPTER 1 1.1 Stepper motor 1.12 Stepper motor types 1.2Microcontroller INTRODUCTION

CHAPTER II 2.1 Power supply 2.1.1 Transformer 2.1.2 Rectifier 2.1.3 Filter 2.1.4 Regulator 2.2 Transmitter section 2.2.1 IR encoder 2.2.2 IR transmitter 2.3 Receiver section 2.3.1 IR receiver 2.3.2 IR decoder 2.4 Micro controller 2.5 Liquid Crystal Display 2.5.1 LCD Pin description 2.6 IR module

COMPONENTS DESCRIPTION

2.7 Decoder IR remote control

CHAPTER III 3.1 Block diagram 3.1.1 Block diagram explanation 3.2 Circuit diagram 3.2.1 Transmitter section explanation 3.2.2 Receiver section explanation CHAPTER IV 4.1 Applications 4.2 Future scope CHAPTER V 5.1 Conclusion 5.2 Bibliography CHAPTER VI 6.1 Appendix

WORKING AND MODELLING

LIST OF FIGURES:

FIG.NO 1.1 1.2 1.3 2.1 2.2 2 .3 2.4 2.5 2.6 3.1 3.2 3.3

FIGURE NAME Variable reluctance motor Unipolar motor Bipolar motor Electrical transformer Brigde rectifier Three terminal voltage regulator Functional block diagram of ATMEL Pin diagram of 89s52 LCD connection Block diagram Schematic diagram of transmitter section Schematic diagram of recevier section

PAGE NO

CHAPTER I

INTRODUCTION

INTRODUCTION STEPPER MOTOR:


A Stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical movements.The shaft or spindle of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence.The motors rotation has several direct relationships to these applied input pulses.The sequence of the applied pulses is directly related to the direction of motor shafts rotation.The speed of the motor shafts rotation is directly related to the frequency of the input pulses and the length of rotation is directly related to the number of input pulses applied Stepping motors can be used in simple open-loop control systems; these are generally adequate for systems that operate at low accelerations with static loads, but closed loop control may be essential for high accelerations, particularly if they involve variable loads. If a stepper in an open-loop control system is over torqued, all knowledge of rotor position is lost and the system must be reinitialized; servomotors are not subject to this problem. Stepping motors are known in German as Schrittmotoren, in French as moteurs pas pas, and in Spanish as motor paso paso. Stepper motor control may be based on open loop or closed loop models. We are primarily interested in open loop models, because this is where stepping motors excel, but we will treat closed loop models briefly because they are somewhat simpler.

STEPPER MOTOR TYPES


Stepping motors come in two varieties, permanent magnet and variable. Lacking a Clabel on the motor, We can generally tell the two apart by feel when no power is applied. Permanent magnet motors tend to "cog" as you twist the rotor with your fingers, while variable reluctance motors almost spin freely (although they may cog slightly because of residual magnetization in the rotor). We can also distinguish between the two varieties with an ohmmeter. Variable reluctance motors usually have three (sometimes four) windings, with a common return, while permanent magnet motors usually have two independent windings, with or without center taps. Center-tapped windings are used in uni-polar permanent magnet motors. Stepping motors come in a wide range of angular resolution. The coarsest motors typically turn 90 degrees per

step, while high resolution permanent magnet motors are commonly able to handle 1.8 or even 0.72 degrees per step. With an appropriate controller, most permanent magnet and hybrid motors can be run in half-steps, and some controllers can handle smaller fractional steps or micro-steps. For both permanent magnet and variable reluctance stepping motors, if just one winding of the motor is energized, the rotor (under no load) will snap to a fixed angle and then hold that angle until the torque exceeds the holding torque of the motor, at which point, the rotor will turn, trying to hold at each successive equilibrium point.

Variable Reluctance Motors

1.1 Variable Reluctance motors If motor has three windings, typically connected as shown in the schematic diagram in Figure 1.1, with one terminal common to all windings, it is most likely a variable reluctance stepping motor. In use, the common wire typically goes to the positive supply and the windings are energized in sequence

Permanent magnet motors


Often referred to as a tin can or canstock motor the permanent magnet step motor is a low cost and low resolution type motor with typical step angels of 7.5 to 15 degres(48-24 steps/revolution).PM motors as the names implies have permanent magnets added to the motor structure.The rotor no longer has teeth as with the VR motor.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 characterstics when compared with the VR type.

These are classified in to two types 1)uni polar motor 2)Bipolar motor

Unipolar Motor:

1.2 Unipolar motor

Bipolar Motor:

1.3 Bipolar motor

MICROCONTROLLER:
In this project work the micro-controller is playing a major role. Micro-controllers were originally used as components in complicated process-control systems. However, because of their small size and low price, Micro-controllers are now also being used in regulators for individual control loops. In several areas Micro-controllers are now outperforming their analog counterparts and are cheaper as well. The purpose of this project work is to present control theory that is relevant to the analysis and design of Micro-controller system with an emphasis on basic concept and ideas. It is assumed that a Microcontroller with reasonable software is available for computations and simulations so that many tedious details can be left to the Microcontroller. The control system design is also carried out up to the stage of implementation in the form of controller programs in assembly language OR in C-Language.

CHAPTER II

COMPONENTS DESCRIPTION

COMPONENTS DESCRIPTION
2.1 POWER SUPPLY: The main aim of this power supply is to convert the 230V AC into 5V DC in order to give supply for the TTL or CMOS devices. In this process we are using a step down transformer, a bridge rectifier, a smoothing circuit and the RPS. At the primary of the transformer we are giving the 230V AC supply. The secondary is connected to the opposite terminals of the Bridge rectifier as the input. From other set of opposite terminals we are taking the output to the rectifier. The bridge rectifier converts the AC coming from the secondary of the transformer into pulsating DC. The output of this rectifier is further given to the smoother circuit which is capacitor in our project. The smoothing circuit eliminates the ripples from the pulsating DC and gives the pure DC to the RPS to get a constant output DC voltage. The RPS regulates the voltage as per our requirement.

Transformer:
A transformer is an electrical device which is used to convert electrical power from one electrical circuit to another without change in frequency.Transformers work only with AC and this is one of the reasons why mains electricity is AC. Step-up transformers increase in output voltage, step-down transformers decrease in output voltage. Most power supplies use a stepdown transformer to reduce the dangerously high mains voltage to a safer low voltage. The input coil is called the primary and the output coil is called the secondary. There is no electrical connection between the two coils; instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the power out is (almost) equal to the power in. Note that as voltage is stepped down current is stepped up. The ratio of the number of turns on each coil, called the turns ratio, determines the ratio of the voltages. A stepdown transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage.

2.1 An electrical transformer

Turns ratio = Vp/ VS = Np/NS Power Out= Power In VS X IS=VP X IP Vp = primary (input) voltage Np = number of turns on primary coil Ip = primary (input) current

RECTIFIER:
A circuit which is used to convert a.c to dc is known as RECTIFIER. The process of conversion a.c to d.c is called rectification. TYPES OF RECTIFIERS: Half wave Rectifier Full wave rectifier Centre tap full wave rectifier. Bridge type full bridge rectifier.

Type of Rectifier Parameter Number of diodes 1 PIV of diodes Vm 2Vm Vm 2 4 Half wave Full wave Bridge

D.C output voltage

Vm/

2Vm/

2Vm/

Vdc,at no-load

0.318Vm

0.636Vm

0.636Vm

Ripple factor Ripple Frequency Rectification Efficiency Transformer Utilization Factor(TUF) RMS voltage Vrms

1.21

0.482

0.482

2f

2f

0.406

0.812

0.812

0.287

0.693

0.812

Vm/2

Vm/2

Vm/2

Full-wave Rectifier:
From the above comparison we came to know that full wave bridge rectifier as more advantages than the other two rectifiers. So, in our project we are using full wave bridge rectifier circuit.

Bridge Rectifier:
A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-wave rectification. This is a widely used configuration, both with individual diodes wired as shown and with single component bridges where the diode bridge is wired internally. A bridge rectifier makes use of four diodes in a bridge arrangement as shown in fig(a) to achieve full-wave rectification. This is a widely used both with individual diodes wired as shown and with single component bridges where the diode bridge is wired internally.

2.2 Bridge rectifier

Filter:
A Filter is a device which removes the a.c component of rectifier output but allows the d.c component to reach the load.

Capacitor filter:
We have seen that the ripple content in the rectified output of half wave rectifier is 121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of ripples is not acceptable for most of the applications. Ripples can be removed by one of the following methods of filtering. (a) A capacitor, in parallel to the load, provides an easier by pass for the ripples voltage though it due to low impedance. At ripple frequency and leave the d.c.to appears the load. Filtering is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 RMS value). To calculate the value of capacitor(C), C = *3*f*r*Rl

Where,

f = supply frequency, r = ripple factor, Rl = load resistance

Note: In our circuit we are using 1000F. Hence large value of capacitor is placed to reduce ripples and to improve the DC component.

(b) An inductor, in series with the load, prevents the passage of the ripple current (due to high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c)

(c) Various combinations of capacitor and inductor, such as L-section filter

section filter,

multiple section filter etc. which make use of both the properties mentioned in (a) and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and another with full wave rectifier.Filtering is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 RMS value). To calculate the value of capacitor(C), C = *3*f*r*Rl Where, f = supply frequency, r = ripple factor, Rl = load resistance Note: In our circuit we are using 1000F. Hence large value of capacitor is placed to reduce ripples and to improve the DC component.

Regulator:
Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output voltages. The maximum current they can pass also rates them. Negative voltage regulators are available, mainly for use in dual supplies. Most regulators include some automatic protection from excessive current ('overload protection') and overheating ('thermal protection'). Many of the fixed voltage regulator ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right. The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the output pin.

2.3 Three Terminal Voltage Regulator capacitor filter, one applied on half wave rectifier and another with full wave rectifier.

2.2 Transmiter section:


2.2.1 IR encoder: Signals coming out of the microcontroller are not the actual signals eligible for transmission. So, they have to be encoded before giving to the transmitter. This encoder circuit will encode the data send by the microcontroller and then transmits the data serially to the IR transmitter module. Here we are using transmitter module for transmitting the data.

2.22 IR transmitter IR transmitter is the device used to transmit the encoded signal. The encoded signal is given to the IR transmitters data pin. Then the signal is modulated by the IR transmitter module and transmitted through the antenna. This section is fully described in the IR communication section

2.3 Receiver section:


2.3.1 IR receiver: IR receiver section will receive the IR signals from all the signals present in the environment and provides it to the decoder.

2.3.2 IR Decoder:
Signals received from the environment will be comprising of so many IR signals, so, here the decoder will remove all noise i.e., unwanted signals and gives it to microcontroller for further processing.

2.4 MICROCONTROLLER:

MICRO CONTROLLER AT89S52

Introduction A Micro controller consists of a powerful CPU tightly coupled with memory, various I/O interfaces such as serial port, parallel port timer or counter, interrupt controller, data acquisition interfaces-Analog to Digital converter, Digital to Analog converter, integrated on to a single silicon chip. If a system is developed with a microprocessor, the designer has to go for external memory such as RAM, ROM, EPROM and peripherals. But controller is provided all these facilities on a single chip. Development of a Micro controller reduces PCB size and cost of design. One of the major differences between a Microprocessor and a Micro controller is that a controller often deals with bits not bytes as in the real world application. Intel has introduced a family of Micro controllers called the MCS-52. The Major Features: Compatible with MCS-52 products 4k Bytes of in-system Reprogrammable flash memory Fully static operation: 0HZ to 24MHZ Three level programmable clock 128 * 8 bit timer/counters Six interrupt sources

Programmable serial channel Low power idle power-down modes

Why AT 89S52
The system requirements and control specifications clearly rule out the use of 16, 32 or 64 bit micro controllers or microprocessors. Systems using these may be earlier to implement due to large number of internal features. They are also faster and more reliable but, 8-bit micro controller satisfactorily serves the above application. Using an inexpensive 8-bit Microcontroller will doom the 32-bit product failure in any competitive market place. Coming to the question of why to use AT89S52 of all the 8-bit microcontroller available in the market the main answer would be because it has 4 Kb on chip flash memory which is just sufficient for our application. The on-chip Flash ROM allows the program memory to be reprogrammed in system or by conventional non-volatile memory Programmer. Moreover ATMEL is the leader in flash technology in todays market place and hence using AT 89S52 is the optimal solution.

AT89S52 MICROCONTROLLER ARCHITECTURE:


The 89S52 architecture consists of these specific features: Eight bit CPU with registers A (the accumulator) and B Sixteen-bit program counter (PC) and data pointer (DPTR) Eight- bit stack pointer (PSW) Eight-bit stack pointer (Sp) Internal ROM or EPROM (8751) of 0(8031) to 4K (89S52) Internal RAM of 128 bytes: 1. Four register banks, each containing eight registers 2. Sixteen bytes, which maybe addressed at the bit level 3. Eighty bytes of general- purpose data memory Thirty two input/output pins arranged as four 8-bit ports:p0-p3

Two 16-bit timer/counters: T0 and T1 Full duplex serial data receiver/transmitter: SBUF Control registers: TCON, TMOD, SCON, PCON, IP, and IE Two external and three internal interrupts sources. Oscillator and clock circuit

2.4 FUNCTIONAL BLOCK DIAGRAM OF MICROCONTROLLER:

The 89S52 oscillator and clock:

The heart of the 89S52 circuitry that generates the clock pulses by which all the internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is provided for connecting a resonant network to form an oscillator. Typically a quartz crystal and capacitors are employed. The crystal frequency is the basic internal clock frequency of the microcontroller. The manufacturers make 89S52 designs that run at specific minimum and maximum frequencies typically 1 to 16 MHz.

Oscillator and timing circuit

Types of memory:
The 89S52 have three general types of memory. They are on-chip memory, external Code memory and external Ram. On-Chip memory refers to physically existing memory on the micro controller itself. External code memory is the code memory that resides off chip. This is often in the form of an external EPROM. External RAM is the Ram that resides off chip. This often is in the form of standard static RAM or flash RAM.

a) Code memory
Code memory is the memory that holds the actual 89C51 programs that is to be run. This memory is limited to 64K. Code memory may be found on-chip or off-chip. It is possible to have 4K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA

b) Internal RAM
The 89S52 have a bank of 128 of internal RAM. The internal RAM is found on-chip. So it is the fastest Ram available. And also it is most flexible in terms of reading and writing. Internal Ram is volatile, so when 89C51 is reset, this memory is cleared. 128 bytes of internal memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains 8 registers. Internal RAM also contains 128 bits, which are addressed from 20h to 2Fh. These bits are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are numbered 00h to 7Fh. The user may make use of these variables with commands such as SETB and CLR. FLASH MEMORY: Flash memory (sometimes called "flash RAM") is a type of constantly-powered non volatile that can be erased and reprogrammed in units of memory called blocks. It is a variation of electrically erasable programmable read-only memory (EEPROM) which, unlike flash memory, is erased and rewritten at the byte level, which is slower than flash memory updating. Flash memory is often used to hold control code such as the basic input/output system (BIOS) in a personal computer. When BIOS needs to be changed (rewritten), the flash memory can be written to in block (rather than byte) sizes, making it easy to update. On the other hand, flash memory is not useful as random access memory (RAM) because RAM needs to be addressable at the byte (not the block) level Flash memory is used in digital cellular phones, digital cameras, LAN switches, PC Cards for notebook computers, digital set-up boxes, embedded controllers, and other devices.

PIN DIAGRAM OF AT89S52

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 ones 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 pull-ups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pull-ups 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 pull-ups 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 pull-ups. 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 pull-ups. 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 pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memories that use 16-bit addresses (MOVX @DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During accesses to external data memories that use 8-bit addresses (MOVX @ RI), Port 2 emits the 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 pull-ups. 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 pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of various special features of the AT89S52 as listed below: Port 3 also receives some control signals for Flash programming and verification.

Port pins and their alternate functions

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/6the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE 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 pulled high. Setting the ALE-disable bit has no 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 12volt 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: It is the Output from the inverting oscillator amplifier. REGISTERS: In the CPU, registers are used to store information temporarily. That information could be a byte of data to be processed, or an address pointing to the data to be fetched. The vast majority of 8051 registers are 8bit registers. In the 8051 there is only one data type: 8bits. The 8bits of a register are shown in the diagram from the MSB (most significant bit) D7 to the LSB (least significant bit) D0. With an 8-bit data type, any data larger than 8bits must be broken into

8-bit chunks before it is processed. Since there are a large number of registers in the 8051, we will concentrate on some of the widely used general-purpose registers and cover special registers in future chapters.

D7 D6 D5 D4 D3 D2 D1 D0

The most widely used registers of the 8051 are A (accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, DPTR (data pointer), and PC (program counter). All of the above registers are 8bits, except DPTR and the program counter. arithmetic and logic instructions. The accumulator, register A, is used for all

SFRs (Special Function Registers) Among the registers R0-R7 is part of the 128 bytes of RAM memory. What about registers A, B, PSW, and DPTR? Do they also have addresses? The answer is yes. In the 8051, registers A, B, PSW and DPTR are part of the group of registers commonly referred to as SFR (special function registers). There are many special function registers and they are widely used. The SFR can be accessed by the names (which is much easier) or by their addresses. For example, register A has address E0h, and register B has been ignited the address F0H, as shown in table. The following two points should noted about the SFR addresses. 1. The Special function registers have addresses between 80H and FFH. These

addresses are above 80H, since the addresses 00 to 7FH are addresses of RAM memory inside the 8051. 2. Not all the address space of 80H to FFH is used by the SFR. The unused locations 80H to FFH are reserved and must not be used by the 8051 programmer.

Regarding direct addressing mode, notice the following two points: (a) the address value is limited to one byte, 00-FFH, which means this addressing mode is limited to accessing RAM locations and registers located inside the 8051. (b) If you examine the l
st

file for an assembly

language program, you will see that the SFR registers names are replaced with their addresses as listed in table. Symbol ACC B PSW SP DPTR DPL DPH P0 P1 P2 P3 IP IE TMOD TCON Name Accumulator B register Program status word Stack pointer Data pointer 2 bytes Low byte High byte Port0 Port1 Port2 Port3 Interrupt priority control Interrupt enable control Timer/counter mode control Timer/counter control 82H 83H 80H 90H 0A0H 0B0H 0B8H 0A8H 89H 88H Address 0E0H 0F0H 0D0H 81H

T2CON

Timer/counter 2 control

0C8H

T2MOD Timer/counter mode2 control 0C9H


TH0 TL0 TH1 TL1 TH2 TL2 RCAP2H RCAP2L SCON SBUF PCON Timer/counter 0high byte Timer/counter 0 low byte Timer/counter 1 high byte Timer/counter 1 low byte Timer/counter 2 high byte Timer/counter 2 low byte 8CH 8AH 8DH 8BH 0CDH 0CCH

T/C 2 capture register high byte 0CBH T/C 2 capture register low byte Serial control Serial data buffer Power control 0CAH 98H 99H 87H

Table: 8051 Special function register Address

A Register (Accumulator)

This is a general-purpose register which serves for storing intermediate results during operating. A number (an operand) should be added to the accumulator prior to execute an

instruction upon it. Once an arithmetical operation is preformed by the ALU, the result is placed into the accumulator. If a data should be transferred from one register to another, it must go through accumulator. For such universal purpose, this is the most commonly used register that none microcontroller can be imagined without (more than a half 8051 microcontroller's instructions used use the accumulator in some way).

B Register
B register is used during multiply and divide operations which can be performed only upon numbers stored in the A and B registers. All other instructions in the program can use this register as a spare accumulator (A).

During programming, each of registers is called by name so that their exact address is not so important for the user. During compiling into machine code (series of hexadecimal numbers recognized as instructions by the microcontroller), PC will automatically, instead of registers name, write necessary addresses into the microcontroller.
R Registers (R0-R7)

This is a common name for the total 8 general purpose registers (R0, R1, and R2 ...R7). Even they are not true SFRs, they deserve to be discussed here because of their purpose. The bank is active when the R registers it includes are in use. Similar to the accumulator, they are used for temporary storing variables and intermediate results. Which of the banks will be active depends on two bits included in the PSW Register. These registers are stored in four banks in the scope of RAM. The following example best illustrates the useful purpose of these registers. Suppose that mathematical operations on numbers previously stored in the R registers should be performed: (R1+R2) - (R3+R4). Obviously, a register for temporary storing results of addition is needed. Everything is quite simple and the program is as follows:

MOV A, R3; Means: move number from R3 into accumulator ADD A, R4; Means: add number from R4 to accumulator (result remains in accumulator) MOV R5, A; Means: temporarily moves the result from accumulator into R5 MOV A, R1; Means: move number from R1 into accumulator ADD A, R2; Means: add number from R2 to accumulator SUBB A, R5; Means: subtract number from R5 (there are R3+R4)

Types of instructions:
Depending on operation they perform, all instructions are divided in several groups:

Arithmetic Instructions Branch Instructions Data Transfer Instructions Logical Instructions Logical Instructions with bits

The first part of each instruction, called MNEMONIC refers to the operation an instruction performs (copying, addition, logical operation etc.). Mnemonics commonly are shortened form of name of operation being executed. For example: INC LJMP LAB5 R1; Increment ;Long Jump LAB5 R1 (long jump (increment to address register specified as R1) LAB5)

JNZ LOOP ;Jump if Not Zero LOOP (if the number in the accumulator is not 0, jump to address specified as LOOP) Another part of instruction, called OPERAND is separated from mnemonic at least by one empty space and defines data being processed by instructions. Some instructions have no operand; some have one, two or three. If there is more than one operand in instruction, they are separated by comma. For example: RET - (return from sub-routine) JZ TEMP - (if the number in the accumulator is not 0, jump to address specified as TEMP) ADD A,R3 - (add R3 and accumulator) CJNE A,#20,LOOP - (compare accumulator with 20. If they are not equal, jump to address specified as LOOP)

Arithmetic instructions

These instructions perform several basic operations (addition, subtraction, division, multiplication etc.) After execution, the result is stored in the first operand. For example: ADD A, R1 - The result of addition (A+R1) will be stored in the accumulator.

Arithmetical Instructions Oscillator Period 1 2 1 2 1

Mnemonic

Description

Byte Number

ADD A,Rn ADD A,Rx ADD A,@Ri ADD A,#X ADDC A,Rn

Add R Register to accumulator

Add directly addressed Rx Register to accumulator 2 Add indirectly addressed Register to accumulator 1 Add number X to accumulator Add R Register with Carry bit to accumulator 2 1

Branch Instructions There are two kinds of these instructions: Unconditional jump instructions: After their execution a jump to a new location from where the program continues execution is executed. Conditional jump instructions:

If some condition is met - a jump is executed. Otherwise, the program normally proceeds with the next instruction.

Branch Instruction Byte Number Oscillator Period

Mnemonic

Description

ACALL adr11 LCALL adr16 RET RETI

Call subroutine located at address within 2 K byte Program Memory space Call subroutine located at any address within 64 K byte Program Memory space Return from subroutine Return from interrupt routine Jump to address located within 2 K byte Program Memory space

1 1

4 4

AJMP adr11

Data Transfer Instructions These instructions move the content of one register to another one. The register which content is moved remains unchanged. If they have the suffix X (MOVX), the data is exchanged with external memory. Data Transfer Instruction Mnemonic Description Byte Cycle

Number MOV A,Rn Move R register to accumulator Move directly addressed Rx register to accumulator Move indirectly addressed register to 1

Number 1

MOV A,Rx

MOV A,@Ri

accumulator Move number X to accumulator

MOV A,#X

Logical Instructions These instructions perform logical operations between corresponding bits of two registers. After execution, the result is stored in the first operand. Logical Instructions Byte Number 1 Cycle Number 1

Mnemonic

Description

ANL A,Rn

Logical AND between accumulator and R register Logical AND between accumulator and directly addressed register Rx Logical AND between accumulator and indirectly addressed register Logical AND between accumulator and number X

ANL A,Rx

ANL A,@Ri

ANL A,#X

Logical Operations on Bits Similar to logical instructions, these instructions perform logical operations. The difference is that these operations are performed on single bits. Logical operations on bits Byte Number 1 2 1 2 1 2 Cycle Number 1 2 1 2 1 2

Mnemonic

Description

CLR C CLR bit SETB C SETB bit CPL C CPL bit

Clear Carry bit Clear directly addressed bit Set Carry bit Set directly addressed bit Complement Carry bit Complement directly addressed bit

TIMERS On-chip timing/counting facility has proved the capabilities of the microcontroller for implementing the real time application. These includes pulse counting, frequency measurement, pulse width measurement, baud rate generation, etc,. Having sufficient number of timer/counters may be a need in a certain design application. The 8051 has two timers/counters. They can be used either as timers to generate a time delay or as counters to count events happening outside the microcontroller. Let discuss how these timers are used to generate time delays and we will also discuss how they are been used as event counters.

PROGRAMMING 8051 TIMERS

The 8051 has timers: Timer 0 and Timer1.they can be used either as timers or as event counters. Let us first discuss about the timers registers and how to program the timers to generate time delays. BASIC RIGISTERS OF THE TIMER Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit architecture, each 16-bit timer is accessed as two separate registers of low byte and high byte. TIMER 0 REGISTERS The 16-bit register of Timer 0 is accessed as low byte and high byte. the low byte register is called TL0(Timer 0 low byte)and the high byte register is referred to as TH0(Timer 0 high byte).These register can be accessed like any other register, such as A,B,R0,R1,R2,etc.for example, the instruction MOV TL0, #4Fmoves the value 4FH into TL0,the low byte of Timer 0.

TIMER 1 REGISTERS Timer 1 is also 16-bit register is split into two bytes, referred to as TL1 (Timer 1 low byte) and TH1 (Timer 1 high byte).these registers are accessible n the same way as the register of Timer 0. TMOD (timer mode) REGISTER Both timers TIMER 0 and TIMER 1 use the same register, called TMOD, to set the various timer operation modes. TMOD is an 8-bit register in which the lower 4 bits are set aside

for Timer 0 and the upper 4 bits for Timer 1.in each case; the lower 2 bits are used to set the timer mode and the upper 2 bits to specify the operation.

2.5 Liquid Crystal Display: Liquid crystal displays (LCDs) have materials which combine the properties of both liquids and crystals. Rather than having a melting point, they have a temperature range within which the molecules are almost as mobile as they would be in a liquid, but are grouped together in an ordered form similar to a crystal. An LCD consists of two glass panels, with the liquid crystal material sand witched in between them. The inner surface of the glass plates are coated with transparent electrodes which define the character, symbols or patterns to be displayed polymeric layers are present in between the electrodes and the liquid crystal, which makes the liquid crystal molecules to maintain a defined orientation angle. One each polarizer are pasted outside the two glass panels. This polarizer would rotate the light rays passing through them to a definite angle, in a particular direction When the LCD is in the off state, light rays are rotated by the two polarizers and the liquid crystal, such that the light rays come out of the LCD without any orientation, and hence the LCD appears transparent. When sufficient voltage is applied to the electrodes, the liquid crystal molecules would be aligned in a specific direction. The light rays passing through the LCD would be rotated by the polarizer, which would result in activating / highlighting the desired characters.

The LCDs are lightweight with only a few millimeters thickness. Since the LCDs consume less power, they are compatible with low power electronic circuits, and can be powered for long durations. The LCD s doesnt generate light and so light is needed to read the display. By using backlighting, reading is possible in the dark. The LCDs have long life and a wide operating temperature range. Changing the display size or the layout size is relatively simple which makes the LCDs more customer friendly. The LCDs used exclusively in watches, calculators and measuring instruments are the simple seven-segment displays, having a limited amount of numeric data. The recent advances in technology have resulted in better legibility, more information displaying capability and a wider temperature range. These have resulted in the LCDs being extensively used in telecommunications and entertainment electronics. The LCDs have even started replacing the cathode ray tubes (CRTs) used for the display of text and graphics, and also in small TV applications. 2.5.1 LCD pin description: The LCD discussed in this section has 14 pins. The function of each pin is given in table.

2.6 LCD CONNECTION

TABLE 1: Pin description for LCD

Pin
1 2 3

Symbol
Vss Vcc VEE

I/O
----

Description
Ground +5V power supply Power supply to

control contrast 4 RS I RS=0 to select

command register RS=1 to select

data register

R/W

R/W=0 for write R/W=1 for read

6 7 8 9 10 11 12 13

E DB0 DB1 DB2 DB3 DB4 DB5 DB6

I/O I/O I/O I/O I/O I/O I/O I/O

Enable The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus

Uses:
The LCDs used exclusively in watches, calculators and measuring instruments are the simple seven-segment displays, having a limited amount of numeric data. The recent advances in technology have resulted in better legibility, more information displaying capability and a wider temperature range. These have resulted in the LCDs being extensively used in telecommunications and entertainment electronics. So in this project, the LCD is used to display the instantaneous This section describes the operation modes of LCDs then describe how to program and interface an LCD to 8051 using Assembly and C.

2.6 IR MODULE: Infrared which (IR) radiation radio is part of the electromagnetic visible spectrum, and

includes

waves,

microwaves,

light,

ultraviolet light, as well as gamma rays and X-rays. The and radio with IR range waves. the falls IR lR between the visible are portion usually from of the spectrum in 1000

wavelengths spectrum

expressed 0.7 to

microns, microns.

extending

Using thermometers of the0.7-14 of at require

advanced can

optic on band.

systems nearly

and

detectors, any every optimum IR portion

non-contact or

IR

focus

portions the IR

micron a a

Because emits along models an the

object

(with of

exception energy may

blackbody) specific point sensor

amount each

band, specific

process and

unique

with

optics

detector types. For at 3.43 example, microns of 5 a sensor is with a narrow for related to metals to measure and measure spectral measuring materials. glass foils. lower range the A centered surface sensor A 1

optimized and used for used

temperature set up for

polyethylene microns is used are is

surfaces. The

micron spectral

sensor ranges

broader temperature

surfaces, such as paper, board, poly, and foil composites. An transmits, object and reflects, emits

energy, as shown in the diagram.

2.7 DECODING IR REMOTE CONTROLS: The origin of this posting was the question what to do with an old TV. I suggested to use the infrared remote control as an input keyboard for a micro controller board and mentioned a piece of code I had written for the 89S51 micro controller. I was asked by some people to share my information about remote controls, so here it is: There are at least two international standards, which are used by remote controls to encode the commands, the RC5 and RECS 80 code. The RECS 80 code uses pulse length modulation. Each bit to be transmitted is encoded by a high level of the duration T followed by a low level of duration 2T representing a logical '0' or 3T representing a logical '1'. 2T _ _ _ T 2T T 3T T

|| || || _| |__| |___| |__

Notice that a '1' takes more time to be transmitted than a '0'. The RC 5 code instead has a uniform duration of all bits. A transition in the middle of the time interval assigned to each bit encodes the logical value. A '0' is encoded by a high to low transition and a '1' by a low to high transition. Therefore we need additional transitions at the beginning of each bit to set the proper start level if a series of equal bits is sent. We don't need this additional transition if the next bit has a different value. This is also called a 'bi phase' code.

|1.Bit|2.Bit|3.Bit|4.Bit|

__ | | |

__ | | |

__

__

|__| |_____| |__| 0 0 1 1

Instead of being fed direct into the IR emitter, most remote controls modulate a 20-30 kHz carrier with this signal. Logic one is represented by a burst of oscillations.

______/\/\/\/\_______/\/\/\/\________ 0 1 0 1 0

The reason is, that you can use a filter tuned to the carrier frequency to distinguish the signal from noise in the ambient light. Fluorescent lamps are the main source of such noise. Photodiodes behind an optical filter, which transmits infrared light but blocks visible light, are used as detectors. The signal from the photodiode is fed through a filter tuned to the carrier frequency and then amplified. The amplified signal is demodulated just like the carrier is demodulated in any AM radio receiver. It can be a lot of pain to design a sensitive receiver that doesnt start to oscillate. It is also necessary to have some automatic gain control to avoid overload of the amplifier at close

distance to the emitter. It is easier to use some integrated circuit that does all of the job. The best i have ever seen (and used) is the TSOP. If you don't know which code your remote control is transmitting you can identify it by viewing the output of your receiver with an oscilloscope. The RECS 80 code uses high pulses of uniform length while the low pulses differ in length. If there are high and low pulses of two different lengths it might be RC5 code. Note that your receiver may invert the levels. How commands like volume are control or channel selction encoded? In the case of the RC5 code there is an international standard. Every command is encoded by 14 bits. The first two bits S are start bits to allow the receiver to adjust the automatic gain control and to synchronize.

| S | S | T | A4 | A3 | A2 | A1 | A0 | C5 | C4 | C3 | C2 | C1 | C

CHAPTER III

WORKING&MODELLING

MODEELLING AND WORKING


3.1 BLOCK DIAGRAM:
Receiver section:

LCD MODULE POWER SUPPLY MICRO COTROLLER Decoder Stepper

Remote section:

Keypad Encoder

IR TX

3.1.1 Block diagram explanation Transmitter section comprises of keypad, IR encoder and IR transmitter Keypad: Keypad in the circuit is to control the directions of motor connected at the receiver section. IR encoder: Signals coming out of the microcontroller are not the actual signals eligible for transmission. So, they have to be encoded before giving to the transmitter. This encoder circuit

will encode the data send by the microcontroller and then transmits the data serially to the IR transmitter module. Here we are using transmitter module for transmitting the data. IR transmitter: IR transmitter is the device used to transmit the encoded signal. The encoded signal is given to the IR transmitters data pin. Then the signal is modulated by the IR transmitter module and transmitted through the antenna. This section is fully described in the IR communication section. RECEIVER SECTION: Receiver section comprises of IR receiver, IR decoder, microcontroller, power supply, LCD and stepper motor. IR receiver: IR receiver section will receive the IR signals from all the signals present in the environment and provides it to the decoder. IR decoder: Signals received from the environment will be comprising of so many IR signals, so, here the decoder will remove all noise i.e., unwanted signals and gives it to microcontroller for further processing.

MICROCONTROLLER: In this project work the micro-controller is playing a major role. Micro-controllers were originally used as components in complicated process-control systems. However, because of

their small size and low price, Micro-controllers are now also being used in regulators for individual control loops. In several areas Micro-controllers are now outperforming their analog counterparts and are cheaper as well. The purpose of this project work is to present control theory that is relevant to the analysis and design of Micro-controller system with an emphasis on basic concept and ideas. It

is assumed that a Microcontroller with reasonable software is available for computations and simulations so that many tedious details can be left to the Microcontroller. The control system design is also carried out up to the stage of implementation in the form of controller programs in assembly language OR in C-Language.

LCD Display Section: This section is basically meant to show up the status of the project. This project makes use of Liquid Crystal Display to display / prompt for necessary information. Power Supply Section: This section is meant for supplying Power to all the sections mentioned above. It basically consists of a Transformer to step down the 230V ac to 9V ac followed by diodes. Here diodes are used to rectify the ac to dc. After rectification the obtained rippled dc is filtered using a capacitor Filter. A positive voltage regulator is used to regulate the obtained dc voltage. MOTOR: Motor is an output device; its direction will be changed according to the speed set by the switches. The speed can be varied by varying the voltage given to the PWM converter (using keypad).

Schematic diagram:
3.2 Transmitter section:

Schematic explanation: Power Supply: The main aim of this power supply is to convert the 230V AC into 5V DC in order to give supply for the TTL or CMOS devices. In this process we are using a step down transformer, a bridge rectifier, a smoothing circuit and the RPS. At the primary of the transformer we are giving the 230V AC supply. The secondary is connected to the opposite terminals of the Bridge rectifier as the input. From other set of opposite terminals we are taking the output to the rectifier. The bridge rectifier converts the AC coming from the secondary of the transformer into pulsating DC. The output of this rectifier is further given to the smoother circuit which is capacitor in our project.

The smoothing circuit eliminates the ripples from the pulsating DC and gives the pure DC to the RPS to get a constant output DC voltage. The RPS regulates the voltage as per our requirement. Keypad section: Key pad section is to increase the speed of the motor in steps. With every press of switch, speed of motor increases. It is connected to encoder data pins. IR Encoder: Encoder is for encoding the data given by the keys and the respected encoded data is emitted into the air. We use HT12A IC for the encoder which as 14 pin with 8 data pins, one data output (enable) pin, VCC, GND and OSC. IR Transmitter: IR transmitter as IR LED used to transmit IR rays .Since the IR rays are out of the visible range we cannot observe the rays from the transmitter. These are Infrared LEDs; the light output is not visible by our eyes. They can be used as replacement LEDs for remote controls, night vision for camcorders, invisible beam sensors, etc. Here this IR transmitter is used as remote keypad. Individual keys having individual functionalities

LCD:
LCD is used to display the status of motor speed either high or low speed. LCD data pins are connected to port 0.0 to 0.7 pins and control pins are connected to P2.5, P2.6, P2.7 pins of microcontrol

Receiver section:
3.3 Receiver schematic:

Schematic explanation: Power Supply: The main aim of this power supply is to convert the 230V AC into 5V DC in order to give supply for the TTL or CMOS devices. In this process we are using a step down transformer, a bridge rectifier, a smoothing circuit and the RPS. At the primary of the transformer we are giving the 230V AC supply. The secondary is connected to the opposite terminals of the Bridge rectifier as the input. From other set of opposite terminals we are taking the output to the rectifier.

The bridge rectifier converts the AC coming from the secondary of the transformer into pulsating DC. The output of this rectifier is further given to the smoother circuit which is capacitor in our project. The smoothing circuit eliminates the ripples from the pulsating DC and gives the pure DC to the RPS to get a constant output DC voltage. The RPS regulates the voltage as per our requirement. Microcontroller: The microcontroller AT89S51 with Pull up resistors at Port0 and crystal oscillator of 11.0592 MHz crystal in conjunction with couple of capacitors of is placed at 18th & 19th pins of 89S51 to make it work (execute) properly. IR Decoder: Decoder is used for decoding the data given by the encoder. We should maintain the same address for the transmission and receiving of the data at the encoder and decoder pins. For decoding also we aare using a 14 pin IC which as one data input pin, 8 data pins, VCC, GND and OSC. IR Receiver: Here for the IR decoder we are using HT12D which is a 14 pin IC. The 8 data pins of the decoder HT12D such as 3, 4, 5, 6, 7, 8, 9 and 10 are totally dedicated to the complete PORT2 of the controller. 11th and 12 th of the decoder are been short to GND. Motor: Motor is an output device; its speed will be varied according to the speed set by the switches. It is connected to port2.0 to 2.3 pins of the microcontroller through driver IC , where stepper motor is connected to output pins

CHAPTER IV

4.1 APPLICATIONS:

Robotics and Wireless Robot Arm. Industries are using IR solutions for monitoring, process, ,inventory tracking, data links and bar code reading devices. Commercial wireless applications such as door announcers, security and access systems, gate control, remote activation, score board and paging systems. Consumer products including electronic toys, home security, gate and garage door openers, intercom, fire and safety systems and irrigation controllers. Bottle filling systems, visitors counter and conveyer application.

FUTURE SCOPE

Thermography Infrared filters Heating Meteorology Astronomy

CHAPTER V

CONCLUSION

5.1 CONCLUSION:

The

project

WIRELESS

STEPPER

MOTOR

CONTROL

USING

IR

COMMUNICATION has been successfully designed and tested. Integrating features of all the hardware components used have developed it. Presence of every module has been reasoned out and placed carefully thus contributing to the best working of the unit. Secondly, using highly advanced ICs and with the help of growing technology the project has been successfully implemented.

5.2 BIBLIOGRAPHY:

The 8051 Micro controller and Embedded Systems -Muhammad Ali Mazidi Janice Gillispie Mazidi

The 8051 Micro controller Architecture, Programming & Applications -Kenneth J. Ayala

Fundamentals Of Micro processors and Micro computers -B. Ram Micro processor Architecture, Programming & Applications - Ramesh S. Gaonkar

Electronic Components -D.V. Prasad

Wireless Communications - Theodore S. Rappaport

Mobile Tele Communications - William C.Y. Lee


References on the Web:

www.national.com www.atmel.com www.microsoftsearch.com www.geocities.com

CHAPTER VI

APPENDIX

#include<reg51.h>

#inlude<string.h> #define bits P2 #define motor P1 #define dataa P1 sbit en=P3^4; sbit rs=P3^5;

code unsigned char title[16]="STEPPER MOTOR"; code unsigned char m1[16]="press 5/6 "; code unsigned char m12[16]="clk / anti clk"; code unsigned char m2[16]="Speed?? (1-->4)"; void cw(unsigned char); void acw(unsigned char); void speed(unsigned char); void lcd_cmd(unsigned char ); void lcd_dat(unsigned char dat); void char speed(unsigned char) void lcd_data(unsigned char); void lcd_init(); void delay(int);

void main() {

int i; for(i=0;title[i]!='\0';i++) { lcd_data(title[i]); } delay(99);

lcd_cmd(0x01); lcd_cmd(0x80);

for(i=0;m1[i]!='\0';i++) { lcd_data(m1[i]); } lcd_cmd(0xc0); for(i=0;m12[i]!='\0';i++) { lcd_data(m12[i]); } lcd_data(m12); while(bits!=0x05|0x06); lcd_cmd(0x01); lcd_cmd(0x80); for(i=0;m2[i]!='\0';i++) { lcd_data(m2[i]); }

while(1) { if(bits==0x05) cw(bits); else if(bits==0x06) acw(bits); } } void cw(unsigned char speed)

{ while(1) { motor=0x01; speed(bits); motor=0x02; speed(bits); motor=0x04; speed(bits); motor=0x08; speed(bits); if(bits==0x06) acw(bits); } } void acw(unsigned char speed) { while(1) { motor=0x08; speed(bits); motor=0x04; speed(bits); motor=0x02; speed(bits); motor=0x01; speed(bits); if(bits==0x05) cw(bits); }

} void char speed(unsigned char bits) { switch(bits) { case 0x01:{delay(2000);break;} case 0x02:{delay(1000);break;} case 0x03:{delay(500);break;} case 0x04:{delay(250);break;} } } void delay(int x) { int i,j; for(i=0;i<1;i++) for(j=0;j<x;j++); } void lcd_init() { lcd_cmd(0x38); lcd_cmd(0x0c); lcd_cmd(0x0e); lcd_cmd(0x80); lcd_cmd(0x01); } void lcd_cmd(unsigned char cmd) { delay(99); rs=0; dataa=cmd;

en=1; delay(5); en=0; } void lcd_dat(unsigned char dat) { delay(99); rs=1; dataa=dat; en=1; delay(5); en=0; }

Das könnte Ihnen auch gefallen