Está en la página 1de 97

GSM Based Industrial automation

1. INTRODUCTION
1.1 Introduction to Project:Wireless communication has announced its arrival on big stage and the world is going mobile. We want to control everything and without moving an inch. This remote control of appliances is possible through Embedded Systems. The use of Embedded System in Communication has given rise to many interesting applications that ensures comfort and safety to human life. GSM (Global System for Mobile communications) is an open, digital cellular technology used for transmitting mobile voice and data services. Here we are using it only for transmitting and receiving the messages. GSM wireless data module is used for remote wireless applications, machine to machine or user to machine and remote data communications in many applications. The communication used in this project is the mobile communication. GSM (GLOBAL SYSTEM FOR MOBILE COMMUNICATION) modem is connected to the microcontroller through a MAX232 which is a TTL level converter. GSM based Industrial automation implements the emerging applications of the GSM technology. Using GSM networks, a control system has been proposed that will act as an embedded system which can monitor and control appliances and other devices locally using built-in input and output peripherals. Remotely the system allows the user to effectively monitor and control the house/office appliances and equipments via the mobile phone set by sending commands in the form of SMS messages and receiving the appliances status.

ECE Department, RVRIET

GSM Based Industrial automation

The objective of this project is to develop a device that allows for a user to remotely control and monitor multiple home/office appliances using a cellular phone. This system will be a powerful and flexible tool that will offer this service at any time, and from anywhere with the constraints of the technologies being applied. Possible target appliances include (but are not limited to) climate control system, security systems, lights; anything with an electrical interface. The proposed approach for designing this system is to implement a microcontroller-based control module that receives its instructions and command from a cellular phone over the GSM network. The microcontroller then will carry out the issued commands and then communicate the status of a given appliance or device back to the cellular phone.

1.2 Background:The new age of technology has redefined communication. Most people nowadays have access to mobile phones and thus the world indeed has become a global village. At any given moment, any particular individual can be contacted with the mobile phone. But the application of mobile phone can not just be restricted to sending SMS or starting conversations. New innovations and ideas can be generated from it that can further enhance its capabilities. Technologies such as Infra-red, Bluetooth, etc which has developed in recent years goes to show the very fact that improvements are in fact possible and these improvements have eased our life and the way we live. Remote management of several home and office appliances is a subject of growing interest and in recent years we have seen many systems providing such controls.

ECE Department, RVRIET

GSM Based Industrial automation

These days, apart from supporting voice calls a mobile phone can be used to send text messages as well as multimedia messages (that may contain pictures, graphics, animations, etc.). Sending written text messages is very popular among mobile phone users. Instant messaging, as it is also known, allows quick transmission of short messages that allow an individual to share ideas, opinions and other relevant information. We have used the very concept to design a system that acts a platform to receive messages which in fact are commands sent to control different appliances and devices connected to the platform. We have designed a control system which is based on the GSM technology that effectively allows control from a remote area to the desired location. The application of our suggested system is immense in the ever changing technological world. It allows a greater degree of freedom to an individual whether it is controlling the household appliances or office equipments. The need to be physically present in order to control appliances of a certain location is eliminated with the use of our system. With the advancement and breakthroughs in technology over the years, the lives of people have become more complicated and thus they have become busier than before. With the adoption of our system, we can gain control over certain things that required constant attention. The application of our system comes in handy when people who forget to do simple things such as turn ON or OFF devices at their home or in their office, they can now do so without their presence by the transmission of a simple text message from their mobile phone. This development, we believe, will ultimately save a lot of time especially when people dont have to come back for simple things such as to turn ON/OFF switches at their home or at their office once they set out for their respective work.

1.3 History of Embedded Systems:-

In the earliest years of computers in the 1930-40s, computers were sometimes dedicated to a single task, but were far too large and expensive for most kinds of tasks performed by embedded computers of today. Over time however, the concept of

ECE Department, RVRIET

GSM Based Industrial automation

programmable controllers evolved from traditional electromechanical sequencers, via solid state devices, to the use of computer technology. Since these early applications in the 1960s, embedded systems have come down in price and there has been a dramatic rise in processing power and functionality. The first microprocessor for example, the Intel 4004, was designed for calculators and other small systems but still required many external memory and support chips. In 1978 National Engineering Manufacturers Association released a standard" for programmable microcontrollers, including almost any computer-based controllers, such as single board computers, numerical, and event-based controllers. The integration of microcontrollers has further increased the applications for which embedded systems are used into areas where traditionally a computer would not have been considered. A general purpose and comparatively low-cost microcontroller may often be programmed to fulfill the same role as a large number of separate components. Although in this context an embedded system is usually more complex than a traditional solution, most of the complexity is contained within the microcontroller itself. The intangible nature of software makes it much easier to prototype and test new revisions compared with the design and construction of a new circuit not using an embedded processor.

ECE Department, RVRIET

GSM Based Industrial automation

Figure 1.1: Blocks of an Embedded System Embedded Device Technology is a transformational technology a technology that is revolutionizing the way we function. Embedded Systems can be seen everywhere from Wrist Watches, Washing Machines, Microwave Ovens and Mobile Telephones to Automobiles, Aircrafts and Nuclear Power Plants. Embedded Systems are the brains behind 90% of all electronic devices worldwide. The explosion of Embedded System Technology is expected to happen across product categories like office products, consumer products, products, automobiles, medical instrumentation, vending machines, communications infrastructure, etc. An Embedded System is a combination of hardware and software designed to control the additional hardware attached to the system. The software system is completely encapsulated by the hardware that it controls. Embedded system means the processor is embedded into that application or it is meant for that specific application. Thus printer, keyboard, and video game player etc. are all examples of devices performing specific application.

ECE Department, RVRIET

GSM Based Industrial automation

In an Embedded System, there is only one application software that is typically burned into ROM. An Embedded System is time-constrained and often resourceconstrained. The brain of an Embedded System is the processor. It may be generalpurpose microprocessor like Intel x86 families or a microcontroller like 8051 family. An embedded product uses a microprocessor or microcontroller to do one specific task only.

A microcontroller is a specific kind of microprocessor whose primary job is to control the hardware it is attached to. A microcontroller has more pins dedicated to carrying I/O signals as compared to microprocessor. A Microcontroller has built-in memory and peripherals (single-chip computer). Whereas a microprocessor has memory and supporting peripherals externally connected.

1.4 Examples of embedded systems:1. Cellular telephones and telephone switches 2. Engine controllers and antilock brake controllers for automobiles 3. Household appliances, including microwave ovens, DVD players 4. Automatic teller machines (ATMs) 5. Home appliances such as fan, refrigerator and tube light etc. 6. Hand held calculators. An embedded system typically has a specialized function with programs stored on ROM. Examples of embedded systems are chips that monitor automobile functions, including engine controls, antilock brakes, air bags, active suspension systems, environmental systems, security systems, and entertainment systems. Everything needed for those functions is custom designed into specific chips. No external operating system is required.

ECE Department, RVRIET

GSM Based Industrial automation

Figure 1.2: Examples of Embedded Systems An embedded system is a special-purpose computer system designed to perform a dedicated function. Unlike a general-purpose computer, such as a personal computer, an embedded system performs one or a few pre-defined tasks, usually with very specific requirements, and often includes task-specific hardware and mechanical parts not usually found in a general-purpose computer. Since the system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product. Embedded systems are often mass-produced, benefiting from economies of scale. Physically, embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. In terms of complexity embedded systems run from simple, with a single microcontroller chip, to very complex with multiple units, peripherals and networks mounted inside a large chassis or enclosure.

ECE Department, RVRIET

GSM Based Industrial automation

Mobile phones or handheld computers share some elements with embedded systems, such as the operating systems and microprocessors which power them, but are not truly embedded systems themselves because they tend to be more general purpose, allowing different applications to be loaded and peripherals to be connected. Network managers will need to manage more and more embedded systems devices, ranging from printers to scanners, to handheld computing devices, to cell phones. All of these have a need to connect with other devices, either directly or through a wireless or direct-connect network. Most will have custom operating systems or variations of existing operating systems (e.g., Microsoft Windows CE). It's easy to picture nearly every electronic device as having an embedded system. For example, refrigerators, washing machines, and even coffee brewers will benefit in some way from embedded systems. A critical feature of an embedded system is its ability to communicate, so embedded systems support Ethernet, Bluetooth (wireless), infrared, or other technologies. A weather station on top of a building may employ an embedded system that gathers information from external sensors. This information can be pushed or pulled. In the push scenario, the data is automatically sent to devices that have requested it. In the pull scenario, users or network devices access the weather station to read the latest information.

ECE Department, RVRIET

GSM Based Industrial automation

1.5 Organization of Thesis: Chapter 2 deals with the block diagram of the project, and the Peripherals of the

project. Chapter 3 provides information on hardware design Chapter 4 deals with software design
Chapter 5 is all about testing methodology Chapter 6 is about source code Chapter 7 is all about project results

Chapter 8 provides the details conclusion and future scope


chapter 9 is about microcontroller

Chapter 10 is L293D
Chapter 11 is about LM324 and IR Sensors Chapter 12 is about index Chapter 13 is References

ECE Department, RVRIET

GSM Based Industrial automation

2. PLAN OF IMPLEMENTATION
2.1 Block Diagram:-

Figure 2.1: Block Diagram

2.2 Micro Controller:A microcontroller is a small computer on a single integrated circuit containing a processor core, memory and programmable input/output peripherals. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers. Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, and remote

ECE Department, RVRIET

10

GSM Based Industrial automation

controls, office machines, appliances, power tools, and toys. By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems.

2.3 DC Motor:A direct current (DC) motor is a fairly simple electric motor that uses electricity and a magnetic field to produce torque, which turns the motor. At its most simple, a DC motor requires two magnets of opposite polarity and an electric coil, which acts as an electromagnet. The repellent and attractive electromagnetic forces of the magnets provide the torque that causes the DC motor to turn. A DC motor requires at least one electromagnet. This electromagnet switches the current flow as the motor turns, changing its polarity to keep the motor running. The other magnet or magnets can either be permanent magnets or other electromagnets. Often, the electromagnet is located in the center of the motor and turns within the permanent magnets, but this arrangement is not necessary.

2.4 Liquid Crystal Display:A liquid crystal display (LCD) is a thin, flat electronic visual display that uses the light modulating properties of liquid crystals (LCs). LCs does not emit light directly. LCDs are more energy efficient and offer safer disposal than CRTs. Its low electrical power consumption enables it to be used in battery-powered electronic equipment. It is an electronically-modulated optical device made up of any number of pixels filled with Liquid crystals and arrayed in front of a light source (backlight) or reflector to produce images in colour or monochrome.

ECE Department, RVRIET

11

GSM Based Industrial automation

2.5 Power Supply:A power supply is a device that supplies electrical energy to one or more electric loads. The term is most commonly applied to devices that convert one form of electrical energy to another, though it may also refer to devices that convert another form of energy (e.g., mechanical, chemical, solar) to electrical energy. A power supply is one that controls the output voltage or current to a specific value; the controlled value is held nearly constant despite variations in either load current or the voltage supplied by the power supply's energy source.

2.6 L293D Motor driver:Large amount of current is required to run a motor. The microcontroller can drive only smaller currents. So a motor driver is interfaced with the microcontroller to which provides necessary current to drive the motors. It also acts as an isolator in between the microcontroller and motors to protect the microcontroller from the back e.m.f produced by the motors.

2.7 IR Tran receivers (TCRT5000):TheTCRT5000 is reflective sensors which include an infrared emitter and phototransistor in a leaded package which blocks visible light. We used two pairs of sensors in our project one is for sensing minimum level and other is for maximum level of water.

2.8 Relay:A relay is an electrically controllable switch widely used in industrial controls, automobiles and appliances.

ECE Department, RVRIET

12

GSM Based Industrial automation

The relay allows the isolation of two separate sections of a system with two different voltage sources i.e., a small amount of voltage/current on one side can handle a large amount of voltage/current on the other side but there is no chance that these two voltages mix up. When current flows through the coil, a magnetic field are created around the coil i.e., the coil is energized. This causes the armature to be attracted to the coil. The armatures contact acts like a switch and closes or opens the circuit. When the coil is not energized, a spring pulls the armature to its normal state of open or closed. There are all types of relays for all kinds of applications.

2.9 LDR:LDRs or Light Dependent Resistors are very useful especially in light/dark sensor circuits. Normally the resistance of an LDR is very high, sometimes as high as 1000,000 ohms, but when they are illuminated with light resistance drops dramatically. LDR is light dependent resistor; its resistance in complete dark is around 100 Kilo ohms that drops to few ohms depending upon intensity of light. This sensor is quite frequently used by students and hobbyists.

2.10 MAX232:The MAX232 is an integrated circuit that converts signals from an RS-232 serial port to signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a dual driver/receiver and typically converts the RX, TX, CTS and RTS signals. The drivers provide RS-232 voltage level outputs (approx. 7.5 V) from a single + 5 V supply via on-chip charge pumps and external capacitors. This makes it useful for implementing RS-232 in devices that otherwise do not need any voltages outside the 0 V to + 5 V range, as power supply design does not need to be made more complicated just for driving the RS-232 in this case. The receivers reduce RS-232 inputs (which may be as high as 25 V), to standard 5 V TTL levels.

ECE Department, RVRIET

13

GSM Based Industrial automation

2.11 4X4 Matrix Keypad:A keypad is a set of buttons arranged in a block or "pad" which usually bear digits and other symbols and usually a complete set of alphabetical letters. If it mostly contains numbers then it can also be called a numeric keypad. Keypads are found on many alphanumeric keyboards and on other devices such as calculators, push-button telephones, combination locks, and digital door locks, which require mainly numeric input. In order to detect which key is pressed from the matrix, we make row lines low one by one and read the columns. Lets say we first make Row1 low, and then read the columns. If any one of the key in row1 is pressed it will make the corresponding column as low i.e. if second key is pressed in Row1, then the column2 will be low. So we come to know that key 2 of Row1 is pressed. This is how scanning is done.

2.12 GSM Module:Sim300 GSM Smart Modem is a multi-functional, ready to use, rugged unit that can be embedded or plugged into any application. The Smart Modem can be controlled and customized to various levels by using the standard AT commands. The modem is fully type-approved, it can speed up the operational time with full range of Voice, Data, Fax and Short Messages (Point to Point and Cell Broadcast).

ECE Department, RVRIET

14

GSM Based Industrial automation

3. HARDWARE DESIGN
3.1 Design and interface of JHD162A with AT89S52:Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as for debugging purpose. The most common type of LCD controller is HITACHI 44780 which provides a simple interface between the controller & an LCD. These LCD's are very simple to interface with the controller as well as are cost effective. The most commonly used ALPHANUMERIC displays are:A. 1x16 (Single Line & 16 characters), B. 2x16 (Double Line & 16 character per line), C. 4x20 (four lines & Twenty characters per line).

The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines. The number on data lines depends on the mode of operation. If operated in 8-bit mode then 8 data lines + 3 control lines i.e. total 11 lines are required. And if operated in 4bit mode then 4 data lines + 3 control lines i.e. 7 lines are required. How do we decide which mode to use? Its simple if you have sufficient data lines you can go for 8 bit mode & if there is a time constrain i.e. display should be faster than we have to use 8bit mode because basically 4-bit mode takes twice as more time as compared to 8-bit mode. 3.1.1 Connections:The LCD has 3control pins: a) RS: Register[To select command(RS=0) or data register(RS=1)] b) R/W: Read/Write[To send read(R/W=1) or write command (R/W=0)] c) E: Enable [To latch the data and command to LCD(high to low transition)]. The LCD has 8 data pins [DB0 TO DB7]: Pins on LCD are Pin-7 to Pin-14

ECE Department, RVRIET

15

GSM Based Industrial automation

3.1.2 Other Connections: The LED+ and LED- pins of LCD are used for the Backlight of LCD. Vcc, Vee and Vss of LCD are used for powering the LCD and controlling the contrast of LCD. When RS is low (0), the data is to be treated as a command. When RS is high (1), the data being sent is considered as text data which should be displayed on the screen. When R/W is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively reading from the LCD. Most of the times there is no need to read from the LCD so this line can directly be connected to Ground thus saving one controller line. The ENABLE pin is used to latch the data present on the data pins. A HIGH LOW signal is required to latch the data. The LCD interprets and executes our command at the instant the EN line is brought low. If you never bring EN low, your instruction will never be executed. PIN 1 2 3 4 5 6 7 8 9 10 11 12 13 14 SYMBOL VSS VCC VEE RS R/W EN DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 I/O ---I I I/O I/O I/O I/O I/O I/O I/O I/O I/O DESCRIPTION Ground +5V power supply Power supply to control contrast RS=0 to select command register RS=1 to select data register R/W=0 for write, R/W=1 for read 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 The 8-bit data bus

Table 3.1: LCD Pin Description

3.2 LCD Interfacing to micro controller:ECE Department, RVRIET 16

GSM Based Industrial automation

Figure 3.1: LCD Interfacing To Micro Controller For Contrast setting a 10K pot should be used as shown in the figure, Display Data Ram (DDRAM) stores the display data. So when we have to display a character on LCD we basically write it into DDRAM. For a 2x16 LCD the DDRAM address for first line is from 80h to 8fh & for second line is 0c0h to 0cfh. So if we want to display

Table 3.2: LCD Commands to pins

3.3 Interfacing the Keypad to the Microcontroller:At the lowest level, keyboards are organized in a matrix of rows and columns. The CPU accesses both rows and columns through ports; therefore, with two 8-bit ports, an 8x8 matrix of keys can be connected to a microprocessor. When a key is pressed, a row and a column make a contact; otherwise, there is no connection between

ECE Department, RVRIET

17

GSM Based Industrial automation

rows and columns. In IBM PC keyboards, a single microcontroller (consisting of a microprocessor, RAM and EPROM, and several PORTS all on a single chip) takes care of hardware and software interfacing of the keyboard, in such systems, it is the function of programs stored in the EPROM of the microcontroller to scan the keys continuously, identify which one has been activated, and present it to the motherboard. In this section we look at the mechanism by which the microcontroller scans and identifies the key. 3.3.1 Scanning and Identifying the Key:-

Figure 3.2: 4X4 Matrix Keypad Fig shows a 4x4 matrix connected to two ports. The rows are connected to an output port and the columns are connected to an input port. If no key has been pressed, reading the input port will yield 1s for all columns since they are all connected to high (Vcc). If all the rows are grounded and a key is pressed, one of the columns will have 0 since the pressed provides the path to ground. It is the function of the microcontroller to scan the keyboard continuously to detect and identify the key pressed. How it is done is explained next. 3.3.2 Grounding Rows and Reading the Columns:To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, and then it reads the columns. If the data read from the columns is D3ECE Department, RVRIET 18

GSM Based Industrial automation

D0=1111, no key has been pressed and the process continues until a key press is detected. However, if one of the column bits has a 0, this means that a key press has occurred. For Example, if D3-D0=1101, this means that a key in the D1 column has been pressed. After a key press is detected the microcontroller will go through the process of identifying the key. Starting with the top row, the microcontroller grounds it by providing a low to row D0 only; then it reads the columns. If the data reads is all 1s, no key in that row is activated and the process is moved to the next row. It grounds the next row, reads the columns, and checks for any 0. This process continues until the row is identified. After identification of the row in which the key has been pressed, the next task is to find out which column the pressed key belongs to. This should be easy since the microcontroller knows at any time which row and column are being accessed. 3.3.3 The Process of Scanning a Key goes through the following 4 Steps:1. To make sense that the preceding key has been released, 0s are output to all rows at

once and the columns are read and checked repeatedly until all the columns are high. When all columns are found to be high, the program waits for a short amount of time before it goes to the next stage of waiting for a key to be pressed.

2. To see if any key is pressed, the columns scanned over and over in an infinite loop until one of them has a zero (0) on it. Remember that the output latches connected to rows still have their initial zeros making them grounded. After the key press detection it waits 20ms for bounce and then scans the columns again. This serves two functions It ensures that the first key detection was not an erroneous one due to a spike noise and The 20ms delay prevents the same key press from being interpreted as a multiple key press .If after 20 ms delay the key is still pressed, it goes to the

ECE Department, RVRIET

19

GSM Based Industrial automation

next stage to detect which row it belongs to ;otherwise it goes back in to the loop to detect a read key press. 3. To detect which row the key press belongs to, it grounds one row at a time reading the column search time .If it finds that all columns are high this means that the key press does not belongs to the row, therefore it grounds the next row and continues until it finds the row key press belongs to, it sets up the starting address for the look up table holding the scan codes for that row and goes to The next stage to identify the key. 4. To identify the key press, it rotates the column bits one bit at a time in to the carry flag and check to see if it is low. Upon finding the zero, it pulls out the (ASCII code) character for that key from the look up table. Otherwise it increments the pointer to point to the next element of the look up table.

3.4 Interfacing L293 Driver to the Microcontroller:L293D is a dual H-Bridge motor driver, So with one IC we can interface two DC motors which can be controlled in both clockwise and counter clockwise direction and if you have motor with fix direction of motion the you can make use of all the four I/Os to connect up to four DC motors. L293D has output current of 600mA and peak output current of 1.2A per channel. Moreover for protection of circuit from back

EMF ouput diodes are included within the IC. The output supply (VCC2) has a wide range from 4.5V to 36V, which has made L293D a best choice for DC motor driver.A simple schematic for interfacing a DC motor using L293D is shown below.

ECE Department, RVRIET

20

GSM Based Industrial automation

Figure 3.3: interfacing of L293 As in the above figure, three pins are needed for interfacing a DC motor (A, B, Enable). If you want the o/p to be enabled completely then you can connect Enable to VCC and only 2 pins needed from controller to make the motor work. As per the truth mentioned in the image above its fairly simple to program the microcontroller. Its also clear from the truth table of BJT circuit and L293D the programming will be same for both of them, just keeping in mind the allowed combinations of A and B. We will discuss about programming in C as well as assembly for running motor with the help of a microcontroller.

3.5 GSM modem:3.5.1 Introduction:-

ECE Department, RVRIET

21

GSM Based Industrial automation

Sim300 GSM Smart Modem is a multi-functional, ready to use, rugged unit that can be embedded or plugged into any application. The Smart Modem can be controlled and customized to various levels by using the standard AT commands. The modem is fully type-approved, it can speed up the operational time with full range of Voice, Data, Fax and Short Messages (Point to Point and Cell Broadcast). 3.5.2 Description of the interfaces:The modem comprises several interfaces: LED Function including operating Status External antenna Serial and control link Power Supply SIM card holder

3.5.3 LED Status Indicator:The LED will indicate different status of the modem: OFF ON Flashing Slowly Flashing rapidly Modem Switched off Modem is connecting to the network Modem is in idle mode Modem is in transmission/communication (GSM only)

GSM is one of the latest mobile technologies using smart MODEM, which can easily interfaced to embedded microcontrollers. Now everything is going to be automated using this technology, using this technology we can access the devices remotely. Using GSM and GPS now we can identify the people, vehicles etc in anywhere of the world.

MODEM is communicating with the microcontroller using AT commands, for example if we want to send an SMS to number 98xxxxxxxxx,the commands we have to send is AT+CMGS=<98xxxxxxxxxx>, <enter>, <message>, <ctrl-Z>.

ECE Department, RVRIET

22

GSM Based Industrial automation

Figure 3.4 GSM checking HyperTerminal snapshot In this project it is used to send SMS to the mobile In this project MODEM is communication with the microcontroller through serial port, the microcontroller will send the commands to the modem through RS 232.and the data is read through serial port therefore to make compatible computer serial port with microcontroller serial port we are using the RS 232 converter. The GSM module has GSM modem, DB9 connector, MAX 232 line driver for its communication with the microcontroller. Since the operating voltage different for the microcontroller and the modem, the MAX 232 is used which provides the electrical interface between an asynchronous communication controller and the serial port connector .The serial port connector here is DB9 connecter. The microcontroller has TTL logic levels for TXD, RXD pins and for RS232 different voltage levels logics. So for proper communications MAX232 is used to convert RS 232 voltages to TTL logic voltage levels. The baud rate is set to 9,600 bits/s. GSM modems in use has baud rate of 9600 bits/sec. It enables us to send and receive 30 messages at a time. With GSM modems, you must insert a valid SIM card into the slot on the front of the modem. Once the modem has been prepared for use, connect it to a serial port on your PC using the data cable that is included with the modem.

ECE Department, RVRIET

23

GSM Based Industrial automation

Figure 3.5 GSM module interface with AT89S52

3.6 Reset Circuit:High logical state on this input halts the MCU and clears all the registers. Bringing this pin back to logical state zero starts the program a new as if the power had just been turned on. In another words, positive voltage impulse on this pin resets the MCU. Depending on the device's purpose and environs, this pin is usually connected to the push-button, reset-upon-start circuit or a brown out reset circuit. The image shows one simple circuit for safe reset upon starting the controller. It is utilized in situations when power fails to reach its optimal voltage. 3.7. Crystal Oscillator Circuit:Input(X1) and output(X2) of internal oscillator. Quartz crystal controlling the frequency commonly connects to these pins. Capacitances within the oscillator mechanism are not critical and are normally about 30pF. Instead of a quartz crystal, miniature ceramic resonators can be used for dictating the pace.

ECE Department, RVRIET

24

GSM Based Industrial automation

3.8 Schematic diagram:-

Figure 3.6: Schematic diagram

4. SOFTWARE DESIGN
4.1 Cross Complier:-

ECE Department, RVRIET

25

GSM Based Industrial automation

A cross

compiler is

a compiler capable

of

creating executable code

for

a platform other than the one on which the compiler is run. Cross compiler tools are used to generate executable for embedded system or multiple platforms. It is used to compile for a platform upon which it is not feasible to do the compiling, like microcontrollers that don't support an operating system. It has become more common to use this tool for Para virtualization where a system may have one or more platforms in use. Not targeted by this definition are source to source translators, which are often mistakenly called cross compilers.

4.1.1 Uses of Cross Compliers:The fundamental use of a cross compiler is to separate the build environment from target environment. This is useful in a number of situations: Embedded computers where a device has extremely limited resources. For example, a microwave oven will have an extremely small computer to read its touchpad and door sensor, provide output to a digital display and speaker, and to control the machinery for cooking food. This computer will not be powerful enough to run a compiler, a file system, or a development environment. Since debugging and testing may also require more resources than are available on an embedded system, crosscompilation can be less involved and less prone to errors than native compilation. Compiling for multiple machines. For example, a company may wish to support several different versions of an operating system or to support several different operating systems. By using a cross compiler, a single build environment can be set up to compile for each of these targets. Compiling on a server farm. Similar to compiling for multiple machines, a complicated build that involves many compile operations can be executed across any machine that is free, regardless of its underlying hardware or the operating system version that it is running.

Boot strapping to a new platform. When developing software for a new platform, or the emulator of a future platform, one uses a cross compiler to compile

ECE Department, RVRIET

26

GSM Based Industrial automation

necessary tools such as the operating system and a native compiler. Compiling native code for emulators for older now-obsolete platforms like the Commodore 64 or Apple II by enthusiasts who use cross compilers that run on a current platform (such as Aztec C's MS DOS 6502 cross compilers running under Windows XP).

4.2 Embedded driver code for LCD:Before starting to display on LCD we need to initialize it. Firstly we must tell the LCD whether we'll be using 8-bit or 4-bit mode. Also we will be telling the LCD that we need 5x8 character font. Both these options are selected using a single command i.e. 38h. So to activate both these options we must execute following instructions.

4.3 Basic Commands of LCD:When LCD is powered up the display should show a series of dark squares, possibly only on part of display. These characters are actually in their off state, so the contrast control should be adjusted anti-clockwise until the squares are just visible. The display module resets itself to an initial state when power is applied, which curiously the display has blanked off so that even if characters are entered, they cannot be seen. It is therefore necessary to issue a command at this point, to switch the display on.

4.3.1 Circuit Description of LCD Experiment:The circuit can be wired up on a plug-in-style prototyping board, using dual-inline switches for the data lines (S1-S8). A toggle switch for the RS input (S10) and a momentary action switch (or macro switch) for usage.

Most of the LCD modules conform to a standard interface specification. A 14pin access is provided having eight data lines, three control lines and three power

ECE Department, RVRIET

27

GSM Based Industrial automation

lines. The connections are laid out in one of the two common configurations, either two rows of seven pins, or a single row of 14 pins. One of the, pins are numbered on the LCDs print circuit board (PCB), but if not, it is quite easy to locate pin1. Since this pin is connected to ground, it often has a thicker PCB track, connected to it, and it is generally connected to metalwork at same point. The LCD requires either 8 or 11 I/O lines to communicate with. For the sake of this tutorial, e going to use an 8-bit data bus--so we'll be using 11 of the 8051's I/O pins to interface with the LCD. A 1-to-1 relation is established between a pin on the 8051 and a line on the 44780 LCD. Thus write assembly program to access the LCD, and equate constants to the 8051 ports so that refer to the lines by their 44780 name as opposed to P0.1, P0.2, etc. DB0 EQU P1.0 DB1 EQU P1.1 DB2 EQU P1.2 DB3 EQU P1.3 DB4 EQU P1.4 DB5 EQU P1.5 DB6 EQU P1.6 DB7 EQU P1.7 EN EQU P3.7 RS EQU P3.6 RW EQU P3.5 DATA EQU P1 Having established the above equates, we may now refer to our I/O lines by their 44780 name. For example, to set the RW line high (1), we can execute the following instruction: SETB RW

4.3.2 Handling the EN Control Line:-

ECE Department, RVRIET

28

GSM Based Industrial automation

As mentioned above, the EN line is used to tell the LCD that you are ready for it to execute an instruction that you've prepared on the data bus and on the other control lines. Note that the EN line must be raised/lowered before/after each instruction sent to the LCD regardless of whether that instruction is read or write text or instruction. In short, you must always manipulate EN when communicating with the LCD. EN is the LCD's way of knowing that you are talking to it. If you don't raise/lower EN, the LCD doesn't know you're talking to it on the other lines. Thus, before we interact in any way with the LCD we will always bring the EN line low with the following instruction: CLR EN And once finished setting up instruction with the other control lines and data bus lines, we'll always bring this line high: SETB EN The line must be left high for the amount of time required by the LCD as specified in its datasheet. This is normally on the order of about 250 nanoseconds, but checks the datasheet. In the case of a typical 8051 running at 12 MHz, an instruction requires 1.08 microseconds to execute so the EN line can be brought low the very next instruction. However, faster microcontrollers (such as the DS89C420 which executes an instruction in 90 nanoseconds given an 11.0592 Mhz crystal) will require a number of NOPs to create a delay while EN is held high. The number of NOPs that must be inserted depends on the microcontroller you are using and the crystal you have selected.The instruction is executed by the LCD at the moment the EN line is brought low with a final CLR EN instruction. Programming Tip: The LCD interprets and executes our command at the instant the EN line is brought low. If you never bring EN low, your instruction will never be executed. Additionally, when you bring EN low and the LCD executes your instruction, it requires a certain amount of time to execute the command. The time it requires to execute an instruction depends on the instruction and the speed of the crystal which is attached to the 44780's oscillator input. 4.3.3 Checking the Busy Status of the LCD:-

ECE Department, RVRIET

29

GSM Based Industrial automation

As previously mentioned, it takes a certain amount of time for each instruction to be executed by the LCD. The delay varies depending on the frequency of the crystal attached to the oscillator input of the 44780 as well as the instruction which is being executed. While it is possible to write code that waits for a specific amount of time to allow the LCD to execute instructions, this method of "waiting" is not very flexible. If the crystal frequency is changed, the software will need to be modified. Additionally, if the LCD itself is changed for another LCD which, although 44780 compatible, requires more time to perform its operations, the program will not work until it is properly modified. A more robust method of programming is to use the "Get LCD Status" command to determine whether the LCD is still busy executing the last instruction received. The "Get LCD Status" command will return to us two tit-bits of information; the information that is useful to us right now is found in DB7. In summary, when we issue the "Get LCD Status" command the LCD will immediately raise DB7 if it's still busy executing a command or lower DB7 to indicate that the LCD is no longer occupied. Thus our program can query the LCD until DB7 goes low, indicating the LCD is no longer busy. Since programmer use this code every time we send an instruction to the LCD, it is useful to make it a subroutine. Let's write the code: WAIT_LCD: CLR RS ;It's a command SETB RW ;It's a read command MOV DATA,#0FFh ;Set all pins to FF initially SETB EN ;Clock out command to LCD MOV A,DATA ;Read the return value JB ACC.7,WAIT_LCD ;If bit 7 high, LCD still busy CLR EN ;Finish the command CLR RW ;Turn off RW for future commands Thus, standard practice will be to send an instruction to the LCD and then call our WAIT_LCD routine to wait until the instruction is completely executed by the

ECE Department, RVRIET

30

GSM Based Industrial automation

LCD. This will assure that our program gives the LCD the time it needs to execute instructions and also makes our program compatible with any LCD, regardless of how fast or slow it is. Programming Tip: The above routine does the job of waiting for the LCD, but was it to be used in a real application a very definite improvement would need to be made: as written, if the LCD never becomes "not busy" the program will effectively "hang," waiting for DB7 to go low. If this never happens, the program will freeze. Of course, this should never happen and won't happen when the hardware is working properly. But in a real application it would be wise to put some kind of time limit on the delay--for example, a maximum of 256 attempts to wait for the busy signal to go low. This would guarantee that even if the LCD hardware fails, the program would not lock up. 4.3.4 Initializing the LCD:Before using the LCD, it must initialize and configure it. This is accomplished by sending a number of initialization instructions to the LCD. The first instruction send must tell the LCD whether be communicating with it with an 8-bit or 4-bit data bus. Also select a 5x8 dot character font. These two options are selected by sending the command 38h to the LCD as a command. Thus, to send this 38h command to the LCD must execute the following 8051 instructions: CLR RS MOV DATA,#38h SETB EN CLR EN LCALL WAIT_LCD Programming Tip: The command 06h is really the instruction 04h plus 02h to configure the LCD such that every time we send it a character, the cursor position automatically moves to the right So, in all, initialization code is as follows: INIT_LCD:

ECE Department, RVRIET

31

GSM Based Industrial automation

CLR RS MOV DATA,#38h SETB EN CLR EN LCALL WAIT_LCD CLR RS MOV DATA,#0Eh SETB EN CLR EN LCALL WAIT_LCD CLR RS MOV DATA,#06h SETB EN CLR EN LCALL WAIT_LCD RET Having executed this code the LCD will be fully initialized and ready to send display data to it. 4.3.5 Clearing the Display:When the LCD is first initialized, the screen should automatically be cleared by the 44780 controller. An LCD command exists to accomplish this function. Not surprisingly, it is the command 01h. Since clearing the screen is a function very likely will wish to call more than once, it's a good idea to make it a subroutine: CLEAR_LCD: CLR RS MOV DATA, #01h SETB EN

ECE Department, RVRIET

32

GSM Based Industrial automation

CLR EN LCALL WAIT_LCD RET How that we've written a "Clear Screen" routine, may clear the LCD at any time by simply executing an LCALL CLEAR_LCD. Programming Tip: Executing the "Clear Screen" instruction on the LCD also positions the cursor in the upper left-hand corner 4.3.6 Writing Text to the LCD:Writing text to the LCD is something we'll almost certainly want to do over and over--so let's make it a subroutine. WRITE_TEXT: SETB RS MOV DATA, A SETB EN CLR EN LCALL WAIT_LCD RET The WRITE_TEXT routine that wrote will send the character in the accumulator to the LCD which will, in turn, display it. Thus to display text on the LCD all need to do is load the accumulator with the byte to display and make a call to this routine. A "HELLO WORLD" Program Now that we have all the component subroutines written, writing the classic "Hello World" program--which displays the text "Hello World" on the LCD is a relatively trivial matter. Consider: LCALL INIT_LCD LCALL CLEAR_LCD MOV A,#'H' LCALL WRITE_TEXT

ECE Department, RVRIET

33

GSM Based Industrial automation

MOV A,#'E' LCALL WRITE_TEXT MOV A,#'L' LCALL WRITE_TEXT MOV A,#'L' LCALL WRITE_TEXT MOV A,#'O' LCALL WRITE_TEXT MOV A,#' ' LCALL WRITE_TEXT MOV A,#'W' LCALL WRITE_TEXT MOV A,#'O' LCALL WRITE_TEXT MOV A,#'R' LCALL WRITE_TEXT MOV A,#'L' LCALL WRITE_TEXT MOV A,#'D' LCALL WRITE_TEXT The above "Hello World" program should, when executed, initialize the LCD, clear the LCD screen, and display "Hello World" in the upper left-hand corner of the display. 4.3.7 Cursor Positioning:The above "Hello World" program is simplistic in the sense that it prints its text in the upper left-hand corner of the screen. However, what if we wanted to display the word "Hello" in the upper left-hand corner but wanted to display the word "World" on the second line at the tenth character? This sounds simple--and actually, it is simple. However, it requires a little more understanding of the design of the

ECE Department, RVRIET

34

GSM Based Industrial automation

LCD.The 44780 contains a certain amount of memory which is assigned to the display. All the text we write to the 44780 is stored in this memory, and the 44780 subsequently reads this memory to display the text on the LCD itself. This memory can be represented with the following "memory map": In the above memory map, the area shaded in blue is the visible display. As you can see, it measures 16 characters per line by 2 lines. The numbers in each box is the memory address that corresponds to that screen position. Thus, the first character in the upper left-hand corner is at address 00h. The following character position (character #2 on the first line) is address 01h, etc. This continues until we reach the 16th character of the first line which is at address 0Fh. However, the first character of line 2, as shown in the memory map, is at address 40h. This means if we write a character to the last position of the first line and then write a second character, the second character will not appear on the second line. That is because the second character will effectively be written to address 10h--but the second line begins at address 40h. Thus we need to send a command to the LCD that tells it to position the cursor on the second line. The "Set Cursor Position" instruction is 80h. To this we must add the address of the location where we wish to position the cursor. In our example, we said we wanted to display "World" on the second line on the tenth character position. Referring again to the memory map, we see that the tenth character position of the second line is address 4Ah. Thus, before writing the word "World" to the LCD, we must send a "Set Cursor Position" instruction--the value of this command will be 80h (the instruction code to position the cursor) plus the address 4Ah. 80h + 4Ah = CAh. Thus sending the command CAh to the LCD will position the cursor on the second line at the tenth character position: CLR RS MOV DATA,#0CAh SETB EN

ECE Department, RVRIET

35

GSM Based Industrial automation

CLR EN LCALL WAIT_LCD The above code will position the cursor on line 2, character 10. To display "Hello" in the upper left-hand corner with the word "World" on the second line at character position 10 just requires us to insert the above code into our existing "Hello World" program. This results in the following: CALL lcd_command Now that we have to Turn On the display & set the cursor option i.e. cursor ON/OFF & Cursor blinking ON/OFF for that we will use the command 0Eh i.e. Display On , Cursor ON but Cursor blinking OFF. MOV A,#0Eh CALL lcd_command And the last command we require is to configure the LCD in such a way that everytime we send a character to it the cursor position automatically increments by one & moves to right i.e. 06h. MOV A,#06h CALL lcd_command The lcd_initialize contains the following instructions lcd_initialize: MOV A,#38h CALL lcd_command MOV A, #38h CALL lcd_command MOV A,#38h CALL lcd_command Ret

ECE Department, RVRIET

36

GSM Based Industrial automation

4.4 Flow Chart for displaying data on screen:-

Fig Flowchart for LCD

4.5 LCD Test Code to Display a Message on Screen:#include <reg51.h> sbit r0=P1^0; sbit r1=P1^1; sbit r2=P1^2;

ECE Department, RVRIET

37

GSM Based Industrial automation

sbit r3=P1^3; sbit c0=P1^4; sbit c1=P1^5; sbit c2=P1^6; sbit c3=P1^7; sfr ldata=0x80; sbit rs=P2^7; sbit rw=P2^6; sbit en=P2^5; sbit busy=P0^7; void lcdcmd(unsigned char); void lcddata(unsigned char); void lcdready(void); void MSDelay(unsigned int); void WriteString(unsigned char,unsigned char *); unsigned char KeyTest(void); void Start(void); void LCDClear(void); void lcdcmd (unsigned char value) { lcdready(); ldata=value; rs=0; rw=0; en=1; MSDelay(1); en=0; } void lcddata (unsigned char value) { lcdready();

ECE Department, RVRIET

38

GSM Based Industrial automation

ldata=value; rs=1; rw=0; en=1; MSDelay(1); en=0; } void lcdready(void) { busy=1; rs=0; rw=1; while(busy==1) { en=0; MSDelay(1); en=1; } } void MSDelay(unsigned int Iter) { unsigned int i, j; for(i=0;i<Iter;i++) { for(j=0;j<1275;j++); } } void WriteString(unsigned char count,unsigned char *MSG) { unsigned char i; for(i=0;i<count;i++)

ECE Department, RVRIET

39

GSM Based Industrial automation

{ lcddata(MSG[i]); } } void LCDClear(void) { lcdcmd(0x0E); lcdcmd(0x01); lcdcmd(0x06); lcdcmd(0x80); } void main(void) { lcdcmd(0x38); lcdcmd(0x0E); lcdcmd(0x01); lcdcmd(0x06); lcdcmd(0x80); WriteString(14,"welcome @ IETE"); lcdcmd(0xC0); WriteString(19,"Enter IETEHYDERABAD"); Start(); }

ECE Department, RVRIET

40

GSM Based Industrial automation

5. TESTING METHODOLOGY 5.1 Hardware Testing:-

Hardware testing is to be done to the each block of the system before programming the micro-controller. Micro-controller (for all 40pins), L293Driver, LM324, IR Sensors and also to the power supply.

5.1.1Test for Micro-Controller:Before dumping the code to the micro controller a pre-test is need to be done. In this pre-test there are certain conditions that controller should follow to prove its proper functionality. Which are as follows;All the ports of the micro controller should read 5volts.ie. P0.0-P0.7, P1.0-P1.7, P2.0-P2.7, P3.0-P3.7. 30th pin of micro controller which is Address Latch Enable should read between the ranges of 1.6-1.8volts. 5.2 Software Testing - Keil Debugger:5.2.1 Introduction to KEIL Software:Keil Vision is an integrated development environment used to create software to be run on embedded systems (like a microcontroller). It allows for such software to be written either in assembly or C programming languages and for that software to be simulated on a computer before being loaded onto the microcontroller. 5.2.2 What is Vision3 Vision3 is an IDE (Integrated Development Environment) that helps write, compile, and debug embedded programs. It encapsulates the following components:

ECE Department, RVRIET

41

GSM Based Industrial automation

A project manager. A make facility. A Tool configuration. An Editor A powerful debugger.

5.2.3 Steps Followed in Creating an Application in Vision:To create a new project in uVision3: 1. Select Project - New Project. 2. Select a directory and enter the name of the project file. 3. Select Project Select Device and select a device from Device Database. 4. Create source files to add to the project 5. Select Project - Targets, Groups, and Files. Add/Files, select Source Group1, and add the source files to the project. 6. Select Project - Options and set the tool options. Note that when the target device is selected from the Device Database all-special options are set automatically. Default memory model settings are optimal for most applications. 7. Select Project - Rebuild all target files or Build target To create a new project, simply start Micro Vision and select Project=>New Project from the pulldown menus. In the file dialog that appears, choose a name and base directory for the project. It is recommended that a new directory be created for each project, as several files will be generated. Once the project has been named, the dialog shown in the figure below will appear, prompting the user to select a target device. In this lab, the chip being used is the AT89S52, which is listed under the heading Atmel.

ECE Department, RVRIET

42

GSM Based Industrial automation

Figure: 5.1 Window for choosing the target device Next, Micro Vision must be instructed to generate a HEX file upon program compilation. A HEX file is a standard file format for storing executable code that is to be loaded onto the microcontroller. In the Project Workspace pane at the left, right click on Target 1 and select Options for Target 1 .Under the Output tab of the resulting options dialog, ensure that both the Create Executable and Create HEX File options are checked. Then click OK as shown in the two figures below.

ECE Department, RVRIET

43

GSM Based Industrial automation

Figure: 5.2 Project Workspace Pane]

Figure: 5.3 Project Options Dialog Next, a file must be added to the project that will contain the project code. To do this, expand the Target 1 heading, rightclick on the Source Group 1 folder, and select Add files Create a new blank file (the file name should end in .asm), select it, and click Add. The new file should now appear in the Project Workspace pane under the Source Group 1 folder. Double-click on the newly created file to open it in

ECE Department, RVRIET

44

GSM Based Industrial automation

the editor. All code for this lab will go in this file. To compile the program, first save all source files by clicking on the Save All button, and then click on the Rebuild All Target Files to compile the program as shown in the figure below. If any errors or warnings occur during compilation, they will be displayed in the output window at the bottom of the screen.

Figure: 5.4 Save All and Build All Target Files keys When the program has been successfully compiled, it can be simulated using the integrated debugger in Keil Micro Vision. To start the debugger, select Debug=>Start/Stop Debug Session from the pulldown menus. At the left side of the debugger window, a table is displayed containing several key parameters about the simulated microcontroller, most notably the elapsed time (circled in the figure below). Just above that, there are several buttons that control code execution. The Run button will cause the program to run continuously until a break point is reached, whereas the Step Into button will execute the next line of code and then pause (the current position in the program is indicated by a yellow arrow to the left of the code).

ECE Department, RVRIET

45

GSM Based Industrial automation

Figure: 5.5 Vision3 Debugger window Breakpoints can be set by doubleclicking on the grey bar on the left edge of the window containing the program code. A breakpoint is indicated by a red box next to the line of code.

ECE Department, RVRIET

46

GSM Based Industrial automation

Figure: 5.6 Reset, Run and Step into options The current state of the pins on each I/O port on the simulated micro controller can also be displayed. To view the state of a port, select Peripherals=>I/O Ports=>Port N from the pulldown menus, where is the port number. A checked box in the port window indicates a high (1) pin, and an empty box indicates a low (0) pin. Both the I/O port data and the data at the left side of the screen are updated whenever the program is paused. The debugger will help eliminate many programming errors, however the simulation is not perfect and code that executes properly in simulation may not always work on the actual microcontroller.

ECE Department, RVRIET

47

GSM Based Industrial automation

5.3 Device Database:A unique feature of the Keil Vision3 IDE is the Device Database, which contains information about more than 400 supported micro controllers. When you create a new n e w Vision3 project and select the target chip from the database, Vision3 sets all assembler, compiler, linker, and debugger options for you. The only option you must configure is the memory map.

5.4 Peripheral Simulation:The Vision3 Debugger provides complete simulation for the CPU and on-chip peripherals of most embedded devices. To discover which peripherals of a device are supported, in Vision3 select the Simulated Peripherals item from the Help menu. You may also use the web-based Device Database. We are constantly adding new devices and simulation support for on-chip peripherals so be sure to check Device Database often.

5.5 Programmer:The programmer used is a powerful programmer for the Atmel 89 series of microcontrollers that includes 89C51/52/55, 89S51/52/55 and many more. It is simple to use & low cost, yet powerful flash microcontroller programmer for the Atmel 89 series. It will Program, Read and Verify Code Data, Write Lock Bits, Erase and Blank Check. All fuse and lock bits are programmable. This programmer has intelligent onboard firmware and connects to the serial port. It can be used with any type of computer and requires no special hardware. All that is needed is a serial communication port which all computers have. All devices also have a number of lock bits to provide various levels of software and programming protection. These lock bits are fully programmable using this programmer. Lock bits are useful to protect the program to be read back from micro controller only allowing erase to reprogram the micro controller. Major parts of this programmer are Serial Port, Power

ECE Department, RVRIET

48

GSM Based Industrial automation

Supply and Firm ware microcontroller. Serial data is sent and received from 9 pin connector by MAX232 chip. A Male to Female serial port cable, connects to the 9 pin connector of hardware and another side connects to back of computer. All the programming intelligence is built into the programmer so you do not need any special hardware to run it. Programmer comes with window based software for easy programming of the devices.

5.6 Pro Load Programming Software:Pro Load is a software working as a user friendly interface for programmer boards from Sun ROM Technologies. Pro Load gets its name from Program Loader term, because that is what it is supposed to do. It takes in compiled HEX file and loads it to the hardware. Any compiler can be used with it, Assembly or C, as all of them generate compiled HEX files. Pro Load accepts the Intel HEX format file generated from compiler to be sent to target microcontroller. It auto detects the hardware connected to the serial port. It also auto detects the chip inserted and bytes used. The software is developed in Delhi and requires no overhead of any external DLL. The programmer connects to the computers serial port (Comm 1, 2, 3 or 4) with a standard DB9 Male to DB9 Female cable. Baud Rate - 57600, COMx Automatically selected by window software. No PC Card Required. After making the necessary selections, the Auto Program button is clicked as shown in the figure below which burns the selected hex file onto the microcontroller.

ECE Department, RVRIET

49

GSM Based Industrial automation

Figure: 5.7 Programming window

ECE Department, RVRIET

50

GSM Based Industrial automation

6. SOURCE CODE

#include <reg51.h> sbit r0=P1^0; //keypad rows sbit r1=P1^1; sbit r2=P1^2; sbit r3=P1^3; sbit c0=P1^4; //keypad columns sbit c1=P1^5; sbit c2=P1^6; sbit c3=P1^7; sfr ldata=0x80; // PORT0 for SFR address(LCD data pins) sbit rs=P2^7; sbit rw=P2^6; sbit en=P2^5; sbit busy=P0^7; //RS set for Giving the Command or Data // Read/write command for the data in the LCD RAM // Enable Bit of the LCD //busy pin of the controller

sbit Motor_In1=P2^0; sbit Motor_In2=P2^3; sbit en1=P2^1; sbit sense1=P3^2; sbit sense2=P3^3; void lcdcmd (unsigned char); void lcddata (unsigned char); void lcdready(void); void MSDelay(unsigned int); void WriteString(unsigned char,unsigned char *); unsigned char KeyTest(void); void Start(void); void LCDClear(void); void MainMenu(void);

ECE Department, RVRIET

51

GSM Based Industrial automation

void UpdateService(void); unsigned char MY_PWD[4]={'1','2','3','4'};

void lcdcmd (unsigned char value) { lcdready(); ldata=value; rs=0; rw=0; en=1; MSDelay(1); en=0; } void lcddata (unsigned char value) { lcdready(); ldata=value; rs=1; rw=0; en=1; MSDelay(1); en=0; } void lcdready(void) { busy=1; rs=0; rw=1; while(busy==1) { en=0; MSDelay(1);
ECE Department, RVRIET 52

GSM Based Industrial automation

en=1;

} } void MSDelay(unsigned int Iter) { unsigned int i, j; for(i=0;i<Iter;i++) { for(j=0;j<1275;j++); } } void WriteString(unsigned char count,unsigned char *MSG) { unsigned char i; for(i=0;i<count;i++) { lcddata(MSG[i]); } } unsigned char KeyTest(void) { P1=0xF0; while (1) { while(P1!=0xF0) { r0=0; r1=1;r2=1;r3=1; if(c0==0) return 'D'; else if(c1==0)

ECE Department, RVRIET

53

GSM Based Industrial automation

return 'F'; else if(c2==0)

return '0'; else if(c3==0) return 'E'; r1=0; r0=1;r2=1;r3=1; if(c0==0) return 'C'; else if(c1==0) return '9'; else if(c2==0) return '8'; else if(c3==0) return '7'; r2=0; r0=1;r1=1;r3=1; if(c0==0) return 'B'; else if(c1==0) return '6'; else if(c2==0) return '5'; else if(c3==0) return '4'; // Down Arrow r3=0; r0=1;r1=1;r2=1; if(c0==0) return 'A'; else if(c1==0) return '3'; else if(c2==0) return '2'; // Redail

ECE Department, RVRIET

54

GSM Based Industrial automation

else if(c3==0) return '1'; // Enter }

} } void MainMenu(void) of project { unsigned char key; LCDClear(); lcdcmd(0x80); LCDClear(); WriteString(14,"1.DOOR 2.SENSE"); lcdcmd(0xC0); WriteString(8,"3.LIGHTS"); key=0x00; do { key=KeyTest(); }while(key!='1' && key!='2' && key!='3'); switch(key) { case '1': { WriteString(8,"User ID:"); loop=0; do { key=KeyTest(); //Start

ECE Department, RVRIET

55

GSM Based Industrial automation

if(key>='0' && key<='9') { uid[loop]=key; lcddata(key);

loop++; MSDelay(100); //LCDClear(); //WriteString(13,"Its My World!"); } }while(loop!=4); lcdcmd(0xC0); WriteString(9,"Password:"); loop=0; do { key=KeyTest(); if(key>='0' && key<='9') { pwd[loop]=key; //lcddata(pwd[loop]); lcddata('*'); MSDelay(100); loop++; } }while(key!='E'); LCDClear(); if((pwd[0]=MY_PWD[0])&& (pwd[1]=MY_PWD[1])&& (pwd[2]=MY_PWD[2])&& (pwd[3]=MY_PWD[3]))

ECE Department, RVRIET

56

GSM Based Industrial automation

{ WriteString(15,"Authenticated!!"); MSDelay(60); key=0; LCDClear();

WriteString(7,"1. open"); lcdcmd(0xC0); WriteString(7,"2. close"); } else { WriteString(16,"Access Denied!!!"); MainMenu(); } do { key=KeyTest(); }while((key!='1')&&(key!='2')); switch(key) { case '1': Motor_In1=0; MSDelay(100); Motor_In2=1; LCDClear(); WriteString(12,"Door is open"); MSDelay(500); Motor_In1=1; Motor_In2=1;

ECE Department, RVRIET

57

GSM Based Industrial automation

LCDClear(); WriteString(7,"Press B"); key=0x00; do { key=KeyTest();

} while(key!='B'); MainMenu(); break; case '2': Motor_In1=1; MSDelay(100); Motor_In2=0; LCDClear(); WriteString(13,"Door is close"); MSDelay(100); Motor_In1=1; Motor_In2=1; LCDClear(); WriteString(7,"Press B"); key=0x00; do { key=KeyTest(); }while(key!='B'); MainMenu(); break; }

ECE Department, RVRIET

58

GSM Based Industrial automation

} break; case '2': { while(1) {

LCDClear(); if(sense1==1) { LCDClear(); lcdcmd(0x80); WriteString(14,"Theif Detected"); lcdcmd(0xc0); WriteString(9,"Near Door"); // SendString(17,"\nWater level_Max\r\n"); // Buzz=0; } if(sense2==0) { LCDClear(); lcdcmd(0x80); WriteString(14,"Theif Detected"); lcdcmd(0xc0); WriteString(9,"Near Locker"); // SendString(17,"\nWater level_Min\r\n"); } else { WriteString(9,"Safe");

ECE Department, RVRIET

59

GSM Based Industrial automation

// SendString(11,"\nSafe Zone\r\n"); } WriteString(7,"Press B"); key = 0x00; do { key=KeyTest(); }while(key!='B');

if(key=='B') //Buzz=1; MainMenu(); } break; } } break; case '3': { LCDClear(); lcdcmd(0x80); WriteString(10,"LIGHTS"); lcdcmd(0xC0); WriteString(13,"1.ON 2.OFF"); key=0x00; do { key=KeyTest(); }while(key!='1'&&key!='2'); switch(key) //Abid

ECE Department, RVRIET

60

GSM Based Industrial automation

{ case '1': LCDClear(); lcdcmd(0x80); WriteString(9,"Lights ON"); Relay=1; LED=0; MainMenu();

break; case '2': LCDClear(); lcdcmd(0x80); WriteString(9,"Lights OFF"); Relay=0; LED=1; MSDelay(100); MainMenu(); break; }break; } } } void Start(void) { unsigned char key; unsigned char uid[4],loop,pwd[4]; key=0x00;

ECE Department, RVRIET

61

GSM Based Industrial automation

// wait for enter. do { key=KeyTest(); }while(key!='E'); LCDClear();

WriteString(8,"User ID:");

loop=0; do { key=KeyTest(); if(key>='0' && key<='9') { uid[loop]=key; lcddata(key); loop++; MSDelay(100); //LCDClear(); //WriteString(13,"Its My World!"); } }while(loop!=4); lcdcmd(0xC0); WriteString(9,"Password:"); loop=0; do { key=KeyTest(); if(key>='0' && key<='9') {
ECE Department, RVRIET 62

GSM Based Industrial automation

pwd[loop]=key; //lcddata(pwd[loop]); lcddata('*'); MSDelay(100); loop++; } } while(key!='E');

LCDClear(); if((pwd[0]=MY_PWD[0])&& (pwd[1]=MY_PWD[1])&& (pwd[2]=MY_PWD[2])&& (pwd[3]=MY_PWD[3])) { WriteString(15,"Authenticated!!"); key=0; do { key=KeyTest(); }while(key!='E'); MainMenu(); } else { WriteString(16,"Access Denied!!!"); Start(); } }

ECE Department, RVRIET

63

GSM Based Industrial automation

void LCDClear(void) { lcdcmd(0x0E); lcdcmd(0x01); lcdcmd(0x06); lcdcmd(0x80); } void main(void) { en1=1;

Motor_In1=1; Motor_In2=1; lcdcmd(0x38); lcdcmd(0x0E); lcdcmd(0x01); lcdcmd(0x06); lcdcmd(0x80); WriteString(16,"Welcome 2 RVRIET"); lcdcmd(0xC0); WriteString(15,"Industrial automation"); MSDelay(100); Start();

ECE Department, RVRIET

64

GSM Based Industrial automation

7. PROJECT RESULTS
We are using GSM module only for transmitting and receiving the messages. GSM wireless data module is used for remote wireless applications, machine to machine or user to machine and remote data communications in many applications. The communication used in this project is the mobile communication. GSM (GLOBAL SYSTEM FOR MOBILE COMMUNICATION) modem is connected to the micro controller through a max 232 which is a TTL level converter. The following are the results of the project

8. CONCLUSION AND FUTURE SCOPE


The project we have undertaken has helped us gain a better perspective on various aspects related to our course of study as well as practical knowledge of

ECE Department, RVRIET

65

GSM Based Industrial automation

electronic equipments and communication. We became familiar with software analysis, designing, implementation; testing and maintenance concerned with our project. The extensive capabilities of this system are what make it so interesting. From the convenience of a simple cell phone, a user is able to control and monitor virtually any electrical devices. This makes it possible for users to rest assured that their belongings are secure and that the television and other electrical appliances was not left running when they left the house to just list a few of the many uses of this system. The end product will have a simplistic design making it easy for users to interact with. This will be essential because of the wide range of technical knowledge that homeowners have. In future we can use a camera in front of the door and an IR sensor which senses the presence of human and that data is sent to our cell through GSM.

APPENDIX A MICRO CONTROLLER


9.1 Introduction to Microcontroller:-

ECE Department, RVRIET

66

GSM Based Industrial automation

A microcontroller (or MCU) is a computer-on-a-chip. It is a type of microprocessor emphasizing self-sufficiency and cost-effectiveness, in contrast to a general-purpose microprocessor (the kind used in a PC).

9.2 Typical Microcontroller Architecture and Features:The basic internal designs of microcontrollers are pretty similar. Figure1 shows the block diagram of a typical microcontroller. All components are connected via an internal bus and are all integrated on one chip. The modules are connected to the outside world via I/O pins.

Figure 9.1: Basic Layout of Microcontroller The following list contains the modules typically found in a microcontroller. You can find a more detailed description of these components in later sections.

Processor Core:The CPU of the controller. It contains the arithmetic logic unit, the control unit, and the registers (stack pointer, program counter, accumulator register, register file . . .).

ECE Department, RVRIET

67

GSM Based Industrial automation

Memory:The memory is sometimes split into program memory and data memory. In larger controllers, a DMA controller handles data transfers between peripheral components and the memory. Interrupt Controller:Interrupts are useful for interrupting the normal program flow in case of (important) external or internal events. In conjunction with sleep modes, they help to conserve power. Timer/Counter:Most controllers have at least one and more likely 2-3 Timer/Counters, which can be used to timestamp events, measure intervals, or count events. Many controllers also contain PWM (pulse width modulation) outputs, which can be used to drive motors or for safe breaking (antilock brake system, ABS). Furthermore the PWM output can, in conjunction with an external filter, be used to realize a cheap digital/analog converter. Digital I/O:Parallel digital I/O ports are one of the main features of microcontrollers. The number of I/O pins varies from 3-4 to over 90, depending on the controller family and the controller type. Analog I/O:Apart from a few small controllers, most microcontrollers have integrated analog/digital converters, which differ in the number of channels (2-16) and their resolution (8-12 bits). The analog module also generally features an analog comparator. In some cases, the microcontroller includes digital/analog converters.

Depending on the modes that are supported by the hardware, the name of the communication sub-system will usually include aA if it supports Asynchronous communications, and a S if it supports Synchronous communications. Both forms are described below.

ECE Department, RVRIET

68

GSM Based Industrial automation

9.3 Micro Controller Packages:1. 40-lead PDIP


2. 44-lead PLCC

3. 44-lead TQFP

Figure 9.2: ATMEL40-pin PDIP

ECE Department, RVRIET

69

GSM Based Industrial automation

Figure 9.3: ATMEL40-pin TQFP

Figure 9.4: ATMEL40-pin TQFP IC

9.4 AT89S52 Micro Controller:9.4.1 Description:The AT89s52 is a low power, high performance CMOS 8-bit micro computer with 8K bytes of flash programmable and erasable read only memory(PEROM).The device is manufactured using Atmels high density non-volatile memory technology and is compatible with the industry standard 80c51 and 80C52 instruction set and pin out. The on-chip flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with flash on a monolithic chip, the Atmel AT89s52 Is a powerful microcomputer which provides a highly flexible and cost

ECE Department, RVRIET

70

GSM Based Industrial automation

effective solution too many embedded controlled applications. The main advantages of 89s52 over 8051 are

Software Compatibility Program Compatibility Re-writability The 89s52 microcontroller has excellent software compatibility, i.e. the

software used can be applicable to any other microcontroller. The program written on this microcontroller can be carried to any base. Program compatibility is the major advantage in 89s52. The program can be used in any other advanced microcontroller. The program can be reloaded and changed for nearly 1000 times. The block diagram of micro controller 4 I/O ports, timers, serial port, interrupts control ON-CHIP ROM, ON-CHIP RAM, CPU, bus control

Figure 9.5: Block Diagram of Micro Controller

ECE Department, RVRIET

71

GSM Based Industrial automation

Microcontrollers usually contain from several to dozens of general purpose input/output pins (GPIO). GPIO pins are software configurable to either an input or an output state. When GPIO pins are configured to an input state, they are often used to read sensors or external signals. Configured to the output state, GPIO pins can drive external devices such as LEDs or motors.

9.5 Internal Layout of Micro Controller: - Internal layout provides the


connections that are established in the micro controller. Very detailed connections are provided in the figure shown below

Figure 9.6: Internal Layout of Micro Controller

ECE Department, RVRIET

72

GSM Based Industrial automation

9.6 Description of ATMEL 89S52:The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density non-volatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with flash on a monolithic chip. The Atmel AT89S52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control. 9.6.1 Features:1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

Compatible with MC S-51 products 8K Bytes of in-system reprogrammable Flash memory Endurance: 1000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24Hz Three-level Program Memory Lock 256 X 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timers/Counters Eight Interrupt Sources Programmable Serial Channel

9.6.2 Pin Diagram of Micro Controller:The micro controller has 40 pins, of which 32 ports, VCC, GND, EA, ALE, PSEN, XTAL1 and XTAL2. The figure 4.3 shows the pin diagram of AT89S52.

ECE Department, RVRIET

73

GSM Based Industrial automation

Figure 9.7: Pin Diagram of ATMEL89S52 Micro Controller 9.6.3 Pin Description:Pin 18: Port 1: Each of these pins can be used as either input or output according to your needs. Also, pins 1 and 2 (P1.0 and P1.1) have special functions associated with Timer; these can be seen in the figure 4.3 shown above. Pin 9: Reset Signal: High logical state on this input halts the MCU and clears all the registers. Bringing this pin back to logical state zero starts the program a new as if the power had just been turned on. In another words, positive voltage impulse on this pin resets the MCU. Depending on the device's purpose and environs, this pin is usually connected to the push-button, reset-upon-start circuit or a brown out reset circuit.

ECE Department, RVRIET

74

GSM Based Industrial automation

The image shows one simple circuit for safe reset upon starting the controller. It is utilized in situations when power fails to reach its optimal voltage.

Figure 9.8: Reset Pin Circuit Pin 10-17: Port 3 as with Port 1, each of these pins can be used as universal input or output. However, each pin of Port 3 has an alternative function.

Pin 10: RXD - Serial input for asynchronous communication or serial output for synchronous communication. Pin 11: TXD - Serial output for asynchronous communication or clock output for synchronous communication Pin 12: INT0 - Input for interrupt 0 Pin 13: INT1 - Input for interrupt 1 Pin 14: T0 Pin 15: T1 Pin 17: RD - Clock input of counter 0 - Clock input of counter 1 - Signal for reading from external RAM memory.

Pin 16: WR - Signal for writing to external (add-on) RAM memory Pin 18-19: X2 and X1 Pin 20: GND: Ground Pin 21- 28: Port 2 if external memory is not present, pins of Port 2 act as

universal input/output. If external memory is present, this is the location of the higher

ECE Department, RVRIET

75

GSM Based Industrial automation

address byte, i.e. addresses A8 A15. It is important to note that in cases when not all the 8 bits are used for addressing the memory (i.e. memory is smaller than 64kB), the rest of the unused bits are not available as input/output. Pin 29: PSEN: MCU activates this bit (brings to low state) upon each reading of byte (instruction) from program memory. If external ROM is used for storing the program, PSEN is directly connected to its control pins. Of the external memory, MCU sends the lower byte of the address register (addresses A0 A7) to port P0 and activates the output ALE. External register (74HCT373 or 74HCT375 circuits are common), memorizes the state of port P0 upon receiving a signal from ALE pin, and uses it as part of the address for memory chip. Pin 30: ALE: During the second part of the mechanical MCU cycle, signal on ALE is off, and port P0 is used as Data Bus. In this way, by adding only one cheap integrated circuit, data from port can be multiplexed and the port simultaneously used for transferring both addresses and data. Pin 31: EA: Bringing this pin to the logical state zero (mass) designates the ports P2 and P3 for transferring addresses regardless of the presence of the internal memory. This means that even if there is a program loaded in the MCU it will not be executed, but the one from the external ROM will be used instead. Conversely, bringing the pin to the high logical state causes the controller to use both memories, first the internal, and then the external (if present). Pin 32-39: Port 0 Similar to Port 2, pins of Port 0 can be used as universal input/output, if external memory is not used. If external memory is used, P0 behaves as address output (A0 A7) when ALE pin is at high logical level, or as data output (Data Bus) when ALE pin is at low logical level. Pin 40: VCC: Power +5V.

ECE Department, RVRIET

76

GSM Based Industrial automation

Input Output (I/O) Ports:Every MCU from 8051 families has 4 I/O ports of 8 bits each. This provides the user with 32 I/O lines for connecting MCU to the environs. Unlike the case with other controllers, there is no specific SFR register for designating pins as input or output. Instead, the port itself is in charge: 0=output, 1=input. If particular pin on the case is needed as output, the appropriate bit of I/O port should be cleared. This will generate 0V on the specified controller pin. Similarly, if particular pin on the case is needed as input, the appropriate bit of I/O port should be set. This will designate the pin as input, generating +5V as a side effect (as with every TTL input). Port 0:Port 0 has two-fold role: if external memory is used, it contains the lower address byte (addresses A0-A7); otherwise all bits of the port are either input or output. Another feature of this port comes to play when it has been designated as output. Unlike other ports, Port 0 lacks the "pull up" resistor (resistor with +5V on one end). This seemingly insignificant change has the following consequences: When designated as input, pin of Port 0 acts as high impedance offering the infinite input resistance with no "inner" voltage. When designated as output, pin acts as "open drain". Clearing a port bit grounds the appropriate pin on the case (0V). Setting a port bit makes the pin act as high impedance. Therefore, to get positive logic (5V) at output, external "pull up" resistor needs to be added for connecting the pin to the positive pole. Therefore, to get one (5V) on the output, external "pull up" resistor needs to be added for connecting the pin to the positive pole. Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs.

ECE Department, RVRIET

77

GSM Based Industrial automation

Port 0 can 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:This is "true" I/O port, devoid of dual function characteristic for Port 0. Having the "pull up" resistor, Port 1 is fully compatible with TTL circuits. Port 1 is an 8-bit bidirectional 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. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following table. Port 1 also receives the low-order address bytes during Flash programming and verification.

Table 9.1: Port1 specifications

ECE Department, RVRIET

78

GSM Based Industrial automation

Port 2:When external memory is used, this port contains the higher address byte (addresses A8A15), similar to Port 0. Otherwise, it can be used as universal I/O port. Port 2 is an 8-bit bidirectional 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 memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory that uses 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 bidirectional 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 shown in the following table. Port 3 also receives some control signals for Flash programming and verification.

ECE Department, RVRIET

79

GSM Based Industrial automation

Table9.2: Port3 specifications:Beside its role as universal I/O port, each pin of Port 3 has an alternate function. In order to use one of these functions, the pin in question has to be designated as input, i.e., the appropriate bit of register P3 needs to be set. From a hardware standpoint, Port 3 is similar to Port 0. As can be seen from the individual descriptions of the ports, they all share highly similar structure. However, you need to consider which task should be assigned to which port. For example: if utilizing port as output with high level (5V), avoid using Port 0, as its pins cannot produce high logical level without an additional resistor connected to +5V. If using other port to a same end, bear in mind that built-in resistors have relatively high values, producing the currents limited to few hundreds of amperes as pin output. RST:Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives High for 96 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled.

ALE/PROG:-

ECE Department, RVRIET

80

GSM Based Industrial automation

Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, 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 weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. PSEN:Program Store Enable (PSEN) 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 enables. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming. XTAL1:Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2:Output from the inverting oscillator amplifier.

9.6.4 Special Function Registers:-

ECE Department, RVRIET

81

GSM Based Industrial automation

A map of the on-chip memory area called the Special Function Register (SFR) space is shown in Table 1. Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect. User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0. Timer 2 Registers:Control and status bits are contained in registers T2CON (shown in Table 2) and T2MOD (shown in Table 3) for Timer 2. The register pair (RCAP2H, RCAP2L) is the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode. Interrupt Registers:The individual interrupt enable bits are in the IE register. Two priorities can be set for each of the six interrupt sources in the IP register.

ECE Department, RVRIET

82

GSM Based Industrial automation

9.7 Oscillator Characteristics:XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be configured for use as an on-chip oscillator, as shown in Figure 11. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven, as shown in Figure 12. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flipflop, but minimum and maximum voltage high and low time specifications must be observed.

ECE Department, RVRIET

83

GSM Based Industrial automation

9.7.1 Oscillator connections:-

Figure 9.9: Oscillator Connections of AT89S52 Note: C1, C2 = 30 pF 10 pF for Crystals = 40 pF 10 pF for Ceramic Resonators 9.7.2 External Clock Drive Configuration:-

Figure 9.10: External Clock Drive Configuration of AT89S52 9.7.3 Idle Mode:In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset.

ECE Department, RVRIET

84

GSM Based Industrial automation

Note that when idle mode is terminated by a hardware reset, the device normally resumes program execution from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when idle mode is terminated by a reset, the instruction following the one that invokes idle mode should not write to a port pin or to external memory. 9.7.4 Power-down Mode:In the Power-down mode, the oscillator is stopped, and the instruction that invokes Power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the Power-down mode is terminated. Exit from Power-down mode can be initiated either by a hardware reset or by an enabled external interrupt. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stab Status of External Pins during Idle and Power-down Modes Status of External Pins during Idle and Power-down Modes

Table 9.3: Power down and Idle Modes of AT89S52

ECE Department, RVRIET

85

GSM Based Industrial automation

APPENDIX B L293 DRIVER


The L293 and L293D are quadruple high-current half-H drivers. The L293D is designed to provide bidirectional drive currents of up to 1A at voltages from 4.5V to 36V. The L293D is designed to provide bidirectional drive currents of up to 600-mA at voltages from 4.5V to 36V. The pin diagram of the L293 driver is shown in the figure 6.1. Both devices are designed to drive inductive loads such as relays, solenoids, dc and bipolar stepping motors.

10.1 Pin Diagram:Pin diagram of L293 driver has 16pins. The heat sinks and input, output pin description is shown in the figure 6.1.

Figure: 10.1Pin diagram of L293 driver All inputs are TTL compatible. Each output is a complete totem-pole drive circuit, with a Darlington transistor sink and a pseudo- Darlington source. Drivers are enabling in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN.When an enable input is high, the associated drivers are enabled and their outputs are active and in phase with their inputs. When the enable input is low, those drivers are disabled and their outputs are off and in the high impedance state. With the proper data inputs, each pair of drivers forms a full-H reversible drive suitable for solenoid or motor applications.

ECE Department, RVRIET

86

GSM Based Industrial automation

10.1.1 Internal Circuit:The internal diagram of the L293 driver circuit is as shown below. The pins 4 and 5, 12 and 13 are connected to ground.

Figure 10.2 : Internal circuit of L293 Driver The internal circuit of L293 Driver is shown in the figure 5.5 as shown above, gives the picture of the driver when connected to the DC Motors. The established connection are shown in the figure 6.2. The table shows the detailed description of the pins of the L293 Driver.

Table 10.1: Pins Description of the L293 Driver

ECE Department, RVRIET

87

GSM Based Industrial automation

APPENDIX C LM324 - LOW POWER QUAD OPERATIONAL AMPLIFIERS 11.1 Description:LM324 is a 14pin IC consisting of four independent operational amplifiers (opamps) compensated in a single package. Op-amps are high gain electronic voltage amplifier with differential input and, usually, a single-ended output. The output voltage is many times higher than the voltage difference between input terminals of op-amp. These op-amps are operated by a single power supply LM324 and need for a dual supply is eliminated. They can be used as amplifiers, comparators, oscillators, rectifiers etc. The conventional op-amp applications can be more easily implemented with LM324. 11.1.2 Features of LM324:1. Wide gain bandwidth : 1.3MHz 2. Input Common-Mode Voltage Range 3. Includes Ground 4. LargeVoltage Gain : 100dB 5. Very Low Supply Current/Amplifier : 375A 6. Low Input Bias Current : 20nA 7. Low Input Offset Voltage : 5mV max. 8. Low Input Offset Current : 2nA 9. Wide Power Supply Range :
a. Single Supply : +3V TO +30V b. Dual Supplies : 1.5V TO 15V

11.2 Unique Characteristics:1. In the linear mode the input common-mode voltage range includes ground and the output voltage can also swing to ground, even though operated from only a single power supply voltage 2. The unity gain cross frequency is temperature compensated
ECE Department, RVRIET 88

GSM Based Industrial automation

3. The input bias current is also temperature compensated

11.3 Pin Description:-

Fig 11.1. Pin Diagram of LM324

11.4 Advantages:1. Eliminates need for dual supplies 2. Four internally compensated op amps in a single package 3. Allows directly sensing near GND and VOUT 4. also goes to GND 5. Compatible with all forms of logic INFRARED SPECTRUM

11.5 Introduction to IR:One of the advantages of infrared remotes is that there is no radio for crooks to monitor and record for use against you later on. Instead, there is a beam of invisible infrared light which comes from a standard hand-held remote control unit so from that

ECE Department, RVRIET

89

GSM Based Industrial automation

point of view it is pretty secure .There is though an enormous variety of tasks to which you could put the unit just think of the myriad of things in your home these days which use infrared remote to turn things on and off change levels, open and close. 11.5.1 What is Infrared: Infrared is an energy radiation with the frequency below our eyes sensitivity so we cannot see it. Even that we cannot see sound frequencies, we know that it exist we can listen them.

Figure: 11.2 IR Spectrum This existence of the infrared and its width in the spectrum is shown in the figure When you approach your hand to fire or warm element, you will feel the heat, but you cant see it. You can see the fire because it emits other types of radiation, visible to your eyes, but it also emits lots of infrared that you can only feel your skin.

11.6 IR Transmitter: The IR LED which is used in the IR sensors which behave as a transmitter, it continuously sends the rays to the receiver when there is a obstacle between them then it sensed.

ECE Department, RVRIET

90

GSM Based Industrial automation

Description:-

Figure: 11.3 QED 234 The QED233 / QED234 is a 940 nm GaAs / AlGaAs LED encapsulated in a clear untainted, plastic T-1 3/4 package. 11.6.1. Features:Wavelength= 940 nm Chip material =GaAs with AlGaAs window Ideal for remote control applications Matched Photo sensor: QSD122/123/124 Medium Emission Angle, 40 High Output Power

11.7 IR Receiver: -

Figure: 11.4 Block Diagram of IR receiver

ECE Department, RVRIET

91

GSM Based Industrial automation

The blocks which perform the different operations at IR receiver to receive the IR signal is shown in the figure: 13.3 11.7.1 Description: The TSOP17 series are miniaturized receivers for infrared remote control systems. PIN diode and preamplifier are assembled on lead frame, the epoxy package is designed as IR filter. The demodulated output signal can directly be decoded by a microprocessor. TSOP17XX is the standard IR remote control receiver series, supporting all major transmission codes.

Fig 11.5 Light Emitting Diode 11.7.2 Features: Photo detector and preamplifier in one package. Internal filter for PCM frequency. Improved shielding against electrical field disturbance. TTL and CMOS compatibility. Output active low. Low power consumption. High immunity against ambient light. Continuous data transmission possible (up to 2400 bps).

ECE Department, RVRIET

92

GSM Based Industrial automation

11.8 Debugging:The C51 compiler uses the Intel Object Format (OMF51) for object files and generates complete symbol information. Additionally, the compiler can include all the necessary information such as; variable names function names, line numbers, and so on to allow detailed and thorough debugging and analysis with dScope-51 or Intel compatible emulators. All Intel compatible emulators may be used for program debugging. In addition, the OBJECTEXTEND control directive embeds additional variable type information in the object file which allows type-specific display of variables and structures when using certain emulators. You should check with your emulator vendor to determine if it is compatible with the Intel OMF51 object module format and if it can accept Keil object modules.

12. INDEX
ECE Department, RVRIET 93

GSM Based Industrial automation

LIST OF FIGURES Figure No.


1.1 1.2 2.1 3.1 3.2 3.3 3.4 3.5 3.6 5.1 5.2 5.3 5.4 5.5 5.6 5.7 7.1 65 7.2 7.3 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 9.10 LCD Display when kit on IR Sensor Detected Message Basic layout of microcontroller ATMEL 40-pin PDIP ATMEL 40-pin TQFP ATMEL 40-pin TQFP IC Block diagram of microcontroller Internal layout of microcontroller Pindiagram of AT89S52 circuit Oscillator connections External clock drive configuration 66 66 68 70 71 71 72 73 75 76 85 85

Particulars
Blocks of an Embedded system Examples of an Embedded system Block Diagram LCD interfacing to microcontroller 4X4 Matrix Keypad Interfacing of L293D GSM checking hyper terminal snap GSM module interfacing with AT89S52 Schematic diagram Window for choosing the target device Project workspace Project option dialog Save all and Build all target files keys Vision3 Debugger window Reset, Run and Step into options Programming window GSM Based Industrial automation

Page No.
05 07 10 17 18 21 23 24 25 43 44 44 45 46 47 50

ECE Department, RVRIET

94

GSM Based Industrial automation

10.1 10.2 11.1 11.2 11.3 11.4 11.5

Pin diagram of L292D Internal circuit of L293D Pin diagram of LM324 IR Spectrums QED 234 Block diagram of IR Receiver Light Emitting Diode 93

87 88 90 91 92 92

ECE Department, RVRIET

95

GSM Based Industrial automation

LIST OF TABLES
Table No.
3.1 3.2 9.1 9.2 9.3 10.1

Particulars
LCD Pin Description LCD commands to pins Port1 specifications Port3 specifications Power down and idle modes of AT89S52 Pin description of L293D

Page No.
17 17 79 81 86 88

ECE Department, RVRIET

96

GSM Based Industrial automation

13. REFERENCES AND BIBLIOGRAPHY


[1]. Principles and Applications of GSM by Vijay Garg, and J.E. Wilkes 1999 [2]. Embedded (EEPROM) Electronics For You Vol.43 No.4 APRIL 2011. [3]. Technology Focus (GSM MODULES) Electronics For You Vol.43 No.3 March 2011 [4]. Wireless Electronic Control Electronics For You Vol.42 No.8 APRIL 2010. [5]. http://www.atmel.com/dyn/resources/prod_documents/doc1919.pdf [6]. http://www.gsm-modem.de/gsm-module.html [7]. http://en.wikipedia.org/wiki/EEPROM [8]. http://en.wikibooks.org/wiki/Serial_Programming/MAX232_Driver_Receiver [9]. http://www.alessioviti.com/lcdprojects/datasheets.htm [10]. http://www.developer.SIM 300.com/Community/Wiki/AT_Commands [11].http://www.atmel.com/Images/doc2513.pdf [12].http://www.datasheetarchive.com/datasheet+for+4x4+keypad-datasheet.html

ECE Department, RVRIET

97

También podría gustarte