Download - main project document final
-
8/7/2019 main project document final
1/83
1
ABSTRACT
Supervisory Control And Data Acquisition (SCADA) is the term used for all Remote control
monitoring of status and fault conditions of an industrial system. This has become an important
factor in the successful deployment of modern industrial process solutions.
This project is mainly useful for industrial monitoring and control and fault
detection. This project uses the AVR microcontroller to acquire the data such as temperature,
voltage and current from each machine in the industry and alert the authority when any fault
occurs in the respective functionality.
By implementing this project, the authority can remotely access the machines through
GSM via simple SMS. This usage of remote connectivity helps controlling and acknowledgment of
the machine status within in seconds of any fault.
-
8/7/2019 main project document final
2/83
2
CHAPTER-1
OVERVIEW
-
8/7/2019 main project document final
3/83
3
1.1 INTRODUCTION :
Supervisory Control And Data Acquisition is the term used for all Remote control monitoring ofstatus and fault conditions of an industrial system. This has become an important factor in the
successful deployment of modern industrial process solutions.
This Project presents a miniature robot which is having in built voice commands. Whatever
the operation performing by the robot that we can here as voice command. The ATMEL (Atmega8)
controller is the robot's brain and controls the robot's movements. It's usually a computer of some type
which is used to store information about the robot and the work environment and to store and execute
programs which operate the robot. The control system contains programs, data algorithms, logic
analysis and various other processing activities which enable the robot to perform.
The DC motors are used, to control the lateral movement of the system on ground. When the
system moves on the ground using the IR, the respective voice commands for robot will be initially
stored in a voice recorder (APR9600) which is interfaced to our ATmega8 microcontroller. That
commands will be played according to robot directions.
-
8/7/2019 main project document final
4/83
4
1.2APPLICATION
1. Vehicle Tracking2.
Position Monitoring ofVehicles3. Vehicle Control System4. Vehicle Speed/Velocity Monitoring/Controlling
1.3 FUTURESCOPE
1. If vehiclehad an accident,then withthehelp of vibration sensor wecandetectthe accident andcansendthelocationto the owner,hospital and police.
2.If anybody steals ourcar wecaneasily findit aroundtheglobe
.
3. Wecan reducethe size ofthekitby using GPS+GSM onthe samemodule.1.4 SOFTWAREREQUIREMENTS
1. Windows Xp OS2. AVR Studio 4.183. WinAVR GCC Compiler4.
AT- Prog Serial Programmer5. GPS DATA Logger
1.5 HARDWAREREQUIREMENT
1. DC power supply 3.5v2. ATmega162 Microcontroller3. GPS Module4. GSM Module5. Buzzer,MAX-232 IC, LEDs ,Standard Cables
-
8/7/2019 main project document final
5/83
-
8/7/2019 main project document final
6/83
6
2.1 INTRODUCTIONTOEMBEDDEDSYSTEM:
Anembedded systemis a special-purposecomputer systemdesignedto perform one or a few
dedicated functions, sometimes with real-timecomputingconstraints. Itis usually embedded as part
of a complete device including hardware and mechanical parts. In contrast, a general-purpose
computer, such as a personal computer, can do many different tasks depending on programming.
Embedded systems havebecome very importanttoday as they controlmany ofthecommondevices
we use.
Since the embedded system is dedicated to specific tasks, design engineers can optimize it,
reducing the size and cost of the product, or increasing the reliability and performance. Some
embedded systems aremass-produced,benefiting fromeconomies 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. Complexity varies from low, with a single microcontrollerchip,to
very high withmultiple units, peripherals andnetworks mountedinside a largechassis orenclosure.
In general, "embedded system" is not an exactly defined term, as many systems have some
element of programmability. Forexample, Handheldcomputers share someelements withembedded
systems such as the operating systems andmicroprocessors which powerthem but arenottruly
embedded systems, because they allow different applications to be loaded and peripherals to be
connected.
Anembedded systemis somecombination ofcomputerhardware and software,either fixedin
capability or programmable, that is specifically designed for a particular kind of application device.
Industrial machines, automobiles, medical equipment, cameras, household appliances, airplanes,
vending machines, and toys (as well as the more obvious cellular phone and PDA) are among the
myriad possible hosts of an embedded system. Embedded systems that are programmable are
provided with a programming interface, and embedded systems programming is a specialized
occupation. Certain operating systems or language platforms are tailored for the embedded market,
such as Embedded Java and Windows XP Embedded. However, somelow-endconsumer products use
very inexpensivemicroprocessors andlimited storage, withthe application and operating systemboth
part of a single program. The program is written permanently into the system's memory inthis case,
ratherthanbeingloadedinto RAM (random access memory), as programs on a personalcomputer are.
-
8/7/2019 main project document final
7/83
7
2.2 APPLICATIONSOFEMBEDDEDSYSTEM
We arelivinginthe Embedded World. You are surrounded withmany embedded products and
your daily life largely depends on the proper functioning of these gadgets. Television, Radio, CD
player of your living room, Washing Machine or Microwave Oven in your kitchen, Card readers,
Access Controllers, Palm devices of your work space enable you to do many of your tasks very
effectively. Apart from all these, many controllers embedded in your car take care ofcar operations
betweenthebumpers andmost ofthetimes you tendto ignore allthesecontrollers.
In recentdays, you are showered with variety ofinformation abouttheseembeddedcontrollers
in many places. All kinds of magazines and journals regularly dish out details about latest
technologies, new devices; fast applications which make you believe that your basic survival is
controlledby theseembedded products. Now you can agreeto the factthattheseembedded products
have successfully invadedinto our world. You mustbe wondering abouttheseembeddedcontrollers
or systems. Whatis this Embedded System?
Thecomputer you useto compose yourmails, orcreate a document or analyzethedatabaseis
known as the standard desktop computer. These desktop computers are manufactured to serve many
purposes and applications.
You need to install the relevant software to get the required processing facility. So, these
desktop computers cando many things. Incontrast,embeddedcontrollers carryout a specific workfor
which they are designed. Most of the time, engineers design these embedded controllers with a
specificgoalinmind. So thesecontrollers cannotbe usedin any other place.
Theoretically, anembeddedcontroller is a combination of a piece ofmicroprocessorbasedhardware
andthe suitable softwareto undertake a specifictask.
Thesedays designers havemany choices inmicroprocessors/microcontrollers. Especially,in8
bit and 32bit,the available variety really may overwhelm even anexperienceddesigner. Selecting a
right microprocessor may turn out as a most difficult first step and it is getting complicated as new
devices continueto pop-up very often. Inthe8bit segment,themost popular and used architectureis
Intel's 8031. Market acceptance of this particular family has driven many semiconductor
manufacturers to develop somethingnew based onthis particular architecture. Even after25 years of
existence, semiconductormanufacturers stillcome out with somekind ofdevice usingthis 8031core.
-
8/7/2019 main project document final
8/83
8
Militaryandaerospacesoftwareapplications Fromin-orbitembedded systems to jumbo jets to vitalbattlefieldnetworks,designers ofmission-
critical aerospace and defense systems requiring real-time performance, scalability, and high-
availability facilities consistently turn to the LynxOS RTOS and the LynxOS-178 RTOS forsoftwarecertificationto DO-178B.
Rich in system resources and networking services, LynxOS provides an off-the-shelf software
platform with hard real-time response backed by powerful distributed computing (CORBA), high
reliability, softwarecertification, andlong-term support options.The LynxOS-178 RTOS for software
certification, based on the RTCA DO-178B standard, assists developers in gaining certification for
their mission- and safety-critical systems. Real-time systems programmers get a boost with
LynuxWorks' DO-178B RTOS training courses.LynxOS-178 is the first DO-178B and
EUROCAE/ED-12B certifiable, POSIX-compatible RTOS solution.
Communicationsapplications "Five-nines" availability, CompactPCI hot swap support, and hard real-time responseLynxOS
delivers on these key requirements and more for today's carrier-class systems. Scalable kernel
configurations, distributed computing capabilities, integrated communications stacks, and fault-
management facilities make LynxOS the ideal choice forcompanies looking for a single operating
system for all embedded telecommunications applicationsfrom complex central controllers to
simpleline/trunkcards.
LynuxWorksJumpstarts for Communications package enables OEMs to rapidly develop mission-
criticalcommunications equipment, with pre-integrated, state-of-the-art,data networking and porting
softwarecomponentsincluding sourcecode foreasy customization.
The Lynx Certifiable Stack (LCS) is a secure TCP/IP protocol stackdesigned especially for
applications where standards certificationis required.
-
8/7/2019 main project document final
9/83
-
8/7/2019 main project document final
10/83
10
CHAPTER-3
INTRODUCTIONTOMICROCONTROLLER
-
8/7/2019 main project document final
11/83
11
3.1 MICROCONTROLLERVERSUSMICROPROCESSOR
What is the difference between a Microprocessor and Microcontroller? By microprocessor is
meant the general purpose Microprocessors such as Intel's X86 family (8086,80286,80386,80486,and the Pentium) or Motorola's 680X0 family (68000, 68010, 68020, 68030, 68040, etc). These
microprocessors containno RAM,no ROM, andno I/O ports onthechip itself. Forthis reason,they
arecommonly referredto as general-purpose Microprocessors.
A system designer using a general-purpose microprocessor such as the Pentium orthe68040
must add RAM, ROM, I/O ports, and timers externally to make them functional. Although the
addition of external RAM, ROM, and I/O ports makes these systems bulkier and much more
expensive,they havethe advantage of versatility suchthatthedesignercandecide onthe amount of
RAM, ROM and I/O ports neededto fitthetaskathand. This is notthecase with Microcontrollers.
A Microcontrollerhas a CPU (a microprocessor) in additionto a fixed amount of RAM, ROM,
I/O ports, and a timer all on a singlechip. In other words,the processor,the RAM, ROM, I/O ports
andthetimer are allembeddedtogether on onechip. Inmany applications, forexample a TV remote
control, there is no need for the computing power of a 486 oreven an8086 microprocessor. These
applications most often require some I/O operations to read signals andturn on and offcertainbits.
3.2MICROCONTROLLERSFOREMBEDDEDSYSTEMS
In the Literature discussing microprocessors, we often see the term Embedded System.
Microprocessors and Microcontrollers are widely used in embedded system products. An embedded
system product uses a microprocessor (or Microcontroller) to do one task only. A printer is an
example ofembedded system sincethe processorinsideit performs onetask only; namely gettingthe
data and printing it. Contrast this with a Pentium based PC. A PC can be used for any number of
applications such as word processor, print-server,banktellerterminal,Video game,networkserver, or
Internetterminal. Software for a variety of applications canbeloaded and run. Ofcoursethe reason a
pc can perform myriad tasks is that it has RAM memory and an operating system that loads the
application softwareinto RAM memory andlets the CPU runit.
-
8/7/2019 main project document final
12/83
12
In an Embedded system, there is only one application software that is typically burned into
ROM. An x86 PC contains or is connectedto various embedded products such as keyboard, printer,
modem,diskcontroller, soundcard, CD-ROM drives,mouse, and so on. Each one ofthese peripherals
has a Microcontrollerinsideitthat performs only onetask. Forexample,insideevery mousethereis a
Microcontrollerto performthetask of findingthemouse position and sendingitto the PC. Table1-1
lists someembedded products.
3.3 TypicalMicrocontrollerArchitectureand 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 onechip. Themodules areconnectedto the outside world via I/O pins.
FIG3.3.1:BASICLAYOUT OF MICROCONTROLLER
The following list contains the modules typically found in a microcontroller. You can find a
moredetaileddescription ofthesecomponents inlater sections.
ProcessorCore:The CPU ofthecontroller. Itcontains the arithmeticlogic unit,thecontrol unit, and
the registers (stackpointer, programcounter, accumulator register, register file...).
Memory: The memory is sometimes split into program memory and data memory. In larger
controllers, a DMA controllerhandles data transfers between peripheralcomponents andthememory.
-
8/7/2019 main project document final
13/83
13
Interrupt Controller: Interrupts are useful for interrupting the normal program flow in case of
(important) external orinternalevents. Inconjunction with sleep modes,they help to conserve power.
Timer/Counter:Mostcontrollers have atleast one andmorelikely 2-3 Timer/Counters, whichcanbe
used to timestamp events, measure intervals, or count events. Many controllers also containPWM
(pulse width modulation) outputs, which can be used to drive motors or for safe breaking (antilock
brake system, ABS). Furthermorethe PWM outputcan,inconjunction with anexternal filter,be used
to realize a cheap digital/analogconverter.
DigitalI/O:
Paralleldigital I/O ports are one ofthe main features ofmicrocontrollers. Thenumber of I/O
pins varies from 3-4 to over 90,depending onthecontroller family andthecontrollertype.
AnalogI/O:
Apart from a few small controllers, most microcontrollers have integrated analog/digital
converters, whichdifferinthenumber ofchannels (2-16) andtheir resolution (8-12bits). The analog
module also generally features an analog comparator. In some cases, the microcontroller includes
digital/analogconverters.
3.4 THEUART:WHATITIS AND HOWITWORKS
The Universal Asynchronous Receiver/Transmitter (UART) controller is the key component
ofthe serialcommunications subsystem of a computer. The UART takes bytes ofdata andtransmits
the individual bits in a sequential fashion. At the destination, a second UART re-assembles the bits
into completebytes.
Serialtransmission is commonly used with modems and fornon-networkedcommunicationbetween
computers, terminals and other devices. There are two primary forms of serial transmission:
Synchronous and Asynchronous. 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.
-
8/7/2019 main project document final
14/83
14
SYNCHRONOUS SERIALTRANSMISSIONSynchronous serialtransmission requires thatthe sender andreceivershare a clock with one
another, orthatthe sender provide a strobe or othertiming signal so thatthe receiverknows whento
readthenextbit ofthedata. Inmost forms of serial Synchronous communication,ifthereis no data
available at a giveninstantto transmit, a fillcharactermustbe sentinstead so thatdata is always being
transmitted. Synchronous communication is usually more efficient because only data bits are
transmittedbetween sender and receiver, and synchronous communicationcanbemorecostly ifextra
wiring andcircuits are requiredto share a clocksignalbetweenthe sender and receiver.
A form of Synchronous transmission is used with printers and fixed disk devices in that the
data is sent on one set of wires while a clock or strobe is sent on a different wire. Printers and fixed
diskdevices arenotnormally serialdevices becausemost fixeddiskinterface standards send anentireword ofdata foreachclock or strobe signalby using a separate wire foreachbit ofthe word. Inthe
PC industry,these areknown as Paralleldevices. The standard serialcommunications hardwareinthe
PC does not support Synchronous operations. This mode is described here forcomparison purposes
only
ASYNCHRONOUS SERIALTRANSMISSIONAsynchronous transmission allows data to betransmitted withoutthe senderhavingto send a
clock signal to the receiver. Instead, the sender and receiver must agree on timing parameters in
advance and special bits are added to each word which are used to synchronize the sending and
receiving units.
When a word is given to the UART for Asynchronous transmissions, a bit called the "Start
Bit" is addedto thebeginning ofeach wordthatis to betransmitted. The Start Bitis usedto alertthe
receiver that a word of data is about to be sent, and to force the clock in the receiver into
synchronization with the clock inthe transmitter. These two clocks must be accurate enough to not
havethe frequency driftby morethan10%duringthetransmission ofthe remainingbits inthe word.
(This requirement was set in the days of mechanical teleprinters and is easily met by modern
electronicequipment.)
-
8/7/2019 main project document final
15/83
15
Afterthe Start Bit,theindividualbits ofthe word ofdata are sent, withthe Least Significant
Bit (LSB) being sent first. Eachbitinthetransmissionis transmitted forexactly the same amount of
time as all ofthe otherbits, andthe receiver looks atthe wire at approximately halfway throughthe
period assignedto eachbitto determineifthebitis a 1 or a 0. Forexample,ifittakes two seconds to
sendeachbit,the receiver willexaminethe signalto determineifitis a 1 or a 0 after one secondhas
passed,thenit will waittwo seconds andthenexaminethe value ofthenextbit, and so on.
The senderdoes notknow whenthe receiverhas looked atthe value ofthebit. The sender
only knows when the clock says to begin transmitting the next bit ofthe word.When the entire data
wordhas been sent,thetransmittermay add a Parity Bitthatthetransmittergenerates. The Parity Bit
may be usedby the receiverto perform simpleerrorchecking. Then atleast one Stop Bitis sentby the
transmitter.
Whenthe receiverhas received all ofthebits inthedata word,itmay checkforthe Parity Bits
(both sender and receiver must agree on whether a Parity Bit is to be used), and then the receiver
looks for a Stop Bit. Ifthe Stop Bitdoes not appear when itis supposedto,the UART considers the
entire wordto begarbled and will report a Framing Errorto thehost processor whenthedata wordis
read. The usualcause of a Framing Erroris thatthe sender and receiverclocks werenot running atthe
same speed, orthatthe signal was interrupted.Regardless of whetherthe data was receivedcorrectly
ornot,the UART automatically discards the Start, Parity and Stop bits. Ifthe sender and receiver are
configuredidentically,thesebits arenot passedto thehost.If another wordis ready fortransmission,
the Start Bit forthenew wordcanbe sent as soon as the Stop Bit forthe previous wordhas been sent.
Because asynchronous data is self synchronizing, if there is no data to transmit, the
transmissionlinecanbeidle.
-
8/7/2019 main project document final
16/83
16
3.5 MICROCONTROLLER
ATmega162
The ATmega162 is a low-power CMOS 8-bitmicrocontroller,based onthe AVR
enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the
ATmega162 achieves throughputs approaching 1 MIPS per MHz allowing the system designer to
optimize powerconsumption versus processing speed.
FIG. 3.5.1 PINOUTOF ATMEGA162
AVR core combines a rich instruction set with 32 general-purpose working registers. All the 32
registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent
registers to be accessed in one single instruction executed in one clock cycle. The resulting
architecture is more code efficient while achieving throughputs up to ten times faster than
conventional CISC microcontrollers.
-
8/7/2019 main project document final
17/83
17
THE ATMEGA162 PROVIDES THE FOLLOWING PROMINENT FEATURES
High-performance, Low-power AVR 8-bit Microcontroller
Advanced RISC Architecture
130 Powerful Instructions Most Single-clockCycle Execution 32x8 General Purpose Working Registers Fully Static Operation Up to 16 MIPS Throughput at16 MHz On-chip 2-cycle Multiplier
High Endurance Non-volatile Memory segments
8KBytes of In-System Self-programmable Flash programmemory 512 Bytes EEPROM 1KByte Internal SRAM Write/Erase Cycles:10,000 Flash/100,000 EEPROM Data retention:20 years at85C/100 years at25C Optional Boot Code Section with Independent LockBits
In-System Programmingby On-chip Boot Program True Read-While-Write Operation Programming Lockfor Software Security
Peripheral Features
Two 8-bit Timer/Counters with Separate Prescaler, one Compare Mode One16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
Mode
Real Time Counter with Separate Oscillator Three PWM Channels 8-channel ADC in TQFP and QFN/MLF package Eight Channels 10-bit Accuracy 6-channel ADC in PDIP package Six Channels 10-bit Accuracy
-
8/7/2019 main project document final
18/83
18
Byte-oriented Two-wire Serial Interface Programmable Serial USART Master/Slave SPI Serial Interface Programmable Watchdog Timer with Separate On-chip Oscillator On-chip Analog Comparator
Special Microcontroller Features
Power-on Reset and Programmable Brown-out Detection Internal Calibrated RC Oscillator External and Internal Interrupt Sources Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and Standby
I/O and Packages
23 Programmable I/O Lines 28-lead PDIP, 32-lead TQFP, and 32-pad QFN/MLF
OperatingVoltages
2.7 - 5.5V (ATmega162L) 4.5 - 5.5V (ATmega162)
Speed Grades
0 - 8 MHz (ATmega162L) 0 - 16 MHz (ATmega162)
Power Consumption at 4 Mhz, 3V,25C
Active: 3.6mA Idle Mode:1.0mA Power-down Mode:0.5 A
The Idle mode stops the CPU while allowing the USART, Two-wire interface, A/D Converter,
SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning. The Power-down
mode saves the registercontents but freezes the Oscillator,disabling all otherchip functions until the
next External Interrupt or Hardware Reset.
In Power-savemode,the Asynchronous Timercontinues to run, allowingthe userto maintain
a timerbase whilethe rest ofthedeviceis sleeping. The ADC Noise Reductionmode stops the CPU
-
8/7/2019 main project document final
19/83
19
and all I/O modules except Asynchronous Timer and ADC,to minimize switchingnoiseduring ADC
conversions.
By combining an8-bit RISC CPU with In-System Self-Programmable Flash on a monolithic
chip, the Atmel ATmega162 is a powerful microcontroller that provides a highly flexible and cost-
effective solutionto many embeddedcontrol applications.
PINDESCRIPTIONS
VCC-Digital supply voltage.
GND-Ground.
PortB (PB7..PB0) XTAL1/XTAL2/TOSC1/TOSC2
Port B is an8-bitbi-directional I/O port with internal pull-up resistors (selected foreachbit).
The Port B output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if
theclockis not running. Depending ontheclock selection fuse settings, PB6canbe used as inputto
the inverting Oscillator amplifier and input to the internal clock operating circuit. Depending on the
clock selection fuse settings, PB7canbe used as output fromtheinverting Oscillator amplifier. Ifthe
Internal Calibrated RC Oscillatoris used as chip clock source, PB7..6 is used as TOSC2..1 input for
the Asynchronous Timer/Counter2ifthe AS2bitin ASSRis set.
PortC (PC5..PC0)
Port C is an7-bitbi-directional I/O port with internal pull-up resistors (selected foreachbit).
The Port C output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if
theclockis not running.
-
8/7/2019 main project document final
20/83
20
PC6/RESET
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical
characteristics of PC6 differ from those of the other pins of Port C. If the RSTDISBL Fuse is
unprogrammed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum
pulselength willgenerate a Reset,eveniftheclockis not running
PortD (PD7..PD0)
Port D is an8-bitbi-directional I/O port withinternal pull-up resistors (selected foreachbit).
The Port D output buffers have symmetrical drive characteristics with both high sink and source
capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up
resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if
theclockis not running.
RESET
Resetinput. A low level onthis pin forlongerthantheminimum pulselength willgenerate a
reset,eveniftheclockis not running. Shorter pulses arenotguaranteedto generate a reset.
AVCC
AVCC is the supply voltage pin for the A/D Converter, Port C (3..0), and ADC (7..6). It
shouldbe externally connectedto VCC,evenifthe ADC is not used. Ifthe ADC is used,it shouldbe
connectedto VCC through a low-pass filter. Notethat Port C (5..4) usedigital supply voltage,VCC.
AREF
AREF is the analog reference pin forthe A/D Converter.
ADC7..6 (TQFPand QFN/MLF Package Only)
In the TQFP and QFN/MLF package, ADC7..6 serve as analog inputs to the A/D converter.
These pins are powered fromthe analog supply and serve as10
-bit ADC channels.
-
8/7/2019 main project document final
21/83
21
FIG3.6.1 BLOCKDIAGRAMOFAT MEGA8
The ATmega162 AVRis supported with a full suite of program and systemdevelopmenttools
including: C compilers, macro assemblers, program debugger/simulators, in-circuit emulators, and
evaluationkits.
A flexibleinterruptmodulehas its control registers inthe I/O space with an additionalglobal
interrupt enable bit in the Status Register. All interrupts have a separate interrupt vector in the
interrupt vectortable. The interrupts have priority in accordance with their interrupt vector position.
The lower the interrupt vector address, the higher the priority. The I/O Memory can be accessed
directly, or as the Data Spacelocations followingthose ofthe Register File,20h - 5Fh
-
8/7/2019 main project document final
22/83
22
I/O PORTS:
All AVR ports have true Read-Modify-Write functionality when used as general digital I/O
ports. This means thatthedirection of one port pincanbechanged without unintentionally changing
the direction of any other pin with the SBI and CBI instructions. The same applies when changing
drive value (ifconfigured as output) orenabling/disabling of pull-up resistors (ifconfigured as input).
Each output buffer has symmetrical drive characteristics with both high sink and source capability.
The pin driver is strong enough to drive LED displays directly. All port pins have individually
selectable pull-up resistors with a supply-voltage invariant resistance. All I/O pins have protection
diodes to bothVCC and Ground.
All registers andbit references inthis section are writteningeneral form. Three I/O memory
address locations are allocated foreach port, oneeach forthe Data Register PORTx, Data Direction
Register DDRx, andthe Port Input Pins PINx. The Port Input Pins I/O locationis read only, while
the Data Register and the Data Direction Register are read/write. In addition, the Pull-up Disable
PUD bitin SFIORdisables the pull-up function for all pins in all ports when set.
Most port pins are multiplexed with alternate functions for the peripheral features on the
device. Enabling the alternate function of some ofthe port pins does not affect the use ofthe other
pins inthe port as generaldigital I/O.
POR TS AS GENERALP URP OSE
I/O:
The ports arebi-directional I/O ports with optionalinternal pull-ups. Each port pinconsists of
three registerbits: DDxn, PORTxn, and PINxn. The DDxnbits are accessed atthe DDRx I/O address,
the PORTxnbits atthe PORTx I/O address, andthe PINxnbits atthe PINxI/O address. The DDxnbit
inthe DDRx Register selects thedirection ofthis pin. If DDxnis writtenlogic one, Pxnis configured
as an output pin. If DDxnis writtenlogiczero, Pxnis configured as aninput pin. If PORTxnis written
logic one when the pin is configured as an input pin, the pull-up resistor is activated. To switch the
pull-up resistor off, PORTxnhas to be writtenlogiczero orthe pinhas to beconfigured as an output
pin. The port pins aretri-stated when a resetconditionbecomes active,evenifno clocks are running.
If PORTxnis writtenlogic one whenthe pinis configured as an output pin,the port pinis drivenhigh
(one). If PORTxn is written logic zero when the pin is configured as an output pin, the port pin is
driven low (zero). Normally, the pull-up enabled state is fully acceptable, as a high-impedance
-
8/7/2019 main project document final
23/83
23
environment willnotnoticethedifferencebetween a stronghighdriver and a pull-up. Ifthis is notthe
case,the PUD bitinthe SFIOR Registercanbe setto disable all pull-ups in all ports.
TABLE3.6.2SELECTIONTABLE
FIG3.6.3 GENERAL I/OBLOCKDIAGRAM1
-
8/7/2019 main project document final
24/83
24
Independent ofthe setting of Data Direction bit DDxn, the port pin can be read through the
PINxn Registerbit. The PINxn Registerbit andthe precedinglatchconstitute a synchronizer. This is
neededto avoidmeta stability ifthe physical pinchanges valueneartheedge oftheinternalclock,but
it also introduces a delay. The maximum and minimum propagationdelays aredenoted tpd, max and
tpd,min respectively.
FIG3.6.4TIMINGDIAGRAMWHILEREADINGAN1
Considertheclock period starting shortly afterthe first fallingedge ofthe systemclock. The
latchis closed whentheclockis low, andgoes transparent whentheclockis high, as indicatedby theshaded region ofthe SYNC LATCH signal. The signal valueis latched whenthe systemclockgoes
low. It is clocked into the PINxn Register atthe succeeding positiveclockedge. As indicatedby the
two arrows tpd,max andtpd,min, a single signaltransition onthe pin willbedelayedbetween and1
systemclock perioddepending uponthetime of assertion.When readingbacka software assigned pin
value, a nopinstruction must be inserted. Theoutinstruction sets the SYNC LATCH signal at the
positive edge of the clock. In this case, the delay tpd through the synchronizer is one system clock
period.
-
8/7/2019 main project document final
25/83
25
FIG3.6.5TIMINGDIAGRAMWHENREADINGAN
3.7 8-BITTIMER/COUNTERREGISTER DESCRIPTION
Timer/CounterControl Register TCCR2
FIG3.7.1 .TCCR1
Bit7 FOC2: Force Output Compare
The FOC2bit is only active when the WGM bits specify a non-PWM mode. However, for ensuring
compatibility with futuredevices,this bitmustbe setto zero when TCCR2is written when operating
in PWM mode. When writing a logical oneto the FOC2bit, animmediate Compare Matchis forced
onthe waveformgeneration unit. The OC2 outputis changed accordingto its COM21:0bits setting.
Notethatthe FOC2bitis implemented as a strobe. Thereforeitis the value presentinthe COM21:0
bits thatdetermines theeffect ofthe forcedcompare. A FOC2 strobe willnotgenerate any interrupt,
nor willitclearthetimerin CTC mode using OCR2 as TOP. The FOC2bitis always read as zero.
Bit6,3 WGM21:0: Waveform Generation Mode
These bits control the counting sequence of the counter, the source for the maximum (TOP)
counter value, and whattype of waveformgenerationto be used. Modes of operation supportedby the
Timer/Counter unit are: Normalmode, Clear T imer on Compare Match (CTC) mode, and two types
of Pulse Width Modulation (PWM) modes
-
8/7/2019 main project document final
26/83
26
TABLE3.7.2TCCR MODES
Bit 5:4 COM21:0: Compare Match Output Mode
Thesebits controlthe Output Compare Pin (OC2) behavior. If one orboth ofthe COM21:0bits
are set,the OC2 output overrides thenormal port functionality ofthe I/O pinitis connectedto.
However,notethatthe Data Direction Register (DDR) bitcorrespondingto OC2 pinmustbe set
in orderto enablethe outputdriver. When OC2is connectedto the pin,the function ofthe COM21:0
bits depends onthe WGM21:0bit setting.
Timer/CounterRegister TCNT2
FIG3.7.3 TCNT
The Timer/Counter Register gives direct access, both for read and write operations, to the
Timer/Counter unit 8-bit counter. Writing to the TCNT2 Register blocks (removes) the Compare
Match on the following timer clock. Modifying the counter (TCNT2) whilethe counter is running,
introduces a riskofmissing a Compare Matchbetween TCNT2 andthe OCR2 Register.
-
8/7/2019 main project document final
27/83
27
OutputCompareRegister OCR2
FIG3.7.4 OCR2
The Output Compare Registercontains an8-bit valuethat is continuously compared withthe
counter value (TCNT2). A matchcanbe usedto generate an Output Compareinterrupt, ortogenerate
a waveform output onthe OC2 pin.
8-BIT TIMER/COUNTER0
Timer/Counter0 is a general purpose, single channel,8-bit Timer/Counter module. The main
features are:
Single Channel Counter
Frequency Generator
External Event Counter
10-bit ClockPrescaler
Overview
A simplifiedblockdiagram ofthe8-bit Timer/Counteris showninFig3.8.1 . Forthe actual placement
of I/O pinsCPU accessible I/O Registers, including I/O bits and I/O pins, are shown in bold. The
device-specific I/O Register and bit locations are listed in the 8-bit Timer/Counter Register
Description.
-
8/7/2019 main project document final
28/83
28
FIG3.7.5 8-BIT TIMER/COUNTER
Registers
The Timer/Counter (TCNT0) is an8-bit register. Interrupt request (abbreviatedto Int. Req.in
the figure) signals are all visible in the Timer Interrupt Flag Register (TIFR). All interrupts are
individually masked with the Timer Interrupt Mask Register (TIMSK). TIFR and TIMSK are not
shown in the figure since these registers are shared by other timer units. The Timer/Counter can be
clockedinternally or via the prescaler, orby anexternalclocksource onthe T0 pin. The ClockSelect
logicblockcontrols whichclock source andedgethe Timer/Counter uses to incrementits value. The
Timer/Counteris inactive whenno clock sourceis selected. The output fromtheclock selectlogicis
referredto as thetimerclock(clkT0).
Definitions
Many register and bit references in this document are written in general form. A lower case
n replaces the Timer/Counternumber,inthis case0. However, when usingthe register orbitdefines
in a program,the precise formmustbe usedi.e. TCNT0 for accessing Timer/Counter0counter value
and so on. Timer/Counter ClockSources
The Timer/Counter can be clocked by an internal or an external clock source. The clock source is
selectedby theclock select logic which is controlledby theclock select (CS02:0) bits located inthe
Timer/Counter Control Register (TCCR0).
-
8/7/2019 main project document final
29/83
29
Counter Unit.
FIG3.7.6 COUNTERUNIT BLOCKDIAGRAM
Operation
The counting direction is always up (incrementing), and no counter clear is performed. The
counter simply overruns when it passes its maximum8-bit value (MAX = 0xFF) and then restarts
fromthebottom (0x00). Innormal operationthe Timer/Counter Overflow Flag (TOV0) willbe setin
the sametimerclockcycle as the TCNT0becomes zero. The TOV0 Flag inthis casebehaves like a
ninthbit,exceptthatitis only set,notcleared. However,combined withthetimer overflow interrupt
that automatically clears the TOV0 Flag, the timer resolution can be increased by software. A new
counter valuecanbe written anytime.
TimingDiagrams
The Timer/Counteris a synchronous design andthetimerclock (clkT0) is therefore shown as
a clock enable signal in the following figures. The figures include information on when Interrupt
Flags are set.Figurecontains timingdata forbasic Timer/Counter operation.
-
8/7/2019 main project document final
30/83
30
The figure shows thecount sequencecloseto the MAX value.
FIG3.7.7TIMINGDIAGRAMS 1
FIG3.7.8 TIMINGDIAGRAMS 2
-
8/7/2019 main project document final
31/83
-
8/7/2019 main project document final
32/83
32
4.1 POWERSUPPLY
A variable regulated power supply, also called a variable bench power supply, is one
where you cancontinuously adjustthe output voltageto your requirements.Varyingthe output
of the power supply is the recommended way to test a project after having double checked
parts placement againstcircuitdrawings andthe parts placementguide.
This type of regulation is ideal for having a simple variable bench power supply.
Actually this is quiteimportantbecaus e one ofthe first projects a hobbyist should und ertakeis
theconstruction of a variable regulated power supply. While a dedicated supply is quitehandy
e.g. 5V or12V,it's muchhandierto have a variable supply onhand,especially fortesting.
Mostdigitallogiccircuits and processors need a 5 volt power supply. To usethese parts
we need to build a regulated 5 volt source.
Usually you start wit h an unregulated power Tomake a 5 volt power supply, we use a LM7805 voltage regulator IC (Integra ted Circuit). The
IC is s hownbelow.
FIG4.1.1LM7805VOLTAGEREGULATOR
The LM7805 is s impleto us e. You simply connectthe positivelead of your unregulated
DC power supply (anything from 9VDC to 24VDC) to the Input pin .
-
8/7/2019 main project document final
33/83
33
4.2 CIRCUITFEATURES
y Brief description of operation: Gives out well regula ted +5V output, output currentcapability of100mA
y Circuit protection: Built -in overheating protection shuts down output when regulator ICgets too hot
y Circuitcomplexity:Very simple andeasy to buildy Circuit performance:Very stable +5V output voltag e, reliable operationy Availability ofcomponents: Easy to get, uses only very commonbasiccomponentsy Designtesting: Bas ed ondatasheetexamplecircuit, I have usedthis circuit successfully
as part ofmany electronics projects
y App lications: Part ofelectronics devices, smalllaboratory power supplyy Power supply voltage: Unregulated DC 8-18V power supplyy Power supply current: Needed outputcurrent + 5 mAy Component costs: Few dollars for the electronics components + the input transformer
cost
4.3 BLOCKDIAGRAM
FIG4.3.1BLOCKDIAGRAMOF POWERSUPPLY
-
8/7/2019 main project document final
34/83
34
EX LECIRCUIT DIAGRAM
FIG 4.3. CIRCUITDDIIAAGGRRAAMM OFPOWER SUPPLY
-
8/7/2019 main project document final
35/83
35
CHAPTER-5
INTRODUCTION TOAVRSTUDIO
-
8/7/2019 main project document final
36/83
36
5.1 IntroductionToAVRStudio:
Now you havethebasichardwaretools,itstimetosetupthesoftwareenvironment.Themain
softwaresyou willneedare:
AVRStudioA GUI IDE
forAVR(www.atmel.com,http://www.atmel.com/dyn/resources/prod_documents/AVRStudio
4.13SP2.exe)
WinAVRafreeCcompilerforAVRs (http://winavr.sourceforge.net/download.html)
PonyProgSerialDeviceProgrammer (www.lancos.com)
Afterdownloadingtheminstallthemin yourcomputer.Itisbetterto installWinAVRin
rootofadrivelikec:\winavrord:\winavr. AlsopleaseinstallWinAVRfirstthen
AVRStudiothiswillletAVRStudio detectthecompiler.Nowyou are readyto
writeyoufirstmicrocontrollerprogram!!!
Inthistutorial,you willlearnthebasicsteps requiredfor anymicrocontrollersbasedproject.Wewill
writeabasichelloworldproject,whichisasimpleLEDblinkerin MCUempiretodemonstratethese
basicsteps.
ENTERINGANDCOMPILINGCODE.StartAVRStudiofromStartMenu->All programs->Atmel AVRTools->AVRStudio4
You willbepresentedwithaProjectwizardasshownbelow.
-
8/7/2019 main project document final
37/83
37
AVRSTUDIOPROJECTWIZARD
PROJECTDETAILSSelectAVRGCCin Projecttypethenenter asuitableprojectname
sayhelloandselectalocationin you
-
8/7/2019 main project document final
38/83
38
harddisk.Thenclicknext.MakesurethatCreateinitialfileandCreatefolder optionischecked.
DEVICESELECTIONInthisdialogboxselectAVRSimulatorinDebugPlatformlistandselectthe
AVRMCUdepending onthetype ofMCUinstalled on yourdevelopmentboard,in
Devicelist.Clickfinish.Afterthat,youwillbe presentedwithan IntegratedDevelopmentEnvironment-
IDE. As shownbelow.
-
8/7/2019 main project document final
39/83
39
AVRSTUDIOMAINWINDOW.This IDEwillhelpyou inediting,modifying,andcompilesource program.Aftera
projectiscompileditgivesyou a.hex filereadytoburntoyour MCU.Themainparts ofthewindoware
ProjectAreadisplaysallthefilessource andheaderinthecurrentproject.Youcan addand
removefilesbythecontextmenu ofdifferentgroupslikesourcefile, headerfilesetc.
Doubleclickafiletoopenitintheeditor.
Codeeditor Here youenter andeditthefiles.
MessageAreaHereAVRStudiowill show errorsandwarninggeneratedbycompilewhenit
triesto compileasourcefile.
Now copypastortypethefollowingcodeinthecodeeditor.
Goto Project->ConfigurationOptionstobringtheProjectoptiondialog.
-
8/7/2019 main project document final
40/83
40
Enterthe CPUfrequency.Ifyou areusingxBoardorxBoardMINIenter16Mhzi.e.16000000.In
addition,select optimization as-O2.Clickok.
Now you haveenteredthecodenowtimetocompileandbuildtheproject.PressF7orselectBuil d-
>Buildorclickthetoolbarbutton forBuildactiveconfiguration.Ifthecodeiserror
freeAVRstudiowill showyou the followingmessage.
-
8/7/2019 main project document final
41/83
41
Buildsucceedwith1warning.Dontworryabouttheone warningitisduetothefactthatANSI standard
suggestthatreturntypeofmain()mustbe one,butfor MCUplatformthereisno environment
oroperatingsystemthatwill receivethisreturnedvalue.So returntype ofmain()isvoid.
Now you have successfullycompiledyou firstproject,whatyou havegotaftercompilation
andbuildis .hexfile.You canfinditin afoldernameddefaultin you projectfolder.Ithas
samenameasyou project,inthiscase hell o.hex
PROGRAMMINGTHEMCUWITH HELLO.HEX .Nowitstimetoburn thishexfiletoyourMCU.Toknowhowtoburnthehexfiletoyou MCUreferto
you programmers manual.You can useeXtremeelectronicsUSBAVRProgrammer toburn
hexfilesto youmcu(seeshopsection).Detailedprocedure isgiven in programmer folderin
itssupportCD.
Programming UsingPonyProg.
Thisistheprogrammer wemadeintheprevioustutorial. Itsuseissimple.StartPonyprog,you will
get a screensimilartothis.
-
8/7/2019 main project document final
42/83
42
-
8/7/2019 main project document final
43/83
43
PonyProgMainWindow.
First,you neetsome setup.Goto menusetup->interface setupandmakesettinglikethis.
PonyProgSetup
Selectthe serial portinwhichyourprogrammer isconnected.Bewaretheremay be
morethat1 availablecomportshowingthere andusually onlyoneisavailableoutsidethe
PCthe restareinternalandmaybe connectedtoyourmodem.Somakesureyouhaveselecteda
portthatisconnectedtoyour programmer andnottoyourmodem.
Next, go to setupcalibration.Nowyou are done.Connecttheprogrammeryou
havemadeto youPCsserial portandconnectits ISPconnectortothe target you havemade.
Switch on thetarget.Thesoftwareisselfexplanatorywith easytouse GUIin thetoptool
barthere isaselection for type of chip you
wanttoprogram.SelectAVRMicroandselectthe type ofMicro(likeATmega8)in
boxnexttoit.
-
8/7/2019 main project document final
44/83
44
CHAPTER-6
GLOBALSYSTEMFORMOBILE
-
8/7/2019 main project document final
45/83
45
6.1GSM MODEM :
GSM stands for Global System for Mobile Communication. It is a globally
accepted standard for digital cellular communication. GSM is the name of astandardization group established in 1982 to create a common European mobile
telephone standard that would formulate specifications for a pan-European mobile
cellular radio system operating at 900 MHz.
Functions GSM Modes
The GSM modem basically consists of a
y SIM card holder to hold the activated SIM card for sending and receiving SMS.y 5V AC power supply header to which the 5v ac adapter is connected.y Power led which gives the indication of modem status that is on or off.y 9 pin female to which the GSM antenna is connected.
-
8/7/2019 main project document final
46/83
46
6.2Block Diagram of GSM:
-
8/7/2019 main project document final
47/83
47
6.3 GSM Network Setup:
USER & APPLICATIONS NETWORK
GSM setup
This is the basic setup of a GSM. Here ME stands for Mobile Equipment, e.g. a
GSM phone (equal to MS; Mobile Station). TE stands for Terminal Equipment, e.g. a
computer (equal to DTE; Data Terminal Equipment). TA stands for Terminal Adaptor, e.g.
a GSM data card (equal to DCE; Data Circuit Terminating Equipment).
Through the mobile equipment the network messages are sent and received.These messages are sent to the terminal adapter which is nothing but a GSM data card.
Now if there is some data to be sent to the mobile equipment then the terminal
equipment that is basically a computer or processor sends out AT COMMANDS to the
terminal adapter which in turn sends the mobile equipment the required data
TATE ME
-
8/7/2019 main project document final
48/83
48
AT mega 8
MCU
GSM
Module
Device 1
Device 2
Device 3
RELAY
Board
UAR
GPIOs
Buzzer
TEMPERATURE
Sensor
PT
CT AD
C
-
8/7/2019 main project document final
49/83
49
CHAPTER-7
ABOUT SCADA
-
8/7/2019 main project document final
50/83
50
7.1 SupervisoryControlandDataAcquisition (SCADA)Networks
Since September11,2001 United States agencies involved withnational
security havebecomeincreasingly concerned aboutthe vulnerability ofthe North
American powergrid, water supply, refining,nuclear facilities and railroads to electronic
intrusions or cyber attacks. Several studies havebeenconducted andhaveidentifiedchanging socio-economicconditions thatincreasethe probability of suchcomputer-based
attacks. Increaseddomestic andinternationalterrorism,industry relatedissues affecting
the utilities jobmarket,the shiftto more open standards forinterconnection of DCS and
SCADA networks and a growing population ofcomputer-literate people with widely
availablehackertools are factors thatcontributegreatly to thelikelihood of suchthreats.
Inthis paper, we willidentify anddiscuss threat origins andhow technologies
availabletoday from GDC canmitigatethesethreats andbe part of a comprehensive
networkdesign and security policy to ensure safe and securecommunications between
components of DCS and SCADA networks.
7.2WhatisaDCS or SCADAnetwork
DCS are usedto controllarge,complex processes such as power plants,
refineries, andchemical plants typically,butnot always, at a single site. A DCS is
comprised of a supervisory layer ofcontrol and one ormoredistributedcontrollers
contained withinthe same processing plant. The supervisory controller runs on a central
server andcommunicates with subordinatecontrollers via some form of peer-to-peer
network. The supervisor sends set points to and requests data fromthedistributed
controllers. Thedistributedcontrollers controltheir process actuators (switches, valves,flow controllers,etc) based on requests fromthe supervisor. Thesecontrollers typically
use a local fieldbus to communicate withthe actuators and sensors eliminatingtheneed
for point-to-point wiringto eachdevice. Many times,thedistributedcontrollers in a DCS
havethecapability to be accessed via a modem allowing remotediagnostics and servicing
by vendors and plantengineers.
A SCADA networktypically consists for a Central Monitoring System (CMS),
contained at a central plant forexample and one ormore Remote Stations. The CMS
houses the Control Server andthecommunications access via a peer-to-peernetwork. The
CMS collects andlogs informationgathered atthe Remote Stations andgeneratesnecessary actions based onthegathereddata. A Remote Stationconsists ofeither a
Remote Terminal Unit (RTU) or a Programmable Logic Controller (PLC) whichcontrols
actuators andmonitors sensors. Remote Stations typically havethecapability to be
interfacedby field operators via laptops or otherhandhelddevices to performdiagnostics
and repair operations.informationbetween Remote Stations andthe CMS. These facilities
canbetelco lines,cable, or RF.
-
8/7/2019 main project document final
51/83
51
7.3 Fieldbus-Ethernet
Itis importantto understandthat DCS and SCADA basedindustries are
undergoing a changeinhow thesenetworks areimplemented. Controllernetworks
typically werebased on proprietary serialcabling and/or fieldbus architectures (Fieldbus,Modbus, Profibus) whichhave upperdata limits of about2Mbps,nodelimitations, and
distancelimitations which all varied fromtechnology to technology. This would allneed
to pass through a gateway to getto theinternal IT networka very cumbersome approach.
Thedevelopment of Ethernet-capablecontrollers and PLCs andtheneed forintegration of
other requirements (security devices,barcode scanners, smartcards,etc) arehelpingto
drivetheindustry towards more open and ubiquitous architectures. This shiftis also made
apparentby the factthatmany vendors areencapsulatingthebus protocols into TCP/IP:
Modbus/TCP (Modbus protocol over TCP/IP, EtherNet/IP (ControlNet/DeviceNet over
TCP/IP), Fieldbus High-Speed Ethernet and ProfiNet (Profibus over Ethenet). Ethernetis
quickly becoming a larger part of DCS and SCADA networkimplementations,in some
cases replacing or augmentingthe olderbus-type architectures.
Threats
As demonstrateddaily, any TCP/IP basednetworkis subjectto intrusion. These
intrusions come fromnumerous sources including:
Threatsfromwithin:-- Company staff,technician, operators.
-- Security breaches may notbeintentional, BUT.
-- Emailed viruses
Threatsfromtheoutside:
-- 3rd party support services
-- Communications lines
-- Vandalism/terrorism
Security measures shouldnotbetakenlightly. Remember,if yournetworkis easy for your
IT Departmentto manage,itis mostlikely easy for an outside party to infiltrate.
-
8/7/2019 main project document final
52/83
52
7.4 HowcanGDCaddresssecurityissueswithDCS and SCADA
networks?
GDC products shouldbe part of a comprehensive securenetworkimplementation.
Otherelements that shouldbe addressed are policies andenforcement, virus detection and
prevention, firewalls, and Intrusion Detection Systems (IDS).
GDCs line of securemodems and IP access products canbethe firstline ofdefense atthemostbasiclevels of
yournetwork OSI Layers 1 and2.
As statedearlier,mostlegacy DCS/SCADA networks havemodem access to
somecontrollers(and potentially elsewhere) for remotemaintenance andtroubleshooting.
GDCs family ofV.34modems with SteadfastSecurity and additionally RADIUS
authenticationcanmaketheseconnections hack-proof . GDCs SteadfastSecurity,
whichis a proprietary,handshake-basedexchange requires a GDC modem atbothends. If
thehandshake passwordexchangeis notcompleted properly,thecallis droppedbefore
everbeingconnectedto thenetwork. With acommonlength password of6-8
alphanumeric,it wouldbe statistically impossible for any hackerto gain access, assuming
they have a GDC modem Additionally,addingRADIUS authenticationsecurity where
applicable would furtherenhancethe security.Withthemigration/augmentation ofthe
DCS and SCADA peer-to-peernetworks to 10/100
-
8/7/2019 main project document final
53/83
53
-
8/7/2019 main project document final
54/83
54
Ethernet, GDCs line of IP access products, SpectraComm IP (SCIP) and
Ethernet switch (SCES) can provide first-lineintrusion prevention. All ofthe
SpectraComm IP and Ethernet switch units implement GDC IronGate Security features.
These features,including port-based shutdown and MAC address filtering,canlimitaccess only to authorizeddevices and personnel as designatedby the MAC Address tables
configuredinthe unitby thenetworkadministrator. It shouldbenotedthat a SCIP unitin
LAN Extension (LAN-X) modecannot only filter MAC addresses onthe LAN,butcan
also filter onthe WAN port as wellto ensurethat unauthorized access does not occur from
thecircuit (Telco facilities). Additionally,the SCIP and SCES implementindustry-
standard TACACS+ compatibleclients forcentralized authentication.
Inlarge-scale processing facilities,the SCIP T1 (1.544 Mbps up to 5000 feet
without repeaters) or SCIP G.S (4 Mbps up to 7000 feet on1 pair or up to 12,000 feet on2pair) in LAN Extension (LANX) mode,canextendthe reachbetweenthe Central and
Distributed Controller wellbeyondthe100meter reach of Ethernet alone. Implementing
the MAC-based filtering and/or TACACS+ inthese situations allows maintenance
personnelto attachto thenetworkatthe SCIP as determinedby thenetworkadministrator.
In SCADA RTU applications,the SCIP T1in LAN-X mode and SCES offer a
compelling andsecure solution where onemighttypically install a router withits
associatedcosts. Implementingthe MAC-based filtering and/or TACACS+ allows only
authorizedmaintenance personneltoaccess thenetworkvia the SCIP/SCES as determined
by thenetworkadministrator.
Additionally,the Contact Sense feature onthe SCIP couldbeimplementedto
alertnetworkmonitoring personnel of suchthings as door opening,high water,highheat,
etc. atthe Remote Stationif so desired. SCIP and SCES havebeenindependently tested
andcertifiedto stringent NEBS Level 3+ requirements for Telcos and additionaltesting
have proventhemto beconsistent withtheclassification as temperature hardened (-40
oC to +70 o C) fordeploymentinextremeenvironments.
-
8/7/2019 main project document final
55/83
55
Typical SCADAApplicatio
-
8/7/2019 main project document final
56/83
56
CHAPTER-8
GLOBAL SYSTEM FORMOBILECOMMUNICATION
-
8/7/2019 main project document final
57/83
57
8.1 GSM
GSM(GLOBAL SYSTEM FOR MOBILE COMMUNICATION) is a digital
mobiletelephony systemthatis widely usedin Europe and other parts ofthe world. GSM
uses a variation oftimedivisionmultiplexing (TDMA) andis themost widely used ofthe
threedigital wireless telephony technologies (TDMA, GSM, and CDMA). GSM digitizes
andcompresses data,thensends itdown a channel withtwo other strams of userdata,each
inits owntime slot. It operates ateitherthe 900 MHz or1800 MHz frequency band
Usingthe HyperTerminal
Hint:: By developing your AT commands using HyperTerminal,it willbeeasier for
you to develop your actual programcodes inVB, C, Java or other platforms.
Go to START\Programs\Accessories\Communications\HyperTerminal (Win2000)
to create a new connection,eg. "My USB GSM Modem". Suggested settings ::
- COM Port:: As indicatedinthe T-Modem Control Tool
- Bits per second:: 9600( or slower )
- Data Bits :8
- Parity : None
- Stop Bits :1
- Flow Control: Hardware
You arenow ready to start working with AT commands. Typein "AT" and you should
get a "OK",else you havenot setup your HyperTerminalcorrectly. Checkyour port
settings and also make sure your GSM modemis properly connected andthedrivers
installed.
-
8/7/2019 main project document final
58/83
58
InitialsetupATcommands
We are ready now to start working with AT commands to setup andcheckthe status of
the GSM modem.
AT Returns a "OK" to confirmthatmodemis working
AT+CPIN="xxxx" To enterthe PIN for your SIM ( ifenabled )
AT+CREG? A "0,1" reply confirms yourmodemis connectedto GSM network
AT+CSQ Indicates the signal strength, 31.99 is maximum.
Sending SMS usingATcommands
We suggesttry sending a few SMS usingthe Control Tool aboveto make sure
your GSM modemcan send SMS before proceeding. Let's lookatthe AT
commands involved..
AT+CMGF=1 To format SMS as a TEXT message
AT+CSCA="+xxxxx" Set your SMS center's number. Checkwith your provider.
To send a SMS,the AT commandto useis AT+CMGS ..
AT+CMGS="+yyyyy"
> Your SMS textmessagehere
The "+yyyyy" is your receipent's mobilenumber. Next, we willlookat receiving SMS via
AT commands.
-
8/7/2019 main project document final
59/83
59
Receiving SMS usingATcommandsThe GSM modemcanbeconfiguredto responseindifferent ways whenit receives a
SMS.
a) Immediate - when a SMS is received,the SMS's details areimmediately sentto thehost
computer (DTE) via the +CMT command
AT+CMGF=1 To format SMS as a TEXT message
AT+CNMI=1,2,0,0,0 Sethow themodem will response when a SMS is received
When a new SMS is receivedby the GSM modem,the DTE will receivethe following..
+CMT : "+61xxxxxxxx" ,, "04/08/30,23:20:00+40"
This thetext SMS message sentto themodem
Yourcomputer (DTE) willhaveto continuously monitorthe COM serial port, read and
parsethemessage.
b) Notification - when a SMS is recieved,thehostcomputer ( DTE ) willbenotified ofthe
new message. Thecomputer willthenhaveto readthemessage fromtheindicated
memory location andclearthememory location.
AT+CMGF=1 To format SMS as a TEXT message
AT+CNMI=1,1,0,0,0 Sethow themodem will response when a SMS is received
When a new SMS is receivedby the GSM modem,the DTE will receivethe following..
+CMTI: "SM",3 Notification sentto thecomputer. Location 3 in SIM memory
AT+CMGR=3 AT commandto send readthe received SMS frommodem
Themodem willthen sendto thecomputerdetails ofthe received SMS fromthe specified
memory location ( eg. 3 ) ..
-
8/7/2019 main project document final
60/83
60
+CMGR: "REC READ","+61xxxxxx",,"04/08/28,22:26:29+40"
This is thenew SMS receivedby the GSM modem
After reading and parsingthenew SMS message,thecomputer (DTE) should send a AT
commandto clearthememory locationinthe GSM modem..
AT+CMGD=3 To clearthe SMS receivememory locationinthe GSM modem
Ifthecomputertries to read a empty/clearedmemory location, a +CMS ERROR: 321 will
be sentto thecomputer.
Usingacomputerprogramtosendandreceive SMS
Once we are ableto workthemodem using AT commands, wecan usehigh-level
programming ( eg.VB, C, Java ) to sendthe AT ASCII commands to and readmessages
fromthe COM serial portthatthe GSM modemis attachedto.
-
8/7/2019 main project document final
61/83
61
8. GSMMODULEPICTURE
-
8/7/2019 main project document final
62/83
62
8.3 GSMFLOWCHART:
-
8/7/2019 main project document final
63/83
63
CHAPTER-9
INRODUCTIONTOUART
-
8/7/2019 main project document final
64/83
64
9 .1 SERIALCOMMUNICATION
The Universal Asynchronous Receiver/Transmitter (UART) controller is the key
component ofthe serialcommunications subsystem of a computer. The UART takes bytes
of data and transmits the individual bits in a sequential fashion. At the destination, a
second UART re-assembles thebits into completebytes.
Serial transmission is commonly used with modems and for non-networked
communicationbetweencomputers,terminals and otherdevices.
There are two primary forms of serial transmission: Synchronous and
Asynchronous. Depending onthe modes that are supportedby thehardware,thename 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
describedbelow.
Somecommon acronyms are:
UART Universal Asynchronous Receiver/Transmitter
USART Universal Synchronous-Asynchronous Receiver/Transmitter
SYNCHRONOUS SERIALTRANSMISSIONSynchronous serialtransmission requires thatthe sender and receiver share a clock
with one another, or that the sender provide a strobe or other timing signal so that the
receiver knows when to read the next bit of the data. In most forms of serial
Synchronous communication,ifthereis no data available at a giveninstantto transmit, a
fill character must be sent instead so that data is always being transmitted. Synchronous
communication is usually more efficient because only data bits are transmitted between
sender and receiver, and synchronous communication can be more costly if extra wiring
andcircuits are requiredto share a clocksignalbetweenthe sender and receiver.
A form of Synchronous transmissionis used with printers and fixeddiskdevices in
thatthedata is sent on one set of wires while a clock or strobeis sent on a different wire.
-
8/7/2019 main project document final
65/83
65
Printers and fixed disk devices are not normally serial devices because most fixed disk
interface standards send anentire word ofdata foreachclock or strobe signalby using a
separate wire for each bit of the word. In the PC industry, these are known as Parallel
devices.
The standard serial communications hardware in the PC does not support
Synchronous operations. This modeis describedhere forcomparison purposes only
ASYNCHRONOUS SERIALTRANSMISSIONAsynchronous transmission allows data to be transmitted without the sender
havingto send a clock signalto the receiver. Instead,the sender and receiver must agree
ontiming parameters in advance and specialbits are addedto each word which are usedto
synchronizethe sending and receiving units.
When a word is given to the UART for Asynchronous transmissions, a bit called
the "Start Bit" is addedto thebeginning ofeach wordthatis to betransmitted. The Start
Bit is used to alert the receiver that a word of data is about to be sent, and to force the
clock in the receiver into synchronization with the clock in the transmitter. These two
clocks mustbe accurateenoughto nothavethe frequency driftby morethan10%during
thetransmission ofthe remainingbits inthe word. (This requirement was set inthedays
ofmechanicalteleprinters andis easily metby modernelectronicequipment.)
Afterthe Start Bit,the individualbits ofthe word ofdata are sent, withthe Least
Significant Bit (LSB) being sent first. Each bit in the transmission is transmitted for
exactly the same amount oftime as all of the other bits, and the receiver looks at the
wire at approximately halfway throughthe period assignedto eachbitto determineifthe
bit is a 1 or a 0. For example, if it takes two seconds to send each bit, the receiver will
examinethe signalto determineifitis a 1 or a 0 after one secondhas passed,thenit will
waittwo seconds andthenexaminethe value ofthenextbit, and so on.
The sender does notknow whenthe receiver has looked atthe value ofthebit.
The sender only knows whentheclocksays to begintransmittingthenextbit ofthe word.
-
8/7/2019 main project document final
66/83
66
Whentheentiredata wordhas been sent,thetransmittermay add a Parity Bitthat
the transmitter generates. The Parity Bit may be used by the receiver to perform simple
errorchecking. Then atleast one Stop Bitis sentby thetransmitter.
Whenthe receiverhas received all ofthebits inthedata word,itmay checkfortheParity Bits (both sender and receivermust agree on whether a Parity Bitis to be used), and
thenthe receiverlooks for a Stop Bit. Ifthe Stop Bitdoes not appear whenitis supposed
to,the UART considers the entire word to begarbled and will report a Framing Errorto
thehost processor whenthedata wordis read. The usualcause of a Framing Erroris that
the sender and receiverclocks werenot running atthe same speed, orthatthe signal was
interrupted.
Regardless of whether the data was received correctly or not, the UART
automatically discards the Start, Parity and Stop bits. If the sender and receiver are
configuredidentically,thesebits arenot passedto thehost.
If another word is ready for transmission, the Start Bit for the new word can be
sent as soon as the Stop Bit forthe previous wordhas been sent.
Because asynchronous data is self synchronizing,ifthereis no data to transmit,
thetransmissionlinecanbeidle.
9.2 NEEDFORSERIALCOMMUNICATION
Serial Cables canbelongerthan Parallelcables. The serial porttransmits a '1' as -3
to -25 volts and a '0' as +3 to +25 volts where as a parallel porttransmits a '0' as 0v and a
'1' as 5v. Therefore the serial port can have a maximum swing of 50V compared to the
parallel port whichhas a maximum swing of 5 Volts. Thereforecableloss is notgoingto
be as much of a problem for serialcables thanthey are for parallel.
You don't need as many wires than parallel transmission. If your device needs to
be mounted a far distance away from the computer then 3 core cable (Null Modem
Configuration) is goingto be a lotcheaperthat running19 or25 corecable. However you
musttakeinto accountthecost oftheinterfacing ateachend.
-
8/7/2019 main project document final
67/83
67
Microcontroller's have also proven to be quite popular recently. Many of these
have in built SCI (Serial Communications Interfaces) which can be used to talk to the
outside world. Serial Communication reduces the pincount ofthese MPU's. Only two pins
are commonly used, Transmit Data (TXD) and Receive Data (RXD) compared with at
least8 pins if you use an8bit Parallelmethod (You may also require a Strobe).
The serialcommunicationis betweenthe MCU and PC. In orderto connectmicro
controller to a pc a serial port is used. Serialcommunication is a very common protocol
for device communication that is standard on almost every PC Most computers include
two RS-232 based serial ports. Serial communication is also a common communication
protocolthatis usedby many devices forinstrumentation acquisitioninconjunction with a
remote sampling device. The concept of serial communication is simple. The serial port
sends and receives bytes of information one bit at a time. Although this is slower than
parallel communication, which allows the transmission of an entire byte at once, it is
simpler andcanbe used over longerdistances. Forexample,the IEEE 488 specifications
for parallelcommunication statethatthecablingbetweenequipmentcanbeno morethan
20meters total, withno morethan2meters between any two devices. Serial,however,can
extend as much as 1200meters.Typically, serial is used to transmit ASCII data.
Communicationis completed using 3 transmissionlines:
y Ground,y Transmity Receive.
Since serial is asynchronous, the port is able to transmit data on one line while
receivingdata on another. Otherlines are available forhandshaking,but arenot required.
The important serialcharacteristics arebaud rate,data bits, parity, and stop bits. Fortwo
ports to communicate,these parameters mustmatch.
y Band rate: The band rate (bits per second) determines how much information istransferred over a given time interval. A band rate can usually be selected between100
and76800baud,e.g. a band rate of 9600corresponds to 9600bits per second.
y Data with: the data with can be either8 bits or7 bits depending upon the nature ofthedata beingtransferred.
y Parity: The parity bitis usedto checkthecorrectness ofthetransmitted or specified at all.
-
8/7/2019 main project document final
68/83
68
y Stopbit: The stop bitis used as theterminatorbit anditis possibleto specify either one ortwo stop bits
Serialdata is transmitted and receivedin frames where a frameconsists of:
y 1 startbity 7 or8data bitsy Optional parity bity 1 stop bit
In many application10 bits are usedto specify an RS232 frame, consisting of1
startbit,8data bits,no parity bit and1 stop bit. Forexample,character Ahas the ASCII
bit 01000001 and is transmitted as shown in Fig. 6.1 with 1 start bit,8 data bits, no
parity, and1 stop bit. Thedata is transmittedleast significantbit first.
Figure. 8.2.1 Transmittingcharacter A (bitpattern01000001)
When10bits are usedto specify the framelength,thetimetakento transmit or receive
eachbitcanbe found fromtheband used.
-
8/7/2019 main project document final
69/83
69
9.3 RS232CONNECTORS
As shown in Fig. 6.2, two types of connectors are used from RS232
communications. These arethe25-way D-typeconnector (known as DB25) andthe 9-pin
D-type connector (also known as DB9). Table 6.2 lists the most commonly used signal
names forboth DB9 and DB25 typeconnectors. The used signals are:
Figure. 8.3.1 RS232Connection
-
8/7/2019 main project document final
70/83
70
Description Signal 9pin
Carrierdetect CD 1
Receivedata RD 2
Transmitdata TD 3
Data terminal ready DTR 4
Signalground SG 5
Data set ready DSR 6
Requestto send RTS 7
Clearto send CTS 8
Ringindicator RI 9
-
8/7/2019 main project document final
71/83
71
SG: Signalground. This pinis usedin all RS232cables
RD: Received data. Data is received at this pin. This pin is used in all two-way
communications
TD: Transmit data. Data is sent out from this pin. This pin is used in all two-way
communications
RTS: Requestto send. This signalis asserted whenthedevice requests data to be sent
CTS: Clearto send. This signalis asserted whenthedeviceis ready to acceptdata
DTR: Data set ready. This signalis assertedto indicatethatthedeviceis ready.
DSR: Data set ready. This signalindicates,by thedevice atthe otherendthatitis ready
CD: Carrier detects. This signal indicates that a carrier signal has been detected by a
modemconnectedto theline.
In some RS232 applicationitis sufficientto use only the SG, RD, and TD.
Also, in some application (e.g. when two similar devices are connected together) it is
necessary to twist pins RD and TD so thatthetransmit pin of onedeviceis connectto the
receive pin ofthe otherdevice and vice versa.
RS232SIGNALLEVELS
RS232 is bi-polar and a voltage of +3 to +15 indicates an ON state (or
SPACE), while a voltage of -3 to -15Vindicate an OFF state (or MARK).
In practice,the ON and OFF statecanbe achieved withlower voltages.
-
8/7/2019 main project document final
72/83
72
Figure 8.3.2PinconfigurationofMAX232
Standard TTL logicdevices,includingthe89C52microcontroller, operate with TTL logic
levels betweenthe voltages of0 and +5V.Voltagelevelconverter ICs are usedto convert
between the TTL and RS232 voltage levels. One such popular IC is MAX232,
manufacturedby MAXIM, and operators with +5 supply. This MAX232 is a 16-pin DIL
chip incorporating two receivers and two transmitters (see Fig. 6.3) and the device
requires fourexternalcapacitors for proper operation.
The89C51 microcontroller can output TTL level RS232 signals from its
TXD (or pin p3.1) pin and itcan receive TTL level RS232 signals from its RXD (or pin
P3.0) pin. This microcontroller canconnectto theexternal RS232compatible equipment
via a MAX232type voltageconverter IC.
-
8/7/2019 main project document final
73/83
73
9.4 LIMITATIONS OFRS- 3
R 2 2 has some serious short omi s as an electricalinterface.
Firstly the interface presupposes a common ground between the DTE and DCE. This is a
reasonable assumption where a short cable connects a DTE and DCE in the same room,
butwith longerlines and connections between devices that may be on different electrical
busses, this may not be true. We have seen some spectacular electrical events causes by
"uncommon grounds".
Secondly, a signal on a single line is impossible to screen effectively for
noise. By screening the entire cable one can reduce the influence of outside noise, but
internally generated noise remains a problem. As the baud rate and line length increase,
the effect of capacitance between the cables introduces serious crosstal until a point is
reached where the data itselfis unreadable.
Using low capacitance cable can reduce crosstal . Also, as it is the higher
frequencies that are the problem, control of slew rate in the signal (i.e., making the signal
more rounded, ratherthan square) also decreases the crosstalk. The original specifications
forRS-2 2 had no specification for maximum slew rate.
-
8/7/2019 main project document final
74/83
74
Voltage levels with respect to ground represent the RS 232 signals. There is a
wire for each signal, together with the ground signal (reference for voltage levels). This
interface is useful for point-to-point communication at slow speeds. For example, port
COM1in a PC canbe used for a mouse, port COM2 for a modem,etc. This is anexample
of point-to-point communication: one port, one device. Due to the way the signals are
connected, a common ground is required. This implies limitedcable length - about 30to
60 meters maximum. (Main problems are interference and resistance of the cable.)
Shortly, RS 232 was designed for communication of local devices, and supports one
transmitter and one receiver.
-
8/7/2019 main project document final
75/83
75
APPLICATIONS:
1. AC Voltage input monitoring
2. DC Voltage input Monitoring
3. DC current input monitoring
4. Temperature Monitoring
5. It can be widely used in industries, Household buildings, petrol-Stations, Rail-ways, Schools...etc.
FUTURE SCOPE
1.Pressure sensor can be implemented
2.Water Level Indicators can be added
3.Fire alert system can be Implemente
-
8/7/2019 main project document final
76/83
76
CONCLUSION :
Hence we successfully implemented the working of GSM BASED
SCADA IMPLEMENTATION USING MICROCOTROLLER.
By implementing this project, the authority can remotely access
the machines through GSM via simple SMS. This usage of remote connectivity helps
controlling and acknowledgment ofthemachine status withinin seconds of any fault.
This projectdeals withthe GSM basedmonitoring ofthe systems
comprising ofheavy duty electrical andelectronics equipment. Depending onthe status
andelectrical parameters consideringtheduty timingconsiderations oftheequipment,the
relays arecontrolled from GSM by the user.
REFERENCES:
y http://support.radioshack.com/support_tutorials/gps/gps_tmline.htm
y http://www.cellular.co.za/gsmtechdata.htmy "A Guide To The Global Positioning System (GPS) GPS Timeline".
Radio Shack. Retrieved2010-01-14.
y "GSM Technical Data". Cellular.co.za. Retrieved2010-08-30.y Let us C, YashwanthKanethkar.y Giovino, Bill. "Microcontroller.com - Embedded Systems supersite"y http://en.wikipedia.org/wiki/Embedded_system
-
8/7/2019 main project document final
77/83
77
CODE:
#include#include#include "adc_routines.h"#include "Gsm_Routines.h"#define _ADC_APPLIC_H_#define _ADC_APPLIC_H_
#define AREF (5.0/1024)#define VOLT_OFF 0#define CURR_OFF 0unsigned int Adc_Read(unsigned char ch);void adc_init(void );
int Voltage_Read(char ch );int Temp_Read(char ch );int Current_Read(char ch );
#endif
extern unsigned char lowbyte,highbyte;
unsigned int Adc_Read(unsigned char ch){
ch=ch&0b00000111; //channel selecting
ADMUX = ch;// Start the AD conversion
ADCSRA|=0x40;// Wait for the AD conversion to completewhile ((ADCSRA & 0x10)==0);ADCSRA|=0x10;return ADC; // returning adc result
void adc_init(void ){
//ADCSRA=(1
-
8/7/2019 main project document final
78/83
78
EPROM PROGRAM:
#include #include #include"EEPROM_routines.h"#include #ifndef _EEPROM_ROUTINES_H_#define _EEPROM_ROUTINES_H_void EEPROM_write(unsigned int addr,unsigned char data);
char EEPROM_read(unsigned int addr);
#endif
void EEPROM_write(unsigned int addr,unsigned char data){//printf("write into eepron %d %x \n\r",addr,data);
// WAIT FOR COMPLETION OF PREVIOUS WRITEwhile(EECR&0X02);//SETUP ADDRESS AND DATA REGISTERSEEAR=addr;EEDR=data;// WRITE LOGICAL ONE TO EEMWE
EECR|=0X04;
// START EEPROM WRITTING BY SETTING EEWEEECR|=0X02;
}
char EEPROM_read(unsigned int addr){
// WAIT FOR COMPLETION OF PREVIOUS WRITEwhile(EECR&0X02);//SETUP ADDRESS REGISTERSEEAR=addr;
// WRITE LOGICAL ONE TO EERE
// START EEPROM READING BY SETTING EEREEECR|=0X01;
return EEDR;}
-
8/7/2019 main project document final
79/83
79
UART INTRODUCTION
#include "UART_routines.h"#include #include
void uart0_init(void){UCSRB = 0x00; //disable while setting baud rateUCSRA = 0x00;UCSRC = (1
-
8/7/2019 main project document final
80/83
80
void transmitHex( unsigned char dataType, unsigned long data){unsigned char count, i, temp;char dataString[] = "0x ";
if (dataType == CHAR) count = 2;if (dataType == INT) count = 4;if (dataType == LONG) count = 8;
for(i=count; i>0; i--){
temp = data % 16;if((temp>=0) && (temp
-
8/7/2019 main project document final
81/83
81
if (c == '\n')uart_putchar('\r', stream);
loop_until_bit_is_set(UCSRA, UDRE);UDR = c;return 0;
}
void port_init(void){
PORTB = 0x00;DDRB = 0xFF;PORTC = 0x00;DDRC = 0x00;PORTD = 0x00;DDRD = 0xFF;}
void init_devices(void){
port_init();
uart0_init();adc_init( );//MCUCR = 0x00;//GICR = 0x00;
//TIMSK = 0x00; //timer interrupt sources//all peripherals are now initialized
}
int main(void){init_devices();int VOLT_RMS=0;int temp=0;int volt_flag=1;int volt_flag2=1;int volt_flag3=1;
int temp_flag=1;int temp_flag2=1;
int i;for(i=0;Mobile_No[i]!='\0';i++)
EEPROM_write(i,Mobile_No[i]);
stdout = &mystdout;
-
8/7/2019 main project document final
82/83
82
SendMessgToMobile("WELCOME TO INDUSTRIAL FAULTMONITORING!\n");
PrepareMobile2ReciveMsg();
while(1){
if(RMesgFlag==1){
Read_Msg();ExtractMessg();
}
temp= Temp_Read(0);VOLT_RMS= Voltage_Read(1);VOLT_RMS=VOLT_RMS;if (temp=42){if(temp_flag2)
{temp_flag=1;temp_flag2=0;PORTB=0b00000010;SendMessgToMobile("Fault occur High temperature");
}}
if(VOLT_RMS
-
8/7/2019 main project document final
83/83