Escolar Documentos
Profissional Documentos
Cultura Documentos
CHAPTER 1
INTRODUCTION
1.1 Introduction
EXPLANATION:
The background of WSN refers to its use in the military applications as in
Battle Surveillance, but now its use has wide in applications such as in many
industrial and civilian applications including the environmental and health
monitoring systems as in our respective project it is being used to r e c o r d t h e
e n v i r o n m e n t a l d a t a f r o m a g r e a t d i s t a n c e , it is also one of its important
application.
Transmitter, a small microcontroller, and a battery. The size of a sensor node can
change from being very small to be a very large in size; it only relies on the required
application.
1.2.1 APPLICATIONS
There are a variety of applications of WSN, and some of the common are
listed below:
A r e a monitoring
V e h i c l e detection
I n d u s t r i a l monitoring
E n v i r o n m e n t a l monitoring
M a c h i n e health monitoring
CHAPTER 2
DESIGN CONSIDERATIONS
2.1 Basic Design
The system has three main functions:
After the user had made his decision, he sends the control commands via serial
communication to the PIC micro controller which processes the digital data input. The
user observes the real time video by a software called SUPER TV pro.
The receiver circuitry is the heart of the system which moves the robot to left,
to right, forward and reverse. The user can monitor all the activities of the robot; in
fact user is controlling the robot. The user is controlling the robot by sending the
control commands via serial communication to the transmitter circuitry [2].
ENVIRONMENT MONITORING ROBOT
The transmitter circuitry is connected to the control PC via serial cable so that
RF communication can be coupled with serial communication of the control PC.
2.4 Receiver
A Robotic car
A Wireless Video Camera
A Receiver Circuitry
4 Sensors (Temperature, Humidity, Light, Smoke)
The receiver circuitry receives the control commands from the transmitter of the
control section via RF receiver. Two motors are connected to the robotic car and the
receiver circuitry such that motors move the robot exactly to the same position and
direction as directed by the control section. This is done by decoding the control
instruction sent by the transmitter with the help of remote control decoder PT 2272.
The PIC microcontroller of the receiver section is programmed in C language. The
speed of the motors can be varied by varying the duty cycle of the PWM of the PIC
micro controller. Greater the duty cycle of the PWM greater will be the speed of the
motor [3].
CHAPTER 3
HARDWARE DESCRIPTION
In everyday life, when anyone drives a car. He monitors his surroundings and
controls the movement of his car. Likewise, this principle is implemented in many
industrial applications. The following figure shows an overview how this project is
using monitoring and controlling principle.
Transmitter is defined as the device which actually transmits the signals. In this project
Transmitter is transmitting the control signals. In this project transmitter transmits control
signals after monitoring the robotic car. This transmitter is connected with computer through
serial port. Computer sends commands which come to transmitter circuitry through serial port
and then these are transmitted to receiver through RF to control robotic car.
3.1.1PIC Microcontroller16F877A:
PIC are popular with developers and hobbyists alike due to their low cost,
wide availability, large user base, extensive collection of application notes,
availability of low cost or free development tools, and serial programming (and re-
programming with flash memory) capability [6].
Features [6]
Interrupts 15
Timers 3
Typical Applications:
PIN 2(RA0/AN0): It is a bi-directional I/O pin and can be used as analog I/O0.
PIN 3(RA1/AN1): It is a bi-directional I/O pin and can be used as analog I/O1.
PIN 4(RA2/AN2/Vref-): It is a bi-directional I/O pin and can also be used as analog
I/O2 or negative analog reference voltage.
ENVIRONMENT MONITORING ROBOT
PIN 5(RA3/AN3/Vref+): It is a bi-directional I/O pin and can also be used as analog
I/O3 or positive analog reference voltage.
PIN 6(RA4/T0CKI): It is a bi-directional I/O pin and can also be the clock input to
the Timer0 timer/counter. Output is open drain type.
PIN 7(RA5/SS/AN4): It is a bi-directional I/O pin and can also be used as analog
I/O4 or the slave selects for the synchronous serial port.
PIN 8(RE0/RD/AN5): It is a bi-directional I/O pin and can also be used to read
control for the PSP or analog input5.
PIN 9(RE1/WR/AN6): It is a bi-directional I/O pin and can also be used to write
control for the PSP or analog input6.
PIN 10(RE3/CS/AN7): It is a bi-directional I/O pin and can also be used to select
control for the PSP or analog input7.
ENVIRONMENT MONITORING ROBOT
PIN 19(RD0/PSP0): It is a bi-directional I/O pin or parallel slave pin when interface
to microprocessor bus.
PIN 20(RD1/PSP1): It is a bi-directional I/O pin or parallel slave pin when interface
to microprocessor bus.
PIN 21(RD2/PSP2): It is a bi-directional I/O pin or parallel slave pin when interface
to microprocessor bus.
PIN 22(RD3/PSP3): It is a bi-directional I/O pin or parallel slave pin when interface
to microprocessor bus.
PIN 23(RC4/SD1/SDA): It is a bi-directional I/O pin and can also be used as SPI
Data In (SPI mode) or data I/O (I2C mode).
ENVIRONMENT MONITORING ROBOT
PIN 24(RC5/SD0): It is a bi-directional I/O pin and can also be used as SPI Data Out
(SPI mode).
PIN 27(RD4/PSP4): It is a bi-directional I/O pin or parallel slave pin when interface
to microprocessor bus.
PIN 28(RD5/PSP5): It is a bi-directional I/O pin or parallel slave pin when interface
to microprocessor bus.
PIN 29(RD6/PSP6): It is a bi-directional I/O pin or parallel slave pin when interface
to microprocessor bus.
PIN 30(RD7/PSP7): It is a bi-directional I/O pin or parallel slave pin when interface
to microprocessor bus.
PIN 33(RB0/INT): It is a bi-directional I/O pin and can be used as external interrupt
pin. It can be software programmed for internal weak pull-up on all input.
PIN 36(RB3/PGM): It is a bi-directional I/O pin and can be used as low voltage
programming input.
PIN 37(RB4): It is a bi-directional I/O pin and also used as Interrupt-on-change pin.
PIN 38(RB5): It is a bi-directional I/O pin and also used as Interrupt-on-change pin.
ENVIRONMENT MONITORING ROBOT
PORTS:
PORT C (Pins 15-18, 23-26): PORT C includes the pins which are timer inputs or
outputs. It also includes compare and PEM outputs. Comparing is additional function
of this port.
PORT E (Pins 8, 9, 10): PORT E is a bi directional I/O port. It includes 8,9,10 pins.
Where 8 and 9 pin can be read and write control for parallel slave port or analogue
inputs 5and 6 respectively. The pin 10 is control select for parallel slave port or
analogue input 7.
A/D Converter:
of the program sets the ADC resolution. An analog voltage presented at the input is
then converted to binary and the value assigned to an integer variable when the
function to read the ADC is invoked [8]. The default input range is set by the supply
(nominally 05 V). If a battery supply is us (which drops over time) or additional
accuracy is needed, a separate reference voltage can be fed in at AN2 (+VE V ref) and
optionally AN3 (V ref). If only +VE V ref is used, the lower limit remains 0 V,
while the upper is set by the reference voltage. This is typically supplied using a zener
diode and voltage divider. The 2.56 V derived from a 2V7 zener gives a conversion
factor of 10 mV per bit for an 8-bit conversion. For a 10-bit input, a reference of
4.096 V might be convenient, giving a resolution of 4mV per bit. The essentials of
ADC operation are illustrated.
The Data EEPROM and FLASH Program Memory are readable and writable
during normal operation over the entire VDD range. These operations take place on a
single byte for Data EEPROM memory and a single word for Program memory. A
write operation causes an erase-then-write operation to take place on the specified
byte or word. So we can re-write in this microcontroller. There are three memory
blocks in each of thePIC16F87X MCUs. The Program Memory and Data Memory
have separate buses so that concurrent access can occur. The PIC16F87X devices
have a 13-bit program counter capable of addressing an 8K x 14 program memory
space. The PIC16F877A has 8K x 14 words of FLASH program memory,
The data memory is partitioned into multiple banks which contain the General
Purpose Registers and the Special Function Registers. Bits RP1 (STATUS<6>) and
RP0 (STATUS<5>) are the bank select bits. Each bank extends up to 7Fh (128 bytes)
[9]. 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
ENVIRONMENT MONITORING ROBOT
frequently used Special Function Registers from one bank may be mirrored in another
bank for code reduction and quicker access.
The Special Function Registers are registers used by the CPU and peripheral
modules for controlling the desired operation of the device. These registers are
implemented as static RAM. GENERAL PURPOSE REGISTER FILE The register
file can be accessed either directly or indirectly through the File Select Register
(FSR).
Serial data connections are useful because only one or two signal wires are
needed compared with at least eight data lines for a parallel bus plus control signals.
The typical PIC microcontroller offers a choice of serial interfaces. The best one for
any given communication channel depends on the distance between nodes, the speed,
and the number of hardware connections required.
USART:
The PIC 16F877A has a dedicated hardware RS232 port, but CCS C allows
any pin to be set up as an RS232 port, providing functions to generate the signals in
ENVIRONMENT MONITORING ROBOT
software. The basic form of the signal has 8 data bits and a stop and start bit. The bit
period is set by the baud rate. A typical value is 9600 baud, which is about 10k bits
per second. The bit period is then about 100 s, about 1 byte per millisecond, or 1 K
byte per second. The data are transferred between shift registers operating at the same
bit rate; the receiver has to be initialized to the same baud setting as the transmitter.
Assuming we are looking at TTL level data, in the idle state, the line is high. When it
goes low, the receiver clock is started, the data are sampled in the middle of each
following data bit period, and data are shifted into the receive register . RS232 is used
to access the standard serial LCD display, in which case, line drivers are not
necessarily required. ASCII characters and control codes are sent to operate the
display, which has its own MCU with a serial interface to receive and decode the data.
It then drives the pixel array to display alphanumeric characters. Most LCD may also
be set up to display simple bit-mapped graphics. In simulation mode, an RS232
virtual terminal provides a convenient way of generating alphanumeric input into the
MCU for testing.
Variables
Looping
Decisions
Variables:
compiler can allocate a corresponding set of locations. Variable values are assumed to
be in decimal by default; so if a value is given in hexadecimal in the source code, it
must be written with the prefix 0x, so that 0xFF represents 255, for example.
Longer labels are sometimes preferable, such as output value, but spaces are
not allowed. Only alphanumeric characters (az, AZ, 09) and underscore, instead of
space, can be used. By default, the CCS compiler is not case sensitive, so a is the
same as A (even though the ASCII code is different). A limited number of key
words in C, such as main and include, must not be used as variable names.
Looping:
Decision Making:
switch needs to be closed before running to see this effect. The LED cannot be
switched off again until the program is restarted [11].
Hi-Tech PIC C:
operations, and basic I/O are provided. It is assumed that the user will develop the
peripheral drivers as required, to suit the particular range of applications and hardware
to be supported, or that the peripheral control registers will be accessed directly. On
the other hand, a major advantage is that a fully featured freeware version, PICC-Lite,
is available for hobbyists, students, and limited commercial purposes. At the time of
writing, the following PIC MCUs are supported with no limitations, as compared to
the full version: 12F629, 12F675, and 16F84. A further set of 16 series chips can be
used with a limitation on RAM and program memory: 627, 684, 690, 877,
887, and 917. Other limitations are imposed due to the limited memory available in
these chips. Hi-Tech also supplies Salvo RTOS, including a freeware version. This is
a cooperative, event-driven, priority-based, multitasking, real-time operating system
designed for microcontrollers with limited RAM and ROM. The manual supplied
(www.pumpkininc.com) with this product contains a very useful introduction to
RTOS principles and is recommended if further information is required on using
RTOS in PICs. An example of Hi-Tech C source code is shown in Listing D.3 . It
outputs a binary count at Port B that is incremented every second using a timer
interrupt. The port register is addressed directly, using the label PORTB . The timer
control bit labels are defined in the header file PIC.H and set directly in the main
routine. Note that here the calculation of the initial loop count constant RELOADS
is calculated in the initial directive block using the arithmetic and logic operations
provided within the directive syntax. Recall that CCS C uses a directive to declare a
function as an ISR; here, the compiler recognizes the keyword interrupt within the
function name instead.
Mikro C:
available at the time of this writing, and the compiler syntax can be assessed prior to
purchase only by reference to code fragments given in the manual. As we see, the
control registers are set up by loading control codes as hex numbers, which requires
the program designer to look up the necessary bit configurations. However, the ADC
access function is simple and concise, allowing the input channel to be selected as the
function parameter.
It converts from RS232 voltage level to TLL voltage levels, and vice versa. It
has dual voltage converters (line drivers) for transferring and receiving data. The
transmitting line drivers are designated as T1 and T2, while the receiving line drivers
are called R1 and R2.
We use only one application in our project i.e. T1 and R1. We place it between
microcontroller and RS-232DB connector. Microcontroller operates at +5V whereas
RS-232 communicates through Computer at +12V. So there is a need to convert the
signal levels going through Computer via serial port to microcontroller and vice
versa.Data coming through serial port is converted from +12V to +5V. Similarly data
coming through microcontroller is converted from +5V to +12V.
In MAX232, the T1 line driver has a designation of T1in and T1out on pin
number 11 and 14, respectively. The T1in (pin 11) is the TTL side and is connected to
ENVIRONMENT MONITORING ROBOT
TxD (pin 25) of the microcontroller, while T1out (pin 14) is the RS232 side that is
connected to RxD (pin 2) of the RS232 DB connector. The R1 line driver has a
designation of R1in and R1out on pin number 13 and 12, respectively. The R1in (pin
13) is the TTL side and is connected to TxD (pin 25) of the RS232 DB connector,
while R1out (pin 12) is the TTL side that is connected to RxD (pin 26) of the
microcontroller.
Voltage Levels:
Features :
Applications:
Portable Computers
Low-Power Modems
Interface Translation
Battery-Powered RS-232 Systems
Multidrop RS-232 Networks
The basic design for optocouplers involves use of an LED that produces a
light signal to be received by a photodiode to detect the signal. In this way, the output
current or current allowed to pass can be varied by the intensity of light.
PC817 Features:
High isolation voltage between input and output Viso= 5000 Vrms
ENVIRONMENT MONITORING ROBOT
Applications:
1. Computer terminals
6. Opto-isolators can help cut down on ground loops, block voltage spikes, and provide
electrical isolation. Where electrical safety is paramount, optocouplers can
totally isolate circuitry which may be touched by humans from mains electricity.
Serial ports have a lot of applications which have been described below:
Computer terminal
Dial-up modems
Printers
Networking (Macintosh AppleTalk at 230.4kbit/s)
Serial Mice
Older Joysticks
GPS receivers (typically NMEA 0183 at 4800bit/s)
Older GSM phones
3.1.5 RF Transmitter
Robotic Car
Decoder PT2272
PIC microcontroller 16F877A
Motor Driver L298
In this project the whole receiver circuitry is embedded over the robotic car.
Further we are actually controlling this car movement. This car is moving with
motors, controlled by motor driver.
The car structure was obtained from the market. It is easily available and it has
a lot of space for mounting motors circuitry and battery packs. It is economical and
easily moveable.
ENVIRONMENT MONITORING ROBOT
In this project PT2272 has been used as decoder. PT2272 is a remote control
decoder paired with PT2262 utilizing CMOS Technology. It has 12 bits of tri-state
address pins providing a maximum of 531,441 (or 312) address codes; thereby,
drastically reducing any code collision and unauthorized code scanning possibilities.
PT2272 is available in several options to suit every application need: variable number
of data output pins, latch or momentary output type. PT2272 is available in 18 pin
package.
Features:
CMOS Technology
Low Power Consumption
Very High Noise Immunity
Up to 12 Tri-State Code Address Pins
Up to 6 Data Pins
Wide Range of Operating Voltage: VCC=4~15V
Single Resistor Oscillator
Latch or Momentary Output Type
Available in DIP and SOP
Applications:
This decoder has a lot of its applications in Car security system, Garage door
controller and Remote control toys etc.
ENVIRONMENT MONITORING ROBOT
In this project this is decoding the signal coming from Receiving antenna and
forwarding the decoded signal to PIC microcontroller which is taking actions to
control motors accordingly the decoded signal.
Motor Control some might even say the holy grail of robotics & mobility in
general. Whether it is a Servo, DC, Stepper, Gas or whatever engine/motor, Motor
driver is being able to control speed, torque, direction...Etc, accurately. It gives us a
great advantage over just being able to turn it on or off. Using a microcontroller like
ENVIRONMENT MONITORING ROBOT
the PIC to control the motors gives us the additional advantage of being able to make
split (micro) second decisions through programmed logic.
The L298 is an integrated monolithic circuit in a 15- lead Multi watt and
Power SO20 packages. It is a high voltage, high current dual full-bridge driver
designed to accept standard TTL logic levels and drive inductive loads such as relays,
solenoids, DC and stepping motors. Two enable inputs are provided to enable or
disable the device independently of the input signals. Board Dimensions are 89 71
28 m. It has 15 pins.
Features:
High Noise Immunity - Dual L298 Motor Driver has logical 0 voltage up to
1.5V.
Bidirectional DC motor control - Dual L298 Motor Driver can control four
DC motors.
Two Phase Bipolar Stepper Motor control - Dual L298 Motor Driver
drivers bipolar stepper motors with winding currents up to 2 A.
Current Sense output - Dual L298 Motor Driver gives voltage output
proportional to motor current.
Easy mounting and setup - Dual L298 Motor Driver has screw terminals for
the high power connections and FRC connectors for the low power
connections. It has four mounting holes for 3mm screws.
Applications:
These DC gear motors are compact, economical and easily available. These
are controlled from motor driver L298. This driver is actually responsible for motors
control. It takes commands from microcontroller and forward to motors accordingly.
ENVIRONMENT MONITORING ROBOT
H-Bridge:
3.4 Battery
Battery has been used in this project to provide power to gear motors and also
to the whole circuit of robot. They are mounted on robotic car. The batteries used for
this project are Acid battery which is used in bike. These batteries are providing
approximately 12V/4A to our robotic car. These are easily available in the market.
ENVIRONMENT MONITORING ROBOT
3.5 Charger
In our project we have used three 12v/1A adapters as shown in figure. First
one is connected to the Camera receiver, second is connected to the computer side
circuit and the third one is used to charge the Acid battery.
First of all the wireless camera installed on our robot car sends the video in form of
RF signals to our computer which receives the signals through TV card inserted in our mother
board of our PC. This TV card supports RF signals coming from wireless camera. The real
time video signals sent by Wireless Camera can be seen on the computer through supported
software named Super TV Pro. This Software Instantly Turns our Computer into a Super
TV.
3.7 TRANSDUCERS
A transducer is a device which measures a physical quantity and converts it
into a signal which can be read by an observer or by an instrument. Monitoring
and controlling of the environmental conditions involve the process that senses the
changes. Following are the sensors that are being used in our project:
L i g h t Sensor (LDR)
T e m p e r a t u r e sensor (LM35)
H u m i d i t y Sensor
S m o k e Sensor
FEATURES:
The circuit that we have implemented in our project is the dark circuit. Its
basic principle of operation is that when an increased intensity of light is incident on
the LDR, its resistance increases and hence the voltage Vout across the LDR
increases. This voltage is basically the output of the light sensor that is then
applied to the pin 14 of CD4051 IC.
FEATURES:
The temperature range over which LM35 can sense is -40 to +110 degree Celsius
and it packaged in a plastic TO-92 transistor [22].
FEATURES:
Humidity sensors are used in cars, office and in meteorology stations to report and
predict weather.
A humidity sensor is used to sense relative humidity. It is used to measure both air
temperature and moisture. Relative humidity that is expressed as a percent is the
ratio of actual moisture in the air to the highest amount of moisture air that
temperature can hold. The warmer the air the more moisture it can hold, so
relative humidity changes with fluctuations in temperature [24].
The m o s t c o m m o n t y p e o f h u m i d i t y s e n s o r u s e s c a p a c i t i v e
measurements. This system depends on electrical capacitance, or the ability
of two nearby electrical conductors to create an electrical field between them. The
sensor itself is composed of two metal plates with a non-conductive polymer film
between the plates. The film is used to collect moisture from the air, and the
moisture causes minute changes in the voltage between the two plates. The
changes in voltage are converted into digital readings showing the total amount of
moisture in the air.
Smoke detectors are typically housed in a disk-shaped plastic enclosure about 150
millimeters (6 in) in diameter and 25 millimeters (1 in) thick, but the shape can vary
by manufacturer or product line. Most smoke detectors work either by optical
detection (photoelectric) or by physical process (ionization), while others use both
detection methods to increase sensitivity to smoke. Sensitive alarms can be used to
ENVIRONMENT MONITORING ROBOT
detect, and thus deter, smoking in areas where it is banned such as toilets and schools.
Smoke detectors in large commercial, industrial, and residential buildings are usually
powered by a central fire alarm system, which is powered by the building power with
a battery backup. However, in many single family detached and smaller multiple
family housings, a smoke alarm is often powered only by a single disposable battery.
In the United States, the National Fire Protection Association estimates that nearly
two-thirds of deaths from home fires occur in properties without working smoke
alarms/detectors.
CHAPTER 4
SOFTWARE CONSIDERATIONS
4.1 Introduction
The programming languages and software used in Environment Monitoring
Robot are:
The detailed description of each of them is given below, whereas the code
written in C.
4.2 C Language
The C programming language was designed for computers, though, and not
embedded systems. It does not support direct access to registers, nor does it allow for
the reading and setting of single bits, two very important requirements for PIC. In
addition, most software developers are accustomed to writing programs that will be
executed by an operating system, which provides system calls the program may use to
access the hardware. However, much code for the PIC is written for direct use on the
processor, without an operating system.
4.3 Micro C
There are many software development tools are available for PIC but Mikro C
is the most famous for educational purposes.
Mikroelectronica supplies range evaluation and development boards for the PIC
and other microcontrollers, as well as C, Pascal, and Basic compilers. The C compiler
ENVIRONMENT MONITORING ROBOT
4.4 PROTEUS
The Proteus Design Suite comprises a fully integrated EDA package with
modules for schematic capture (ISIS), circuit simulation (PROSPICE), PCB layout
(ARES) and embedded co-simulation (VSM). The simulation functions take place
entirely within the schematic editor whilst ISIS and ARES share a common, easy to
use, Windows user interface. All of which reduces the time it will take you to master
the software. Naturally, ISIS and ARES are themselves tightly integrated, offering
both forward and backward annotation.
ENVIRONMENT MONITORING ROBOT
In this project, we have used Super TV Pro to make our PC a super TV. The
hardware required for this application software for proper working is PCI Video
Capture Card. With the help of this software, we are able to watch the real time video
sent by the video camera on our PC at remote location from the site. After observing
the video on the software, user can make his decision and can take actions
accordingly.
In our project, we have developed the front end form for controlling the robotic car
and receiving values from robotic car.
CHAPTER 5
CONCLUSION
The experimental setup of device installed with computer is able to control the
Robotic car via RF and also receiving all sensors readings from a robotic car at a
desired location with the help of PIC 16F877A Microcontroller. Microcontroller is
also controlling the robotic car with the help of H-Bridge circuitry. Our Front end
application is developed in Visual Basic 2012 able to control the robotic car and
collects the environmental values on user request successfully. First, we will move the
robotic car to desired location and then request for values.
As per the requirement different type of sensors can be connected to the PIC
16F877A and the data read can be sent to the user at regular intervals.
As the PIC 16F877A can receive data from external devices through its ports,
the status of such devices can be transmitted to the user regularly through RF
or any greater communication system.
It is not only limited to ground but also extended for monitoring in air,
mountains and sea level etc.
APPENDICES
APPENDIX A
A.1 SOURCE CODE
A.1.1 C Code for Microcontroller of Computer Side Circuit
ADCON1 and TRIS registers control the operation of the A/D port pins.
To be used as analog inputs, the TRIS bits must be set to inputs.
*/
trisb.f0=1; //Configure PORTB pin 0 as input for Alert
PORTd = 255; //(8 bit, 19200 baud rate, no parity bit...)
porta=255;
while (1) //Infinite loop
{
if(alert==1)
{
}
if (USART_Data_Ready()) //if data is received
{
i = USART_Read(); // read the received data
switch(i) //Using switch statement
{
case '1': //For forward movement
PORTD = 0B11111100; //3CODE
// fwr();
DELAY_MS(500); //500ms delay
PORTD = 0B11111111; //To stop the car
break;
i=' ';
USART_Write(i); //send data via USART
i='D';
USART_Write(i); //send data via USART
i='A';
USART_Write(i); //send data via USART
i='T';
USART_Write(i); //send data via USART
i='A';
USART_Write(i); //send data via USART
USART_Write('\r'); //Carriage Return
USART_Write('\n'); //Line Feed
}
void right() //Defining Function for right turn
{
i='R';
USART_Write(i); //send data via USART
i='I';
USART_Write(i); //send data via USART
i='G';
USART_Write(i); //send data via USART
i='H';
USART_Write(i); // send data via USART
i='T';
USART_Write(i); //send data via USART
USART_Write('\r'); //Carriage Return
USART_Write('\n'); //Line Feed
}
void left() //Defining Function for left turn
{
i='L';
USART_Write(i); //send data via USART
i='E';
USART_Write(i); //send data via USART
ENVIRONMENT MONITORING ROBOT
i='F';
USART_Write(i); //send data via USART
i='T';
USART_Write(i); //send data via USART
USART_Write('\r'); //Carriage Return
USART_Write('\n'); // Line Feed
}
void fwr() //Defining Function for forward
{
i='F';
USART_Write(i); //send data via USART
i='O';
USART_Write(i); //send data via USART
i='R';
USART_Write(i); //send data via USART
i='W';
USART_Write(i); //send data via USART
i='A';
USART_Write(i); //send data via USART
i='R';
USART_Write(i); //send data via USART
i='D';
USART_Write(i); //send data via USART
USART_Write('\r'); //Carriage Return
USART_Write('\n'); //Line Feed
}
void rev() //Defining Function for reverse
{
i='R';
USART_Write(i); //send data via USART
i='E';
USART_Write(i); //send data via USART
i='V';
USART_Write(i); //send data via USART
ENVIRONMENT MONITORING ROBOT
i='E';
USART_Write(i); //send data via USART
i='R';
USART_Write(i); //send data via USART
i='S';
USART_Write(i); //send data via USART
i='E';
USART_Write(i); //send data via USART
USART_Write('\r'); //Carriage Return
USART_Write('\n'); //Line Feed
}
*********************************************************************
portd.f6=0;
portd.f5=1;
Delay_ms(800);
portd.f6=1;
portd.f5=1;
}
void dwn()
{
portd.f6=1;
portd.f5=0;
Delay_ms(800);
portd.f6=1;
portd.f5=1;
}
void fwr()
{
PORTd.F7=0;
PORTd.F6=1;
PORTd.F5=0;
PORTd.F4=1;
Delay_ms(300);
}
void rev()
{
PORTd.F7=1;
PORTd.F6=0;
PORTd.F5=1;
PORTd.F4=0;
Delay_ms(300);
}
void right()
{
PORTd.F7=0;
PORTd.F6=1;
ENVIRONMENT MONITORING ROBOT
PORTd.F5=1;
PORTd.F4=0;
}
void left()
{
PORTd.F7=1;
PORTd.F6=0;
PORTd.F5=0;
PORTd.F4=1;
}
void stop()
{
PORTd.F7=1;
PORTd.F6=1;
PORTd.F5=1;
PORTd.F4=1;
}
void reset()
{}
void send ()
{}
void chk()
{
val=&portc;
val=~val;
val=val&0x0f;
}
void main()
{
Usart_Init(9600); //initialize USART module
initMain(); //Calling function
PORTB = 255; //set PORTB to 255
PORTD.F7=1; //set PORTD's pin7 to 1
PORTC.F4=0; //set PORTC's pin4 to 0
ENVIRONMENT MONITORING ROBOT
Delay_ms(2000);
PORTC.F4=1; //set PORTC's pin4 to 1
while (1)
{ //endless loop
chk();
if (val ==9) //If val = 9 then getting data from sensors
{
Delay_ms(2000);
adc_rd1 = ADC_read(0); //get ADC value from channel 0 (RA0/AN0)
Delay_ms(200);
adc_rd1 = ADC_read(0); //get ADC value from channel 0 (RA0/AN0)
tlong = (long)adc_rd1 * 5000; // covert adc reading to milivolts
tlong = tlong / 1023; //0..1023 -> 0-5000mV
ch = tlong / 1000; //extract volts digit
temp=ch;
send(); //Calling send function
ch = (tlong / 100) % 10; //extract 0.1 volts digit
temp=ch;
send(); //Calling stop function
ch = (tlong / 10) % 10; //extract 0.01 volts digit
temp=ch;
send(); //Calling send function
adc_rd1 = ADC_read(1); //get ADC value from Ist channel
(RA1/AN1)
Delay_ms(200);
adc_rd1 = ADC_read(1); //get ADC value from Ist channel (RA1/AN1)
tlong = (long)adc_rd1 * 5000; //covert adc reading to milivolts
tlong = tlong / 1023; //0..1023 -> 0-5000mV
ch = tlong / 1000; //extract volts digit
temp=ch;
send(); //Calling send function
ch = (tlong / 100) % 10; //extract 0.1 volts digit
temp=ch;
send(); //Calling send function
ENVIRONMENT MONITORING ROBOT
Delay_ms(800);
}
}
}
*********************************************************************
A.1.3 Visual Basic Code for creation of Form and how to connect it to MS-Access
Imports System
Imports System.ComponentModel
Imports System.Threading
Imports System.IO.Ports
Dim myPort As Array 'COM Ports detected on the system will be stored here
Delegate Sub SetTextCallback(ByVal [text] As String) 'Added to prevent threading
errors during receiveing of data
cmbBaud.Items.Add(19200)
cmbBaud.Items.Add(38400)
cmbBaud.Items.Add(57600)
cmbBaud.Items.Add(115200)
Timer1.Start()
For i = 0 To UBound(myPort)
cmbPort.Items.Add(myPort(i))
Next
cmbPort.Text = cmbPort.Items.Item(0) 'Set cmbPort text to the first COM port
detected
cmbBaud.Text = cmbBaud.Items.Item(0) 'Set cmbBaud text to the first Baud
rate on the list
btnDisconnect.Enabled = False 'Initially Disconnect Button is Disabled
End Sub
End Sub
TextBox4.Text = "Alert"
End If
count = False
End If
System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\ENVIRONMENT MONITORING ROBOT\ENVIRONMENT
MONITORING ROBOT.accdb")
con.Open()
'paste the connection string above
ENVIRONMENT MONITORING ROBOT
MsgBox("Connection OK")
sqlStr = "Select * from Datap where Id=" & id & ""
'Write the sql query
End While
End If
System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\ENVIRONMENT MONITORING ROBOT\ENVIRONMENT
MONITORING ROBOT.accdb")
con.Open()
'paste the connection string above
'open the connection
MsgBox("Connection OK")
sqlStr = "insert into Datap values(" & TextBox5.Text & ",'" & TextBox6.Text &
"'," & TextBox1.Text & "," & TextBox2.Text & "," & TextBox3.Text & ",'" &
TextBox4.Text & "');"
'Write the sql query
cmd = New OleDb.OleDbCommand(sqlStr, con)
'pass the parameter as sql Query, con "Connection OBJ"
cmd.ExecuteNonQueryAsync()
'cmd.ExecuteNonQuery()
'"ExecuteNonQuery() for insert, update, delete query"
MsgBox("Record Inserted OK")
con.Close()
'close the connection after operation get completed.
End Sub
End Class
*********************************************************************
ENVIRONMENT MONITORING ROBOT
APPENDIX 8
B.1 ACRONYMS
MS Microsoft
MSB Most Significant Bit
MSSP Master Synchronous Serial Port
OSC Oscillator
PC Personal Computer
PCB Printed Circuit Board
PGC Programming Clock
PGD Programming Data
PIC Peripheral Interface Controller
PICC Peripherally Inserted Central Catheter
PLC Peripheral Interface Controller
POR Power on Reset
PSP Parallel Slave Pin
PWM Pulse Width Modulation
RAM Read Access Memory
RF Radio Frequency
ROM Read Only Memory
RX Receiver
SFR Special Function Register
SOP Small Outline Package
SPI Serial Peripheral Interface
SS Slave Select
TTL Transistor Transistor Logic
TV Television
TX Transmitter
USART Universal Synchronous/Asynchronous
USB Universal Serial Bus
VB Visual Basic
WAP Web Access Protocol
WSN Wireless Sensor Networks
ENVIRONMENT MONITORING ROBOT
APPENDIX C
C.1 REFERENCES
[1] http://lifesciences.ieee.org/articles/116-robotics-for-environmental-monitoring
[2] http://www.ecse.monash.edu.au/staff/mehmety/IEEESensors_electronicpill.pdf
[3] http://www.scribd.com/doc/114108613/LIVE-HUMAN-BEING-DETECTION-
WIRELESS-REMOTE-CONTROLLED-ROBOT
[4] http://nerdclub-uk.blogspot.com/2011/11/pic16f877a-resetting.html
[5] http://www.hobbyprojects.com/microcontroller-tutorials/pic16f877a/introduction-to-the-
pic16f877a.html
[6]http://www.academia.edu/1846824/Wireless_Radio_Frequency_Module_Using_PIC_Micr
ocontroller
[7] http://www.mikroe.com/chapters/view/16/
[8] http://zux163-090.adsl.green.ch/armando/eBooks/Programming%208-
bit%20PIC%20Microcontrollers%20in%20C.pdf
[9] http://www.dimensionengineering.com/appnotes/Gmeter/PIC16F818.pdf
[10] http://zux163-090.adsl.green.ch/armando/eBooks/Programming%208-
bit%20PIC%20Microcontrollers%20in%20C.pdf
[11] Programming 8-bit PIC Microcontrollers in C: with Interactive Hardware Simulation
By Martin P. Bates
[12] http://www.pantechsolutions.net/microcontroller-boards/uart-interfacing-with-
pic16f877a-primer
[13] http://www.societyofrobots.com/electronics_negative_voltages.shtml
[14] http://myfreetimehobbies.blogspot.com/2012/09/pic-serial-communication-tutorial-
uart.html
[15] http://wiki.analog.com/university/courses/electronics/electronics-lab-22
[16] http://www.pro-tecc.co.za/store/index.php?main_page=product_info&products_id=6688
[17] http://entegreciniz.com/asp/product/5122/pc817
[18] http://www.usconverters.com/index.php?main_page=page&id=61&chapter=0
[19] http://www.ebay.ca/itm/5pcs-PT2272-L4-PT2272-DIP-18-Remote-Control-Decoder-IC-
/290776861732?pt=LH_DefaultDomain_0&hash=item43b3a6cc24
[20] http://www.datasheetdir.com/PT2272+RF-transceiver
[21] http://www.electronics-tutorials.ws/io/io_4.html
[22] http://www.ti.com/lit/ds/symlink/lm35.pdf
[23] http://www.facstaff.bucknell.edu/mastascu/elessonsHTML/Sensors/TempLM35.html
ENVIRONMENT MONITORING ROBOT
[24] http://www.wisegeek.com/what-is-a-humidity-sensor.htm
[25] http://knowledgeweb.afac.com.au/research/community/detectors
[26] http://tutorial.cytron.com.my/wp-content/uploads/2011/08/sens01.gif
[27] http://ayo-baca-aja.blogspot.com/2010/01/ldr-dan-photodioda.html
[28] http://www.ni.com/white-paper/2991/en/
[29] http://leisonmotor.en.made-in-china.com/productimage/jMNJDeiPfBrk-
2f0j00MBtESATyLFzs/China-CE-RoHS-12V-Low-Rpm-DC-Gear-Motor.html
[30] http://commons.wikimedia.org/wiki/File:L298_IMGP4533_wp.jpg
[31] http://www.rapidonline.com/electronic-components/l298-dual-full-bridge-driver-
34494/
THE END