26
CHAPTER NO. 6 DESIGN AND IMPLEMENTATION 6.1. INTRODUCTION: To monitor the environment conditions it is necessary to design and implement the Wireless sensor Multimeter. The sensors such as Temperature, Soil moisture, Humidity, Wind speed, rain, soil pH and Sun shone duration must be designed and connect to wireless Sensor multimeter. The System using ZigBee module should be designed which sense the soil moisture, temperature and according to that the irrigation motor should be controlled. 6.2. SOIL pH SENSOR: pH probe of the meter is connected to the non-inverting input of operational amplifier. The output voltage Vout is directly proportional to pH. The IC is soldered directly to the BNC connector. Acid pHs produce negative voltage. Basic pHs produces positive pHs.TL082 is used for pH meter. 6.3. SOIL MOISTURE SENSOR: The two copper leads act as the sensor probes. They are immersed into the specimen soil whose moisture content is under test. The soil is examined under three conditions: Dry condition, Optimum condition and Excess water condition. Fig. No. 6.1. Circuit Diagram of Soil moisture sensor.

17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

CHAPTER NO. 6

DESIGN AND IMPLEMENTATION

6.1. INTRODUCTION:

To monitor the environment conditions it is necessary to design and implement

the Wireless sensor Multimeter. The sensors such as Temperature, Soil moisture,

Humidity, Wind speed, rain, soil pH and Sun shone duration must be designed and

connect to wireless Sensor multimeter. The System using ZigBee module should be

designed which sense the soil moisture, temperature and according to that the irrigation

motor should be controlled.

6.2. SOIL pH SENSOR:

pH probe of the meter is connected to the non-inverting input of operational

amplifier. The output voltage Vout is directly proportional to pH. The IC is soldered

directly to the BNC connector. Acid pHs produce negative voltage. Basic pHs produces

positive pHs.TL082 is used for pH meter.

6.3. SOIL MOISTURE SENSOR:

The two copper leads act as the sensor probes. They are immersed into the

specimen soil whose moisture content is under test. The soil is examined under three

conditions: Dry condition, Optimum condition and Excess water condition.

Fig. No. 6.1. Circuit Diagram of Soil moisture sensor.

Page 2: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.4. TEMPERATURE SENSOR:

National Semiconductor’s LM35 IC has been used for sensing the temperature.

Fig. No. 6.2. Temperature sensor with ADC

6.5. LIGHT SENSOR:

An LDR and a normal resistor are wired in series across a voltage, as shown in

circuit below. Depending on which is tied to the 5V and which to 0V, the voltage at the

point between them, call it the light sensor node, will either rise or fall with increasing

light. The voltage value decreases with increase in light intensity. The sensor node

voltage is compared with the threshold voltages for different levels of light intensity

corresponding to the conditions- optimum, dim, dark and night. In order to increase the

sensitivity of the sensor just reduces the value of fixed resistor in series with the sensor.

Fig. No. 6.3. Circuit Diagram of Light sensor.

Page 3: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.6. HUMIDITY SENSOR:

A capacitance type humidity sensor is selected.

Fig. No. 6.4. Circuit Diagram of Humidity sensor.

6.7. WIND SPEED SENSOR:

The circuit required a 9 VDC supply voltage which is regulated down to a

constant 5 VDC by the LM7805 voltage regulator. The 5VDC passes through a 16 ohm

power resistor to the 2 series-connected 1N4148 diodes mounted in the outdoor probe.

The 5 VDC supply routed through the 16 ohm power resistor forms an approximate

constant current source supply to the diodes. The electric power dissipated in the diodes

causes a rise in both their temperature. The temperature difference of the two diodes in

the probe creates a voltage imbalance. The voltage imbalance from the diodes is sent to

the amplifier. The amplifier monitors the voltage from the probe. The amplifier chip also

receives a reference voltage for comparison. The reference voltage is created by the

adjustable potentiometer, and trims the 'zero adjust'. The INA122 amplifier chip is

programmed by the feedback resistor to provide a fixed signal gain. In this circuit the

feedback resistor is 1200 ohms, which provides a signal gain of 172X. The output of the

amplifier is sent to the microcontroller.

Page 4: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

Fig. No. 6.5. Circuit Diagram of Wind Speed sensor.

6.8. RAIN SENSOR:

A rain sensor or rain switch is a switching device activated by rainfall.

Fig. No. 6.6. Circuit Diagram of Rain sensor.

6.9. RELAY CIRCUIT:

Fig. No. 6.7. Circuit Diagram of Relay.

Page 5: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

Relays are switching devices employed to control large power or to perform

switching operations. Relay is considered as switch. The electromagnetic relay is used.

6.10. BLOCK DIAGRAM:

6.10.1. Wireless Sensor Multimeter on Farm:

Fig. No. 6. 8. Block Diagram of Wireless Sensor Multimeter on Farm

6.10.2. Master Module:

Fig. No. 6. 9. Block Diagram of Master Module

Temp. Sensor

Humidity Sensor

Light Sensor

Rain Sensor

ADC 0808

Microcontroller

89c51

Power Supply

ZIGBEE NODE

Power

Supply

Wind Speed Sensor

LCD

Display

ZIGBEE

NODE RS 232

Connection Computer

Power Supply

Page 6: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.10.3. Wireless Sensor Module on Farm to sense Field Parameters:

Fig. No. 6. 10. Block Diagram of Farm to sense Field Parameters

6.10.4. Wireless Sensor Module on Farm to Irrigate the Land:

Fig. No. 6. 11. Block Diagram of Farm to Irrigate Land

ZigBee

Module

Microcontroller

Soil

Moisture

Sensor

Temp. Sensor Humidity

Sensor

Power Supply

Page 7: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.11. ZIGBEE (X-BEE):

ZigBee cost-effective, standards-based wireless network that supports low data

rates, low power consumption, security and reliability. The ZigBee Alliance operates on

the IEEE 802.15.4 wireless standard. ZigBee devices are actively limited to a through-

rate of 250Kbps operating on the 2.4 GHz ISM band, which is available throughout most

of the world. Due to its low power output, ZigBee devices can sustain themselves on a

small battery for years. ZigBee is the only standards-based technology that addresses the

needs of most remote monitoring and control and sensory network application.

6.11.1. Key Features:

• Long Range Data Integrity:

Indoor/Urban: up to 100’ m

Outdoor line-of-sight: up to 300’ (100 m)

Transmit Power: 1 mW (0 dBm)

Receiver Sensitivity: -92 dBm

• Advanced Networking & Security:

Retries and Acknowledgements

DSSS (Direct Sequence Spread Spectrum)

Each direct sequence channels has over 65,000 unique network addresses

Source/Destination Addressing Uncast & Broadcast Communications

Point-to-point, point-to-multipoint and peer-to-peer supported Coordinator/End

Device operations

• Low Power:

TX Current: 45 mA (@3.3 V)

RX Current: 50 mA (@3.3 V)

Power-down Current: < 10 µA

Transmitter X-bee:-

• Data to be transmitted is written to the DI pin of module.

• On reception of the data at the DI pin X-bee will send a flow control signal ‘clear

to send’ (CTS) to microcontroller.

Page 8: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

• When X-bee gives the DO (data out) signal to microcontroller, it will send a

request for flow control signal to continue the transfer.

Receiver X-bee:-

• Microcontroller will continuously monitor the status of DI pin. When it goes high,

it will take the data and process it.

• Microcontroller will request for flow control signal.

Here taking into consideration the distance of transmitter from receiver I have

chosen the X-bee with on chip antenna AP command.

Some of the specifications of X-bee are as follows:-

• Range – 100 meter.

• Transmit power - 100mW (20dBm).

• Receiver sensitivity – 100dBm.

• RF data rate – 2,50,000 bps.

• TX Current: 215 mA (@3.3 V)

• RX Current: 55 mA (@3.3 V)

6.11.2. Microcontroller (P89V51RD2):

•The P89V51RD2 is an 80C51 microcontroller with 64 kB Flash and 1024 bytes of

data RAM.

•A key feature of the P89V51RD2 is its X2 mode option. The design engineer

Can choose to run the application with the conventional 80C51 clock rate (12clocks

per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve

twice the throughput at the same clock frequency.

•Another way to benefit from this feature is to keep the same performance by reducing

the clock frequency by half, thus dramatically reducing the EMI.

•The Flash program memory supports both parallel programming and in serial In-

System Programming (ISP). Parallel programming mode offers gang-programming at

high speed, reducing programming costs and time to market.

•ISP allows a device to be reprogrammed in the end product under software control.

•The capability to field/update the application firmware makes a wide range of

applications possible.

Page 9: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

•The P89V51RD2 is also In-Application Programmable (IAP), allowing the Flash

program memory to be reconfigured even while the application is running.

6.11.3. LCD:

Fig. No. 6. 12. LCD Display

LCD display can be interfaced with microcontroller to read the output directly. I used a

two line LCD display with 16 characters each.

Number Symbol Function

1 Vss 0v Power Supply (GND Level)

2 Vdd Power Supply for Logic Circuit

3 Vo Is for adjusting the contrast of the display. Usually, when this pin is grounded the pixels will be the darkest

4 RS Data/Instruction select

5 R/W Determines if we read from or write to the LCD

6 E Enables or disables the LCD module

7-14 DB0-DB7 Bi-directional data bus

6.12. CIRCUIT DIAGRAMS:

Some Circuit Diagrams are drawn below.

Page 10: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.12.1. X-bee module Interfacing with serial port:

Fig. No. 6. 13. ZigBee module interfacing diagram.

6.12.2. LCD Interfacing:

Fig. No. 6. 14. LCD interfacing diagram.

Page 11: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.12.5. Connection of sensor with microcontroller and power suply:

Fig. No. 6. 15. Connection with microcontroller

PIC16F877A

Page 12: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.12.6. Motor Connection:

Fig. No. 6. 16. Motor connnection

6.13. HYPERTERMINAL CONFIGURATION:

To configure the Windows HyperTerminal follow the steps below:

1. Launch Windows HyperTerminal, enter the application name and select an icon.

Fig. No.6.17.: Connection window

Page 13: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

2. Select the COM port.

Fig. No. 6.18.: Com port Selection

3. Configure the COM port in the same way as your UART. For the HyperTerminal

Application, the communications are configured as follows:

Fig. No.6.19. : Configuring the COM port

4. Configure the Windows HyperTerminal by selecting File>Settings:

– Set Backspace key to Ctrl + H, space, Ctrl + H.

– Set Telnet terminal ID to ANSI.

– Uncheck all ASCII sending options in the ASCII Setup window.

Page 14: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

– Check Force incoming data to 7 bit ASCII

UM0884 HyperTerminal configuration

Doc ID 16898 Rev 1 21/23

Fig. No. 6.20. Configuring the HyperTerminal

5. Connecting your STM8S-DISCOVERY board and launch the application using STVD.

The HyperTerminal window is display. If it is not or if wrong characters are displayed

Restart the process starting from step 1.

Fig. No.6.21. HyperTerminal window

6.14. PROTEUS:

With PROTEUS VSM - interactive circuit simulation into the design environment.

For the first time ever it is possible to draw a complete circuit for a micro-controller

based system and then test it interactively, all from within the same piece of software.

Page 15: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

Meanwhile, ISIS retains a host of features aimed at the PCB designer, so that the same

design can be exported for production with ARES or other PCB layout software.

6.15. X-CTU:

It provides you a neat GUI for configuring and updating X-Bee. It also has a

communication and range test.

Tools Required:

� Two X-Bee Modules with Development Boards

� RS232 (Serial Port) Connection

� X-CTU

Step 1 – Module Connection Test:

Now we have two X-Bee modules, refer one as “A” and other as “B”. Connect module A

with serial port of your PC through the development board. The diagram below explains

the connection;

Fig. No.6.22. Module Connection Test

Connection is being made, now run X-CTU. X-CTU is so�ware for configuring

and testing X-Bee modules. At the startup the PC Settings tab requires the information

needed for serial connection on to the X-Bee module. Select the COM Port to which X-

Bee is connected. The other settings remain same i.e. Baud, Flow Control, Data Bits,

Parity and Stop Bits. These are the defaults settings comes with X-Bee.

Page 16: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

Step 2 – Settings and Firmware:

Communication between the modules and PC is OK, now it should proceed

towards establishing communication link between both the modules. There are many

networking topologies offered by X-Bee protocol. I setup a Point-to-Point

communication. In X-CTU go to “Modem Configuration” tab and press “Read”. This tab

shows the internal configuration of XBee module. Since the setting up P2P connection,

and need to exchange the Addresses of XBee modules with each other.

“Func�on Set” is the firmware inside XBee. It is responsible for different

topologies and configura�ons. For Module A we will use ZNET 2.5 ROUTER/END

DEVICE AT. Select the Function on Set from the drop-down menu and press Write. It

will download the new function on set into module A. For Module B select ZNET 2.5

COORDINATOR AT and download it too. Now both the modules have their respective

firmware inside, all we need is to set the target module address. Module A will have

address of B in its DESTINATION field. Module B will have address of A in its

DESTINATION field.

Fig. No.6.23. Settings and Firmware

Source Addresses can’t be changed while Destination Addresses are variable.

Source addresses are fixed to specific module. Write the destination addresses for both

the modules and make sure that PAN ID is same in both modules. Click Write to

download the new settings.

Step 3 – Communication Test:

Till this step, I have tested the modules and setup the communication settings.

Now I checked the real wireless communication between the modules. X-CTU has built-

in communication and range test. The range test sends a data packet and expects the same

Page 17: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

packet to be received. I connected module A to PC and send packets through X-CTU.

Module B will not be connected to any device but its Rx and Tx was joined electrically.

So whatever module B receives was be sent again.

Fig. No.6.24. Communication Test

As you can see, the ultimate result will be that whatever is sent to module A will

come back. If the test goes right it will ensure that everything is perfectly setup. To create

a loopback connection, I have to put a jumper between the Rx and Tx pins of Module B’s

DB9 Connector. Pin 2 and Pin 3 will be connected to each other.To create a loopback

connection on, I have to put a jumper between the Rx and Tx pins of Module B’s DB9

Connector. Pin 2 and Pin 3 will be connected to each other and connected both the

modules to separate PCs and check the communication using Hyper Terminal.

Once the modules are setup and configured properly, there is nothing left .All the hassles

of wireless communication are handled by X-Bee itself.

6.16. FLASH MAGIC:

6.16.1. High Speed Communications:

Some devices (the Rx2 and 66x families) feature the ability to switch from the

initial baud rate to a high speed communications mode, allowing speeds higher than the

auto baud method in the Boot loader would be able to accurately measure. To enable the

High Speed communications mode select the option in the Advanced Options window

and select whether the device is operating in 6-clock mode or 12-clock mode (if

applicable). Flash Magic will calculate the highest possible baud rate that may be used by

both the device and the PC COM Port and automatically switch to it after connecting at

the initial baud rate specified in the main window. If you experience problems with this

Page 18: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

feature, then try limiting how fast the high speed communications mode can go. Select

the maximum speed from the drop-down list. If in doubt, select 9600 and start increasing

until the problems appear.

6.16.2. Terminal Interface:

Flash Magic features a simple terminal interface, designed to communicate with a

Microcontroller during the testing of firmware.

Fig. No.6.25. Terminal Interface-1

The default setting when the COM port is opened for the terminal interface is

that DTR and RTS are both asserted. This is standard COM port behavior. Because

sometimes target hardware requires certain states for DTR and RTS it is possible to

configure the state they will be in while the COM port is opened. To do this check

"Modify default COM Port behavior" and choose the appropriate option from the drop

down list. The terminal interface allows cut and pasting of blocks of text into it. In order

to allow commands to be pasted a delay character is supported. When the option is

enabled and the delay character is entered into the terminal window, Flash Magic will

pause sending the rest of the data for the specified time period. For example, suppose that

the delay character was enabled and set to '#' with a delay of 1000ms. Pasting the

following into the terminal window:

Page 19: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

1#S400##3 would result in '1' being sent out of the COM Port followed by a delay of

1000ms, followed by 'S400' being transmitted, followed by a delay of 2000ms. Followed

by '3 being transmitted. Note that the delay character itself is not transmitted, so any

delay character selected must be a character that is not used in the serial command set

implemented in the firmware.Connections are always made with eight bits, no parity, one

stop bit and no flow control. Once the settings have been accepted the terminal window

will open.

Fig. No.6.26. Terminal interface-2

The top part of the window shows the output from the device. The bottom part is

where characters are entered for transmission. The sizes of the areas may be adjusted by

resizing the window and dragging the splitter located between the output and input areas.

To transmit data, simply type or cut and paste into the input box. Output will appear in

the output window. By keeping the input and output separate, it is possible to copy the

input and output into documentation such as test reports. It also allows for the replaying

of inputs simply by copying it, saving it in a file for pasting later and perhaps adding

delay characters if needed. To change the settings choose Settings… from the Options

menu. To one or both of the input and output areas, choose the relevant entry from the

Options menu. The COM port is open whenever the terminal window is open, so there is

no need to click on connect or disconnect buttons. Window content and settings are

Page 20: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

retained when the window is closed, allowing quick and easy switching between the

terminal window and the ISP operations of Flash Magic.

6.17. FLOW CHARTS:

6.17.1. ADC:

Fig. No.6.27. ADC flow chart

Start

Initialize ADC channel

Initialize val.

Set ADC channel

Clear “done” bit

Start conversion

Wait for conversion

Return the val. to port

Stop

Page 21: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.17.2. LCD interfacing:

Fig. No.6.28. LCD interfacing flow chart

Start

Initialize char s[ ] array

Call function LCD_init

Call function Init_serial

Call function LCD_test ();

End

Page 22: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.17.3. Serial Communication:

Fig. No.6.29. Serial connection flow chart

Start

Initialize character

UART0_Tx & UART1_Rx

Initialize pin select block for

Tx & Rx

Enable FIFOs and reset them

Set DLAB & word length to 8 bits & baud rate to

9600

Clear DLAB

Stop

Page 23: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.17.4. Motor Valve Flow Chart:

Fig. No.6.30. Valve flow chart flow chart

Page 24: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.17.5. Motor Node Flow chart:

Fig. No.6.31. Motor node flow chart

6.18. DESIGN PHOTO:

6.18.1. ZigBee Module interfaced with microcontroller:

Fig. No.6.32. Design photo-1

Start

Send request to Master

Is

parameter ok?

Send to Motor

NO

YES

Page 25: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.18.2. ZigBee Multisensor:

Fig. No.6.33. Design photo-12

6.18.3. Master Side ZigBee Module:

Fig. No.6.34. Design photo-3

Page 26: 17 Chapter 6 - INFLIBNETshodhganga.inflibnet.ac.in/bitstream/10603/21154/14/14...per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput

6.18.4. Motor Side Module:

Fig. No.6.35. Design photo-4 6.18.5. Soil moisture sensor:

Fig. No.6.36. Design photo-5

6.19. CONCLUSION:

The prototype system is designed and implemented successfully using ZigBee

module. The sensors designed. The Design is ready for agriculture parameters control and

monitor using wireless sensor networks. The System is reliable and economic. Now it is

necessary to take field readings on various crops.