Você está na página 1de 56

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

CHAPTER 1 INTRODUCTION

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


1.1 MOTIVATION The motivation to our project INDUSTRIAL AUTOMATION USING I2C PROTOCOL is designed and In this project fans, Lights and implements multiple machines programmer. This project has ! of the "ome or Industries are programmed to #$%#&& at the three important modules; they are sensor, Microcontroller unit and Driver units of the machines. particular time. 'uch applications are motivated us to do the (roject successfully. 1.2 STATEMENT OF PROBLEM $o) a day the automation field gets a )ide gro)th in the )orld )ide. *nder this concept here the project is developed. In this project the "ome or Industries, fans, lights and ! are controlled +y using I,! !#MM*$I! TI#$. &or instance, if )ant to control one oven unit, it needs to set the schedule for the system at )hich time it )ant to s)itch #$%#&&. "ere the microcontroller follo)s the timing of the particular machine and control it. In this place the controller needs to )or- in real time to meet the dead line, other)ise the right ans)er +ecome )rong ans)er after the dead line. 1.3 RELATED WORK To complete our project )e studied a+out (I! 1.f/00 controller and its features. 1e lso )e

also studied ho) to interface loads )ith (I! microcontroller, 2elays and 2elay Drivers. visited sites ho) stuff )or-s.com, ))).Microchip.com, ))).)i-ipedia.com. 1.4 SCOPE OF WORK

The project3 INDUSTRIAL AUTOMATION USING I2C PROTOCOL is used in scheduling the process of industrial machines and +y doing this the automation or automatic control over the loads )ere achieved.

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

CHAPTER-2 BACK GROUND INFORMATION

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


2.1 INTRODUCTION The project report descri+es the design Development and &a+rication of #ne demo unit of the project )or- INDUSTRIAL AUTOMATION USING I2C PROTOCOL3 +y using em+edded systems. $o) a day, )ith the advancement technology, particularly in the field of Microcontrollers, all the activities in our daily living have +ecome a part of Information technology and )e find microcontrollers in each and every application. Thus, trend is directing to)ards Microcontrollers +ased project )or-s. "o)ever, in this project )or- to program the #$%#&& timings different machines the microcontroller interacts )ith I,! !#MM*$I! TI#$. Then the decisions are ta-en )ith the help of microcontroller and associated soft)are. The microcontroller +loc- is playing a major role in this project )or-. The micro controller chip used in this project )or- is (I! 1.&/00 and this is li-e heart of the project )or-. The (I! 1.&/00 microcontroller is a 567pin I!. The entire project )as developed in em+edded systems. ccess !ontrol, etc system is something that maintains

its e8istence and functions as a )hole through the interaction of its parts. 9.g. :ody, Man-ind, system is a part of the )orld that a person or group of persons during some time interval and for some purpose choose to regard as a )hole, consisting of interrelated components, each component characteri;ed +y properties that are selected as +eing relevant to the purpose. 9m+edded 'ystem is a com+ination of hard)are and soft)are used to achieve a single specific tas-. 9m+edded systems are computer systems that monitor, respond to, or control an e8ternal environment. 9nvironment connected to systems through sensors, actuators and other I%# interfaces. 9m+edded system must meet timing < other constraints imposed on it +y environment. n em+edded system is a microcontroller7+ased, soft)are driven, relia+le, real7time control system, autonomous, or human or net)or- interactive, operating on diverse physical varia+les and in diverse environments and sold into a competitive and cost conscious mar-et.

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


n em+edded system is not a computer system that is used primarily for processing, not a soft)are system on (! or *$I=, not a traditional +usiness or scientific application. "igh7end em+edded < lo)er end em+edded systems. "igh7end em+edded system 7 >enerally 4,, .5 :it !ontrollers used )ith #'. 98amples (ersonal Digital ssistant and Mo+ile phones etc. Lo)er end em+edded systems 7 >enerally /, 1. :it !ontrollers used )ith a minimal operating systems and hard)are layout designed for the specific purpose. 98amples 'mall controllers and devices in our everyday life li-e 1ashing Machine, Micro)ave #vens, )here they are em+edded in. Microcontrollers are em+edded inside some other device so that they can control the features or actions of the project. nother name for a microcontroller therefore is 9m+edded !ontroller3. Microcontrollers are dedicated to one tas- and run one specific program. The program is stored in 2#M ?read only memory@ and generally does not change. Microcontrollers are often lo)7price devices. !oming to our project )henever the students standing in front of the door for entering in to the la+ is sensed +y the I2 sensor; this signal sends to controller through signal conditioning circuit. The controller ta-es it as an interrupt signal and gives control signal to the drive unit to open the door. 'ame li-e this in side la+ if any human +eing sensed +y the controller through I2 transceiver it )ill further turn #$ the fans, !, lights using driver unit. 2.2 PRELIMINARIES 2.2.1 INTRODUCTION TO EMBEDDEDSYSTEMS 9m+edded 'ystem is a com+ination of hard)are and soft)are used to achieve a single specific tas-. n em+edded system is a microcontroller7+ased, soft)are driven, relia+le, real7time control system, autonomous, or human or net)or- interactive, operating on diverse physical varia+les and in diverse environments and sold into a competitive and cost conscious mar-et.

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

BLOCK DIAGRAM FOR EMBEDDED SYSTEM

FIGS 2.1 BLOCK DIAGRAM OF EMBEDDED SYSTEM CLASSIFICATION 2eal Time 'ystems. 2T' is one )hich has to respond to events )ithin a specified deadline. right ans)er after the dead line is a )rong ans)er

RTS CLASSIFICATION "ard 2eal Time 'ystems 'oft 2eal Time 'ystem

HARD REAL TIME SYSTEM B"ardB real7time systems have very narro) response time. 98ampleC $uclear po)er system, !ardiac pacema-er.

SOFT REAL TIME SYSTEM

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


B'oftB real7time systems have reduced constrains on BlatenessB +ut still must operate very Duic-ly and repeata+le. 98ampleC 2ail)ay reservation system E ta-es a fe) e8tra seconds the data remains valid. LANGUAGES USED ! !FF Gava Linu8 da ssem+ly

MPLAB FEATURES M(L : Integrated Development 9nvironment ?ID9@ is a free, integrated toolset for the development of em+edded applications employing MicrochipHs (I!I and ds(I!I microcontrollers. M(L : Integrated Development 9nvironment ?ID9@ is a free, integrated toolset for the development of em+edded applications employing MicrochipHs (I!I and ds(I!I microcontrollers. M(L : ID9 runs as a 4,7+it application on M' 1indo)sI, is easy to use and includes a host of free soft)are components for fast application development and super7charged de+ugging. M(L : ID9 also serves as a single, unified graphical user interface for additional Microchip and third party soft)are and hard)are development tools. Moving +et)een tools is a snap, and upgrading from the free soft)are simulator to hard)are de+ug and programming tools is done in a flash +ecause M(L : ID9 has the same user interface for all tools. M(L : ID9Js 'IM, high speed soft)are simulator for (I! and ds(I! ?Digital 'ignal (rocessing (I! Microcontroller@ devices )ith peripheral simulation, comple8 stimulus injection and register logging 2.2.2 INTRODUCTION TO RELAYS

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


relay is usually an electromechanical device that is actuated +y an electrical current. The current flo)ing in one circuit causes the opening or closing of another circuit. 2elays are li-e remote control s)itches and are used in many applications +ecause of their relative simplicity, long life, and proven high relia+ility. 2elays are used in a )ide variety of applications throughout industry, such as in telephone e8changes, digital computers and automation systems. "ighly sophisticated relays are utili;ed to protect electric po)er systems against trou+le and po)er +lac-outs as )ell as to regulate and control the generation and distri+ution of po)er. In the home, relays are used in refrigerators, )ashing machines and dish)ashers, and heating and air7 conditioning controls. lthough relays are generally associated )ith electrical circuitry, there are many other types, such as pneumatic and hydraulic. Input may +e electrical and output directly mechanical, or vice versa. 2.2.3 I2C PROTOCOL: I,! is a popular protocol and is supported +y many devices. This presentation ans)ers some Duestions a+out I,! and e8plains )ith a full e8ample ho) to connect a (I!micro M''( module to an 99(2#M. $e8t, )e )ill e8amine the use of I,! on the (I!micro microcontroller. The details of ho) '(I is implemented on a (I!micro device )ill +e e8amined. 1e 1ill loo- at the M''( module, )hich is availa+le on a )ide selection of popular (I! microcontrollers. The )al-though )ill e8plore code for +oth )riting and reading a serial 99(2#M. The e8ample sends sample data to the 99(2#M, then reads +ac- the data and displays it. The code to do this loo-s rather long, +ut it is not comple8. 1e )ill +rea- the code do)n into smaller and easy to understand sections. &inally, there )ill +e a fe) resources given at the end of the presentation. These resources )ill allo) you to e8plore in more detail the I,! interface.I,! stands for Inter7 Integrated !ircuit !ommunications. I,! is implemented in the (I!micro +y a hard)are module called the Master 'ynchronous 'erial (ort, -no)n as the M''( module . This module is +uilt into many different (I!micro devices. It allo)s I,! serial communication +et)een t)o or more devices at a high speed and communicates )ith other (I!micro devices and many peripheral I!Js on the mar-et today.I,! is a synchronous protocol that allo)s a master device to initiate communication )ith a slave device. Data is e8changed +et)een these devices. 1e )ill loo- at this more in detail as )e progress though this presentation. I,! is also +i7directional. This is implemented +y an c-no)ledge3 system. The c-no)ledge3 system or !K3 system allo)s data to +e sent in one direction to one item on the I,! +us, and then, that item )ill !K3 to indicate the data )as

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


received. 1e )ill loo- at this in detail later, as you can see, this is a po)erful feature of I,!. 'ince a peripheral can ac-no)ledge data, there is little confusion on )hether the data reached the peripheral and )hether it )as understood. I,! is a synchronous protocol that allo)s a master device to initiate communication )ith a slave device. Data is e8changed +et)een these devices. 'ince I,! is synchronous, it has a clocpulse along )ith the data. 2',4, and other asynchronous protocols do not use a cloc- pulse, +ut the data must +e timed very accurately. 'ince I,! has a cloc- signal, the cloc- can vary )ithout disrupting the data. The data rate )ill simply change along )ith the changes in the cloc- rate. This ma-es I,! ideal )hen the micro is +eing cloc-ed imprecisely, such as +y a 2! oscillator. I,! is a Master7'lave protocol. $ormally, the master device controls the cloc- line, '!L. This line dictates the timing of all transfers on the I,! +us. #ther devices can manipulate this line, +ut they can only force the line lo). This action means that item on the +us can not deal )ith more incoming data. :y forcing the line lo), it is impossi+le to cloc- more data in to any device. This is -no)n as !loc- 'tretching3. cloc- is manipulated. s stated earlier, no data )ill +e transferred unless the ll slaves are controlled +y the same cloc-, '!L. I,! is a 'erial Interface

and uses only the follo)ing t)o signals to serially e8change data )ith another deviceC 'D 7 This signal is -no)n as 'erial Data. ny data sent from one device to another goes on this line. '!L 7 This is the 'erial !loc- signal. It is generated +y the master device and controls )hen data is sent and )hen it is read. s mentioned earlier, the signal can +e forced lo) so that no cloc- can occur. This is done +y a device that has +ecome too +usy to accept more data. I,! lines can have only t)o possi+le electrical states. These states are -no)n as float high3 and drive lo)3. I,! )or-s +y having a pull7up resistor on the line and only devices pull the line lo). If no device is pulling on the line, it )ill float high3. This is )hy pull7up resistors are important in I,!. If no pull7up resistor )ere used, the line )ould float to an un-no)n state. If one tried to drive the line high, it might cause contention )ith a device trying to drive the line lo). This contention could damage the either or +oth devices driving the line. To prevent this, the pull7up7drive lo) system controls )hen one device has control of the +us. If another device tried to use the +us )hen it )as +usy, it )ould find the +us to +e driven lo) already and -no) it )as +usy. 9ven if it tried to use the +us accidentally, it )ould only drive it lo) and not damage other devices. LetJs no) discuss the data transfer element. The data +loc- represents the transfer of / +its of information. The data is sent on the 'D line and '!L produces a cloc-. The cloc- can +e aligned )ith the data to is only considered valid )hen '!L is indicate )hether each +it is a 13 or a 63. Data on 'D

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


high. 1hen '!L is not high, the data is permitted to change. This is ho) the timing of each +it )or-s. The (I!micro microcontroller also can transmit data +ytes. To do so, )e load a +uffer )ith the +yte of data to send, tell it to send it and )ait for its completion. Data +ytes are used to transfer all -inds of information. 1hen communicating to another I,! device, the / +its of data may +e a control code, an address or data. Many possi+ilities e8ist and they )ill +e discussed in detail in the manual for the device you are interfacing to. In this presentation )e )ill connect a serial 99(2#M to the +us and loo- at the signals involved. #ther I,! devices )ill reDuire similar signals, +ut may not +e identical. !hec- the device datasheet for the peripheral. Lastly )e )ill discuss the ACK and NACK condition. device can !K3 or ac-no)ledge a transfer of each +yte +y +ringing the 'D line lo) during the Lth cloc- pulse of '!L. The L +its of a transfer loo- li-e thisC / +its are cloc-ed out for the data, then during the Lth +it the item receiving the data gra+s the +us for one +it. If it drives this +it lo), then the device is signaling an !K3. #ther)ise, it it allo)s the 'D line to float high it is transmitting !K, +ut a a $ !K3. 2emem+er that the device must actively drive the +us lo) to send an $ !K could +e a passive response. This is one of the +enefits of I,!. The I,! engine sends data out on the I,! +us using the !loc- ?'!L@ and Data ?'D @ lines for communication. The I,! engine on the (I!micro device contains many registers )hich configure it as )ell as control its operation. The user has full access to these registers and )e )ill loo- at them later in this presentation. The I,! engine on a peripheral is usually fairly transparent to the user. The data sheet on the peripheral )ill tell you ho) to use the peripheral +y telling you )hat commands must +e sent and ho) it )ill respond. ll / +its in this register are used for this I,! mode and are the follo)ingC >!9$ 7 indicates >eneral !all 9$a+le3 !K'T T 7 stands for !Kno)ledge +it 'T Tus3 !KDT 7 refers to the !Kno)ledge +it DaTa3 !K9$ 7 controls the !Kno)lege 9$a+le3 2!9$ 7 is the 2e!eive 9$a+le3 (9$ 7 is the +it for sto( condition 9$a+le3 29'9$ 7 is the control for a 2e'tart condition 9$a+le3 '9$ 7 is the +it for 'tart condition 9$a+le3 If &osc )ere 5 M";, and ''( DD )ere L ?decimal@, then lets calculate the I,! speedC

16

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


!alculating the denominator first, )e add the ''( DD value of L to 1 giving us 16. Then 16 is multiplied +y 5 to yield 56. 5 M"; divided +y 56 is 166 -"; or 166 -+ps.

11

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

CHAPTER-3 IMPORTANT APPROACHES TO THE PRO ECT

1,

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


3.1 MICROCONTROLLER

3.1.1 INTRODUCTION TO MICROCONTROLLER computer7on7a7chip is a variation of a microprocessor )hich com+ines the processor core ?!(*@, some memory, and I%# ?input%output@ lines, all on one chip. The computer7on7a7chip is called the microcomputer )hose proper meaning is a computer using a ?num+er of@ microprocessor?s@ as its !(*s, )hile the concept of the microcomputer is -no)n to +e a microcontroller. microcontroller can +e vie)ed as a set of digital logic circuits integrated on a single silicon chip. This chip is used for only specific applications. Most microcontrollers do not reDuire a su+stantial amount of time to learn ho) to efficiently program them, although many of them, )hich have Duir-s, )hich you )ill have to understand +efore you, attempt to develop your first application. long )ith microcontrollers getting faster, smaller and more po)er efficient they are also getting more and more features. #ften, the first version of microcontroller )ill just have memory and digital I%#, +ut as the device family matures, more and more pat num+ers )ith varying features )ill +e availa+le. In this project )e used (I! 1.f/00 microcontroller. &or most applications, )e )ill +e

a+le to find a device )ithin the family that meets our specifications )ith a minimum of e8ternal devices, or an e8ternal +ut )hich )ill ma-e attaching e8ternal devices easier, +oth in terms of )iring and programming. 3.1.2 MICRO CONTROLLER CORE FEATURES "igh7performance 2I'! !(*. #nly 4A single )ord instructions to learn. ll single cycle instructions e8cept for program +ranches )hich are t)o cycle. #perating speedC D! 7 ,6 M"; cloc- input D! 7 ,66 ns instruction cycle. *p to /K 8 15 )ords of &L '" (rogram Memory, *p to 4./ 8 / +ytes of Data Memory ?2 M@ *p to ,A. 8 / +ytes of 99(2#M data memory. (in out compati+le to the (I!1.!04:%05:%0.%00 Interrupt capa+ility ?up to 15 sources@ 9ight level deep hard)are stac-

14

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


Direct, indirect and relative addressing modes. (o)er7on 2eset ?(#2@. (o)er7up Timer ?(12T@ and #scillator 'tart7up Timer ?#'T@. 1atchdog Timer ?1DT@ )ith its o)n on7chip 2! oscillator for relia+le operation. (rogramma+le code7protection. (o)er saving 'L99( mode. 'electa+le oscillator options. Lo)7po)er, high7speed !M#' &L '"%99(2#M technology. &ully static design. In7!ircuit 'erial (rogrammingM ?I!'(@ M. 'ingle AN In7!ircuit 'erial (rogramming capa+ility. In7!ircuit De+ugging via t)o pins. (rocessor read%)rite access to program memory. 1ide operating voltage rangeC ,.6N to A.AN. "igh 'in-%'ource !urrentC ,A m . !ommercial and Industrial temperature ranges. Lo)7po)er consumption.

3.1.3 ADVANTAGES OF USING A MICROCONTROLLER OVER MICROPROCESSOR A !"#$%&"' ($)) *#" + M$,'-,-&.'-))"' . >ather input from various sensors (rocess this input into a set of actions *se the output mechanisms on the Microcontroller to do something useful 2 M and 2#M are in+uilt in the M!. !heap compared to M(. Multi machine control is possi+le simultaneously.

3.1.4 APPLICATIONS: !ell phones. !omputers.

15

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


2o+ots. Interfacing to t)o pcJs.

3.2 PIC MICROCONTROLLER 1/F011A 3.2.1 INTRODUCTION TO PIC MICROCONTROLLER 1/F011A The (I! 1.f/00 microcontroller is a 567pin I!. The first pin of the controller is M!L2 tan- circuit consists of a 5 M"P

pin and the AN dc supply is given to this pin through 16KO resistor. This supply is also given to 11th pin directly. The 1,th pin of the controller is grounded. crystal oscillator and t)o ,,pf capacitors is connected to 14 th and 15th pins of the (I!. 3.2.2 FEATURES OF PIC MICROCONTROLLER 1/F011A #perating freDuencyC D!7,6Mh;. &lash program memory ?15 +it )ords@C/K Data memory ?in +ytes@C 4./ 99(2#M Data memory ?in +ytes@C,A. InterruptsC 1A I%o portsC , :, !, D, 9 TimersC 4 nalog comparatorsC , InstructionsC 4A

1A

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

3.2.3 PIN DIAGRAM OF PIC 1/ F014A2011A

FIG 3.1 PIN DIAGRAM OF PIC 1/ F014A2011A

1.

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

3.2.4 FUNCTIONAL BLOCK DIAGRAM OF PIC 1/F011A

FIG 3.2 PIN DIAGRAM OF PIC 1/F014A2011A 3.3 POWER SUPPLY UNIT

CIRCUIT DIAGRAM

10

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

FIG 3.3 POWER SUPPLY UNIT POWER SUPPLY UNIT COSISTS OF FOLLOWING UNITS 1@ 'tep do)n transformer ,@ 2ectifier unit 4@ Input filter 5@ 2egulator unit A@ #utput filter 3.3.1 STEP DOWN TRANSFORMER The 'tep do)n Transformer is used to step do)n the main supply voltage from ,46N ! to lo)er value. This ,46 ! voltage cannot +e used directly, thus it is stepped do)n. The Transformer consists of primary and secondary coils. To reduce or step do)n the voltage, the transformer is designed to contain less num+er of turns in its secondary core. The output from the secondary coil is also ! )aveform. Thus the conversion from ! to D! is essential. This conversion is achieved +y using the 2ectifier !ircuit%*nit. S."3 !-(& .'+&#4-'5"'# can step do)n incoming voltage, )hich ena+les you to have the correct voltage input for your electrical needs. &or e8ample, if our eDuipment has +een specified for input voltage of 1, volts, and the main po)er supply is ,46 volts, )e )ill need a step down transformer, )hich decreases the incoming electrical voltage to +e compati+le )ith your 1, volt eDuipment. 3.3.2 RECTIFIER UNIT The 2ectifier circuit is used to convert the ! voltage into its corresponding D! voltage. There are "alf71ave, &ull71ave and +ridge 2ectifiers availa+le for this specific function. The

1/

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


most important and simple device used in 2ectifier circuit is the diode. The simple function of the diode is to conduct )hen for)ard +iased and not to conduct in reverse +ias. B'$!%" '",.$4$"': +ridge rectifier ma-es use of four diodes in a +ridge arrangement to achieve

full7)ave rectification. This is a )idely used configuration, +oth )ith individual diodes )ired as sho)n and )ith single component +ridges )here the diode +ridge is )ired internally.

!$-!" 6'$!%" or 6'$!%" '",.$4$"' is an arrangement of four diodes in a +ridge configuration that provides the same polarity of output voltage for either polarity of input voltage. 1hen used in its most common application, for conversion of alternating current ? !@ input into direct current ?D!@ output, it is -no)n as a +ridge rectifier. rectification from a t)o7)ire center7tapped transformer design. The &or)ard :ias is achieved +y connecting the diodeJs positive )ith positive of the +attery and negative )ith +atteryJs negative. The efficient circuit used is the &ull )ave :ridge rectifier circuit. The output voltage of the rectifier is in rippled form, the ripples from the o+tained D! voltage are removed using other circuits availa+le. The circuit used for removing the ripples is called &ilter circuit. 3.3.3 INPUT FILTER !apacitors are used as filter. The ripples from the D! voltage are removed and pure D! voltage is o+tained. nd also these capacitors are used to reduce the harmonics of the input voltage. The primary action performed +y capacitor is charging and discharging. It charges in positive half cycle of the ! voltage and it )ill discharge in negative half cycle. 'o it allo)s only ! voltage and does not allo) the D! voltage. The 1666Qf capacitor serves as a BreservoirB +ridge rectifier provides full7)ave ! input, resulting in lo)er cost and )eight as compared to a

1L

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


)hich maintains a reasona+le input voltage to the 0/6A throughout the entire cycle of the ac line voltage. The four rectifier diodes -eep recharging the reservoir capacitor on alternate half7cycles of the line voltage, and the capacitor is Duite capa+le of sustaining any reasona+le load in +et)een charging pulses. This filter is fi8ed +efore the regulator. Thus the output is free from ripples. Input side the lo) pass filter has +een used.

L-( 3+## 4$)."':

#ne simple electrical circuit that )ill serve as a lo)7pass filter consists of a resistor in series )ith a load, and a capacitor in parallel )ith the load. The capacitor e8hi+its reactance, and +loc-s lo)7freDuency signals, causing them to go through the load instead. t higher freDuencies the reactance drops, and the capacitor effectively functions as a short circuit. The com+ination of resistance and capacitance gives you the time constant of the filter R S RC ?represented +y the >ree- letter tau@. The +rea- freDuency, also called the turnover freDuency or cutoff freDuency ?in hert;@, is determined +y the time constantC or eDuivalently ?in radians per second@C #ne )ay to understand this circuit is to focus on the time the capacitor ta-es to charge. It ta-es time to charge or discharge the capacitor through that resistorC t lo) freDuencies, there is plenty of time for the capacitor to charge up to

practically the same voltage as the input voltage. t high freDuencies, the capacitor only has time to charge up a small amount

+efore the input s)itches direction. The output goes up and do)n only a small fraction of the amount the input goes up and do)n. t dou+le the freDuency, thereHs only time for it to charge up half the amount.

,6

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


3.3.4 REGULATOR UNIT

FIG 3.4 1078 REGULATOR 2egulator regulates the output voltage to +e al)ays constant. The output voltage is maintained irrespective of the fluctuations in the input ! voltage. s and then the ! voltage changes, the D! voltage also changes. Thus to avoid this 2egulators are used. lso )hen the

internal resistance of the po)er supply is greater than 46 ohms, the output gets affected. Thus this can +e successfully reduced here. Mean)hile it also contains current7limiting circuitry and thermal overload protection, so that the I! )onHt +e damaged in case of e8cessive load current; it )ill reduce its output voltage instead. The regulators are mainly classified for lo) voltage and for high voltage. &urther they can also +e classified asC 1@ (ositive regulator Input pin >round pin #utput pin

It regulates the positive voltage. ,@ $egative regulator >round pin Input pin #utput pin

It regulates the negative voltage.

,1

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


1078 VOLTAGE REGULATOR: The 7805 provides circuit designers )ith an easy )ay to regulate D! voltages to Av. 9ncapsulated in a single chip%pac-age ?I!@, the 7805 is a positive voltage D! regulator that has only 4 terminals. They areC Input voltage, >round, #utput Noltage. 1012 12V INTEGRATED CIRCUIT 3-TERMINAL POSITIVE VOLTAGE REGULATOR:

The 0/1, fi8ed voltage regulator is a monolithic integrated circuit in a T#,,6 type pac-age designed for use in a )ide variety of applications including local, on+oard regulation. This regulator employs internal current limiting, thermal shutdo)n, and safe area compensation.

1ith adeDuate heat7sin-ing it can deliver output currents in e8cess of 1.6 ampere. lthough designed primarily as a fi8ed voltage regulator, this device can +e used )ith e8ternal components to o+tain adjusta+le voltages and currents.

3.3.8 OUTPUT FILTER The &ilter circuit is often fi8ed after the 2egulator circuit. !apacitor is most often used as filter. The principle of the capacitor is to charge and discharge. It charges during the positive half cycle of the ! voltage and discharges during the negative half cycle. The 16Qf and .61Qf capacitors serve to help -eep the po)er supply output voltage constant )hen load conditions change. The electrolytic capacitor smoothJs out any long7term or lo) freDuency variations. "o)ever, at high freDuencies this capacitor is not very efficient. Therefore, the .61Qf is included to +ypass high7freDuency changes, such as digital I! s)itching effects, to ground. 3.4 LCD DISPLAY LiDuid crystal display ?L!D@ has material )hich com+ines the properties of +oth liDuid and crystals. They have a temperature range )ithin )hich the molecules are almost as mo+ile as they )ould +e in a liDuid, +ut are grouped together in an order form similar to a crystal. LCD DISPLAY:

,,

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

More microcontroller devices are using Hsmart L!DH displays to output visual information. The follo)ing discussion covers the connection of a "itachi L!D display to a (I! microcontroller. L!D displays designed around "itachiHs L!D "D550/6 module, are ine8pensive, easy to use, and it is even possi+le to produce a readout using the / 8 /6 pi8els of the display. "itachi L!D displays have a standard '!II set of characters plus Gapanese, >ree- and mathematical sym+ols. &or an /7+it data +us, the display reDuires a FAN supply plus 11 I%# lines. &or a 57+it data +us it only reDuires the supply lines plus seven e8tra lines. 1hen the L!D display is not ena+led, data lines are tri7state )hich means they are in a state of high impedance ?as though they are disconnected@ and this means they do not interfere )ith the operation of the microcontroller )hen the display is not +eing addressed. The L!D also reDuires 4 BcontrolB lines from the microcontroller. 9na+le ?9@ This line allo)s access to the display through 2%1 and 2' lines. 1hen this line is lo), the L!D is disa+led and ignores signals from 2%1 and 2'. 1hen ?9@ line is high, the L!D chec-s the state of the t)o control lines and responds accordingly. 2ead%1rite ?2%1@ This line determines the direction of data +et)een the L!D and microcontroller. 1hen it is lo), data is )ritten to the L!D. 1hen it is high, data is read from the L!D. 2egister select ?2'@ 1ith the help of this line, the L!D interprets the type of data on data lines. 1hen it is lo), an instruction is +eing )ritten to the L!D. 1hen it is high, a character is +eing )ritten to the L!D. L-%$, 9 2%1 6 1 6 #.+.*# ccess ccess 1riting -& to to data ,-&.'-) L!D L!D to )$&"#C disa+led ena+led L!D

,4

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


1 2' 1riting 'et 'et 'et 'et 2' +it data to 2%1 to 9 9 logic 6 the 2eading 6 1 L!D +it or line line 1 is done in to ?instruction to to or several data from L!D Instruction !haracter stepsC lo) character@ high lo)

'et data to data lines ?if it is )riting@

2ead data from data lines ?if it is reading@. 2eading data from the L!D is done in the same )ay, +ut control line 2%1 has to +e high. 1hen )e send a high to the L!D, it )ill reset and )ait for instructions. Typical instructions sent to L!D display after a reset areC turning on a display, turning on a cursor and )riting characters from left to right. 1hen the L!D is initiali;ed, it is ready to continue receiving data or instructions. If it receives a character, it )ill )rite it on the display and move the cursor one space to the right. The !ursor mar-s the ne8t location )here a character )ill +e )ritten. 1hen )e )ant to )rite a string of characters, first )e need to set up the starting address, and then send one character at a time. !haracters that can +e sho)n on the display are stored in data display ?DD@ 2 M. The si;e of DD2 M is /6 +ytes. The L!D display also possesses .5 +ytes of !haracter7>enerator ?!>@ 2 M. This memory is used for characters defined +y the user. Data in !> 2 M is represented as an /7+it character +it7 map. 9ach character ta-es up / +ytes of !> 2 M, so the total num+er of characters, )hich the user can define, is eight. In order to read in the character +it7map to the L!D display, )e must first set the !> 2 M address to starting point ?usually 6@, and then )rite data to the display. The definition of a HspecialH character is given in the picture. :efore )e access DD 2 M after defining a special character, the program must set the DD 2 M address. 1riting and reading data from any L!D memory is done from the last address )hich )as set up using set7address instruction. #nce the address of DD 2 M is set, a ne) )ritten

,5

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


character )ill +e displayed at the appropriate place on the screen. *ntil no) )e discussed the operation of )riting and reading to an L!D as if it )ere an ordinary memory. :ut this is not so. The L!D controller needs 56 to 1,6 microseconds ?u'@ for )riting and reading. #ther operations can ta-e up to A m'. during that time, the microcontroller cannot access the L!D, and so a program needs to -no) )hen the L!D is +usy. 1e can solve this in t)o )ays. #ne )ay is to chec- the :*'T +it found on data line D0. This is not the +est method +ecause L!DHs can get stuc-, and program )ill then stay forever in a loop chec-ing the :*'T +it. The other )ay is to introduce a delay in the program. The delay has to +e long enough for the L!D to finish the operation in process. Instructions for )riting to and reading from an L!D memorysho)n in the previous ta+le. t the +eginning )e mentioned that )e needed 11 I%# lines to communicate )ith an L!D. "o)ever, )e can communicate )ith an L!D through a /7+it data +us. The )iring for connection via a /7+it data +us is sho)n in the diagram +elo). In this e8ample )e use an L!D display )ith ,81. characters, la+eled LM1.=,1, +y Gapanese ma-er '" 2(.

INTERFACING PIC MICROCONTROLLER TO LCDC

,A

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21

10k

4"#$ 22pf 22pf

1N 4007 1N 4007

V IN GND

VOUT

P% %6f877&

230v

1N 4007 1N 4007

1000uf

LM 7805 3

P O T +5v
1

1 0 3

5v

step down transformer

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

7812
3

+12v OUTPUT

+5v

o o o o o

display &ontC A 8 / dots :uilt7in !ontrollerC"D550/6 or !omp Input DataC5 :its or /7:its Interface (o)er 'upplyC F5N 'ingle (o)er Duty !ycleC 1%1. Duty

3.8 RELAY DRIVER

,.

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


The *L$,661 , *L$,66, , *L$,664 and *L$,665 are high Noltage, high current Darlington arrays each containing seven open collector Darlington pairs )ith common emitters. 9ach channel rated at A66m and can )ithstand pea- currents of .66m .'uppressiondiodesare included for inductive load driving and the inputs are pinned opposite the outputs to simplify +oard layout. These versatile devices are useful for driving a )ide range of loads including solenoids, relays D! motors; L9D displays filament lamps, thermal print heads and high po)er +uffers. The *L$,661 %,66, %,664 and ,665 are supplied in 1.pin plastic DI( pac-ages )ith a copper lead frame to reduce thermal resistance. They are availa+le also in small outline pac-age ?'#71.@ as *L$,661D%,66,D%,664D%,665D. 3.8.1 FEATURES OF DRIVER '9N9$D 2LI$>T#$' (92 ( !K >9. #*T(*T !*229$T A66m (92 D2IN92 ?.66m (9 K@ #*T(*T N#LT >9 A6N. I$T9>2 T9D '*((29''I#$ DI#D9' &#2 I$D*!TIN9 L# D'. #*T(*T' ! $ :9 ( 2 LL9L9D &#2 "I>"92!*229$T. TTL%!M#'%(M#'%DTL!#M( TI:L9 I$(*T'. I$(*T' (I$$9D #((#'IT9 #*T(*T' T# 'IM(LI&TL T#*T

3.8.2 PIN CONNECTION

,0

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

FIG 3.8 PIN CONNECTIONS OF A RELAY 3.8.3 RELAYS relay is usually an electromechanical device that is actuated +y an electrical current. The current flo)ing in one circuit causes the opening or closing of another circuit. 2elays are li-e remote control s)itches and are used in many applications +ecause of their relative simplicity, long life, and proven high relia+ility. 2elays are used in a )ide variety of applications throughout industry, such as in telephone e8changes, digital computers and automation systems. "ighly sophisticated relays are utili;ed to protect electric po)er systems against trou+le and po)er +lac-outs as )ell as to regulate and control the generation and distri+ution of po)er. In the home, relays are used in refrigerators, )ashing machines and dish)ashers, and heating and air7 conditioning controls. lthough relays are generally associated )ith electrical circuitry, there are many other types, such as pneumatic and hydraulic. Input may +e electrical and output directly mechanical, or vice versa. ll relays contain a sensing unit, the electric coil, )hich is po)ered +y ! or D!

current. 1hen the applied current or voltage e8ceeds a threshold value, the coil activates the armature, )hich operates either to close the open contacts or to open the closed contacts. 1hen a po)er is supplied to the coil, it generates a magnetic force that actuates the s)itch mechanism. The magnetic force is, in effect, relaying the action from one circuit to another. The first circuit is called the control circuit; the second is called the load circuit.

,/

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


O&2O44 C-&.'-): 98ampleC ir conditioning control, used to limit and control a high

po)er3 load, such as a compressor Limit !ontrolC 98ampleC Motor 'peed !ontrol, used to disconnect a motor if it runs slo)er or faster than the desired speed L-%$, O3"'+.$-&C 98ampleC Test 9Duipment, used to connect the instrument to a num+er of testing points on the device under test. 3.8.4 ELECTROMECHANICAL RELAYS In our project )e )ill +e using an electromechanical relay, )hich )ill +e a A pin relay and the )or-ing of the relay )ill +e li-e as. The general7purpose relay is rated +y the amount of current its s)itch contacts can handle. Most versions of the general7purpose relay have one to eight poles and can +e single or dou+le thro). These are found in computers, copy machines, and other consumer electronic eDuipment and appliances.

FIG 3./ MECHANICAL RELAY 3.8.4.1 INTERNAL OPERATION OF MECHANICAL RELAYS S.+&!+'!C 'ingle 'ide 'ta+le )ith any of the follo)ing three different methods for closing contactsC 1. F)"9*'" T:3"C The armature actuates the contact spring directly, and the contact is driven into a stationary contact, closing the circuit. ,. L$4.--44 T:3"C The movea+le piece is energi;ed +y the armature, and the contact closes

,L

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


4. P)*&%"' T:3"C The lever action caused +y the energi;ation of the armature produces a long stro-e action. 2eedC simple contact point. 5. P-)+'$;"!C !an +e either a single side sta+le or dual7)inding. used to either attract or repel the armature that controls the contact. remains in the current state after the coil is de7energi;ed. 3.8.8 LOAD TYPES Load parameters include the ma8imum permissi+le voltage and the ma8imum permissi+le current. The relay can handle +oth volts and amps. :oth the si;e of the load and its type are important. There are four types of loadsC 1@ 2esistive, ,@ Inductive, 4@ ! or D!, and 5@ "igh or Lo) Inrush 3.8.8.1 RESISTIVE LOAD It is the one that primarily offers resistance to the flo) of current. 98amples of resistive loads include electric heaters, ranges and ovens, toasters and irons. 3.8.8.2 INDUCTIVE LOADS It include po)er drills, electric mi8ers, fans, se)ing machines and vacuum cleaners. 2elays that are going to +e su+jected to high7inrush inductive loads, such as an ! motor, )ill often +e rated in horsepo)er, rather than in volts and amps. This rating reflects the amount of po)er the relay contacts can handle at the moment the device is turned on ?or s)itched@. 3.8.8.3 HIGH OR LOW IN RUSH 'ome load types dra) significantly higher amounts of current ?amperage@ )hen first turned then they do )hen the circuit later sta+ili;es ?loads may also pulsate as the circuit continues operating, thus increasing and decreasing the current@. turned on ?some manufacturers refer to this as lamp load@. n e8ample of a high inrush load is a light +ul+, )hich may dra) 16 or more times its normal operating current )hen first permanent magnet is 'ingle 'ide 'ta+le !ontact that involves lo) contact pressure and a

definite polarity ?F or 7@ is

reDuired +y the relay coil. The latching option ma-es a polari;ed relay dual7)inding, meaning it

3.8.8.4 AC OR DC

46

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


This affects the contacts circuit of the relay ?due to 9M&@ and the timing seDuencing. It may result in performance issues in the s)itching capacity of the relay for different load types ?I.e. resistive, inductive, etc.@. 3./ TEMPERATURE SENSOR: F"+.*'"#

U U U U U U U U U U U

!ali+rated directly in V !elsius ?!entigrade@ Linear F 16.6 mN%V! scale factor 6.AV! accuracy guaranteea+le ?at F,AV!@ 2ated for full 7AAV to F1A6V! range 'uita+le for remote applications Lo) cost due to )afer7level trimming #perates from 5 to 46 volts Less than .6 Q current drain Lo) self7heating, 6.6/V! in still air $onlinearity only WXV! typical Lo) impedance output, 6.1 #hm for 1 m load

T:3$,+) A33)$,+.$-& G"&"'+) D"#,'$3.$-&

The LM4A series are precision integrated7circuit temperature sensors, )hose output voltage is linearly proportional to the !elsius ?!entigrade@ temperature. More...

( 2 M9T2I! T :L9C Temperature ccuracy ?F%7@ 'upply Min Yuiescent !urrentZ Temperature Min 1, 6.A deg ! 5 Nolt A. u 756, 6, 7AA deg !

41

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


Temperature Ma8 'ensor >ain 'upply Ma8 'ingle 'upply #utput Impedance Yuiescent !urrent utomotive 'election >uide 166, 116, 1A6 deg ! 16 mN%Deg ! 46 Nolt $o 6.5 #hm 6.6A. m Tes

G"&"'+) D"#,'$3.$-& The LM4A series are precision integrated7circuit temperature sensors, )hose output voltage is linearly proportional to the !elsius ?!entigrade@ temperature. The LM4A thus has an advantage over linear temperature sensors cali+rated in V Kelvin, as the user is not reDuired to su+tract a large constant voltage from its output to o+tain convenient !entigrade scaling. The LM4A does not reDuire any e8ternal cali+ration or trimming to provide typical accuracies of WXV! at room temperature and W[V! over a full 7AA to F1A6V! temperature range. Lo) cost is assured +y trimming and cali+ration at the )afer level. The LM4AHs lo) output impedance, linear output, and precise inherent cali+ration ma-e interfacing to readout or control circuitry especially easy. It can +e used )ith single po)er supplies, or )ith plus and minus supplies. s it dra)s only .6 Q from its supply, it has very lo) self7heating, less than 6.1V! in still air. The LM4A is rated to operate over a 7AAV to F1A6V! temperature range, )hile the LM4A! is rated for a 756V to F116V! range ?7 16V )ith improved accuracy@. The LM4A series is availa+le pac-aged in hermetic T#75. transistor pac-ages, )hile the LM4A!, LM4A! , and LM4AD are also availa+le in the plastic T#7L, transistor pac-age. The LM4AD is also availa+le in an /7lead surface mount small outline pac-age and a plastic T#7,,6 pac-age.

4,

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

CHAPTER-4 DESCRIBING ABOUT PRO ECT IMPLEMENTATION

44

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


4.1 BLOCK DIAGRAME OF INDUSTRIAL AUTOMATION USING I2C PROTOCOL

Power supply Alarm unit Unit

LCD display

Master PIC micro-controller

Keypad

I2C Protocol

I2C Protocol

Slave PIC micro-controller 1

Slave PIC micro-controller 2

Temperature sensor

Driver Unit

Human detection sensor

Driver Unit

Load or Equipment

Fan

Light

45

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


4.2 DESCRIPTION OF THE BLOCK DIAGRAM The entire project is po)ered )ith the po)er supply unit, the project it needs t)o different dc po)er supply one is F1,v it is maintained through LM0/1, positive 1,v regulator and one more dc FAv supply is maintained through LM0/6A positive Av regulator. The major parts of the project are I2 sensors , Driver circuits and Microcontrollers of (I!1.&/00 . "ere )e are using three (I! controllers, one is master and another t)o is slave. The t)o sensors are placed in t)o different places, and they are connected to the different controllers. 1hen any ma8imum temperature is finding +y the temperature sensor, it send the alert to the master controller. Then the controller )ill +lo) the +u;;er. 1hen any particle or human is finding +y the human detection sensor, second slave controller )ill send the alert to the master controller. In this project )e are going to design the hard)are circuit for industrial monitor )ith alarm in many rooms. "ere )e are using many sensors and only one controller )ith display unit. Display unit is used to display )hich one is found the human.

4A

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


4.3 CIRCUIT DIAGRAM
%0 0( (%3(0 %0 0( (%3(0

+5v

+5v

+5v

+5v

+5v %0 T0&*'"%TT(0

+5v %0 T0&*'"%TT(0

,4

,3

,2

,1 +5v +5v

.U//(0 +5v 10,

4"#$

22pf

22pf

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21

UL* 2003

L"135 +5v
+5v

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21

P% 16+877&

P% 16+877&

P% 16+877&

+5v

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21

1 2 3 4 5 6 7 8

16 15 14 13 12 11 10 9 +12v

+&* * *O

L%2#T * *O

1*4007 1*4007 1*4007 'T(P!O)* 1*4007


1 1

U3 V IN GND VOUT

+5v +5v

1000-f +

LM 7805 3

TR AN S FO R M E R

U4 V IN GND VOUT

L" 7812
3

+12v OUTPUT

1 2 3 4 5 6 7 8

16 15 14 13 12 11 10 9 +12v

LO&! * *O

1 0 3 POT +5v 1 2 3 4 5 6 7

8 9 10 11 12 13 14 15 16

UL* 2003

+5v

FIG 4.3 CIRCUIT DIAGRAM OF INDUSTRIAL AUTOMATION USING I2C PROTOCOL

4.

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


4.4 POWER SUPPLY DIAGRAM

FIG 4.3 POWER SUPPLY DIAGRAM 4.8 CIRCUIT DESCRIPTION 4.8.1 POWER SUPPLY (o)er supply unit consists of 'tep do)n transformer, 2ectifier, Input filter, 2egulator unit, #utput filter. The 'tep do)n Transformer is used to step do)n the main supply voltage from ,46N ! to lo)er value. This ,46 ! voltage cannot +e used directly, thus it is stepped do)n. The Transformer consists of primary and secondary coils. To reduce or step do)n the voltage, the transformer is designed to contain less num+er of turns in its secondary core. The output from the secondary coil is also ! )aveform. Thus the conversion from ! to D! is essential. This conversion is achieved +y using the 2ectifier !ircuit%*nit. The 2ectifier circuit is used to convert the ! voltage into its corresponding D!

voltage. There are "alf71ave, &ull71ave and +ridge 2ectifiers availa+le for this specific function. The most important and simple device used in 2ectifier circuit is the diode. The simple function of the diode is to conduct )hen for)ard +iased and not to conduct in reverse +ias. The &or)ard :ias is achieved +y connecting the diodeJs positive )ith positive of the +attery and negative )ith +atteryJs negative. The efficient circuit used is the &ull )ave :ridge rectifier circuit. The output voltage of the rectifier is in rippled form, the ripples from the o+tained D! voltage are removed using other circuits availa+le. The circuit used for removing the ripples is called &ilter circuit.

40

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


!apacitors are used as filter. The ripples from the D! voltage are removed and pure D! voltage is o+tained. positive half cycle of the nd also these capacitors are used to reduce the harmonics of the input ! voltage and it )ill discharge in negative half cycle. "ere )e used voltage. The primary action performed +y capacitor is charging and discharging. It charges in 1666Q& capacitor. 'o it allo)s only ! voltage and does not allo) the D! voltage. This filter is fi8ed +efore the regulator. Thus the output is free from ripples. 2egulator regulates the output voltage to +e al)ays constant. The output voltage is maintained irrespective of the fluctuations in the input ! voltage. s and then the ! voltage changes, the D! voltage also changes. Thus to avoid this 2egulators are used. lso )hen the

internal resistance of the po)er supply is greater than 46 ohms, the output gets affected. Thus this can +e successfully reduced here. The regulators are mainly classified for lo) voltage and for high voltage. "ere )e used 0/6A positive regulator. It reduces the .N dc voltage to AN dc Noltage. The &ilter circuit is often fi8ed after the 2egulator circuit. !apacitor is most often used as filter. The principle of the capacitor is to charge and discharge. It charges during the positive half cycle of the ! voltage and discharges during the negative half cycle. 'o it allo)s only ! voltage and does not allo) the D! voltage. This filter is fi8ed after the 2egulator circuit to filter any of the possi+ly found ripples in the output received finally. "ere )e used 6.1Q& capacitor. The output at this stage is AN and is given to the Microcontroller In the po)er supply circuit t)o regulators are used. 0/6A regulator is used to produce positive AN dc and 0/1, regulator produces positive 1,N dc voltage. 2elays and *L$ ,664 drivers operates at 1,N dc and microcontroller and sensors are operated at AN dc voltage. The output of the 0/6A regulator is connected to (I! 1.f/00 microcontroller, sensors and the output of the 0/1, regulator is connected to driver I!s and relays. 4.8.2 CONTROLLER CIRCUIT The (I! 1.f/00 microcontroller is a 567pin I!. The first pin of the controller is M!L2 pin and the AN dc supply is given to this pin through 16KO resistor. This supply is also given to 11th pin directly. The 1,th pin of the controller is grounded. tan- circuit consists of a 5 M"P crystal oscillator and t)o ,,pf capacitors are connected to 14 th and 15th pins of the (I!. The circuit consist one driver I! *L$ ,664 is acts as voltage driver. It is a 1.7 pin I!. This is of $($ transistor type. nd this I! is a com+ination of 0 transistors. t a time )e can

4/

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


connect seven loads to each I!. In this project )e used , relays and they connected to driver. These relays act as s)itches. The / th pin of driver I!s is grounded and the L th pin is connected to 1,N dc voltage )hich is from 0/1, regulator. &irst to t)o pins of driver I! are connected to 2:6, 2:1 pins of the controller respectively. 'imilarly 1Ath, 1.th pins are connected to 2elays 21 and 2,, respectively. The relays used in this project are of 'ingle pole 'ingle thro) type. The 2elay Driver !ircuit is the main circuit that ena+les the actual control over the applications. s per the project designed, the 2elay Driver circuit signals the appliances to +e used if the user is valid or authenticated. "ere )e are using transistor as the relay driver circuit. 2elay is connected )ith the transistor, )hich generally contains five pins totally. The first t)o pins are connected )ith the transistor and contain the magnetic coil )ound +et)een them. The rest of the pins are common point, $ormally #pen ?$#@ point and $ormally !lose ?$!@ point. Initially common point is in contact )ith $ormally !lose point. The magnetic coil also contains an arrangement very similar to that of a hoo-. 1hen supply is given at the supply point, the magnetic coil of the relay gets energi;ed or activated. Due to this a magnetic field is created that lifts the hoo- up)ards. Thus the arrangement that )as initially closed gets opened no). The status of the relay point gets changed ?i.e. common point gets connected )ith normally open point@. The status of the relay is depends upon the conduction of the transistor. The transistor configuration used here is that of common emitter mode. The conduction of the transistor depends on the +ase voltage of the transistor. The supply to the transistor is given from the regulator of the po)er supply +oard. $ormally transistor acts as a s)itch. The s)itch then gets activated +y the Microcontroller. The output of the relay driver circuit is given to any of the port pins. The Microcontroller is programmed to respond corresponding to the relay signal o+tained. Thus the transistor acts as a s)itch to control the relay and indirectly controls the appliances. The -eys )ere connected in 2:0, 2:., 2:A, and 2:5 pins of the microcontroller. The L!D display unit it contains 1. pins the 1th < ,th 7 t)o pins supply pins 1A th < 1.th pin +ac-light pins, 4rd pin +rightness adjustment pin, 5th pin 2'7reset pin, Ath pin 21 pin ?read%)rite pin@ . th pin 9$7ena+le pin these things are interfaced )ith microcontroller 2!1, 2!,, 2!4 respectively and 0 th to 15th pin are connected in (2#TD of the microcontroller.

4L

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

CHAPTER-8 SOFTWARE RE<UIREMENTS

56

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

SOFTWARE RE<UIREMENTS 8.1 SOFTWARE TOOLS M(L : (rotel (ropic "I7Tech (I! ! !ompiler

8.2 MPLAB INTEGRATION M(L : Integrated Development 9nvironment ?ID9@ is a free, integrated toolset for the development of em+edded applications employing MicrochipHs (I! micro and ds(I! microcontrollers. M(L : ID9 runs as a 4,7+it application on M' 1indo)s, is easy to use and includes a host of free soft)are components for fast application development and super7charged de+ugging. M(L : ID9 also serves as a single, unified graphical user interface for additional Microchip and third party soft)are and hard)are development tools. Moving +et)een tools is a snap, and upgrading from the free simulator to M(L : I!D , or the M(L : I!9 emulator is done in a flash +ecause M(L : ID9 has the same user interface for all tools. !hoose M(L : !1/, the highly optimi;ed compiler for the (I!1/ series microcontrollers, or try the ne)est MicrochipHs language tools compiler, M(L : !46, targeted at the high performance (I!,5 and ds(I! digital signal controllers. #r, use one of the many products from third party language tools vendors. They integrate into M(L : ID9 to function transparently from the M(L : project manager, editor and compiler. 8.3INTRODUCTION TO EMBEDDED =C>: E9: H$.", ? ,@ K"$) ? , "I7T9!" 'oft)are ma-es industrial7strength soft)are development tools and ! compilers that help soft)are developers )rite compact, efficient em+edded processor code. &or over t)o decades "I7T9!" 'oft)are has delivered the industryHs most relia+le em+edded soft)are development tools and compilers for )riting efficient and compact code to run on the most popular em+edded processors. *sed +y tens of thousands of customers including

51

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


>eneral Motors, 1hirlpool, Yualcomm, Gohn Deere and many others, "I7T9!"Hs relia+le development tools and ! compilers, com+ined )ith )orld7class support have helped serious em+edded soft)are programmers to create hundreds of +rea-through ne) solutions. 1hichever em+edded processor family you are targeting )ith your soft)are, )hether it is the 2M, (I!! or /6A1 series, "I7T9!" tools and ! compilers can help you )rite +etter code and +ring it to mar-et faster. "I7T9!" (I!! is a high7performance ! compiler for the Microchip (I! micro 16%1,%15%1.%10 series of microcontrollers. "I7T9!" (I!! is an industrial7strength implements full I'#% $'I !, )ith the e8ception of recursion. $'I ! compiler 7 not a su+set implementation li-e some other (I! compilers. The (I!! compiler ll data types are supported including ,5 and 4, +it I999 standard floating point. "I7T9!" (I!! ma-es full use of specific (I! features and using an intelligent optimi;er, can generate high7Duality code easily rivaling hand7)ritten assem+ler. utomatic handling of page and +an- selection frees the programmer from the trivial details of assem+ler code. 8.4 EMBEDDED AC COMPILER $'I ! 7 full featured and porta+le 2elia+le 7 mature, field7proven technology Multiple ! optimi;ation levels n optimi;ing assem+ler &ull lin-er, )ith overlaying of local varia+les to minimi;e 2 M usage !omprehensive ! li+rary )ith all source code provided Includes support for ,57+it and 4,7+it I999 floating point and 4,7+it long data types Mi8ed ! and assem+ler programming *nlimited num+er of source files Listings sho)ing generated assem+ler !ompati+le 7 integrates into the M(L : development tools 2uns on multiple platformsC 1indo)s, Linu8, *$I=, Mac #' =, 'olaris ID9, M(L : I!D and most 4rd7party

5,

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


8.8 EMBEDDED DEVELOPMENT ENVIRONMENT This environment allo)s you to manage all of your (I! projects. Tou can compile, assem+le and lin- your em+edded application )ith a single step. #ptionally, the compiler may +e run directly from the command line, allo)ing you to compile, assem+le and lin- using one command. This ena+les the compiler to +e integrated into third party development environments, such as MicrochipHs M(L : ID9. 8./ EMBEDDED SYSTEM TOOLS 8./.1 ASSEMBLER n assem+ler is a computer program for translating assem+ly language \ essentially, a mnemonic representation of machine language \ into o+ject code. cross assem+ler ?see cross compiler@ produces code for one type of processor, +ut runs on another. The computational step )here an assem+ler is run is -no)n as assem+ly time. Translating assem+ly instruction mnemonics into opcodes, assem+lers provide the a+ility to use sym+olic names for memory locations ?saving tedious calculations and manually updating addresses )hen a program is slightly modified@, and macro facilities for performing te8tual su+stitution \ typically used to encode common short seDuences of instructions to run inline instead of in a su+routine. ssem+lers are far simpler to )rite than compilers for high7level languages. 8./.2 ASSEMBLY LANGUAGE HAS SEVERAL BENEFITS S3""!C ssem+ly language programs are generally the fastest programs around. S3+,"C ssem+ly language programs are often the smallest. C+3+6$)$.:: Tou can do things in assem+ly )hich are difficult or impossi+le in "igh level languages. K&-()"!%"C Tour -no)ledge of assem+ly language )ill help you )rite +etter programs, even )hen using "igh level languages. n e8ample of an assem+ler )e use in our project is 2 D A1. 8./.3 SIMULATOR 'imulator is a machine that simulates an environment for the purpose of training or research. 1e use a *M(' simulator for this purpose in our project.

54

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


8./.4COMPILER compiler is a program that reads a program in one language, the source language and translates into an eDuivalent program in another language, the target language. The translation process should also report the presence of errors in the source program. 'ource (rogram ] !ompiler ] Target (rogram

9rror Messages There are t)o parts of compilation. The analysis part +rea-s up the source program into constant piece and creates an intermediate representation of the source program. The synthesis part constructs the desired target program from the intermediate representation. 8./.8 COUSINS OF THE COMPILER ARE 1. (reprocessor. ,. ssem+ler.

4. Loader and Lin-7editor. naive approach to that front end might run the phases serially. 1. Le8ical analy;er ta-es the source program as an input and produces a long string of to-ens. ,. 'ynta8 naly;er ta-es an out of le8ical analy;er and produces a large tree. 'emantic analy;er ta-es the output of synta8 analy;er and produces another tree. 'imilarly, intermediate code generator ta-es a tree as an input produced +y semantic analy;er and produces intermediate code 8././ PHASES OF COMPILER The compiler has a num+er of phases plus sym+ol ta+le manager and an error handler.

55

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

Input (rogram ^ Le8ical

'ource

naly;er ^ 'ynta8 naly;er ^ 'ym+ol Ta+le Manager ^ Intermediate !ode >enerator ^ !ode #ptimi;er ^ !ode >enerator ^ #ut (rogram FABRICATION DETAILS The fa+rication of one demonstration unit is carried out in the follo)ing seDuence. &inali;ing the total circuit diagram, listing out the components and sources of procurement. (rocuring the components, testing the components and screening the components. Target 'emantic naly;er 9rror "andler

5A

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


Ma-ing layout, repairing the interconnection diagram as per the circuit diagram. ssem+ling the components as per the component layout and circuit diagram and soldering components.. 8.1 COMPONENTS USED 1. 'tep Do)n Transformer ,. Diodes 4. !apacitors 5. 2egulators A. Light 9mitting Diodes .. Driver I!s 0. (I! microcontroller /. 2elays L. !rystal #scillator 16. 2esistors :? ,46%1,N@ E 1 $o. :?1$5660@ E 5 $o :1666Q& E 1 $o, ,,p&7 , $os :0/1, E 1 $o, 0/6A E 1 $o :L9D_s E ,$os :*L$ ,664 E 1$o :1.f/00 E 1 $o :'ingle (ole 'ingle Thro) Type ,$os :5M"; E 1$os :446 O E 1$os,16 KO7 A $o :1 KO E ,$os

5.

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

CHAPTER-/ RESULTS

RESULT

50

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

5/

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

CHAPTER-1 CONCLUSION

1.1 APPLICATIONS 1. In comple8 +uildings ,. In te8tiles industries 4. 9nergy management systems

5L

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


5. In spinning mills 1.2 CONCLUSION The 'ystem operated successfully. 1.3 FUTURE SCOPE OF THE PRO ECT This project can +e enhanced in future to home and office automation and also to -no) ho) the eDuipments or mechinaries in the industry are )or-ing.

A6

INDUSTRIAL AUTOMATION USING I2C PROTOCOL

CHAPTER-0 BIBLIOGRAPHY

BIBLIOGRAPHY BOOKS !ustomi;ing and programming ur pic microcontroller7 M:B" P'"!,B!omplete guide to pic microcontroller 7"-6--B

A1

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


WEB SITIES: Microchips.com httpC%%))).mi-roele-troni-a.co.yu%english%product%+oo-s%(I!+oo-%6Z*vod.htm ho) stuff )or-s.com ! programming for em+edded systems - K$'B C*'")) Teach yourself electronics and electricity7 S.+& G$6)$#,9m+edded Microcomputer system- -&+.D+& (.V+)E+&-F2777G 9m+edded (I! microcontroller7 -D& P"+.5+&

APPENDIH-A CODING: `includeapic.hb

A,

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


void delay?@; unsigned int iS6; signed int countS6; `define ir1 2:0 `define ir, 2:. `define dcZfor 2D0 `define dcZrev 2D. `define light 2DA `define fan 2D5 void main?@ c T2I'!S686.; T2I'DS6866; T2I' S6866; T2I':S68&&; T2I'9S6866; (#2T!S6=66; (#2TDS6=66; (#2T S6=66; (#2T:S6=66; (#2T9S6=66; )hile?1@

A4

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


c if?ir1SS1@ c dcZforS1; countFF; delay?@; delay?@; delay?@; dcZforS6; delay?@; dcZrevS1; delay?@; delay?@; delay?@; dcZrevS6; d if?countbS1@ c if?ir,SS1@ c dcZforS1; count77;

A5

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


if?count aS6@ countS6; delay?@; delay?@; delay?@; dcZforS6; delay?@; dcZrevS1; delay?@; delay?@; delay?@; dcZrevS6; d d if?countSS6@ c fanS6; lightS6; d if?countbS1@ c fanS1;

AA

INDUSTRIAL AUTOMATION USING I2C PROTOCOL


lightS1; d d d void delay?@ c for?iS6;iaSA6666;iFF@; d INSTALLING CODING INTO PIC MICROCONTROLLER 1. 1rite the program in M(L : ID9. ,. 'ave the file as e.c. and compile it. 4. fter successful compilation of the coding close the M(L : ID9. 5. &i8 the !ontroller I! into (I! &lash -it. A. Then clic- on Micro controller Micro 'ystems (I! &lash 'oft)are Icon on the des-top. .. It displays on dialog +o8. Then select open and select the program )hich )e already saved as e.c. 0. Then it as-s the !onfirmation that The I! is empty, select o-. /. Then it as-s &uses 'ettings, select T9' L. Then it displays &uses 'ettings Dialog :o8. 16. In that put 1DT 77 b Disa+led, 12T77 b 9na+led, #scillator77 b =T then clic- on #K. 11. Then it displays the (rogram successfully installed into (I!. 1,. Then 2emove the I! from the (I! &lash and it is ready for used into the project or circuit operation.

A.

Você também pode gostar