Sie sind auf Seite 1von 93

GSM Based Device control A PROJECT REPORT

Submitted by Aby Babu Rajan (41502106003) Anoop Jacob (41502106134)

in partial fulfillment for the award of the degree of

BACHELOR OF ENGINEERING IN ELECTRONICS AND COMMUNIATION ENGINEERING

SRM ENGINEERING COLLEGE, KATANKALATHUR

ANNA UNIVERSITY: CHENNAI 600 025

MAY 2006

ANNA UNIVERSITY: CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this project report GSM BASED DEVICE CONTROL is the bonafide work of Aby Babu Rajan (41502106003) and Anoop Jacob (41502106134) who carried out the project work under my supervision.

SIGNATURE Dr. S. Jayashri HEAD OF THE DEPARTMENT M.E., Ph.D.

SIGNATURE Mr. B. Viswanathan SUPERVISOR Asst. Professor B.SC, B.TECH, M.E. E.C.E S.R.M Nagar, Kattankulathur-603203. Kancheepuram District

E.C.E S.R.M Nagar, Kattankulathur 603203 Kancheepuram District.

ABSTRACT

In the recent years of serious accidents dealing with temperature monitoring and control of the various industries we fail to still keep up the standards. To make things easier for the supervisor, we have made a project which makes everything controllable with a help of a cellphone.

The project is more helpful in case of crisis, the situation being the absence of the supervisor at the work place so that he/she is unable to monitor in person for the purpose of safety (in industries).

This project can be further extended to employ in various industries and even in household appliances where the entire monitor and control various other parameters could also performed at no cost

Among these, this project focuses on the monitor & control of the parameter temperature, which has been a major parameter of danger in most of the industries leading to a lot of disastrous histories. Hence temperature control is the major concern of this project. So, the machine setup refers to any high temperature machine like boilers, furnaces, etc.

This project offers users with enormous benefits of simplicity, being compatible to situations where the presence near the machine poses a great threat to safety, needing just basic knowledge of messaging & what more it has a lot of reliability. ACKNOWLEDGEMENT

In lieu of the successful completion of our project we would like to acknowledge the help of those following people. Their constant help, guidance and encouragement proved invaluable till the end.

We express our faithful thanks to our principal Prof. R. Venkataramani for having granted us permission for doing this external project.

We are grateful to our beloved professor and Head of the Department Dr. S. Jayashri, for her continuous encouragement and support.

We would like to convey our deepest gratitude to our project coordinator & guide Asst. Prof. B. Viswanathan for his invaluable guidance and support throughout the course of the project.

We express our sincere thanks to SANDS Instrumentation, Chennai for guiding us with invaluable suggestions and keen interest towards our project. We sincerely acknowledge who are directly or indirectly involved in making of this project a successful one.

TABLE OF CONTENTS

CHAPTER NO.

TITLE ABSTRACT LIST OF FIGURES LIST OF TABLES

PAGE NO.

Introduction

1.1 : Need for the system

Design consideration:

2.1 Hardware :

2.1.1 2.1.2 2.1.3

Hardware description Hardware components involved Technical Details of microcontroller

7 8 10

2.2 Software :

11

2.2.1 2.2.2

Installation Software Software Details

11 11

Hardware design

13

3.1: Prototype block diagram of the system:

13

3.2: Hardware Implementation

15

3.3 System hardware

16

3.3.1: UART 3.3.1.1 General Description 3.3.1.2 Features 3.3.1.3 Functional Description 3.3.1.4 Internal Reg functional Description. 3.3.2: GSM Modem 3.3.2.1 Introduction 3.3.2.2 Basic Operation 3.3.3: Stepper Motor 3.3.3.1 General Description 3.3.3.2 Electrical Type of Stepper Motors -VR, HR, Hybrid 3.3.3.3 Mechanical Type of Stepper Motors 3.3.3.4 Operation 3.3.3.5 For Short Cut finding the proper wiring sequence 3.3.3.6 Specification of the motor in use

16 16 17 22 23 28 28 34 38 38 39

40 40 46

46

3.3.4: Thermistor: 3.3.4.1 Thermistor Temperature sensor 3.3.4.2 Description 3.3.4.3 The temperature resistive mode of thermistor 3.3.4.4 Graphical Representation 3.3.4.5 Terminology 3.3.5: Relay 3.3.6: Regulator

47 47 48

51 52 53 54 55

Software design 4.1: Coding 4.2: Software Application

56 56 80

4.2.1: How to run the program. 4.2.2 Final Demo 4.2.3 Dos and Donts

80 81 83

Conclusion

84

Reference

85

LIST OF FIGURES FIGURE NO. 1.1 TITLE. SMS Format PAGE NO. 3

2.1

Basic Block Diagram

3.1

Prototype Block Diagram

13

3.2

Hardware Implementation

15

3.3

PLCC package

16

3.4

Block diagram UART

18

3.5

GSM Modem Interface

29

3.6

15pin Female Connector

29

3.7

Hyper Terminal in windows 98

32

3.8

Assigning a name to new session

32

3.9

Setting correct com port and Baud rate

33

3.10

Checking Modem

33

3.11

Stepper motor with 6 pole router & 4 pole stator

41

3.12

Bipolar Stepper Motor

42

3.13

Changing position of rotor

44

3.14

Excitation of stepper motor

46

3.15

Configuration of PTC

49

3.16

Typical PTC Curve

50

3.17

PTC Thermistor VS temp response

50

3.18

Thermistor

51

3.19

PTC Thermistor curve

52

3.20

Static Voltage/current curve

53

LIST OF TABLES

TABLE NO. 3.1

TITLE UART simple description

PAGE NO. 19

3.2

Baud Rate Generator Programming Table

23

3.3

STI6C550 Internal Registers

24

3.4

To set the word length

25

3.5

To set the Stop length

26

3.6

Functions of pins of Female connecter

30

3.7

Stepping Sequences

43

3.8

Advantages and disadvantages of Thermistor

51

4.1

Trouble Shooting

83

CHAPTER 1: INTRODUCTION:

GSM Based Device Control is to automate and control electrical devices remotely using the Short Message Service, a tele service of GSM mobile communication is the main object of this project. This project deals with the monitoring and controlling of a remote system, be it a machine in an industry, or a simple household appliances like a gas stove, a water heater, etc. by using the technology of embedded systems employing Microcontroller AT89C51.

The tele services of GSM which has a service useful for message transfer, the short message services (SMS), is used in this project. This service offers transmission of messages through the unused channels. Automation is done via this short messaging service of GSM.

The project is more helpful in case of crisis, the situation being the absence of the supervisor at the work place so that he/she is unable to monitor in person for the purpose of safety (in industries).

This project can be further extended to employ in various industries and even in household appliances where the entire monitor and control various other parameters could also performed at no cost.

This project uses embedded system as the platform. Embedded system is a system, which incorporates in it an intelligent device to control and monitor any events surrounding it. Some of such intelligent devices include microprocessors,

microcontrollers, DSPS, etc. This project uses microcontroller AT89C51. MIK has modifies Havard architecture.

10

Among these, this project focuses on the monitor & control of the parameter temperature, which has been a major parameter of danger in most of the industries leading to a lot of disastrous histories. Hence temperature control is the major concern of this project. So, the machine setup refers to any high temperature machine like boilers, furnaces, etc.

This machine setup, here, is governed & controlled by the controller, the MIK. MIK acts as the heart of the project. It communicates parallel & hence it has an external UART to communicate with the PC & vice versa. There is a requirement in this project for the MIK to communicate with the GSM modem also, which supports serial communication. Therefore an external UART (16C550) is used to serve the purpose. This UART converts parallel to serial to communicate with the modem & communicates using the special Attention (AT) commands.

Hence the message to be sent to the control engineer about the status of the machine so as to enable a control message from the control engineer, is done using one of the AT command, AT+CMGS. An example format of this command is as follows.

AT+CMGS=+919840876411 >SYSTEM ON! COMMAND AWAITED

+CMG: 74 OK This means that a message SYSTEM ON! COMMAND AWAITED is being sent to the control engineer. The response +CMG & OK mention that they have been sent to the mobile number specified. The various messages that are usually sent to the control engineers mobile & those that are received are as follows

11

The messages sent to the engineer from the modem about the machine status are as follows. SYSTEM ON! COMMAND AWAITED - Initially to inform the controller that the machine has been turned & it expects instructions

COMMAND ACCOMPLISHED When the specified task of the control engineer has been accomplished & when it requires further instructions

TEMPERATURE=40 NORMAL indicates the present temperature & its condition if NORMAL, ABOVE RANGE (or) BELOW RANGE The command messages that are sent by the engineer to the machine to perform

are as follows *A*45*M5

The above are the SMS formats that are sent to the machine via the modem to instruct it about the mode, range, and time of operation. *A*045* M5

Represents mode A Automatic M Manual Fig 1.1. SMS Format Temperature range required being set

Time for which the machine should be active M Minutes 5 five min.

12

The other sms formats sent by the engineer to instruct the number of steps the regulator should move either forward (or) reverse are as follows. *10F* *05R*

Here F refers to forward rotation by number of steps mentioned & R refers to reverse motion by number of steps specified. These sms formats that are sent & received by the control engineer are processed by the MIK, which instructs the devices, connected to its ports to act according to the instructions given. The MIK first sends the message SYSTEM ON! COMMAND WAITED. The GSM modem on transmitting this message to the control engineer waits for receiving the command from him/her.

On reception of message from the control engineers mobile, MIK checks for the validity of the format & then turns on the relay, which activates the machine setup. It then checks for the mode.

If the mode is mentioned as AUTOMATIC, then the MIK instructs the sensor & the regulator such that the sensor senses the condition automatically about the status of the machine and takes actions accordingly to regulate the stepper motor either to move forward or in reverse direction.

If the mode is mentioned as MANUAL, then the MIK instructs the sensor to sense the status which is conveyed to the supervisor every time it goes out of normal condition & also updates every minute when the machine maintains normal temperature. On reception of out of normal status, the control engineer sends command to MIK to move a prescribed number of steps forward (or) in reverse. This motion of stepper motor actually is connected to the fuel feeding system of the boiler. When temperature goes below threshold level in the boiler, the fuel feeding system opens wider for more fuel to get in & produce more heat & opens lesser when the condition goes above threshold.

13

The sensor used here is the Thermistor, which is well known for its accuracy & the precision in its limited range. This project employs a positive temperature coefficient thermistor named KTY10, which suits the purpose.

This project was modularized into the following to develop on.

Regulatory action control Data acquisition from boiler Supervisory control of MIK based on acquired data GSM modem MIK interfacing Supervisory control of MIK based on ctrl. Enggs commands

The hardware & software for each of these modules were developed. Hence the important hardware & software sections which needs more concern & hence explanations are mentioned here. MIK UART GSM MODEM STEPPER MOTOR THERMISTORS RELAY & REGULATOR

The detailed explanations & the details, the datasheets, etc. of them are made available in the chapters to come

1.1 Need for the system

14

Our system GSM based device control provides an absolute solution for the monitoring and controlling of a remote system. This system is more helpful in case of crisis, the situation being the absence of the supervisor at the work place so that the user is unable to monitor in person for the purpose of safety. This tele services of GSM, has an excellent service useful for message transfer, the short message service, is used in this system. This service offers transmission of messages through the used channels. Automation is done via this short messaging service of GSM

Moreover this system can be further extended to employ in various industries especially in security appliances for business solutions. It can even make things easier for the person who wants to control simple household appliances where the person with the cell phone has the complete monitoring power with out being in site.

CHAPTER 2: Design Consideration

2.1 HARDWARE:

2.1.1 Hardware Description:

15

Basic Block Diagram


ON/OFF

RELAY

ELECTRICAL DEVICES S M S

Indicator

AT C MGS

89C51

Ext UART

GSM MODEM

fig 2.1 In the above block diagram, it shows us the basic type how the entire system are inter connected. Initially a message is send from the cell phone to the system, the GSM modem receives the message and then the GSM modem acts according to the message. Hence the modem sends a signal to the controller AT89C51 MIK through an interface known as UART which helps in converting to serial data from parallel data and vice versa to the kit. The controller verifies the message and acts according. After processing the message, MIK sends a signal whether to switch on or off the electronic device. At the same time there is a feedback of the message send back to the cell phone so that the user knows that the system has started. Depending on the state of the system, the entire kit controls the working of the entire system with another message send from the user.

2.1.2. Hardware components involved: Universal asynchronous transmitter and receiver (UART): The ST16C550 (550) is a universal asynchronous receiver and transmitters with 16 byte transmit and receive FIFO. It operates at 3.3 and 5V power supplies. A programmable baud rate generator can select transmit and receive clock rates from 50 bps

16

to 1.5 Mbps. The ST16C550 is an improved version of the NS16C550 UART with higher operating speed and lower access time. The ST16C550 on board status registers provides the error conditions, type and status of the transfer operation being performed. Included are complete MODEM control capability and a processor interrupt system that may be software tailored to the users requirements. The ST16C550 provides internal loop back capability for on board diagnostic testing.

The ST16C550 is available in 40 pin PDIP, 44 pin PLCC, and 48 pin TQFP packages. It is fabricated in an advanced CMOS process to achieve low drain power and high speed requirements. MIK serves parallel communication whereas GSM modem serves serial communication. Hence there is a need of conversion from parallel to serial communication. UART converts is connected between MIK and GSM modem, which serves this purpose.

GSM Modem: The SMS/MMS Gateway requires a connection to an SMSC (Short Messaging

Service Centre) to interface with SMS and MMS networks. An SMSC connection can consist of GSM MODEM A GSM modem or phone connected to a PC serial port (or to a USB port with an appropriate modem driver). A GSM modem can be an external modem device. Insert a GSM SIM card into this modem, and connect the modem to an available serial port on your computer. When you install your GSM modem, or connect your GSM mobile phone to the computer, be sure to install the appropriate Windows modem driver from the device manufacturer. To simplify configuration, the Now SMS/MMS Gateway will

communicate with the device via this driver. An additional benefit of utilizing this driver is that you can use Windows diagnostics to ensure that the modem is communicating properly with the computer.

Stepper Motor:

17

A stepper motor system is an electro-mechanical rotary actuator that converts electrical pulses into unique shaft rotations. This rotation is directly related to the number of pulses. The speed is synchronous to the rate of pulsing. The result is absolute speed and position. Stepper motors feature bi-directional control, built-in braking, variable torque, power control, precision accuracy, high resolution, open-loop control, and direct interface to digital systems. Compared to other servo systems, steppers exhibit an excellent power to weight ratio, minimum rotor inertia, no drift, no starting surge, and no cumulative errors.

Thermistor: Thermistors are special solid temperature sensors that behave like temperature-

sensitive resistors; hence their name is a contraction of "thermal" and "resistor". They are mostly very small bits of special material that exhibit more than just temperature sensitivity. They are highly sensitive and have very reproducible resistance Vs temperature properties. They are used inside many other devices as temperature sensing and correction devices as well as in specialty temperature sensing probes for commerce, science and industry & in this project for sensing of the various levels of temperatures as normal, above threshold & below threshold, the threshold being set by the user (i.e.) the supervisor or the control engineer Thermistors typically work over a relatively small temperature range, compared to other temperature sensors, and can be very accurate and precise within that range, although not all are. There is a variety of temperature sensors on the market all of which meet specific application needs. The most common sensors that are used to solve these application problems include the thermocouple, Resistive Temperature Detector (RTD), thermistor, and silicon-based sensors.

Relay:

18

A RELAY is a device that operates a switch by remote control. A relay triggers interruption of a circuit when a fault is detected. An electromechanical switch that use a small amount of electricity to charge an electromagnet, which results in physically pulling down a connecting switch to complete a circuit. Regulator:

This project employs a simple fan regulator to regulate the amount of current flowing through the machine setup. The stepper motor is connected to the machine setup via the regulator. As instructions pass on from the control engineer to the PIC, the number of steps to be moved either forward or reverse as specified by the engineer is passed on to the stepper motor. The motor rotates accordingly which in turn is conveyed to the machine via a regulator whose potentiometer knob is connected to the stepper motors motion. As pot gets varied, the amount of current flowing through the setup is also varied according to motors motion either in the forward direction or in the reverse direction.

2.1.3: Technical Details of Micro controller kit Introduction

Philips P89C51RD2 is a system programmable microcontroller board with external UART, 3-8 decoder and all ports terminated.

P89C51RD2 Microcontroller Kit is a product developed by SANDS, mainly used for studying the various functions of 80C51, which is the original and fundamental member of MCS-51 family micro controllers. Here the controller is integrated with various external devices like UART, Decoder

The operating speed of our kit is 18.432 MHz.

Description 19

Here the microcontroller is the main operating chip (Master). The controller has its own 64K bytes of program memory and 1k byte of data memory. In addition, it is incorporated with Modem controlled UART (16C550). Decoder also provided to choose the appropriate chip select according to the control word of the controller. The vector interrupts 0(INTO) can be given externally by using the interrupt switch. In system programming can be done with the Program/Run Mode switch.

The primary serial Port (Comm. 1) 1 is used for Micro controller communication with PC and all other devices. Secondary serial port (Comm. 2) connected with UART (Universal Asynchronous Receiver Transmitter) is also used for serial communication at a programmable baud rate.

2.2 SOFTWARE:

2.2.1 Installation Software

The kit package contains one installation CD. The CD has the following software. 1. Flash Magic Software. 2. Pcterm. Exe

2.2.2 Software Details: Flash Magic software:

Flash Magic is windows software from Embedded System Academy that allows easy access to all the ISP features provided by the device. These Features include,

Erasing the Flash Memory (Individual blocks or whole Block) Programming the Flash Memory. Modifying the Boot vector and status byte Reading the Flash Memory Performing a blank check on a section of Flash Memory etc.,

20

Under windows only one application may have access the COM. Port at any one time, preventing other application from using COM port. Flash Magic only obtain access to the selected COM port when ISP operations are being performed. This means some other applications that need to use COM port, such as debugging tools may be used while Flash Magic is loaded.

PC Term:

The software tool developed by SANDS for exploring the P89C51RD2 kit is PCTERM. This is a Serial Port Communication and terminal Emulation Software. It can also be used as a Hardware monitoring Utility.

PC TERM as Communication Software: The Baud Rate for communication can range from 300bps to 115200 bps to satisfy UART. Here the user can select various parameters of serial communication all in one screen. Files are exported and imported easily. A help window enables other options available to be viewed.

PCTERM as terminal Emulator:

Putting the device to be emulated in Terminal Mode permits PC term to act Terminal Emulator providing PC control of the device. This allows commands from the serial port and all keyboard entries to be mapped to serial port.

CHAPTER 3: HARDWARE DESIGN

3.1 Prototype block diagram of the system:

21

Thermistor
ON/OFF

RELAY
Voltage Regulator

Stepper Motor
AT C MGS

S M S

89C51

Ext UART

GSM MODEM

Fig 3.1

This project focuses on the monitor & control of the parameter temperature, which has been a major parameter of danger in most of the industries leading to a lot of disastrous histories. Hence temperature control is the major concern of this project. So, the machine setup refers to any high temperature machine like boilers, furnaces, etc.

In this project we are setting the entire apparatus such a way that it basically helps to control and monitor temperature. A SMS is send from the cell phone to the system and the GSM modem which is connected to the MIK kit receives the message. It then sends a signal to the controller MIK 89C51 through an external UART which

22

converts Serial to parallel and vice versa. The controller receives the signal and acts according what ever is the command and acts accordingly.

Initially the system is switched ON with the help of the command from the user with the help of the relay. The second path of the signal goes to the stepper motor through the Regulator which helps in reducing or increasing the voltage with the help of stepper motor.

The thermistor is the sensor which senses the temperature from the electrical device (bulb) and sends a feedback to the controller.

The controller hence sends a signal through the UART to the GSM modem which ultimately sends a message back to the user (Supervisor) saying what condition the system .

At any time of the Normal condition the user has all the power to switch off or on the system if needed. This system is very effective whenever the user wants to leave the site and wants to monitor the system when out of site.

23

3.2 Hardware Implementation:

HARDWARE IMPLEMENTATION

Fig 3.2

24

3.3: System Hardware: The system consists of the below hardware components. A detailed explanation will be given below for each module.

3.3.1 UART: 3.3.1.1 GENERAL DESCRIPTION


1

The ST16C550 (550) is a universal asynchronous receiver and transmitters with

16 byte transmit and receive FIFO. It operates at 3.3 and 5V power supplies. A programmable baud rate generator can select transmit and receive clock rates from 50 bps to 1.5 Mbps. The ST16C550 is an improved version of the NS16C550 UART with higher operating speed and lower access time.

Fig 3.3: PLCC package The ST16C550 on board status registers provides the error conditions, type and status of the transfer operation being performed. Included are complete MODEM control capability and a processor interrupt system that may be software tailored to the users

Refer 1

25

requirements. The ST16C550 provides internal loop back capability for on board diagnostic testing.

The ST16C550 is available in 40 pin PDIP, 44 pin PLCC, and 48 pin TQFP packages. It is fabricated in an advanced CMOS process to achieve low drain power and high speed requirements. MIK serves parallel communication whereas GSM modem serves serial communication. Hence there is a need of conversion from parallel to serial communication. UART converts is connected between MIK and GSM modem, which serves this purpose.

3.3.1.2 FEATURES:

Pin to pin and functionally compatible to the Industry Standard 16C550 24MHz clock operation at 5V 16MHz clock operation at 3.3V 16 byte transmit FIFO 16 byte receive FIFO with error flags Full duplex operation Transmit and receive control Four selectable receive FIFO interrupt trigger levels Standard modem interface Compatible with ST16C450 Low operating current (1.2mA typ.)

26

Fig 3.4: Block diagram of UART

27

Table 3.1: Symbol description

28

29

30

3.3.1.3 FUNCTIONAL DESCRIPTION

The ST16C550 provides serial asynchronous receive data synchronization, parallel-to-serial and serial-to-parallel data conversions for both the transmitter and receiver sections. These functions are necessary for converting the serial data stream into parallel data that is required with digital data systems. Synchronization for the serial data stream is accomplished by adding start and stops bits to the transmit data to form a data character (character orientated protocol). Attaching a parity bit to the data character insures data integrity. The receiver for any transmission bit errors checks the parity bit. The electronic circuitry to provide all these functions is fairly complex especially when manufactured on a single integrated silicon chip. The ST16C550 represents such integration with greatly enhanced features.

The ST16C550 is fabricated with an advanced CMOS process. The ST16C550 is an upward solution that provides 16 bytes of transmit and receive FIFO memory, instead of 1 byte provided in the 16C450. The ST16C550 is designed to work with high-speed modems and shared network environments that require fast data processing time. Increased performance is realized in the ST16C550 by the larger transmit and receive FIFOs. This allows the external processor to handle more networking tasks within a given time. The 4 selectable levels of FIFO trigger provided for maximum data throughput performance especially when operating in a multi-channel environment.

The combination of the above greatly reduces the bandwidth requirement of the external controlling CPU, increases performance, and reduces power consumption. The ST16C550 is capable of operation to 1.5Mbps with a 24 MHz crystals or external clock input. With a crystal of 14.7464 MHz and through a software option, the user can select data rates up to 460.8Kbps or 921.6Kbps.

PROGRAMMABLE BAUD RATE GENERATOR

31

Programming the Baud Rate Generator Registers DLM (MSB) and DLL (LSB) provides a user capability for selecting the desired final baud rate. The example in Table 3.2 below shows selectable baud rates when using a 1.8432 MHz crystal. For custom baud rates, the divisor value can be calculated using the following equation:

Divisor (in decimal) = (XTAL1 clock frequency) / (serial data rate x 16)

Table 3.2: Baud rate generator programming table

3.3.1.4 INTERNAL REGISTERS FUNCTIONAL DESCRIPTIONS

The ST16C550 provides 12 internal registers for monitoring and control and are shown in Table below. These registers function as data holding registers (THR/RHR), interrupt status and control registers (IER/ISR), a FIFO control register (FCR), line status and control registers, (LCR/LSR), modem status and control registers (MCR/MSR), programmable data rate (clock) control registers (DLL/DLM), and a user assessable scratchpad register (SPR).

Table 3.3: ST16C550 Internal registers 32

Note *1: The BRG registers are accessible only when LCR bit-7 is logic 1. Note *2: The value represents the registers initialized HEX value. An X signifies a 4bit un-initialized nibble.

TRANSMIT AND RECEIVE HOLDING REGISTER

The serial transmitter section consists of an 8-bit Transmit Hold Register (THR) and Transmit Shift Register (TSR). The status of the THR is provided in the Line Status Register (LSR). Writing to the THR transfers the contents of the data bus (D7-D0) to the THR, providing that the THR or TSR is empty. The THR empty flag in the LSR register

33

will be set to logic 1 when the transmitter is empty or when data is transferred to the TSR. Note that a write operation can be performed when transmit holding register empty flag is set (logic 0 = at least one byte in FIFO / THR, logic 1= FIFO/THR empty). The serial receive section also contains an 8-bit Receive Holding Register, RHR. Receive data is removed from the ST16C550 and receive FIFO by reading the RHR register. Receiver status codes will be posted in the LSR.

LINE CONTROL REGISTER (LCR)

The Line Control Register is used to specify the asynchronous data communication format. The word length, the number of stop bits, and the parity are selected by writing the appropriate bits in this register. Bit 0&1 is for word length and it is set as11 for 8 bit and other bits to zero.

LCR BIT 0-1: These two bits specify the word length to be transmitted or received (logic 0 or cleared is the default condition). Table 3.4: To set the word length

Table 3.5: To set the stop bit

34

LCR BIT-2: (logic 0 or cleared is the default condition .The length of stop bit is specified by this bit in conjunction with the programmed word length

LCR BIT-3: Parity or no parity can be selected via this bit. Logic 0 = No parity (normal default condition) Logic 1 = A parity bit is generated during the transmission; receiver checks the data and parity for transmission errors.

LCR BIT-4: If the parity bit is enabled with LCR bit-3 set to logic 1, LCR BIT-4 selects the even or odd parity format. Logic 0 = ODD Parity is generated by forcing an odd number of logic 1s in the transmitted data. The receiver must be programmed to check the same format. (Normal default condition) Logic 1 = EVEN Parity is generated by forcing an even the number of logic 1s in the transmitted. The receiver must be programmed to check the same format.

LCR BIT-5: If the parity bit is enabled, LCR BIT-5 selects the forced parity format. LCR BIT-5 = logic 0, parity is not forced (normal default condition) LCR BIT-5 = logic 1 and LCR BIT-4 = logic 0, parity bit is forced to a logical 1 for transmit and receive data. LCR BIT-5 = logic 1 and LCR BIT-4 = logic 1, parity bit is forced to a logical 0 for transmit and receive data.

35

LCR BIT-6: When enabled the Break control bit causes a break condition to be transmitted (the TX output is forced to a logic 0 state). This condition exists until disabled by setting LCR bit-6 to logic 0. Logic 0 = No TX break condition. (Normal default condition) Logic 1 = Forces the transmitter output (TX) to a logic 0 for alerting the remote receiver to a line break condition.

LCR BIT-7: The internal baud rate counter latch and Enhance Feature mode enable. Logic 0 = Divisor latch disabled. (Normal default condition) Logic 1 = Divisor latch and enhanced feature register enabled.

LINE STATUS REGISTER (LSR)

This register provides the status of data transfers between the ST16C550 and the CPU.

LSR BIT-0: Logic 0 = No data in receive holding register or FIFO. (Normal default condition) Logic 1 = Data has been received and is saved in receive holding register or FIFO.

LSR BIT-1: Logic 0 = No overrun error. (Normal default condition) Logic 1 = Overrun error. A data overrun error occurred in the receive shift register. This happens when additional data arrives while the FIFO is full. In this case the previous data in the shift register is overwritten. Note that under this condition the data byte in the receive shift register is not transfer into the FIFO; therefore the data in the FIFO is not corrupted by the error.

LSR BIT-2: Logic 0 = No parity error (Normal default condition) Logic 1 = Parity error. The receive character does not have correct parity information and is suspect. In the FIFO mode, this error is associated with the character at the top of the FIFO.

36

LSR BIT-3: Logic 0 = No framing error (Normal default condition). Logic 1 = Framing error. The receive character did not have a valid stop bit(s). In the FIFO mode this error is associated with the character at the top of the FIFO.

LSR BIT-4: Logic 0 = No break condition (Normal default condition) Logic 1 = The receiver received a break signal (RX was a logic 0 for one character frame time). In the FIFO mode, only one break character is loaded into the FIFO.

LSR BIT-5: This bit is the Transmit Holding Register Empty indicator. This bit indicates that the UART is ready to accept a new character for transmission. In addition, this bit causes the UART to issue an interrupt to CPU when the THR interrupt enable is set. The THR bit is set to logic 1 when a character is transferred from transmit holding register into the transmitter shift register. The CPU resets the bit to logic 0 concurrently with the loading of the transmitter holding register. In the FIFO mode this bit is set when the transmit FIFO is empty; it is cleared when at least 1 byte is written to the transmit FIFO.

LSR BIT-6: This bit is the Transmit Empty indicator. This bit is set to a logic 1 whenever transmit holding register and the transmit shift register are both empty. It is reset to logic 0 whenever either the THR or TSR contains a data character. In the FIFO mode this bit is set to one whenever the transmit FIFO and transmit shift register are both empty.

LSR BIT-7: Logic 0 = No Error (normal default condition) Logic 1 = At least one parity error, framing error or break indication is in the current FIFO data. This bit is cleared when there are no remaining LSR errors in the RX FIFO. 3.3.2: GSM MODEM

3.3.2.1 Introduction Maestro 20 is a ready-to-use GSM modem for voice, data, fax and SMS services. It also supports GPRS (Class 2) for hi-speed data transfer. Using AT command for all

37

kinds of operations can easily control maestro 20. With standard 9-pin RS232 port and telephone-like audio plug the Maestro 20 can be set up with minimal effort.

Fig 3.5: Interfaces

15-PIN D-SUB FEMALE CONNECTOR (RS232 / AUDIO)

The connector provides serial link and audio link to the modem. It consists of 15 pins and its functional details are as follows

Fig 3.6:15 pin female connector

38

Table 3.6: Functions of pins of female connector

STATUS INDICATOR

The LED will indicate different status of the modem: - Off Modem switched off - On Modem is connecting to the network - Flashing slowly Modem is in idle mode - Flashing rapidly Modem is in transmission/communication (GSM only)

SMA FEMALE ANTENNA CONNECTOR

Connect this to an external antenna with SMA male connector. Make sure the antenna is for the GSM900/1800 frequency with impedance of 50ohm, and also connector is secured tightly.

39

INSTALL THE SIM CARD

Use a ball pen or paper clip to press the SIM holder eject button. The SIM holder will come out a little. Then take out the SIM holder. Note: DO NOT pull out the SIM holder without pushing the ejector. Put the SIM card to the tray; make sure it has completely sat on the tray. Put the tray back into the slot.

CONNECT THE EXTERNAL ANTENNA (SMA TYPE)

Connect this to an external antenna with SMA male connector. Make sure the antenna is for the GSM900/1800 frequency with impedance of 50ohm, and also connector is secured tightly.

Note: Please use antenna designed for GSM 900/1800 MHz operation. Incorrect antenna will affect communication and even damage the modem and connect the DC power supply and also connect the modem to the external device.

CHECKING THE MODEM (using Microsoft Windows TM HyperTerminal as example)

1. On the first time power-up you can use terminal software to communicate with the modem through an RS-232 serial Port. On Windows 98, start the HyperTerminal program. Assign a name for a new session as in fig 3.8 2 Choose a correct COM port and baud rate setting as in fig 3.9 and type AT and check for OK

40

Fig 3.7: HyperTerminal in windows 98

Fig 3.8: Assigning a name to a new session

41

Fig3.9: setting correct COM port and baud rate

Fig 3.10: Checking the MODEM

42

3.3.2.2 BASIC OPERATION

The words, Mobile station (MS) or Mobile Equipment (ME) are used for mobile terminals supporting GSM services. A call from a GSM mobile station to the PSTN is called a mobile originated call (MOC) or outgoing call, and a call from a fixed network to a GSM mobile station is called a mobile terminated call (MTC) or incoming call.

Command always start with AT (which means Attention) and finish with a <CR> character. GSM modem communicates with a mobile Via AT commands. Followings are examples of some AT commands. AT AT+CSQ AT+CGMI AT+CMGS AT+CMGR AT+CNMI AT+CSCA AT+CCLK

The first command that has to be operated is AT and the result code of this command should be OK which indicates that the modem is ready for communication. The operations and the result codes of some of the AT commands are as follows

43

44

45

46

3.3.3: STEPPER MOTORS 3.3.3.1: GENERAL DESCRIPTION

A step motor converts electrical energy into discrete motions or steps. The motor consists of multiple electrical windings wrapped in pairs (phases) around the outer stationary portion of the motor (stator). The inner portion (rotor) consists of iron or

47

magnetic disks mounted on a shaft and suspended on bearings. The rotor has projecting teeth, which align with the magnetic fields of the windings. When the coils are energized in sequence by direct current, the teeth follow the sequence and rotate a discrete distance necessary to realign with the magnetic field. The number of coil combinations (phases) and the number of teeth determine the number of steps (resolution) of the motor. For example, a 200 step per rev (spr) motor has 50 rotor teeth times 4 coil combinations to equal 200spr.

There are no brushes between the rotor and stator assembly; a stepper motor is a multi pole (polyphase) brushless DC motor. These multiple coil pairs can be connected either positive or negative resulting in four unique full steps. When the coils are sequenced correctly, the motor rotates for- ward. When the sequence is reversed, the motor rotates in reverse. When the sequence is held, the rotor locks (brakes) in place.

The amount of torque required to force the rotor from position is the holding or static torque. If the rotor slips (step loss), it will align with the next available coil combination; either four steps forward or four steps backwards. Steppers can be stalled or held indefinitely without damage.

If the sequencing is faster than the rotor can move, the rotor will slip until sequencing is slowed enough for the rotor to again lock-in to the sequence. The rotor requires a minimum settling time (ringing) to stop when held. This limits the minimum time for the motor to change direction successfully.

3.3.3.2 Electrical type of stepper motors-VR, PM, HYBRID VR (Variable Reluctance) motors have soft iron rotors with teeth and are mostly used for specialty applications. Permanent magnet motors have magnet rotors with no teeth.

48

Hybrid motors are hybridization of both VR and PM and have magnetic rotors with teeth. These types differ in terms of construction based on the use of permanent magnets and/or iron rotors with laminated steel stators.

3.3.3.3 MECANICAL TYPE OF STEPPER MOTORS Pressed Case (PC) and Machined Case (MC) Pressed Case (tin can) motors are stamped, mated shells with sleeve bearings. Machined case motors have cast aluminum end-bells with ball hearings; the bodies are stacks of laminations held together with screws. A PC is generally the permanent magnet type and has a 7.5 or 15 degree step angle. PM motors settle faster than hybrids. If the sequencing frequency (step rate) is close to the natural frequency of the coils, the motor will attempt to resonate at submultiples of this period; resulting in step loss and unusual noise (growling).

3.3.3.4 OPERATION The stepper motor uses the theory of operation for magnets to make the motor shaft turn a precise distance when a pulse of electricity is provided. You learned previously that like poles of a magnet repel and unlike poles attract. Figure 3.11 shows a typical cross-sectional view of the rotor and stator of a stepper motor. From this diagram you can see that the stator (stationary winding) has four poles, and the rotor has six poles (three complete magnets). The rotor will require 12 pulses of electricity to move the 12 steps to make one complete revolution. Another way to say this is that the rotor will move precisely 30 for each pulse of electricity that the motor receives. The number of degrees the rotor will turn when a pulse of electricity is delivered to the motor can be calculated by dividing the number of degrees in one revolution of the shaft (360) by the

49

number of poles (north and south) in the rotor. In this stepper motor 360 is divided by 12 to get 30.

When no power is applied to the motor, the residual magnetism in the rotor magnets will cause the rotor to detent or align one set of its magnetic poles with the magnetic poles of one of the stator magnets. This means that the rotor will have 12 possible detent positions. When the rotor is in a detent position, it will have enough magnetic force to keep the shaft from moving to the next position. This is what makes the rotor feel like it is clicking from one position to the next as you rotate the rotor by hand with no power applied.

Fig 3.11: Diagram that shows the position of the six-pole rotor and four-pole stator of a typical stepper motor

When power is applied, it is directed to only one of the stator pairs of windings, which will cause that winding pair to become a magnet. One of the coils for the pair will become the North Pole, and the other will become the South Pole. When this occurs, the stator coil that is the North Pole will attract the closest rotor tooth that has the opposite polarity, and the stator coil that is the South Pole will attract the closest rotor tooth that has the opposite polarity. When current is flowing through these poles, the rotor will now

50

have a much stronger attraction to the stator winding, and the increased torque is called holding torque. By changing the current flow to the next stator winding, the magnetic field will be changed 90. The rotor will only move 30 before its magnetic fields will again align with the change in the stator field. The magnetic field in the stator is continually changed as the rotor moves through the 12 steps to move a total of 360. STEP MODES Stepper motor "step modes" include Full, Half and Micro step. The type of step mode output of any motor is dependent on the design of the driver. The coils are activated, in sequence, to attract the rotor, which is indicated by the arrow in the picture. (Remember that a current through a coil produces a magnetic field.) This conceptual diagram depicts a 90-degree step per phase. Assuming Terminal 1a is positive and 1b is negative, the rotor points to the East in this diagram. If these two terminals were reversed in polarity the rotor would point to the West. Coil 2 is entirely de-activated in the diagram.

Fig3.12: Conceptual model of bipolar stepper motor

51

In a basic "Wave Drive" clockwise sequence, winding 1 is de-activated and winding 2 activated to advance to the next phase. The rotor is guided in this manner from one winding to the next, producing a continuous cycle. Note that if two adjacent windings are activated, the rotor is attracted mid-way between the two windings. The following table describes 3 useful stepping sequences and their relative merits. The polarity of terminals is indicated with +/-. After the last step in each sequence the sequence repeats. Stepping backwards through the sequence reverses the direction of the motor. Note that these sequences are identical to those for a unipolar Stepper Motor. The high torque two-phase mode is the preferred mode, which is employed in this project. Table 3.7: Stepping Sequences

Sequence

Polarity

Name Wave Drive, One-Phase

Description Consumes the least power. Only one phase is energized at a time. Assures positional accuracy regardless of any winding imbalance in the motor.

0001 0010 0100 1000 0011 0110 1100 1001

---+ --+-+-+----++ -++++-+--+

HiTorque, TwoPhase

Hi Torque - This sequence energizes two adjacent phases, which offers an improved torque-speed product and greater holding torque.

0001 0011 0010 0110

---+ --++ --+-++-

Half-Step

Half Step - Effectively doubles the stepping resolution of the motor, but the torque is not uniform for each step. (Since we are effectively switching between Wave Drive

52

0100 1100 1000 1001 Fig 3.13

-+-++-+--+--+ shows the position

and Hi-Torque with each step, torque alternates each step.) This sequence reduces motor resonance, which can sometimes cause a motor to stall at a particular resonant frequency. Note that this sequence is 8 steps. of the rotor changing as the current

supplied to the stator changes.

Fig 3.13:Movement of the stepper motor rotor as current is pulsed to the stator. (a) Current is applied to the top and bottom windings, so the top winding is north (b) Current is applied to left and right windings, so the left winding is north (c) Current is applied to the top and bottom windings, so the bottom winding is north (d) Current is applied to the left and right windings so the right winding is north.

In Fig. 3.13a you can see that when current is applied to the top and bottom stator windings, they will become a magnet with the top part of the winding being the North Pole, and the bottom part of the winding is being the South Pole. You should notice that this will cause the rotor to move a small amount so that one of its south poles is aligned

53

with the north stator pole (at the top), and the opposite end of the rotor pole, which is the north pole, will align with the south pole of the stator (at the bottom). A line is placed on the south-pole piece that is located at the 12 o'clock position in Fig. 3.13a so that you can follow its movement as current is moved from one stator winding to the next.

In Fig. 3.13b current has been turned off to the top and bottom windings, and current is now applied to the stator windings shown at the right and left sides of the motor. When this occurs, the stator winding at the 3 o'clock position will have the polarity for the south pole of the stator magnet, and the winding at the 9 o'clock position will have the north-pole polarity. In this condition, the next rotor pole that will be able to align with the stator magnets is the next pole in the clockwise position to the previous pole. This means that the rotor will only need to rotate 30 in the clockwise position for this set of poles to align it so that it attracts the stator poles.

In Fig. 3.13c you can see that the top and bottom stator windings are again energized, but this time the top winding is the south pole of the magnetic field and the bottom winding is the North Pole. This change in magnetic field will cause the rotor to again move 30 in the clockwise position until its poles will align with the top and bottom stator poles. You should notice that the original rotor pole that was at the 12 o'clock position when the motor first started has now moved three steps in the clockwise position.

In Fig. 3.13d you can see that the two side stator windings are again energized, but this time the winding at the 3 o'clock position is the North Pole. This change in polarity will cause the rotor to move another 30 in the clockwise direction. You should notice that the rotor has moved four steps of 30 each, which means the rotor has moved a total of 120 from its original position. This can be verified by the position of the rotor pole that has the line on it, which is now pointing at the stator winding that is located in the 3 o'clock position.

54

3.3.3.5 SHORTCUT FINDING THE PROPER WIRING SEQUENCE

The sequence of windings & the common terminal are to be found for proper wiring of the motor. It is required to first detect the common terminal (Vcc). To do this the resistances between the wires of the motor are found. This resistance (Rwc) is x between a coil winding & the common terminal whereas it is2x (Rww) between two coil windings. Thus in this way the common terminal& the windings are separated.

Fig 3.14: Excitation of stepper motor

Next step is to detect the proper sequence of wiring of the windings. Connect the 4 coil wires to the controller in any pattern. If it doesn't work at first, you only need try these 2 swaps... 12 4 8 12 8 4 18 2 4 - (arbitrary first wiring order) - switch end pair - switch middle pair

It is finished when the motor turns smoothly in either direction. If the motor turns in the opposite direction from desired, reverse the wires so that ABCD would become DCBA.

3.3.3.6 SPECIFICATIONS OF THE MOTOR IN USE (IN THIS PROJECT) Voltage = 5V Current = 200mA Rwc =77 ohms Rww =155 ohms.

55

Since the current requirement is 200mA for the motor, it is required provide current amplification by using the current driving IC ULN2803 which also acts as the inverter, hence an inverter IC 7404 is used prior to current amplifier.

3.3.4: THERMISTOR 3.3.4.1 THERMISTOR TEMPERATURE SENSOR


2

Thermistors are special solid temperature sensors that behave like temperature-

sensitive resistors; hence their name is a contraction of "thermal" and "resistor". They are mostly very small bits of special material that exhibit more than just temperature sensitivity. They are highly sensitive and have very reproducible resistance Vs temperature properties. They are used inside many other devices as temperature sensing and correction devices as well as in specialty temperature sensing probes for commerce, science and industry & in this project for sensing of the various levels of temperatures as normal, above threshold & below threshold, the threshold being set by the user (i.e.) the supervisor or the control engineer Thermistors typically work over a relatively small temperature range, compared to other temperature sensors, and can be very accurate and precise within that range, although not all are. There is a variety of temperature sensors on the market all of which meet specific application needs. The most common sensors that are used to solve these application problems include the thermocouple, Resistive Temperature Detector (RTD), thermistor, and silicon-based sensors. CHOOSE THE RIGHT TEMPERATURE SENSOR (based on application)

Of the temperature sensors on the market today, the thermocouple, RTD, Thermistor, and Integrated Silicon Sensors are continuing to dominate. The thermocouple is most appropriate for higher temperature sensing, while the RTD is best suited for lower
2

Refer 3

56

temperatures were good linearity is desirable. The Thermistor is typically used for applications with smaller temperature ranges, but it offers greater accuracy than the thermocouple or the RTD. All four of the sensors mentioned in this application note have the capability of providing good, accurate, and reliable performance, making the final sensor selection appear somewhat trivial. However, once the temperature sensor has been selected, the next step is to design the analog and digital signal conditioning circuit. The design of this circuit will determine the actual performance that is finally achieved.

GET THE GREAT ACCURACY OF THERMISTOR

If accuracy is a high priority, the thermistor should be the temperature sensor of choice & since in this project accuracy of temperature measurement & hence its control seek importance, thermistors are chosen.

Thermistors are available in two varieties, NTC and PTC. The NTC (negative temperature coefficient) thermistor is constructed of ceramics composed of oxides of transition metals (manganese, cobalt, copper, and nickel). With a current excitation the NTC has a negative temperature coefficient that is very repeatable and fairly linear. These temperature dependent semiconductor resistors operate over a range for -100C to 450C. The type of thermistor in use in this project is the PTC type.

3.3.4.2: DESCRIPTION

The PTC thermistor has a positive temperature co-efficient and is constructed from barium titanate. The sensitivity of the PTC is considerably higher than the sensitivity of the NTC thermistor and should be used when a specific temperature range is of interest (-25 to150C).

Positive Temperature Coefficient thermistors are truly remarkable for their ability to function as self-regulating heating elements. They can operate at a nearly constant temperature over a broad range of voltage and dissipation conditions. PTC heaters can be

57

manufactured in many different configurations. These include discs, rectangles, squares, cylinders, and various shapes with holes to increase surface area. Multiple PTCs can be used in parallel to provide constant heating over a larger area. This project employs disc type thermistor

Fig 3.15: Different configurations of PTC Switching PTC (Positive Temperature Coefficient) thermistors are solid-state devices that exhibit several decades of resistance change over a narrow temperature range. This extremely large positive resistance change as the temperature increases generates many applications for these parts.

Over the lower portion of the resistance versus temperature curve the thermistor resistance if fairly constant. At higher temperatures the material passes through a threshold temperature (between 80C and 140C, dependent on chemical composition of the ceramic) where the resistance versus temperature characteristics change dramatically (fig 3.16).At this point, increases in temperature cause a rise in the PTC's resistance and the PTC resistive / temperature characteristics become very steep.

58

Fig 3.16: Typical PTC curve.

A second type of PTC thermistor is known as the Silistor. This device is constructed of a thermally sensitive silicon material and also has a positive temperature coefficient (-60C to 150C) that is linear over the entire operating range. Both of the thermal characteristics of the PTC type thermistors are shown in Figure 3.17

Fig 3.17: PTC thermistor and silistor resistance versus temperature response.

59

3.3.4.3 THE TEMPERATURE- RESISTIVE MODE OF THERMISTOR [The excitation method]

An electrical configuration for the thermistor is shown in Figure 3.18. This illustrates a seemingly obvious way to excite the thermistor and measure the change in resistance where the sensing element is excited with a voltage source. With this style of excitation, the magnitude of the current source is typically below 100mA, preferably 20mA.

Lower currents prevent the thermistor from entering a self-heating condition. This style of excitation is effective for sensing a limited range of temperatures. Larger ranges of temperature have deltas in resistance that are too high to accurately convert the resistance to voltage without bumping into the noise limitations of the analog signal path.

Fig 3.18: Thermistor excited by a precision voltage source PTC Thermistor has both advantages and disadvantages. They are listed in the table below. Table 3.8: Advantages and disadvantages of thermistor

ADVANTAGES

DISADVANTAGES

Fast Small Two-wire

Non-Linear Excitation Required Limited temperature range

60

Inexpensive

Self-heating Fragile

3.3.4.4 GRAPHICAL REPRESENTATION

PTC Thermistors can be formulated to have switching temperatures as low as zero (0) C to well over 200 C. Figure 3.19 illustrates typical 60, 80, 100, and 120 C switching temperature curves.

Fig 3.19: PTC thermistor curve (Resistance Vs Temperature)

Figure 3.20 illustrates a static voltage / current curve. The static voltage / current curve are very helpful in over current applications.

61

Fig 3.20: Static voltage/current curve

3.3.4.5 TERMINOLOGY

BASE RESISTANCE - The resistance value of a thermistor at a specified temperature with negligible electrical power to avoid self heating. Usually base resistance will be defined at 25 C.

SWITCH TEMPERATURE - The temperature when the resistance of the PTC thermistor reaches two (2) times the base resistance, sometimes referred to as Curie point or transition temperature.

MAXIMUM OPERATING VOLTAGE - The maximum rated voltage the thermistor can continuously withstand (60 cycles AC or DC).

62

DISSIPATION CONSTANT - The amount of power through self-heating necessary to raise the thermistor body one (1) degree Celsius - units: Mw/C.

TIME CONSTANT - The time, in seconds, required for a thermistor dissipating negligible power to change 63% of the total difference between its initial and final body temperature when subjected to a change in temperature

Although the thermistor is non-linear, it can be tamed for a limited temperature range. This allows the design of an inexpensive temperature sensing device which can be used in a variety of Analog-to-Digital Converter applications.

3.3.5 RELAYS

A RELAY is a device that operates a switch by remote control. A relay triggers interruption of a circuit when a fault is detected. An electromechanical switch that uses a small amount of incoming electricity to charge an electromagnet, which physically pulls down a connecting switch to complete a circuit. This allows a low-power circuit to divert the electricity in a high-power circuit. Relays are those, which are used for the control of the ac or dc power. This project employs the relay for the purpose of either switching on or off the machine setup. When the MIK receives instructions from the control engineer, it initially analyses the command & on encountering a start functioning command as *M045M5*, the

63

mode is set as Manual & range as 45 to 55 degrees & keeps the machine setup ON for 5 minutes & hence on receiving this instruction, the MIK initiate the relay to switch ON the machine.

Thus relay is connected via a condenser to the machine.

3.3.6 REGULATORS

This project employs a simple fan regulator to regulate the amount of current flowing through the machine setup. The stepper motor is connected to the machine setup via the regulator. As instructions pass on from the control engineer to the PIC, the number of steps to be moved either forward or reverse as specified by the engineer is passed on to the stepper motor. The motor rotates accordingly which in turn is conveyed to the machine via a regulator whose potentiometer knob is connected to the stepper motors motion. As pot gets varied, the amount of current flowing through the setup is also varied according to motors motion either in the forward direction or in the reverse direction. CHAPTER 4: Software Design

4.1 Coding: ;//FOR CHECKING COM2(UART CONFIGURED AT 0000) ;//GET AND TX THRU COM2(UART PORT)

;//WHEN SYSTEM IS RESET IT MUST JUMP TO START ORG 2000H LJMP START

ORG 2003H

64

RETI

ORG 200BH LJMP ISR

ORG 2013H RETI

ORG 201BH RETI

ORG 2023H RETI

;//CODE SEGMENTING

CSEG AT 2100H

;//INITIALISING THE SYSTEM, INITIALISING THE PROGRAM STATUS WORD TO 00H, ;//MAKING THE STACK POINTER POINT TO 64H, SELECTING REGISTER BANK1 AND ;//CALLING THE SERIAL PORT INITIALISATION

START: CLR A MOV PSW,#00H MOV SP,#64H CLR RS0 SETB RS1 SETB EA

65

CLR EX1 SETB ET1 CLR EX0 SETB ET0 SETB ES CALL SIO_INIT CLR PSW.5

CALL SIO_INT

MOV DPTR,#0018H MOV A,#99H MOVX @DPTR,A MOV 45H,A

MOV R7,#00H CLR P1.0 ;//SENDING OK ONTO THE PCTERM SCREEN

MOV A,#'A' CALL TX MOV R2,A CALL OUT_CHAR CALL DELAY MOV A,#'T' MOV R2,A CALL OUT_CHAR CALL DELAY MOV A,#0DH

66

MOV R2,A CALL OUT_CHAR CALL DELAY AT1: CALL IN_CHAR CJNE A,#0AH,AT1

AT2: CALL IN_CHAR CJNE A,#0AH,AT2

MOV A,#'\' CALL TX

SKIP1:

MOV

DPTR,#CNMI

LCALL CMD_TX

CNM1: LCALL IN_CHAR CJNE A,#'=',CNM1

MOV

DPTR,#CNMI1

LCALL CMD_TX

MOV

R2,#0DH

LCALL OUT_CHAR

67

CNM2: LCALL IN_CHAR CJNE A,#0AH,CNM2

CNM3: LCALL IN_CHAR CJNE A,#0AH,CNM3

LCALL DELAY

;CALLING DELAY SUBROUTIN

MOV DPTR,#CMGF LCALL CMD_TX

MOV R2,#0DH LCALL OUT_CHAR

CMG1: LCALL IN_CHAR CJNE A,#0AH,CMG1

CMG2: LCALL IN_CHAR CJNE A,#0AH,CMG2

LCALL DELAY

68

LCALL MESREAD

SETB P1.0 MOV A,42H

MOV

43H,A

LCALL TIMERON

MOV A,#0DH CALL TX

CONT: CALL CONTROL CALL DELAY

MOV A,#0DH CALL TX JNB PSW.5,SKIPP CLR PSW.5 MOV A,#'+' CALL TX

LCALL SENDMESS

MOV A,#'$'

CALL TX

69

SKIPP: JMP CONT

;// MOVING DATA FROM RECEIVE BUFFER REGISTER, CHECKING FOR DATA READY BY ANDING ;// WITH 01H

IN_CHAR: MOV DPTR,#0005H IN_CHAR1: MOVX A,@DPTR ANL A,#01 CJNE A,#01,IN_CHAR1 MOV DPTR,#0000H MOVX A,@DPTR MOV R2,A CALL TX RET

;//MOVING DATA FROM TRANSMITTER HOLDING REGISTER TO THE PCTERM SCREEN, CHECKING ;//FOR TRANSMITTER BUFFER HOLDING REGISTER EMPTY BY ANDING THE DATA WITH 20H

OUT_CHAR: MOV DPTR,#0005H OUT_CHAR1: MOVX A,@DPTR

70

ANL A,#20H

CJNE A,#20H,OUT_CHAR1 MOV DPTR,#0000H MOV A,R2 MOVX @DPTR,A RET

SIO_INIT: MOV MOV DPTR,#0003H A,#80H ;//ADD OF Line Control Register

;//DLAB = 1 and 8 bit Wordlength

MOVX @DPTR,A MOV MOV DPTR,#0000H A,#0CH ;//DLL

;//9600 BPS

MOVX @DPTR,A MOV MOV DPTR,#0001H ;//IER

A,#00H

MOVX @DPTR,A MOV MOV DPTR,#0003H A,#03H ;//LCR

MOVX @DPTR,A MOV MOV DPTR,#0001H ;//IER

A,#00H

MOVX @DPTR,A MOV MOV DPTR,#0004H A,#0AH ;//MCR

MOVX @DPTR,A RET

DELAY:

71

MOV LMK:NOP NOP

R7,#0FFH

DJNZ R7,LMK RET

DELAY1: MOV LMK10: MOV R6,#7FH R7,#0FFH

LMK0: NOP NOP DJNZ DJNZ RET R6,LMK0 R7,LMK10

SIO_INT: MOV A,#0F6H MOV TH1,A MOV SCON,#50H MOV TMOD,#21H MOV 87H,#80H SETB TR1 CLR TI CLR RI RET RX: JNB RI,$

72

MOV A,SBUF CLR RI RET TX: JNB TI,$ CLR TI MOV SBUF,A RET

ENTER: CLR MOV ENT2: MOV A,R3 A R3,A

MOVC A,@A+DPTR CJNE RET ENT1: CALL INC CALL JMP TX R3 DELAY ENT2 A,#'*',ENT1

;TO DELETE THE MESSAGE FROM LOCATION 1 MESDEL:

73

MOV

DPTR,#DEL

CALL CMD_TX

MES1: CALL IN_CHAR CJNE A,#'D',MES1

MOV

DPTR,#DEL12

CALL CMD_TX MOV R2,#0DH

CALL OUT_CHAR

MES2: CALL IN_CHAR CJNE A,#0AH,MES2

DEL1: CALL IN_CHAR CJNE A,#0AH,DEL1

RET

MESID:

;WAIT FOR MESSAGE INDICATION

ID1: CALL IN_CHAR

74

CJNE A,#0AH,ID1

ID2: CALL IN_CHAR CJNE A,#0AH,ID2

RET

MESREAD:

RED1: CALL IN_CHAR CJNE A,#0AH,RED1

RED2: CALL IN_CHAR CJNE A,#0AH,RED2

RED6:

MOV R0,#40H RED7: CALL IN_CHAR CJNE A,#'*',ESC CALL IN_CHAR MOV @R0,A ;40H -TYPE IS STORED CALL IN_CHAR CJNE A,#'*',ESC

75

INC R0 CALL IN_CHAR SUBB A,#30H SWAP A MOV @R0,A CALL IN_CHAR SUBB A,#30H ADD A,@R0 MOV @R0,A CALL IN_CHAR CJNE A,#'*',ESC INC R0 CALL IN_CHAR SUBB A,#30H MOV @R0,A ESC: CALL IN_CHAR CJNE A,#0AH,ESC RET ;42H TIME IS STORED ;41H TEMPERATURE VALUE IS STORED

CONTROL:

ADC: MOV DPTR,#0008H MOV A,#0FFH MOVX @DPTR,A

76

JB P3.2,$ MOVX A,@DPTR MOV 30H,A

MOV DPTR,#TEMP1 CALL ENTER ; CALL MSGSEND ; MOV R2,#1AH ; CALL OUT_CHAR

TX1:

CLR C MOV A,30H SUBB A,#5CH MOV 31H,A MOV B,#03H DIV AB ;REFERENCE FOR THERMISTOR

MOV DPTR,#NME MOVC A,@A+DPTR

MOV 32H,A

ANL A,#0F0H SWAP A CJNE A,#09H,DIS1

77

JMP DIS2

DIS1: JC DIS2 ADD A,#07H

DIS2: CLR C ADD A,#30H CALL TX

MOV A,32H ANL A,#0FH CJNE A,#09H,DIS11 JMP DIS21

DIS11: JC DIS21 ADD A,#07H

DIS21: CLR C ADD A,#30H CALL TX

MOV A,#0DH CALL TX

78

MOV A,32H CJNE A,41H,ENT RET

ENT: JC ENTOP JMP ENTCLO

ENTCLO:

MOV A,45H RL A MOV 45H,A MOV DPTR,#0018H MOVX @DPTR,A CALL DELAY CALL DELAY CALL DELAY CALL DELAY1 CALL DELAY1 CALL DELAY1

MOV A,#'F' CALL TX RET

79

ENTOP:

CLR C

MOV A,45H RR A MOV 45H,A MOV DPTR,#0018H MOVX @DPTR,A CALL DELAY CALL DELAY CALL DELAY CALL DELAY1 CALL DELAY1 CALL DELAY1

MOV A,#'R' CALL TX RET

TIMERON:

MOV MOV MOV

50H,#06H 51H,#7FH TH0,#00H

80

MOV SETB RET

TL0,#00H TR0

ISR: CLR TR0

DJNZ 51H,ISR1 MOV 51H,#0FFH

DJNZ 50H,ISR1 MOV MOV 51H,#7FH 50H,#06H

DJNZ 42H,ISR1 MOV MOV SETB ISR1: MOV MOV SETB RETI SENDMESS: MOV A,#']' CALL TX MOV A,#'A' CALL TX MOV R2,A CALL OUT_CHAR CALL DELAY MOV A,#'T' MOV R2,A CALL OUT_CHAR TH0,#00H TL0,#00H TR0 A,43H 42H,A PSW.5

81

CALL DELAY MOV A,#0DH MOV R2,A CALL OUT_CHAR CALL DELAY

AT11: CALL IN_CHAR CJNE A,#0AH,AT11

AT21: CALL IN_CHAR CJNE A,#0AH,AT21

MOV A,#'\' CALL TX

SKIP11:

MOV

DPTR,#CNMI

LCALL CMD_TX

CNM11: LCALL IN_CHAR CJNE A,#'=',CNM11

MOV

DPTR,#CNMI1

82

LCALL CMD_TX

MOV

R2,#0DH

LCALL OUT_CHAR

CNM21: LCALL IN_CHAR CJNE A,#0AH,CNM21

CNM31: LCALL IN_CHAR CJNE A,#0AH,CNM31

LCALL DELAY

;CALLING DELAY SUBROUTIN

MOV DPTR,#CMGF LCALL CMD_TX

MOV R2,#0DH LCALL OUT_CHAR

CMG11: LCALL IN_CHAR CJNE A,#0AH,CMG11

CMG21: LCALL IN_CHAR CJNE A,#0AH,CMG21

83

; CALL TES

MOV DPTR,#SEN LCALL CMD_TX

SEND1: CALL IN_CHAR CJNE A,#'=',SEND1

MOV DPTR,#SEN1 LCALL CMD_TX

SEND2: CALL IN_CHAR CJNE A,#'3',SEND2

MOV DPTR,#SEN2 LCALL CMD_TX

SEND3: CALL IN_CHAR CJNE A,#'"',SEND3

MOV R2,#0DH CALL OUT_CHAR

SEND4: CALL IN_CHAR CJNE A,#0AH,SEND4

84

MOV A,32H CJNE A,41H,ABNOR

MOV DPTR,#RANGE

JMP ABNOR1

ABNOR: MOV DPTR,#RANGE1

ABNOR1: LCALL CMD_TX CLR P1.0

ABNOR2: LCALL IN_CHAR CJNE A,#'L',ABNOR2

MOV R2,#1AH CALL OUT_CHAR

SEND6: CALL IN_CHAR CJNE A,#0AH,SEND6

85

MOV A,#0AH CALL TX

MOV A,#'P' CALL TX

RET

CMD_TX: CLR A ;SEND STRINGS TO MODEM --- MODULE

MOVC A,@A+DPTR MOV R2,A CJNE A,#'*',CMOUT RET CMOUT: INC DPTR PUSH DPH PUSH DPL CALL OUT_CHAR POP DPL POP DPH JMP CMD_TX

NUM:

DB

'ENTER THE MOBILE NUMBER *'

86

DEL:

DB

'AT+CMGD*'

SEN:

DB

'AT+CMGS=*'

SEN1:

DB

'"+919894*'

SEN2:

DB

'731808"*'

DEL12:

DB

'=1,4*'

READ1:

DB

'AT+CMGR*'

UNKNOWN:

DB

'UNAUTHORISED NUMBER*'

MAN:

DB

'MANUAL*'

AUTO:

DB

'AUTOMATIC*'

FAIL:

DB

'INVALID MESSAGE*'

TEMP:

DB

'0123456789'

INFORM:

DB

'INVALID FORMAT*'

TEMP1:

DB

'CURRENT TEMPERATURE=*'

RANGE:

DB

'NORMAL*'

RANGE1:

DB

'ABNORMAL*'

RANGE2:

DB

'RANGE*'

87

CNMI:

DB

'AT+CNMI=*'

CNMI1:

DB

'2,2,0,0,0*'

CMGF:

DB

'AT+CMGF=1*'

NME:

DB

25H,26H,27H,28H,29H,30H,31H,32H,33H,34H,35H,36H,37H,38H,39H,40H,41H,42H,4 3H,44H,45H

END 4.2: Software Application 4.2.1 HOW TO RUN THE PROGRAM Before starting Check working condition of MIK Board, Power Supply, FRC Connector, and Communication Cable. Check if any of the wires in the interface board is broken or if any of the IC in the board is missing Check Relay circuit and connect the Power lines as per circuit. Connect the terminal (6 pin RMC female) from the main board to the relay board. See the Vcc and ground pins connections exactly. Connect the UART board to MIK using FRC connector ensuring the polarity and connect the GSM modem to the UART board. Connect the FRC connector from the MIK board to Main board and see the correct connection. Connect the power supply and communication cable to MIK board

88

Keep ready a mobile phone to send message to the GSM modem. Before downloading the final hex code make sure that the program containing the correct Message Center Number for the Connection in the GSM modem and ensure the correct mobile number to which the status has to be sent.

E.g., AIRCEL Chennai 00919841044446 AIRTEL Chennai 00919840011003 Before connecting the GSM modem to the UART Board Ensure the signal strength by connecting to the PC and giving commands from PCTERM

4.2.2 Final DEMO Keep ready the final hex code to be downloaded into the MIK board after building the project and exporting the hex code with A00h as the end limit. Disconnect the Relay board terminal before downloading the code. Now download the code and switch to RUN mode and reset the MIK board. Now the load will be off. Before this open PCTERM and keep ready. Now connect the relay board terminal correctly. Now in PCTERM the following commands which are from MIK to GSM modem and Vice versa will be shown

AT OK AT+CSCA=00919XXXXXXXXX OK AT+CNMI=2,2,0,0,0 OK AT+CMGF=1 OK TO SET TIME Y The control will wait to receive a character which decides whether to set time in GSM modem or to proceed with the next command

89

Pressing capital Y will allow user to set time in yy/mm/dd, hh:mm:ss format. Any other characters other than Y will proceed to next command. On pressing Y the following command will be generated. AT+CCLK=05/03/23,15:45:00

Generated by MIK

From this user has to enter up to .

Then the modem will respond as OK. Then the modem will send message to the mobile number in the Program as below AT+CMGS=+919xxxxxxxxx > SYSTEM ON! COMMAND AWAITED! +CMGS: XX OK COMMAND AWAITED Then the system will wait for the message to be received. The message can be from any mobile with the following format Automatic: Manual: *A040-050M4* *M040-050M4*

A automatic, 040-050 is temperature in decimal in centigrade. M minute, 4 number of minutes M- Manual in the second command Then the total operation will be for 4+1 minutes, which is done by checking the time in GSM modem using the AT+CCLK? Command. In Automatic operation the temperature will be monitored and controlled in range for the desired time. Status is sent to the mobile, which controls. After time reaches the temperature is brought down fully low and bulb turned off. In manual, first the temperature is normalized and monitored. If it goes high or low the following message is sent Temperature=0xx ---------- Range - Above or Below Command Awaited Then the system will wait for a message to receive. The message format can be *xxF* or *xxR*

90

X integer number in decimal, F- Forward, R- Reverse The stepper motor will step forward or reverse xx times Then again the temperature is monitored and the operation is continued till the time limit is over. After time is over in both operations the message Mission accomplished! Command Awaited! is sent. And the control will wait for message. 4.2.3 Dos and Donts Do not reset the MIK board with the relay terminal connected. Do check the signal strength of the GSM modem by connecting to the PC. Do not leave any wires carrying AC current without insulation. Do not try to over run the processor by giving wrong commands for long time. Do keep the communication and 1 to 1 cables well differentiated. Do ensure the correct connections of thermistor board, relay board and the stepper motor terminals.

Trouble shooting. Table 4.1 S.No Section Problem 1 1. No response from MIK Board MIK board during active stage

Due to 1.Communication cable problem 2.Com Port not selected according to the PC. 3.System UART not working for ALT+O command in PCTERM 1.Wrong cable connection from PC to Modem. (1 to 1 Modem) 2. Hang over.

Remedy 1.Change cable 2.Change com port and check communication by shorting 2 and 3 pin of cable. 3. Change system. 1. Connect correct cable. 2. Switch off modem once with resetting of program. Now reexecute it. 91

2 GSM Modem

1. Modem not responding to any command or no command is accepted. 2.Modem is not responding to commands in between

3 Electrical Section

demo 3. No message is sent or received 4. Message not sent in between demo. ERROR received 1. Relay is not switching

3. Message Center Number is not correct. 4. Due to poor signal quality. 1. Improper insertion of relay terminal.

Change the CSCA number in program. Reset program. Reset GSM modem 1. Check relay board connection

CHAPTER 5: CONCLUSION

5.1 RESULT Thus the goal is attained using MIKs programming & effectively utilizing its hardware (i.e.) its ports, timers, etc. MIK 89C51 has various features, which enables these tasks to be easier in all aspects. This project offers users with enormous benefits of simplicity, being compatible to situations where the presence near the machine poses a great threat to safety, needing just basic knowledge of messaging & what more it has a lot of reliability.

One added advantage of this project is that the control engineer who supervises the machine can be engaged in any other extra work, so that the company can enhance its production. All these features enhance the usefulness of the project.

5.2 FUTURE ENHANCEMENTS

This project can be further extended to monitor & control more than one parameter with the same simplicity, compatibility & reliability. This project can also be extended to use in household appliances like gas stoves, wherein the utensil with the material to be cooked can be prepared & kept ready on the special gas

92

stove & can ordered to cook via the messaging service, for the prescribed amount of time with the temperature being maintained at specified limits, before we reach home. Reference:

Reference Books: 1. Thomas.R. Peltier., Information Security policies procedures and standard, Auerbach publication, 2001 2. Smith, Daniel Collins., 3G Wireless Networks, Mcgraw Hill Telecom professional, 2001 3. Stephen. J. Chapman., Electric Machinery Fundamental, Mcgraw Hill Telecom professional, 2004 4. Dogan Ibrahim,Microcontroller Project in C for the 8051, Newves Publication, 2004

Websites: 5. www.tectarget.com 6. www.reed-electronics.com 7. www.aecelectronics.com

93

Das könnte Ihnen auch gefallen