21-10-2016, 02:01 PM
1460354071-ad12.doc (Size: 582 KB / Downloads: 7)
Introduction
GSM (Global System for Mobile Communications, originally Grouped Special Mobile), is a standard set developed by the European Telecommunications Standards Institute (ETSI) to describe technologies for second generation (or "2G") digital cellular networks. Developed as a replacement for first generation analog cellular networks, the GSM standard originally described a digital, circuit switched network optimized for full duplex voice telephony. The standard was expanded over time to include first circuit switched data transport, then packet data transport via GPRS. Packet data transmission speeds were later increased via EDGE. The GSM standard is succeeded by the third generation (or "3G") UMTS standard developed by the 3GPP. GSM networks will evolve further as they begin to incorporate fourth generation (or "4G") LTE Advanced standards. "GSM" is a trademark owned by the GSM Association.
The GSM technology has been applied in numerous technical areas due to their flexibility and coverage ranges. The technology is now considered to be a most viable and economical candidate for remote measurements in mobile appliances. The motivation is to facilitate the users to automate their vehicles having ubiquitous access. The system provides availability due to development of a low cost system. Since the automobile parameters and pollution levels cannot be monitored from a single place, here in our work we have chosen the GSM technology to communicate the sensed parameters to remote locations
1.2 Embedded System
An embedded system is a computer system designed to do one or a few dedicated and/or specific functions often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. By contrast, a general-purpose computer, such as a personal computer (PC), is designed to be flexible and to meet a wide range of end-user needs. Embedded systems control many devices in common use today.
Embedded systems contain processing cores that are typically either microcontrollers or digital signal processors (DSP). The key characteristic, however, is being dedicated to handle a particular task. They may require very powerful processors and extensive communication, for example air traffic control systems may usefully be viewed as embedded, even though they involve mainframe computers and dedicated regional and national networks between airports and radar sites.
Since the embedded system is dedicated to specific tasks, design engineers can optimize it to reduce the size and cost of the product and increase the reliability and performance. Some embedded systems are mass-produced, benefiting from economies of scale.
In general, "embedded system" is not a strictly definable term, as most systems have some element of extensibility or programmability. Physically embedded system ranges from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the system controlling the nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or enclosure. Some embedded systems are mass-produced, benefiting from economies of scale.
1.2.1 Benefits Of Embedded Control Design
1. Eliminates necessity of complex circuitry
2. Smarter products
3. Smaller size
4. Lower cost
5. User friendly
6. State of the art technology
Wireless Communication
Wireless telecommunications is the transfer of information between two or more points that are physically not connected. Distances can be short, as a few meters as in television remote control; or long ranging from thousands to millions of kilometers for deep-space radio communications. It encompasses various types of fixed, mobile, and portable two-way radios, cellular telephones, personal digital assistants (PDAs), and wireless networking. Other examples of wireless technology include GPS units, Garage door openers or garage doors, wireless computer mice, keyboards and Headset (telephone/computer), headphones, radio receivers, satellite television, broadcast television and cordless telephones.
1.4 Concept Of the Project
Vehicle emissions control is the study and practice of reducing the motor vehicle emissions such as emissions produced by motor vehicles, especially internal combustion engines. Emissions of many air pollutants have been shown to have variety of negative effects on public health and the natural environment. Emissions that are principal pollutants of concern include:
1. Methane is not toxic, but is more difficult to break down in a catalytic converter, so in effect a "non-methane hydrocarbon" standard can be considered to be looser. Since methane is a greenhouse gas, interest is rising in how to eliminate emissions of it.
2. Carbon monoxide (CO) - A product of incomplete combustion, carbon monoxide reduces the blood's ability to carry oxygen; overexposure (carbon monoxide poisoning) may be fatal.
It is always an important task to measure the emissions and send it to a
remote controlling authority through a mobile network. This paper addresses the detection of hydrogen leaks for safety warning systems in automotive applications and the measurement of nitrogen oxide concentration in exhaust gases of zero-emission vehicles.
This methodology enables efficient design space exploration and sensitivity
analysis, allowing an optimal analog–digital and hardware–software partitioning.Such analysis drives also the development of effective data fusion techniques to reduce the measure uncertainty (due to cross sensitivity to other gases or to temperature/humidity variations). Such techniques have been implemented on a micro controller based mixed- signal embedded platform for intelligent sensor interfacing with limited complexity, suitable for automotive applications.
1.4.1 Parameter Monitoring Details
• Gas Emission monitoring
• SMS Facility
1.4.1.1 Gas Emission Monitoring
CO2 Sensor
A carbon dioxide sensor is an instrument for the measurement of carbon dioxide gas. The most common principles for CO2 sensors are infrared gas sensors (NDIR) and chemical gas sensors. Measuring carbon dioxide is important in monitoring indoor air quality and many industrial processes. The CO2 sensor measures carbon dioxide concentration (ppm) in gases, such as air. The CO2 sensor is a new solid electrolyte sensor which offers high selectivity to CO2, low dependency on humidity and compact size. A range of 350 to 5,000 ppm of carbon dioxide can be detected by CO2 sensor, making it ideal for indoor air control applications.
The CO2 sensitive element consists of a solid electrolyte formed between two electrodes, together with a printed heater (RuO2) substrate. By monitoring the change in an electromotive force (EMF) generated between the two electrodes, it is possible to measure CO2 gas concentration. The top of the sensor cap contains adsorbent (zeolite) for the purpose of reducing the influence of interference gases. The sensing element exhibits a linear relationship between the generated EMF and the logarithm CO2 gas concentration. A built-in microprocessor and digital-to-analog converter produce an output voltage that is linearly proportional to the CO2 gas concentration.
Methane Sensor
The sensing element of gas sensors is a tin dioxide (SnO2) semiconductor which has low conductivity in clean air. In the presence of a detectable gas, the sensor's conductivity increases depending on the gas concentration in the air. A simple electrical circuit can convert the change in conductivity to an output signal which corresponds to the gas concentration. The TGS 842 has high sensitivity and selectivity to methane. Due to its low sensitivity to alcohol vapors and its low temperature/humidity dependency, the sensor can achieve good reproducibility, making it ideal for domestic gas alarms.
1.4.1.2 SMS Facility
Some advanced GSM modems like WaveCom and Multitech, support the SMS text mode. This mode allows you to send SMS messages using AT commands, without the need to encode the binary PDU field of the SMS first. This is done by the GSM modem. Short message service – SMS available on digital networks allowing text messages of up to 160 characters to be sent and received via that network operator’s message center to the mobile phones, or from the internet, using a SMS gateway website. If the mobile phone is switched off or out of range, unlike paging, but similar to e-mail, short messages are stored and forwarded at the next opportunity.
In this project, we can send the parameter monitored to the mobile phone as per the requirements. This project aims in sending messages when the emission of toxic gas exceeds the normal emission rate. The message will be sent to the Public network regarding Abnormal Emission with date and time.
1.5 Objective
1. Monitoring the Emission of toxic gases in atmosphere .
2. By monitoring the change in potential across the resistors the excess
emission of toxic gas is detected.
3. To make patient free to move around after heart surgery.
4. Sends alerts in the form of SMS messages to Public network .
5. Continuous access to the Emission rate through wireless communication.
1.6 Overview
The main cope of this project is that to make People pollution free to move around the environment. For this in real time a small device is operated in the any Bus stop / Roof of the taxi cab which will measure Emission rate and if it exceeds given rate and inform to the regarding public network and will provide the corresponding information to avoid the unwanted emission of heavy vehicles. For this purpose we are doing this project in simulation method. We are using PIC microcontroller for this in which codings are embedded and interfaced to the LCD display, Gas sensors and temperature sensors and GSM modem through RS232 interface
Expanding Automotive Electronic System
A vast increase in automotive electronic systems coupled with related demands on power and design, has created an array of new engineering opportunities and challenges. Today's high-end vehicles may have more than 4 kilometers of wiring, compared to 45 meters in vehicles manufactured in 1955. Reducing wiring mass through in-vehicle networks will bring an explosion of new functionality and innovation. Our vehicles will become more like PCs, creating the potential for a host of plug-and-play devices. On average, US commuters spend 9 percent of their day in an automobile. Thus, introducing multimedia and telematics to vehicles will increase productivity and provide entertainment for millions. Further, X-by-wire solutions will make computer diagnostics a standard part of mechanics' work and may even create an electronic chauffeur. Presents an idea about interfacing various sensing systems in the automobile and issues related with signal processing.
2.2 An Oxygenating Additive for Reducing the Emission of Diesel Engine
Oxygenated diesel fuel blends reduce the emission of particulate matter (PM) and to be an alternative to diesel fuel. This paper describes a new kind of oxygenate additive, ethylene glycol mono acetate (EGM), and its effects on the characteristics of performance and emission of a compression ignition engine. The results show that the engine power outputs decrease and the BSFC increase when the diesel engine fueled with blends, but the diesel equivalent BSFC decrease. The results also indicate that all oxygenated fuels tested in this study show a beneficial effect on reducing smoke emissions at the operation conditions compared with diesel fuel. With the EGM15, an average smoke reduction of 49.9% and a maximal smoke reduction of 71% are obtained. The blends have little effects on the NO2 emissions at most loads. The CO emissions of the EGM-diesel blends decrease obviously at high load. All these results indicate the potential of EGM-diesel blend for clean combustion in diesel engine. Enumerates the emission parameters and discusses the additives to be added to reduce the flue gas emissions.
2.3 An Electronic Control System for Exhaust Emissions
Its electronic control system can provide different time intervals and variable A/F ratio at lean mode and rich mode. In storage mode, the engine operates at lean burn under rich oxygen environment. In reduction mode, ECU turns down both the throttle angle and ignition timing to provide a stable torque output. This electronic control system is used to investigate the impact of engine speed and load on emission characteristics and fuel economy. It is indicated from experimental results that the upstream placement of TWC (three way catalyst) ahead of the designed NO2 adsorber catalyst gives rise to highest converting efficiency to reduce the NO2 emission level. The roles of engine speed on exhaust emissions and fuel economy are reflected by operating time of lean burn and rich burn as well as the time ratio between the two regarding this designed catalyst converter. Engine load acts as a major factor in affecting exhaust emission characteristics and fuel economy of the leanburn engine. The heavier the engine load, the higher the NO2 emission level, the less the NO2 conversion rate, the better fuel economy. Details different techniques on emission control and fuel economy.
2.4 Smart Transducer Interface For Networked Sensors
Sensors and actuators are used, often networked in a distributed control system, in a number of applications ranging from industrial automation to environmental condition monitoring/control, to intelligent transport systems to homeland defense. The paper reviews the implementation for embedded systems of a sensor network interface, based on the emerging IEEE 1451 family of standards, targeting smart transducers, i.e. sensors or actuators integrating on-chip also the mixed-signal processing chain and a digital communication host port. As application case example, a networked system of hydrogen sensors to monitor the gas leak in hydrogen-based vehicles is presented. Defines the embedded based solutions for emission monitoring and emission control with various communication aspects.
Signal Processing and Amplification
The signal conditioning requirements to interface a sensor have been undergoing a major transition from the days of using a few trim resistors and amplification to obtain a usable output from a sensor. Today, a systems approach is among the alternatives that many signal conditioning companies offer. In many instances, an application-specific integrated circuit or ASIC is essential to a successful sensor application.
The sensor interface option is selected by evaluating the complexity of the sensor circuitry, in addition to the required hardware and software trade-offs of the micro controller.
The available sensor interface options that are proportional to temperature include:
• Analog
• Frequency
• Ramp Rate
• Duty Cycle
• Serial Output
• Logic Output
Signal conditioning is widely used in the world of data acquisition. The most common transducers produce an output in the form of voltage, current, charge, capacitance, and resistance. However, we need to convert these signals to voltage in order to send input to an A-to-D converter. This conversion (modification) is commonly called signal conditioning. Signal conditioning can be a current-to-voltage conversion or a signal amplification. For example, the thermistor changes resistance with temperature.
The change of resistance must be translated into voltages in order to be of any use to an ADC. Look at the case of connecting an LM35 to an ADC0848. Since the ADC0848 has 8-bit resolution with a maximum of 256 (28) steps and the LM35 (or LM34) produces 10 mV for every degree of temperature change, we can condition Vin of the ADC0848 to produce a Vout of 2560 mV (2.56 V) for full-scale output. Therefore, in order to produce the full-scale Vout of 2.56 V for the ADC0848, we need to set Vref = 2.56. This makes Vout of the ADC0848 correspond directly to the temperature as monitored by the LM35.
3.1.3 PIC Micro Controller Interfacing
PIC is a family of Harvard architecture microcontrollers made by Microchip Technology, derived from the PIC1650 originally developed by General Instrument's Microelectronics Division. The name PIC initially referred to "Peripheral Interface Controller".
A PIC micro controller is a single integrated circuit small enough to fit in the palm of a hand. ‘Traditional’ microprocessor circuits contain four or five separate integrated circuits - the microprocessor (CPU) itself, an EPROM program memory chip, some RAM memory and an input/output interface. With PIC micro controllers all these
functions are included within one single package, making them cost effective and easy to use. PIC micro controllers can be used as the ‘brain’ to control a large variety of products. In order to control devices, it is necessary to interface (or ‘connect’) them to the PIC micro controller. This section will help to enable those with limited electronics experience to successfully complete these interfacing tasks.
PICs are popular with both industrial developers and hobbyists alike due to their low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development tools, and serial programming (and re-programming with flash memory) capability.
The PIC architecture is characterized by its multiple attributes:
a. Separate code and data spaces (Harvard architecture) for devices other than PIC32, which has a Von Neumann architecture.
b. A small number of fixed length instructions
c. Most instructions are single cycle execution (2 clock cycles, or 4 clock cycles in 8bit models), with one delay cycle on branches and skips
d. One accumulator (W0), the use of which (as source operand) is implied (i.e. is not encoded in the opcode)
e. All RAM locations function as registers as both source and/or destination of math and other functions.
f. A hardware stack for storing return addresses
g. A fairly small amount of addressable data space (typically 256 bytes), extended through banking
h. Data space mapped CPU, port, and peripheral registers
i. The program counter is also mapped into the data space and writable (this is used to implement indirect .
j. There is no distinction between memory space and register space because the RAM serves the job of both memory and registers, and the RAM is usually just referred to as the register file or simply as the registers.
3.1.4 GSM Modem
A GSM modem is a specialized type of modem which accepts a SIM card, and operates over a subscription to a mobile operator, just like a mobile phone. From the mobile operator perspective, a GSM modem looks just like a mobile phone. When a GSM modem is connected to a computer, this allows the computer to use the GSM modem to communicate over the mobile network. While these GSM modems are most frequently used to provide mobile internet connectivity, many of them can also be used for sending and receiving SMS and MMS messages. A GSM modem can be a dedicated modem device with a serial, USB or Bluetooth connection, or it can be a mobile phone that provides GSM modem capabilities.
For the purpose of this document, the term GSM modem is used as a generic term to refer to any modem that supports one or more of the protocols in the GSM evolutionary family, including the 2.5G technologies GPRS and EDGE, as well as the 3G technologies WCDMA, UMTS, HSDPA and HSUPA. A GSM modem exposes an interface that allows various application to send and receive messages over the modem interface. The mobile operator charges for this message sending and receiving as if it was performed directly on a mobile phone. To perform these tasks, a GSM modem must support an “extended AT command set” for sending/receiving SMS messages, as defined in the ETSI GSM 07.05 and 3GPP TS 27.005 specifications.
GSM modems can be a quick and efficient way to get started with SMS, because a special subscription to an SMS service provider is not required. In most parts of the world, GSM modems are a cost effective solution for receiving SMS messages, because the sender is paying for the message delivery. A GSM modem can be a dedicated modem device with a serial, USB or Bluetooth connection, such as the Falcom Samba 75. (Other manufacturers of dedicated GSM modem devices include Wavecom , Multitech and iTegno.) To begin, insert a GSM SIM card into the modem and connect it to an available COM port of the computer.
A GSM modem could also be a standard GSM mobile phone with the appropriate cable and software driver to connect to a serial port or USB port on your computer. Any phone that supports the “extended AT command set” for
sending/receiving SMS messages, as defined in ETSI GSM 07.05 and/or 3GPP TS 27.005, can be supported by the SMS & MMS Gateway. Note that not all mobile phones support this modem interface. Due to some compatibility issues that can exist with mobile phones, using a dedicated GSM modem is usually preferable to a GSM mobile phone. This is more of an issue with MMS messaging, where if you wish to be able to receive inbound MMS messages with the gateway, the modem interface on most GSM phones will only allow you to send MMS messages. This is because the mobile phone automatically processes received MMS message notifications without forwarding them via the modem interface.
LCD Interface
A Liquid Crystal Display is an electronic device that can be used to show numbers or text. There are two main types of LCD display, numeric displays (used in watches, calculators etc) and alphanumeric text displays (often used in devices such as photocopiers and mobile telephones). The display is made up of a number of shaped ‘crystals’. In numeric displays these crystals are shaped into ‘bars’, and in alphanumeric displays the crystals are simply arranged into patterns of ‘dots’. Each crystal has an individual electrical connection so that each crystal can be controlled independently. When the crystal is ‘off’ (i.e. when no current is passed through the crystal) the crystal reflect the same amount of light as the background material, and so the crystals cannot be seen. However when the crystal has an electric current passed through it, it changes shape and so absorbs more light. This makes the crystal appear darker to the human eye - and so the shape of the dot or bar can be seen against the background. It is important to realise the difference between a LCD display and an LED display. An LED display (often used in clock radios) is made up of a number of LEDs which actually give off light (and so can be seen in the dark). An LCD display only reflects light, and so cannot be seen in the dark.
3.1.5.1 LCD Characters
The table on the next page shows the characters available from a typical LCD display.The character ‘code’ is obtained by adding the number at the top of the column with the number at the side of the row. Note that characters 32 to 127 are always the same for all LCDs, but characters 16 to 31 & 128 to 255 can vary with different LCD manufacturers. Therefore some LCDs will display different characters from those shown in the table.
Characters 0 to 15 are described as ‘user-defined’ characters and so must be defined before use, or they will contain ‘randomly shaped’ characters. For details on how to use these characters see the LCD manufacturers data sheets. Most 16x1 LCDs are in actual fact 8x2 LCDs, but with the ‘second’ line positioned directly after the first (instead of underneath it). This makes 16x1 displays confusing to use, as, after 8 characters have been printed, the cursor seems to disappear in the middle of the display! If this type of display is needed, remember that the ‘ninth’ character is actually the first character of the second line.
GSM or Serial Interface
Most computers can ‘talk’ to other devices by serial communication. Serial communication uses a common ‘protocol’ (or code) where characters are converted into numbers and then transmitted via cables. A computer mouse normally ‘communicates’ serially with a computer, and computer modems work by turning these numbers into sounds to travel down telephone lines. As all computers use the same ASCII code for transmitting and receiving characters it is relatively easy to program the PIC micro controller to ‘talk’ to any type of computer. All that is needed is a suitable cable and some very simple electronic circuits.
Connecting To the Serial Device
The system we will use requires just three wires between the computer and the Micro controller. The ground wire provides a common reference, the RX wire sends signals from the computer to the PIC micro controller, and the TX wire sends signals from the PIC micro controller to the computer. The best way to make a serial cable is to buy a serial ‘extension’ cable and cut it in half. This will give two cables with a suitable connector at each end. To use this system a communication software package is required for the PC. The examples below use the Terminal option within the Programming Editor software, but any communications package can be used.
There are various different protocols that can be used for serial communication, and it is important that both the computer and the micro controller use the same setting. The 2400,N,8,1 protocol is used here, which means baud speed 2400, no parity, 8 data bits and one stop bit. This baud speed is quite slow by modern standards, but is quite sufficient for the majority of project work tasks. All ‘handshaking’ (hardware or software) must also be disabled.
3.1.6 MAX232 Interface
The Max 232 is a dual RS-232 receiver / transmitter that meets all EIA RS232C specifications while using only a +5V power supply. It has 2 onboard charge pump voltage converters which generate +10V and –10V power supplies from a single 5V power supply. It has four level translators, two of which are RS232 transmitters that convert TTL\ CMOS input levels into + 9V RS232 outputs. The other two level translators are RS232 receivers that convert RS232 inputs to 5V TTL\CMOS output level. These receivers have a nominal threshold of 1.3V, a typical hysterisis of 0.5V and can operate upto + 30V input.
1. Suitable for all RS232 communications.
2. +/- 12V power supplies required.
3. Voltage quadrapular for input voltage upto 5.5V (used in power supply.
Section of computers, peripherals, and modems).
Three main sections of MAX232 are
1. A dual transmitter
2. A dual receiver
3. +/-5V to+/- 10V dual charge pump voltage converter.
Power Supply Section
The MAX232 power supply section has 2 charge pumps the first uses external capacitors C1 to double the +5V input to +10V with input impedance of approximately 200. The second charge pump uses external capacitor to invert +10V to –10V with an overall output impedance of 45. The best circuit uses 22F capacitors for C1 and C4 but the value is not critical. Normally these capacitors are low cost aluminum electrolyte capacitors or tantalum if size is critical. Increasing the value of C1 and C2 to 47F will lower the output impedance of +5V to+10V doublers by about 5 and +10V to -10V inverter by about 10. Increasing the value of C3 and C4 lowers the ripple on the power supplies thereby lowering the 16 KHz ripple on the RS232 output. The value of C1 and C4 can be lowered to 1F in systems where size is critical at the expense of an additional 20 impedance +10V output and 40 additional impedance at –10V input.
3.2.1 Transmitter Section
Each of the two transmitters is a CMOS inverter powered by + 10V internally generated supply. The input is TTL and CMOS compatible with a logic threshold of about 26% of Vcc. The input if an unused transmitter section can be left unconnected: an internal 400K pull up resistor connected between the transistor input and Vcc will pull the input high forming the unused transistor output low. The open circuit output voltage swing is guaranteed to meet the RS232 specification +/- 5v output swing under the worst of both transmitters driving the 3K Minimum load impedance, the Vcc input at 4.5V and maximum allowable ambient temperature typical voltage with 5K and Vcc= +.9 v The slow rate at output is limited to less than 30V/s and the powered done output impedance will be a minimum of 300 with +2V applied to the output with Vcc =0V.The outputs are short circuit protected and can be short circuited to ground indefinitely.
3.2.2 Receiver Section
The two receivers fully conform to RS232 specifications. They’re input impedance is between 3K either with or without 5V power applied and their switching threshold is within the +3V of RS232 specification. To ensure compatibility with either RS232 IIP or TTl\CMOS input. The MAX232 receivers have VIL of 0.8V and VIH of 2.4V the receivers have 0.5V of hysterisis to improve noise rejection.
The TTL\CMOS compatible output of receiver will be low whenever the RS232 input is greater than 2.4V. The receiver output will be high when input is floating or driven between +0.8V and –30V.
3.2.3 Electrical Characteristics Of Max232
Vcc = 6v V+ = 12v V- = 12v
Input voltage:
T1in, T2in: -0.3 to (Vcc+ 0.3v)
R1in, R2in: +30v or –30v
Output voltage:
T1out, T2out: ((V+) +0.3v) to ((V-) +0.3v)
R1out, R2out: -0.3V to (Vcc+0.3V)
Power dissipation: 375mW
3.2.4 Serial Communication
One of the 8051’s many powerful features is its integrated UART, otherwise known as a serial port. The fact the 8051 have an integrated serial port means that we
may very easily read and write values to the serial port. If it were not for the integrated serial port, writing a byte to a serial line would be a rather tedious process requiring turning on and off one of the I/O lines in rapid succession to properly “clock out” each individual bit, including start bits, stop bits, and parity bits.
However, we do not have to do this, Instead, we simply need to configure the serial port’s operation mode and baud rate. Once configured, all we have to do is write to an SFR to write a value to the serial port or read the same SFR to read a value from the serial port. The 8051 will automatically let us know when it has finished sending the character we wrote and will also let us know whenever it has received a byte so that we can process it. We do not have to worry about transmission at the bit level—which saves us quite a bit of coding and processing time.
Setting The Serial Port Mode
The first things we must do when using the 8051’s integrated serial port is, obviously, configure it. This lets us tell the 8051 how many data bits we want, the baud rate we will be using, and how the baud rate will be determined.
First, let’s present the “Serial Control” (SCON) SFR and define what each bit of the SFR represents:
Bit name Bit Address Explanation of Function
7 SM0 9Fh Serial Port mode bit 0
6 SM1 9Eh Serial Port mode bit 1.
5 SM2 9Dh Multiprocessor Communications Enable (explained later)
4 REN 9Ch Receiver Enable. This bit must be set in order to receive
characters.
3 TB8 9Bh Transmit bit 8. The 9th bit to transmit in mode 2 and 3.
2 RB8 9Ah Receive bit 8. The 9th bit received in mode 2 and 3.
1 TI 99h Transmit Flag. Set when a byte has been completely transmitted.
0 RI 98h Receive Flag. Set when a byte has been completely received
The SCON SFR allows us to configure the Serial Port. Thus, We’ll go through each bit and review it’s function.
The first four bits(bits 4 through 7) are configuration bits.
Bits SM0 and SM1 let us set the serial mode to a value between 0 and 3, inclusive. The four modes are defined in the chart immediately above. As we can see,
selecting the Serial Mode selects the mode of operation (8-bit/9-bit, UART or Shift Register) and also determines how the abud rate will be calculated. In modes 0 and 2 the baud rate is fixed based on the oscillator’s frequency. In modes 1 and 3 the baud rate is variable based on how often Timer 1 overflows. We’ll talk more about the various Serial Modes in a moment.
The next bit, SM2, is a flag for “Multiprocessor Communication.” Generally, whenever a byte has been received the 8051 will set the “RI” (Receive Interrupt) flag. This lets the program know that a byte has been received and that it needs to be processed. However, when SM2 is set the “RI” flag will only be triggered if the 9th bit received was a “1”. That is to say, if SM2 is set and a byte is received whose 9th bit is clear, the RI flag will never be set. This can be useful in certain advanced serial applications. For now it is safe to say that we will almost always want to clear this bit so that the flag is set upon reception of any character.
The next bit, REN, is “Receiver Enable.” This bit is very straightforward: If we want to receive data via the serial port, set this bit. We will almost always want to set this bit.The last four bits (bits 0 through 3) are operational bits. They are used when actually sending and receiving data—they are not used to configure the serial port.
The TB8 bit is used in modes 2 and 3. In modes 2 and 3, a total of nine data bits are transmitted. The first 8 data bits are the 8 bits of the main value, and the ninth bit is taken from TB8. If TB8 is set and a value is written to the serial port, the data’s bits will be written to the serial line followed by a “set” ninth bit. If TB8 is clear the ninth bit will be “clear.”The RB8 also operates in modes 2 and 3 functions essentially the same way as TB8, but on the reception side. When a byte is received in modes 2 or 3, a total in nine bits are received. In this case, the first eight bits received are the data of the serial byte received and the value of ninth bit received will be placed in RB8.
TI means “transmit Interrupt.” When a program writes a value to the serial port, a certain amount of time will pass before the individual bits of the byte are “clocked out” the serial port. If the program were to write another byte to the serial port before the first byte was completely output, the data being sent would be garbled. Thus, the 8051 lets the program know that it has “clocked out” the last byte by setting the TI bit. When the TI bit is set, the program may assume that the serial port is “Free” and ready to send the next byte. Finally, the RI bit means “Receive Interrupt.” It functions similarly to the “TI” bit, but it indicates that a byte has been received. That is to say,
whenever the 8051 has received a complete byte it will trigger the RI bit to let the program know that it needs to read the value quickly, before another byte is read.
Setting The Serial Port Baud Rate
Once the serial port mode has been configured, as explained above, the program must configure the serial port’s baud rate. This only applies to Serial Prot modes 1 and 3. The Baud Rate is determined based on the oscillator’s frequency when in mode 0 and 2. In mode 0, the baud rate is always the oscillators frequency divided by 12. This means if we’re crystal are 11.059Mhz, mode 0 baud rate will always be 921,583 baud. In mode 2 the baud rate is always the oscillator frequency divided by 64, so and 11.059Mhz crystal speed will yield a baud rate of 172, 797.
In modes 1 and 3, the baud rate is determined by how frequently timer 1 overflows. The more frequently timer 1 overflows, the higher the baud rate. There are many ways one can cause timer 1 to overflow at a rate that determines a baud rate, but the most common method to put timer 1 in 8-bit auto-reload mode (timer mode2) and set a reload value (TH1) that causes Timer 1 to overflow at a frequency appropriate to generate a baud rate.
To determine the value that must be placed in TH1 to generate a given baud rate, we may use the following equation (assuming PCON.7 is clear).
TH1 = 256 – ((Crystal / 384 ) / Baud)
If PCON.7 is set then the baud rate is effectively doubled, thus the
equation becomes :
TH1 = 256 – ((Crystal / 192) / Baud)
For example, if we have an 11.059Mhz crystal and we want to configure the serial port to 19,200 baud we try plugging it in the first equation :
TH1 = 256 - ((Crystal / 384)/Baud)
TH1 = 256 - ((11059000 / 384) / 19200)
TH1 = 256 - ((28,799) / 19200)
TH1 = 256 – 1.5 = 254.5
As we can see, to obtain 19,200 baud on a 11.059Mhz crystal we’d have to set TH1 to 254.5. If we set it to s54 we will have achieved 14,400 baud and if we set it to 255 we will have achieved 28,800 baud. Thus we’re stuck…
But not quite… to achieve 19,200 baud we simply need to set PCON.7 (SMOD). When we do this we double the baud rate and utilize the second equation mentioned above. Thus we have :
TH1 = 256 - ((Crystal / 192)/ Baud)
TH1 = 256 - ((1105900 / 192) / 19200)
TH1 = 256 - ((57699) / 19200)
TH1 = 256 – 3 = 253
Here we are able to calculate a nice, even TH1 value. Therefore, to obtain 19,200 baud with an 11.059Mhz crystal we must :
1.Configure Serial Port mode 1 or 3
2. Configure Timer 1 to timer mode 2 (8-bit auto-reload).
3. Set TH1 to 253 to reflect the correct frequency for 19,200 baud.
4. Set PCON.7(SMOD) to double the baud rate.
Reading the Serial Port
Reading data received by the serial port is equally easy. To read a byte from the serial port one just needs to read the value stored in the SBUF (99h) SFR after the 8051 has automatically set the RI flag in SCON. For example, if our program wants to wait for a character to be received and subsequently read in into the Accumulator, the following code segment may be used:
JNB RI,$; wait for the 8051 to set the RI flag
MOV A, SBUF; Read the character from the port
The first line of the above code segment waits for the 8051 to set the RI flag; again, the 8051 sets the RI flag automatically when it receives a character via the serial port. So as long as the bit is not set the program repeats the “JNB” instruction continuously. Once the RI bit is set upon character reception the above condition automatically fails and program flow falls through to the “MOV” instruction that reads the value.
Once the serial port mode has been configured, as explained above, the program must configure the serial port’s baud rate. This only applies to Serial Prot modes 1 and 3. The Baud Rate is determined based on the oscillator’s frequency when in mode 0 and 2. In mode 0, the baud rate is always the oscillators frequency divided by 12. This means if
we’re crystal are 11.059Mhz, mode 0 baud rate will always be 921,583 baud. In mode 2 the baud rate is always the oscillator frequency divided by 64, so and 11.059Mhz crystal speed will yield a baud rate of 172, 797.
In modes 1 and 3, the baud rate is determined by how frequently timer 1 overflows. The more frequently timer 1 overflows, the higher the baud rate. There are many ways one can cause timer 1 to overflow at a rate that determines a baud rate, but the most common method to put timer 1 in 8-bit auto-reload mode (timer mode2) and set a reload value (TH1) that causes Timer 1 to overflow at a frequency appropriate to generate a baud rate.
To determine the value that must be placed in TH1 to generate a given baud rate, we may use the following equation (assuming PCON.7 is clear).
TH1 = 256 – ((Crystal / 384 ) / Baud)
If PCON.7 is set then the baud rate is effectively doubled, thus the
equation becomes :
TH1 = 256 – ((Crystal / 192) / Baud)
For example, if we have an 11.059Mhz crystal and we want to configure the serial port to 19,200 baud we try plugging it in the first equation :
TH1 = 256 - ((Crystal / 384)/Baud)
TH1 = 256 - ((11059000 / 384) / 19200)
TH1 = 256 - ((28,799) / 19200)
TH1 = 256 – 1.5 = 254.5
As we can see, to obtain 19,200 baud on a 11.059Mhz crystal we’d have to set TH1 to 254.5. If we set it to s54 we will have achieved 14,400 baud and if we set it to 255 we will have achieved 28,800 baud. Thus we’re stuck…
But not quite… to achieve 19,200 baud we simply need to set PCON.7 (SMOD). When we do this we double the baud rate and utilize the second equation mentioned above. Thus we have :
TH1 = 256 - ((Crystal / 192)/ Baud)
TH1 = 256 - ((1105900 / 192) / 19200)
TH1 = 256 - ((57699) / 19200)
Here we are able to calculate a nice, even TH1 value. Therefore, to obtain 19,200 baud with an 11.059Mhz crystal we must :
1. Configure Serial Port mode 1 or 3
2. Configure Timer 1 to timer mode 2 (8-bit auto-reload).
3. Set TH1 to 253 to reflect the correct frequency for 19,200 baud.
4. Set PCON.7(SMOD) to double the baud rate.
3.2.5 Power Supply Unit
As we all know any invention of latest technology cannot be activated without the source of power. So it this fast moving world we deliberately need a proper power source which will be apt for a particular requirement. All the electronic components starting from diode to Intel IC’s only work with a DC supply ranging from _+5v to _+12. we are utilizing for the same, the most cheapest and commonly available energy source of 230v-50Hz and stepping down , rectifying, filtering and regulating the voltage. This will be dealt briefly in the forth-coming sections.
3.2.5.1 Step Down Transformer
When AC is applied to the primary winding of the power transformer it can either be stepped down or up depending on the value of DC needed. In our circuit the transformer of 230v/15-0-15v is used to perform the step down operation where a 230V AC appears as 15V AC across the secondary winding . One alteration of input causes the top of the transformer to be positive and the bottom negative. The next alteration will temporarily cause the reverse. The current rating of the transformer used in our project is 2A. Apart from stepping down AC voltages , it gives isolation between the power source and power supply circuitries.