Report For Industrial Monitoring-1
Report For Industrial Monitoring-1
Report For Industrial Monitoring-1
CHAPTER 1
INTRODUCTION
A smart city enables the effective utilization of resources and better quality of
services to the citizens. To provide services such as air quality management,
weather monitoring and automation of homes and buildings in a smart city, the
basic parameters are temperature, humidity and CO2. This Project presents a
customised design of an Internet of Things (IoT) enabled environment
monitoring system to monitor temperature, humidity and CO2. In developed
system, data is sent from the transmitter node to the receiver node. The data
received at the receiver node is monitored and recorded in an excel sheet in a
personal computer (PC) through Serial Port Communication.
The IoT has a large role to play in future smart cities.The IoT can be used in
practically all scenarios for public services by governments. Sensor-enabled
devices can help monitor the environmental impact of cities, collect details
about sewers, air quality, and garbage. Such devices can also help monitor
woods, rivers, lakes, and oceans. Many environmental trends are so complex,
that they are difficult to conceptualize. The Internet of Things (IoT) is a recent
communication paradigm that envisions a near future, in which the objects of
everyday life will be equipped with microcontrollers, transceivers for digital
communication, and suitable protocol stacks that will make them able to
communicate with one another and with the users, becoming an integral part of
the Internet.
An embedded system is a special purpose computer system, which is
completely encapsulated by the device it controls. An embedded system has
specific requirement and performs pre-define tasks, unlike a general-purpose
personal computer.
Sophisticated Functionality
Real-Time Operation
Low manufacturing Cost
Low Power Consumption
Real-Time Operation
CHAPTER 2
EXISTING SYSTEM:
PROPOSED SYSTEM:
PIC16F877A
CARBON MONOXIDE (GAS)
SENSOR MODULE
A RAIN DETECTOR
I
D /
HUMIDITY SENSOR C O
MODULE P
O
R LANDSLIDE
T DETECTION SENSOR
TEMPERATURE SENSOR
S (TILT SENSOR
MODULE
MODULE)
UART
IoT TRANSCEIVER
1. Microcontroller
2. Iot module (ESP8266mcu)
3. Tilt Sensor Module
4. Gas Sensor Module
5. Humidity Sensor Module
6. Rain Detector
7. Temperature Sensor Module
8. Usb To Rs232 Cable
Software Requirements:
1. Pic Compiler
2. Embedded C
Advantages:
Fig.No.2.2
CHAPTER 3
PIC MICROCONTROLLER
The Microcontroller that has been used for this project is from PIC
series. PIC microcontroller is the first RISC based microcontroller fabricated in
CMOS (complementary metal oxide semiconductor) that uses separate bus for
instruction and data allowing simultaneous access of program and data memory.
The complete architecture of PIC 16F877 is shown in the fig 2.1. Table 2.1
gives details about the specifications of PIC 16F877. Fig 2.2 shows the
complete pin diagram of the IC PIC 16F877.
Fig.3.1 Architecture of PIC16F877
NOTE:
1. This buffer is a Schmitt Trigger input when configured as an external
interrupt.
Some pins for these I/O ports are multiplexed with an alternate function for the
peripheral features on the device. In general, when a peripheral is enabled, that
pin may not be used as a general purpose I/O pin.
This section is not applicable to the 28-pin devices. PORTD is an 8-bit port with
Schmitt Trigger input buffers. Each pin is individually configurable as an input
or output. PORTD can be configured as an 8-bit wide microprocessor Port
(parallel slave port) by setting control bit PSPMODE (TRISE<4>). In this
mode, the input buffers are TTL.
The PORTE pins become control inputs for the microprocessor port
when bit PSPMODE (TRISE<4>) is set. In this mode, the user must make sure
that the TRISE<2:0> bits are set (pins are configured as digital inputs). Ensure
ADCON1 is configured for digital I/O. In this mode the input buffers are TTL.
There are three memory blocks in each of the PIC16F877 MUC’s. The program
memory and Data Memory have separate buses so that concurrent access can
occur.
3.8.1 PROGRAM MEMORY ORGANISATION
The data memory is partitioned into multiple banks which contain the General
Purpose Registers and the special functions Registers. Bits RP1 (STATUS<6)
and RP0 (STATUS<5>) are the bank selected bits.
RP1:RP0 Banks
00 0
01 1
10 2
11 3
Table No.3.2
Each bank extends up to 7Fh (1238 bytes). The lower locations of each
bank are reserved for the Special Function Registers. Above the Special
Function Registers are General Purpose Registers, implemented as static RAM.
All implemented banks contain special function registers. Some frequently
used special function registers from one bank may be mirrored in another bank
for code reduction and quicker access.
3.8.3 EEPROM
The data EEPROM and flash program memory are readable and
writable during normal operation over the entire VDD range. A bulk erase
operation may not be issued from user code (which includes removing code
protection. The data memory is not directly mapped in the register file space.
Instead it is indirectly addressed through the special function registers (SFR).
There are six SFRS used to read and write the program and data EEPROM
memory.
EECON1
EECON2
EEDATA
EEDATH
EEADR
EEADRH
EEDATA holds the 8-bit data for read/write and EEADRR holds the address of
the EEPROM location being accessed.
3.9 TIMERS
Timer 0
8-bit timer/counter
Software programmable prescaler
Internal or external clock select
Readable writable
Interrupt on overflow
Edge selects for external clock
Timer 1
The input clock (Fosc/4) has a prescale option of 1:1, 1:4 OR 1:16, selected
by control bits.
The timer2 module has an 8-bit period register PR2. Timer2 increments from
00h until it match PR2 and then resets to 00h on the next increment cycle.
PR2 is a readable and writable register. The PR2 register is initialized to
FFh upon reset.
The match output of TMR2 goes through a 4-bit postscaler (which gives a
1:1 to 1:16 scaling inclusive) to generate a tmr2 interrupt
Timer 2 can be shut off by clearing control bit tmr2on to minimize power
consumption.
The prescaler and postscaler counters are cleared when any of the following
occurs:
A write to the tmr2 register
A write to the t2con register
An any device reset
Tmr2 is not cleared when t2con is written
3.10 INTERRUPTS
The Pic16f87x Family has upto 14 Sources of Interrupt. The interrupt control
register (INTCON) records individual interrupt requests in flag bits. IT also has
individual interrupt requests in flag bits. IT also has individual and global
interrupt enables bits.Though some modules may generate multiple interrupts
such as (USART) They have 14 sources.
XTAL1 and XTAL2 are the input and output respectively of an inverting
amplifier which is intended for use as a crystal oscillator in the pierce
configuration, in the frequency range of 1.2 MHz to 12 Mhz. XTAL2 also the
input to the internal clock generator.
Since the input to the clock generator is dividing by two flip flops there are no
requirements on the duty cycle of the external oscillator signal. However,
minimum high and low times must be observed.
CHAPTER 4
4.1 Filter
Assume that the input voltage Vin and voltage across the capacitor Vc is
zero volts. At some point Vin jumps to the value V. At that instant Vc is still
zero volts. Over time the capacitor will start to charge and if Vin stays at V long
enough, Vc will approach V. The rate Vc approaches V depends on the time
constant (TC).
TC =R*C
Vc=V(1-e^(-t/RC))
Now consider the situation where Vin is at voltage V for a short period of
time. The capacitor will not have time to charge very much, and Vc will not be
able to approach V. If the length of Vin being high is short compared to TC,
Vc may not get high enough to reach the threshold voltage of the
microcontroller input. The microcontroller will never recognize the input signal
went high.
Let’s get back to our static electricity problem. A static electricity burst
is usually a very short pulse. The RC circuit will limit how high the voltage
will get. A resistor of a couple of hundred ohms and a capacitor of .01 or .1
microfarads will give reasonable protection to the input.
Fig.No.4.2
The low pass filter can be used for other purposes. Part 6 mentioned
switch bounce. This is where a mechanical switch will often make and break
contact when it is actuated. Proper values of RC can filter out these spikes.
RC filters are also used for filtering out high frequencies for A/D (Analog to
Digital) converters. Their use in those applications will be covered in a future
installment.
The nature of the signal inputs must be kept in mind when using RC
filtering. Suppose we have a sensor that indicates one revolution of a motor. If
the motor is running fast enough, or if the values of R and C are too high, the
inputs will be filtered out. The voltage at the pin will never reach the switching
threshold and the micro will think the motor is not running.
Looking at the situation from the analog world, an RC circuit has a
frequency at which point ½ of the input voltage is lost. This is also known as the
3dB point. This is known as the cut off frequency, or Fc.
Fc = 1/(2πRC)
The frequency of a signal going through an RC filter must be much less than Fc
for proper operation.
The first data sheet parameter to look for is the Maximum Allowable
Voltage. This must be higher than the normal operating signal voltages.
Otherwise, the normal signal will trip it, possibly preventing the signal from
reaching the threshold voltage. Another key specification is the capacitance.
You will want to use low capacitance suppressors for high frequency signals.
Otherwise, the signal will get filtered out as in the RC filter described earlier.
Another specification is the maximum surge current. The higher this is,
the more abuse the circuit can take, but often at a higher cost, size and
capacitance.Since transient suppressors look like capacitors during normal
operation, you need to consider the same frequency related considerations as if
you had used a regular RC filter. The resistor is optional. Use one between 10
and a few hundred ohms for things like user switches. Leave the resistor off and
use low capacitance types for high frequency signals.
4.3 Rectifier
The output DC voltage of a half wave rectifier can be calculated with the
following two ideal equations:
For single-phase AC, if the transformer is center-tapped, then two diodes back-
to-back (i.e. anodes-to-anode or cathode-to-cathode) can form a full-wave
rectifier. Twice as many windings are required on the transformer secondary to
obtain the same output voltage compared to the bridge rectifier above.
Fig.No.4.5
A half-wave rectifier will only give one peak per cycle and for this and
other reasons is only used in very small power supplies. A full wave rectifier
achieves two peaks per cycle and this is the best that can be done with single-
phase input. For three-phase inputs a three-phase bridge will give six peaks per
cycle and even higher numbers of peaks can be achieved by using transformer
networks placed before the rectifier to convert to a higher phase order.
The standard does not define such elements as the character encoding or the
framing of characters, or error detection protocols. The standard does not define
bit rates for transmission, except that it says it is intended for bit rates lower
than 20,000 bits per second. Many modern devices support speeds of 115,200
bit/s and above. RS 232 makes no provision for power to peripheral devices.
Details of character format and transmission bit rate are controlled by the serial
port hardware, often a single integrated circuit called a UART that converts data
from parallel to asynchronous start-stop serial form. Details of voltage levels,
slew rate, and short-circuit behavior are typically controlled by a line driver that
converts from the UART's logic levels to RS-232 compatible signal levels, and
a receiver that converts from RS-232 compatible signal levels to the UART's
logic levels.
Because the application of RS-232 has extended far beyond the original purpose
of interconnecting a terminal with a modem, successor standards have been
developed to address the limitations. Issues with the RS-232 standard include.
The large voltage swings and requirement for positive and negative
supplies increases power consumption of the interface and complicates
power supply design. The voltage swing requirement also limits the upper
speed of a compatible interface.
Single-ended signaling referred to a common signal ground limits the
noise immunity and transmission distance.
Multi-drop connection among more than two devices is not defined.
While multi-drop "work-arounds" have been devised, they have
limitations in speed and compatibility.
Asymmetrical definitions of the two ends of the link make the assignment
of the role of a newly developed device problematic; the designer must
decide on either a DTE-like or DCE-like interface and which connector
pin assignments to use.
The handshaking and control lines of the interface are intended for the
setup and takedown of a dial-up communication circuit; in particular, the
use of handshake lines for flow control is not reliably implemented in
many devices.
No method is specified for sending power to a device. While a small
amount of current can be extracted from the DTR and RTS lines, this is
only suitable for low power devices such as mice.
The 25-way connector recommended in the standard is large compared to
current practice.
Role in modern personal computers
RS-232 has mostly been replaced in personal computers by USB for local
communications. Compared with RS-232, USB is faster, uses lower voltages,
and has connectors that are simpler to connect and use. However, USB is
limited by standard to no more than 5 meters of cable, thus favoring RS-232
when longer distances are needed. Both standards have software support in
popular operating systems. USB is designed to make it easy for device drivers
to communicate with hardware. However, there is no direct analog to the
terminal programs used to let users communicate directly with serial ports. USB
is more complex than the RS-232 standard because it includes a protocol for
transferring data to devices. This requires more software to support the protocol
used. RS-232 only standardizes the voltage of signals and the functions of the
physical interface pins. Serial ports of personal computers are also sometimes
used to directly control various hardware devices, such as relays or lamps, since
the control lines of the interface can be easily manipulated by software. This is
not feasible with USB, which requires some form of receiver to decode the
serial data.
Standard details
Voltage Level
Fig.No.4.7
The RS-232 standard defines the voltage levels that correspond to logical
one and logical zero levels for the data transmission and the control signal lines.
Valid signals are plus or minus 3 to 15 volts; the ±3 V range near zero volts is
not a valid RS-232 level. The standard specifies a maximum open-circuit
voltage of 25 volts: signal levels of ±5 V, ±10 V, ±12 V, and ±15 V are all
commonly seen depending on the power supplies available within a device. RS-
232 drivers and receivers must be able to withstand indefinite short circuit to
ground or to any voltage level up to ±25 volts. The slew rate, or how fast the
signal changes between levels, is also controlled.
For data transmission lines (TxD, RxD and their secondary channel
equivalents) logic one is defined as a negative voltage, the signal condition is
called marking, and has the functional significance. Logic zero is positive and
the signal condition is termed spacing. Control signals are logically inverted
with respect to what one sees on the data transmission lines. When one of these
signals is active, the voltage on the line will be between +3 to +15 volts. The
inactive state for these signals is the opposite voltage condition, between −3 and
−15 volts. Examples of control lines include request to send (RTS), clear to
send (CTS), data terminal ready (DTR), and data set ready (DSR).
Because the voltage levels are higher than logic levels typically used by
integrated circuits, special intervening driver circuits are required to translate
logic levels. These also protect the device's internal circuitry from short circuits
or transients that may appear on the RS-232 interface, and provide sufficient
current to comply with the slew rate requirements for data transmission.
Because both ends of the RS-232 circuit depend on the ground pin being
zero volts, problems will occur when connecting machinery and computers
where the voltage between the ground pin on one end, and the ground pin on the
other is not zero. This may also cause a hazardous ground loop. Use of a
common ground limits RS-232 to applications with relatively short cables. If the
two devices are far enough apart or on separate power systems, the local ground
connections at either end of the cable will have differing voltages; this
difference will reduce the noise margin of the signals. Balanced, differential,
serial connections such as USB, RS-422 and RS-485 can tolerate larger ground
voltage differences because of the differential signaling
Connectors
RS-232 devices may be classified as Data Terminal Equipment (DTE) or
Data Communication Equipment (DCE); this defines at each device which
wires will be sending and receiving each signal. The standard recommended but
did not make mandatory the D-subminiature 25 pin connector. In general and
according to the standard, terminals and computers have male connectors with
DTE pin functions, and modems have female connectors with DCE pin
functions. Other devices may have any combination of connector gender and
pin definitions. Many terminals were manufactured with female terminals but
were sold with a cable with male connectors at each end; the terminal with its
cable satisfied the recommendations in the standard.
The standard specifies 20 different signal connections. Since most devices use
only a few signals, smaller connectors can often be used.
Fig.No.4.8
4.5 Transformer
Basic principles
The transformer is based on two principles: first, that an electric current
can produce a magnetic field (electromagnetism) and second that a changing
magnetic field within a coil of wire induces a voltage across the ends of the coil
(electromagnetic induction). Changing the current in the primary coil changes
the magnetic flux that is developed. The changing magnetic flux induces a
voltage in the secondary coil.
Fig.No. 4.9
An ideal transformer is shown in the adjacent figure. Current passing through
the primary coil creates a magnetic field. The primary and secondary coils are
wrapped around a core of very high magnetic permeability, such as iron, so that
most of the magnetic flux passes through both the primary and secondary coils.
If a load is connected to the secondary winding, the load current and voltage
will be in the directions indicated, given the primary current and voltage in the
directions indicated (each will be alternating current in practice).
Induction law
The voltage induced across the secondary coil may be calculated from
Faraday's law of induction, which states that:
where Vs is the instantaneous voltage, Ns is the number of turns in the
secondary coil and Φ is the magnetic flux through one turn of the coil. If the
turns of the coil are oriented perpendicularly to the magnetic field lines, the flux
is the product of the magnetic flux density B and the area A through which it
cuts. The area is constant, being equal to the cross-sectional area of the
transformer core, whereas the magnetic field varies with time according to the
excitation of the primary. Since the same magnetic flux passes through both the
primary and secondary coils in an ideal transformer,[34] the instantaneous
voltage across the primary winding equals
Taking the ratio of the two equations for Vs and Vp gives the basic
equation[35] for stepping up or stepping down the voltage
SENSORS
FEATURES
Power supply: Up to 24V, switching less than 5mA
Size: Cylindrical, 4mm (0.16") diameter & 12mm (0.45") long.
Sensitivity range: > +-15 degrees Lifetime: 50,000+ cycles (switches)
APPLICATIONS
To monitor the angle at which a mobile phone or tablet is held for the
auto-rotate function To detect the position of hand-held game systems
and in game controllers
To monitor laser levels and seismic activity
Measuring the "look angle" of a satellite antenna towards a satellite.
5.3 GAS SENSOR MQ-3
GENERAL DESCRIPTION In current technology scenario, monitoring of
gases produced is very important. From home appliances such as air
conditioners to electric chimneys and safety systems at industries monitoring of
gases is very crucial. Gas sensors spontaneously react to the gas present, thus
keeping the system updated about any alterations that occur in the concentration
of molecules at gaseous state. The gas sensor module consists of a steel
exoskeleton under which a sensing element is housed. This sensing element is
subjected to current through connecting leads. This current is known as heating
current through it, the gases coming close to the sensing element get ionized and
are absorbed by the sensing element. This changes the resistance of the sensing
element which alters the value of the current going out of it. The connecting
leads of the sensor are thick so that sensor can be connected firmly to the circuit
and sufficient amount of heat gets conducted to the inside part. They are casted
from copper and have tin plating over them.
PRODUCT DESCRIPTION MQ-3 gas sensor is designed with sensitive
material of Alcohol, which with lower conductivity in clean air. When the target
combustible gas exists, the sensor’s conductivity is higher. Signal conditioning
circuit is used to convert the change of conductivity to correspond output signal
with the input gas concentration. MQ-3 gas sensor has high sensitivity to
alcohol, Propane and other combustible steam, it is with low cost and suitable
for different application. The MQ-3 gas module is mounted on a pcb board
which has an operating voltage of 5VDC. The sensor output values can be get
by means of both analog and digital.
FEATURES
Analog and Digital output
Good sensitivity to Alcohol in wide range
Operation voltage: 5VDC
Simple drive circuit
Long life and low cost
APPLICATIONS
Domestic gas leakage detector
Industrial Combustible gas detector
Portable gas detector
FEATURES
APPLICATIONS
Power Supplies
Battery Management
HVAC
Appliances
RAIN DETECTOR
GENERAL DESSRIPTION This rain detector will give you a heads-up the
instant it starts to rain, hopefully giving you time to close windows and bring in
possessions. The batterypowered circuit draws virtually no current when the
sensor is dry and the current consumption is low when the buzzer is activated so
a couple of AA cells will last a long time. Alternately, a molded power supply
with a simple voltage regulator to drop the voltage to 3 volts could be used. The
circuit is basically a handy flasher circuit that operates well on only 3 volts
using ordinary silicon transistors. When the circuit is triggered, the buzzer is
pulsed about once per second for a very short time, giving it a "dripping water"
sound which seems appropriate.
CHAPTER 6
SOFTWARE
Device specific include files contain all the information the compiler needs to
optimize code generation for the specific PIC® MCU.
Op-code length
Memory size
Pin functionality
Memory banking
Peripheral resources
Hardware stack size
The device specific include files also initialize device registers and
peripherals, relieving developers from the tedium of studying data sheets to
learn register map details, flag settings, etc.
The compiler can handle in-line or separate functions, as well as parameter
passing in re-usable registers. Transparent to the user, the compiler handles calls
across pages automatically and analyzes program structure and call tree
processes to optimize RAM and ROM Usage. Additional features include:
The CCS compiler contains over 307 built-in functions that simplify access
to hardware while producing efficient and highly optimized code. Functions are
included for device hardware features such as:
Why recreate the wheel coding your own arithmetic functions in assembly or
C? Standard C math libraries are supplied with the CCS compiler.
1, 8, 16 and 32-bit integer types and 32-bit floating point are supported
for all devices
48 and 64-bit integer types and 64-bit floating point for PIC24 and dsPIC
DSC devices
The compiler also has the ability to represent decimal numbers using a
new data type, the fixed point decimal.
Fixed point decimal gives you decimal representation, but at integer
speed. This gives you a phenomenal speed boost over using float.
DSP in-line assembly is supported for your most performance critical
code.
Built-in functions, include files, interrupts, and code examples help you to
quickly "get on the bus". Serial buses such as I2C™ and SPI™, CAN, ECAN
and USB interfaces and RS232 communications protocols are fully supported
by the CCS compiler and development kits.
String compression for 7-bit ASCII strings has been implemented for
Microchip's 14-bit opcode PIC12 and PIC16 families. Studies conducted by
CCS show that string functions that used to take 2,300 bytes of ROM to
implement now consume as little as 1,884, a savings of 18%
IDE includes support for separately compiling source code files and then
linking them together for the final build. The PCW IDE has tools to easily
define the units, figure out what units need to recompiled on a build and
automatically calling the linker.
Fig.No.6.1
C Aware Editor
PCW includes a full-featured C aware Windows editor. The editor has color
syntax highlighting, tab control, bookmarks, context sensitive help and searches
for matching } or ). The IDE allows easy access to the call tree, symbol map
and other helpful screens. It also includes a direct interface to device
programmers and debuggers.
Fig.No.6.2
New Project Wizard generates an initial .H and .C file for your project based on
some standard forms that you fill out. Some forms include helpful information
such as: interactively calculating and showing the timer options for you based
on your clocks, allocating pins for device drivers and setting up pin names.
Fig.No.6.3
A navigation bar shows all project related files. This allows for quickly opening
or compiling a file from the navigation bar. The navigation bar can even be used
to track non-C files associated with the project such as project documentation
files.
Fig.No.6.4
Another navigation bar shows all project functions and identifiers. Double click
on an identifier to move the editor cursor to the location where the identifier is
declared.
Fig.No.6.5
Special Viewers
Special viewers include quick and easy access to data sheets, valid fuses and
interrupts for devices, a hex file disassembler, COD file interpreter and an
advanced source/list file compare. Shown to the right is just the file/compare.
Fig.No.6.6
C-Metrics Calculator
The PCW IDE allows the viewing of all SFR's for a given part and has the
ability to generate custom .h files with the register and bit definitions for
specific functions.
Fig.No.6.8
The device selector makes it easy to find parts with the right number of pins,
memory and other criteria. Grids can be sorted by any column or easily printed.
Individual rows can selected to find more details on the part and to check
distributor price and availability.
Fig.No.6.11