Final Report - University of Victoria

advertisement
University of Victoria
Department of Electrical and Computer Engineering ELEC 499 ‐ Group #3 Project Report Robert Bellrose (V00166537) Daniel Bennett (V00135180) Tomas Torres Bonet (V00172224) Sanjeet Sahota (V00200513) Wojtek Siedlaczek (V00238292) Submitted: Friday, July 30th, 2010 Dr. Michael McGuire Assistant Professor Department of Electrical and Computer Engineering Faculty of Engineering University of Victoria P.O. Box 3055 STN CSC Victoria, B.C. V8W 3P6 July 30th, 2010
Dear Dr. McGuire,
Please accept the following ELEC 499 Project Report titled, “Smart-Spray”. The purpose
of this project was to research, design and build an in-ground sprinkler system with a
programmable spray pattern. A prototype was built to demonstrate the desired
functionality, which is laid out in this report.
Sincerely,
Robert Bellrose
Dan Bennett
Tomas Torres Bonet
Sanjeet Sahota
Wojtek Siedlaczek
Table of Contents List of Tables and Figures………………………………………………………………………………………………v Summary ....................................................................................................................... vi 1.0 1.1 1.2 1.3 Introduction ........................................................................................................... 2 Problem Description ...................................................................................................................................... 2 Project Description ......................................................................................................................................... 3 Report Scope ...................................................................................................................................................... 3 2.0 Project Development.............................................................................................. 4 2.1 Design Concept ................................................................................................................................................. 4 2.2 Part Selection .................................................................................................................................................... 5 2.2.1 Sprinkler Head................................................................................................................................................... 5 2.2.2 Microprocessor .................................................................................................................................................. 5 2.2.3 Micro Controller Programmer ................................................................................................................... 5 2.2.4 PCB Board ............................................................................................................................................................ 6 2.2.5 Electronic Parts ................................................................................................................................................ 6 2.2.6 Stepper Motors .................................................................................................................................................. 6 2.2.7 Fluid Control Valve .......................................................................................................................................... 6 2.2.8 Helical Shaft Coupler ...................................................................................................................................... 6 2.2.9 Miscellaneous Parts ........................................................................................................................................ 7 2.3 Electrical Design ............................................................................................................................................... 7 2.3.1 Schematic Design ............................................................................................................................................. 7 2.3.2 PCB Layout Design .......................................................................................................................................... 8 2.4 Mechanical Design ........................................................................................................................................... 9 2.4.1 Control Valve Bracket .................................................................................................................................... 9 2.4.2 Sprinkler Gear Drive .................................................................................................................................... 10 2.4.3 Housing Unit & Sprinkler Mount............................................................................................................ 11 2.5 Software Design ............................................................................................................................................ 12 2.5.1 Initial Testing of Stepper Motor Control ............................................................................................ 12 2.5.2 The Program ................................................................................................................................................... 13 3.0 Results ................................................................................................................. 16 3.1.1 Demonstration Results ............................................................................................................................... 16 3.1.2 Mechanical Results ....................................................................................................................................... 16 3.1.3 Electrical Results ........................................................................................................................................... 16 4.0 Problems Encountered ......................................................................................... 17 4.1 Mechanical ....................................................................................................................................................... 17 4.1.1 Flow Control Valve ....................................................................................................................................... 17 4.1.2 Sprinkler Rotation ........................................................................................................................................ 18 4.1.3 Water Leakage ............................................................................................................................................... 19 4.2 Electrical & Programming ........................................................................................................................ 19 4.2.1 Shorted PCB Trace ........................................................................................................................................ 19 4.2.2 Pins Swapped in PCB Design .................................................................................................................... 20 4.2.3 L6208 Sense Resistors ................................................................................................................................. 20 4.2.4 Motor Rotation ............................................................................................................................................... 20 5.0 Recommendations ............................................................................................... 21 5.1 Mechanical Updates ..................................................................................................................................... 21 5.1.1 Mechanical Drive System .......................................................................................................................... 21 5.1.2 DC Motors with Optical Shaft Encoders ............................................................................................. 21 5.1.3 Control Valve Modifications ..................................................................................................................... 22 5.1.4 Custom Built Valve ....................................................................................................................................... 22 5.1.5 Pressure Regulator ....................................................................................................................................... 23 5.2 Electrical & Programming Updates ....................................................................................................... 23 5.2.1 Relocation of Electronics ........................................................................................................................... 23 5.2.2 Program Loading Capabilities & GUI .................................................................................................. 23 6.0 Conclusions .......................................................................................................... 25 7.0 References ........................................................................................................... 26 Appendices Appendix A ‐ Electrical Schematic Appendix B ‐ PCB Layout Appendix C ‐ Valve Design Drawing Appendix D ‐ Block Diagram of Main Program Appendix E ‐ Source Code Appendix F ‐ Progress Report #1 Appendix G ‐ Progress Report #2 List of Figures
FIGURE 1: OVERSPRAYING AND OVERLAPPING OF EXISTING IN‐GROUND SPRINKLERS ......................... 2 FIGURE 2: PRINTED CIRCUIT BOARD .............................................................................................................. 9 FIGURE 3: CONTROL VALVE ASSEMBLY ........................................................................................................ 10 FIGURE 4: COMPLETE HOUSING AND CONNECTED CIRCUIT ...................................................................... 11 FIGURE 5: STEPPER MOTOR WAVEFORM OPERATING AS BIPOLAR IN FULL STEP DRIVE .................... 13 List of Tables
TABLE 1: MATERIALS AND COSTS ................................................................................................................... 5 TABLE 2: STEPPER MOTOR VOLTAGE SEQUENCE………………………………………………………………..7 Summary
A common problem with current sprinkler systems is the tendency to over/under-spray in a
set circular or semi-circular pattern. This can lead to overlapping of watered areas, or the
watering of sidewalks, hedges, and other obstacles. Water conservation is an important
topic in society today and unnecessary consumption of water needs to be avoided.
The following report outlines the development of Smart-Spray; a programmable sprinkler
which is capable of spraying irregular patterns. This document outlines the purpose of the
device and the steps taken to design and create it. The mechanical, electrical and computer
programming developments are documented in full detail. The problems encountered and
the implemented solutions are also included. The end results of the product are discussed
and a recommendations section is also included which has suggestions for further
developments.
1.0 Introduction
1.1 Problem Description
Most in-ground sprinkler system sprays a set circular or semi-circular pattern. This leads
to overlapping areas being watered to cover the entire lawn, which can be seen in Figure 1.
It is not uncommon that a byproduct of this is areas such as sidewalks, hedges, and other
obstacles are watered unnecessarily. In modern society there is a concern with being
green and efficient, especially when dealing with natural resources. Unnecessary
consumption of water is a waste of one of our most important natural resources and should
be minimized. Restrictions on water consumption, especially when regarding lawn
maintenance, are becoming tighter. Communities all over North America have various
watering restrictions such as metered water consumption and restrictions on when watering
of lawns is appropriate. Breaking these rules will almost always cost the home or business
owner money. A sprinkler system that minimizes water consumption would help conserve
a natural resource as well as save home and business owners money.
Figure 1: Overspraying and Overlapping of Existing In-Ground Sprinklers
2
1.2 Project Description
Smart-Spray is a product that is able to change the distance and angular position of the inground sprinkler. Variations in spray distance are achieved through changing the water
flow using a custom built electronically controlled valve. The motor attached to the
sprinkler head is also electronically controlled and can spray any angular range from zero
to three-hundred sixty degrees.
This product will allow home and business owners to have an in-ground sprinkler system
that can be tailored to the shape of their lawn or whatever area they wish to be watered.
This will lead to minimizing water consumption, as only the appropriate areas are watered
and overlapping areas are reduced drastically. This can potentially save the customer
money as they are using less water when watering their lawn. While there may be some
economical savings, the primary motive for the development of Smart-Spray is green
initiative to reduce unnecessary water consumption.
1.3 Report Scope
This report contains the technical design process and specifications of the Smart-Spray inground sprinkler system. Problems encountered are analyzed and the implemented
solutions are discussed. Future updates are outlined in the recommendations section on
how to improve functionality as well as reducing cost. This report is targeted towards
readers with a general engineering background.
3
2.0 Project Development
This section focuses on how the problem was solved and contains the design concept and
how it was implemented. The electrical, mechanical, and software designs are addressed
as well as part selection with costs and justification.
2.1 Design Concept
The beta version of Smart-Spray is a self-contained in-ground cube with a sprinkler
protruding from the top. The box was fabricated using MDF and glued together. It is fed a
pair of leads providing the unit with power and a hose acting as a water supply.
Within the unit, the water supply is passed through a custom electronically controlled flow
valve before being piped to the sprinkler head. The electronic valve consists of a modified
gate valve connected to a stepper motor via a helical shaft coupler. These components are
all assembled together using a custom built bracket. This valve allows for the control of
the flow to the sprinkler that results in the change of spray distance.
The sprinkler head is held in place using a PVC pipe sleeve, which is mounted to the roof
of the box unit. A gear driven system is used to change the angular position of the spray.
A large diameter gear (~3in.) was bored out and attached concentrically to the sprinkler’s
body. This was driven using a second stepper motor whose shaft was also equipped with a
gear.
The leads for the stepper motors were wired to the PCB, which contained the
microprocessor controller for the system. The microprocessor contains the
preprogrammed sprinkling pattern and acts as the “brain” for the unit. It sends the angular
position and spray distance to the respective motors. The board was powered using the
two power leads, which feed the unit.
Before testing, all of the pipes and fittings were wrapped in Teflon tape to prevent leakage.
To protect the circuitry, a plastic water barrier was created and installed into the box.
Furthermore, the circuitry was shielded using a small Ziploc bag incase any water made it
past the barrier.
For the purposes of this course the developed product was intended to be merely a proof of
concept. The end result was a neatly contained unit that encompassed most of the design
ideas contained in this report. It will require a redesign and many adjustments before an
actual prototype can be created.
4
2.2 Part Selection
The following section contains the reasoning behind the parts selection for this project.
Table 1 displays the materials that were required for this project as well as the costs
associated:
Part
Sprinkler Head
Microprocessor
Micro Controller Programmer
PCB Board
Electronic Parts
Stepper Motors (x2)
Fluid Control Valve
Helical Shaft Coupler
Miscellaneous Parts
Cost
$30
Free
$40
Covered by ECE Dept.
$50
$82 ($41 ea.)
$6
$42
$38
Total
$288
Table 1: Materials and Costs
2.2.1 Sprinkler Head
The sprinkler assembly, an Orbit Saturn 3, was purchased from a hardware store. This is
an in-ground (pop-up head style) sprinkler with automatic rotation. The auto-rotation was
disabled, such that the angular position could be controlled with higher accuracy using a
motor driven system.
2.2.2 Microprocessor
The microprocessor chosen for this project was the Microchip PIC18F4550. The
PIC18F4550 was picked because it has two PWM outputs, USB support, and a free IDE
(Integrated Development Environment) provided by Microchip to use with their
microprocessors. Free samples of the PIC18F4550 were donated by Microchip.
2.2.3 Micro Controller Programmer
The micro controller programmer was used to connect to and program the microprocessor.
The model used was the PicKit2 which was purchased from Digi-Key. It was economical
and compatible with the chosen microprocessor.
5
2.2.4 PCB Board
The PCB board was custom built for this project. The Department of Electrical and
Computer Engineering took the design, created the board, and graciously offered to cover
the production costs.
2.2.5 Electronic Parts
Various electronic parts were needed for connecting the components on the PCB. These
included resistors, capacitors, diodes, USB ports, and various wires and connectors.
2.2.6 Stepper Motors
There were two stepper motors used in the design. One used to control the angular
position of the sprinkler head and the other was coupled to a valve and used to control the
flow. Despite their cost, the decision to use stepper motors was made due to their ability to
achieve high accuracy and resolution in their shaft positions. The motors were purchased
from SOC Machines, a North Vancouver based company. They were chosen because they
offered a high torque stepper motor at a reasonable price.
2.2.7 Fluid Control Valve
The fluid control valve was purchased from a hardware store. It was a standard gate valve
with a twisting top. The wheel handle was removed and the shaft was re-machined so it
could be attached to the driving motor.
After much experimentation, the gate model was chosen over other models, as it gave good
distance control with minimal required shaft torque. This was an important factor as the
motors have maximum torque ratings.
2.2.8 Helical Shaft Coupler
The flow valve and the controlling stepper motor were joined using a helical shaft coupler.
The selection of the coupler was made using a heavy influence from the machine shop. It
was purchased online from McMaster-Carr.
6
2.2.9 Miscellaneous Parts
There were many miscellaneous parts used in the final construction. These included hoses,
fittings, PVC piping, brackets, and MDF for creating the sprinkler enclosure. These
supplies were purchased as needed from a hardware store.
2.3 Electrical Design
The electrical design consisted of two main parts, the schematic design and the PCB layout
design.
2.3.1 Schematic Design
Once bipolar stepper motors were chosen to rotate the valve and the sprinkler, a driver
circuit had to be designed. Bipolar stepper motors have four wires that need to be
energized at different times. To move the motor one step the sequence shown in Table 2
had to be executed from left to right.
Wire
A
D
B
C
Voltage Sequence
0
1
1
0
1
1
0
0
1
0
0
1
0
0
1
1
Table 2: Stepper Motor Voltage Sequence
The initial plan was to generate the voltage sequence in software on the MCU
(Microcontroller Unit) then output it to the motor using power MOSFETS. To speed up
the design this method was not used since getting the proper timing for the voltage
sequence in software could be difficult to get correct.
The solution to this problem was to use a stepper motor driver chip that could output the
correct voltage sequence using a finite state machine. The driver chip was expensive but
drastically reduced design time to get the motors functioning.
2.3.1.1 L6208 Bipolar Motor Driver
The motor driver chip selected was the L6208 from STMicroelectronics (See project
website for Data Sheet). This chip receives a clock from the microcontroller and generates
the correct voltage sequence using digital logic. The L6208 has built in power MOSFETS
to drive the motor and it also has internal protection diodes to protect the board from
current spikes generated by the motor windings.
7
The L6208 has several configuration bits to set the rotation direction, full-step or half-step
mode, enable on or off, and reset among other things. For a full explanation of these
configuration bits please refer to the Programming section (specifically Section 2.5.2.1).
Two L6208 chips were used in the design; one for each stepper motor.
2.3.1.2 PIC18F4550 Microcontroller
After the L6208 was chosen a microcontroller had to be selected. It was decided that a PIC
MCU from Microchip would be used since there was a lot of documentation available for
their compilers and MCUs. Another deciding factor was that Microchip also supplied a
free IDE (Integrated Development Environment). A microcontroller that was capable of
outputting two PWM (Pulse Width Modulated) signals and could support USB
communication was needed. Each of the L6208 chips had six configuration pins that had
to be controlled by the MCU. Therefore the MCU needed at least twelve general purpose
I/O, two PWM outputs, USB support, and had to be from Microchip. The PIC18F4550
satisfied all the above requirements plus it had extra I/O pins and an on-board ADC (The
datasheet for the PIC18F4550 can be found on the project website).
The PIC18F4550 could be programmed using a serial connection, which eliminated the
need to use a high pin count interface such as JTAG, which many other MCUs use. Each
one of the PWM signals was used as the clock source for the L6208 motor driver. The
configuration bits on the L6208s were set using the general purpose I/O of the
PIC18F4550. Please refer to Appendix A for the electrical schematic.
2.3.2 PCB Layout Design
After finishing the electrical schematic, the PCB layout had to be designed. Surface mount
devices were chosen to minimize the size of the PCB leading to a reduction in costs. A
two-layer design was implemented since the component count for this project was fairly
low and it was drastically cheaper to keep it as a two-layer PCB. The L6208 used analog
circuitry to amplify the motor output and it used digital logic to create the waveforms. The
analog ground of each L6208 had to be connected to the digital ground of the PCB at one
central point to reduce the switching noise caused by the digital logic. Please refer to
Appendix B for the PCB layout.
8
Figure 2 shows the populated PCB with two L6208s, and the PIC18F4550. The eight
wires on the right hand side are connected to the two stepper motors.
Figure 2: Printed Circuit Board
2.4 Mechanical Design
2.4.1 Control Valve Bracket
The mechanical design began with the construction of the electronic valve assembly. With
the guidance of the mechanical engineering lab, a rough sketch of the assembly was
produced. This sketch was then turned into an AutoCad drawing that can be viewed in
Appendix C.
The bracket consisted of the valve and stepper motor being mounted to separate aluminum
plates. These two plates were then fastened together using a pair of standoffs. The two
plates were positioned such that the motor and valve shafts were directly aligned.
Since the shafts could not be perfectly aligned, a helical shaft coupler was implemented to
couple the shafts. The coupler can flex up to five degrees, which allows for imperfections
in the alignment of the two shafts. Furthermore the shaft of the valve changes height as it
spins, so the compression that the helical coupler offered was ideal.
9
The bottom plate, where the valve was mounted, was intentionally made much larger than
required. This was to allow room to mount the circuit board. Later on in the project, three
holes were drilled and tapped and the circuit board was mounted using standoffs. A final
image of the control valve bracket with the valve and stepper motor mounted on it can be
seen in Figure 3.
Figure 3: Control Valve Assembly
2.4.2 Sprinkler Gear Drive
The sprinkler gear drive was required to rotate the sprinkler through its angular positions.
This system consisted of a driving gear and a receiving gear. The driving gear was
mounted to a stepper motor and the receiving gear was attached to the sprinkler body.
The receiving gear was slightly larger in diameter than the sprinkler body and made of
plastic. With the aid of a mechanical engineering student, the gear was bored out to the
perfect size using a lathe. It was then attached to the sprinkler body. The tolerances
between the bored out gear and the sprinkler were so small that glue was not needed to
keep the gear in place. This proved to be advantageous, as it needed to be adjusted up and
down the length of the sprinkler during the mounting process.
The next step for the gear drive system was to mount the second gear to the shaft of the
stepper motor. This process was also done with a lathe and the assistance of a mechanical
engineering student and the shop technician. A flat plate with a central sleeve was
manufactured. The sleeve was the exact diameter of the stepper motor shaft and was used
to mount the assembly to the motor. A second flat plate was produced and used as a
backing for the gear. The second plastic gear was placed between the two plates and the
three pieces were fastened together. Next the assembly was mounted to the motor shaft
and the two were secured together.
10
Extreme attention to detail and care was exercised in both of the gear mounting operations,
for it was important that the gears were concentrically mounted. If mounted incorrectly,
the distance between the receiving gear and the driving gear could vary as the sprinkler
turned, which would lead to complete separation or jamming of the teeth.
2.4.3 Housing Unit & Sprinkler Mount
The housing unit for the Smart-Spray was a ten-inch tall box made out of MDF with a one
foot square base. One side of the box was left open for viewing and testing purposes.
Holes were bored out in the top for the sprinkler and in the side for the hose and power
leads.
A cylindrical sleeve was produced to house and
mount the sprinkler body. The sleeve was used to
keep the sprinkler rigidly in place. The diameter of
the sleeve was slightly larger than the sprinkler body
to minimize friction. The sleeve consisted of two
short pieces of PVC piping which were joined
together using two steel brackets. A large gap was
needed between the two sections of pipe to allow for
the gear drive connection. Once built, the sleeve was
mounted to the ceiling inside the box.
Figure 4: Completed Housing
and Connected Circuit
With the sleeve mounted, the sprinkler was put in
place. The stepper motor with the driving gear was
placed inside the box and mounted to the ceiling. The
motor had to be carefully mounted to ensure that the
marginal amount of play between the sprinkler and
sleeve didn’t affect the meshing of the gear teeth.
The electronically controlled valve setup with mounted PCB was connected to the motor
leads and sprinkler piping. With the housing and mounting completed and the circuit
connected, the testing of the Smart-Spray could begin. Figure 4 shows the inside of the
Smart-Spray housing.
11
2.5 Software Design
After the board design was completed, early code development could begin. Initial tests
were done to configure the device and check all inputs and outputs to verify the PCB board
was functioning correctly. All programming for this project was performed in the HI-Tech
C development environment.
2.5.1 Initial Testing of Stepper Motor Control
A critical step in programming was to ensure the L6208 stepper motor drivers were
working and receiving all the inputs necessary to function as designed. Each stepper motor
driver had 5 basic inputs from the microprocessor:
1. Clockwise/Counter-Clockwise Control Bit
2. Reset Control Bit
3. Half Step or Full Step Control Bit
4. Enable Bit
5. Clock Input
2.5.1.1 Clockwise/Counter-Clockwise Control Bit
When set high, the stepper motor moved in a counter-clockwise rotation; when set low, the
stepper motor moved in a clockwise rotation. This allowed control over the position of the
sprinkler head, as well as closing and opening the valve.
2.5.1.2 Reset Control Bit
The reset control bit was used to reset the finite state machine within the motor driver. The
bit was set to high so that the FSM would restart from the initial state after each iteration.
2.5.1.3 Half Step or Full Step Control Bit
When this control bit was set to high, it allowed the motor to move in half step mode.
Although this bit was not used in the final design, it could be implemented to further
increase the precision of closing and opening the valve. The stepper motor moved in 1.8°
increments in full step mode. Operating in half step mode, the step size would be reduced
to 0.9°.
12
2.5.1.4 Enable Bit
The enable bit allowed for the motor to be stopped and started. When high, the motor
moved according to the previously described settings; when low the motor stopped. This
bit helped for a more accurate path to be sprayed because the sprinkler head could be
stopped, to allow for pressure adjustments, and then continue moving.
2.5.1.5 Clock Input
One of the most critical aspects of the stepper motor driver is the clock input. The clock
input, a simple PWM from the microprocessor, was fed into the stepper driver to create the
4 necessary outputs for the stepper motor. The frequency of the PWM set the speed of the
stepper motor. After receiving the necessary inputs, the driver was to output the following
waveform to run the stepper motor as bipolar in full step drive.
Figure 5: Stepper Motor Waveform Operating as Bipolar in Full Step Drive
In this design the I/O ports on the microprocessor were all set to output. This can be easily
changed for future design considerations to add modules as needed. The initial code was
used to test each output by individually setting the bits to high and low, and viewing the
output at the pins.
2.5.2 The Program
The design of the main program can be broken into four main sections, which include: the
configuration of the microprocessor, initializing the system, moving the sprinkler motor,
and moving the valve motor. A main function was also created to contain the infinite loop
that runs the code continuously.
13
2.5.2.1 Setting the Configuration
To configure the microprocessor the configuration registers had to be set to meet the
requirements of the project. The first configuration register, Config1, was set to use the
internal oscillator to produce a clock of 250 KHz. Using the OpenPWM function, a 15 Hz
PWM was created. The OpenPWM function used the internal clock and a timer to set the
period to 1/15Hz. The equation that was provided in the data-sheet to calculate the period
was:
Solving for the period, a value of approximately 255 was obtained.
The other configuration register being edited was the Config3. This register sets the
MCLR bit to 1, which enabled the microprocessor to clear the memory before loading the
new configuration. Every other bit was set to 0 to run in higher power operation mode.
2.5.2.2 Initializing the System
To initialize the system, all I/O pins for the microprocessor were set to output by setting
the tri-state registers A to E to 0 (setting to 1 is input). All ports were then cleared before
beginning any of the processes to ensure unwanted data is not accidentally stored.
2.5.2.3 Moving the Sprinkler Motor
To move the sprinkler, a simple MoveSprinklerMotor function was called from the main
function. Each call of the function moved the sprinkler head by 1.8°. The
MoveSprinklerMotor function set the enable, reset, and half/full step bit high. The
OpenPWM function was then called to send the PWM to the motor. A simple delay to
allow the motor to turn for 3 steps (account for the gearing ratio) was invoked and then the
PWM was closed to stop motor.
14
2.5.2.4 Moving the Valve Motor
The MoveValveMotor function read in values of an array for the number of steps to turn
the valve. The values obtained in the array are the number of steps from the zero position.
The function read in the old value and the new value to calculate the new number of steps
and whether the motor needed to open or close the valve. The function compared the old
value to the new value and chose between three possible options:
1. If the old value was smaller than the new value, the CW/CCW bit was set to low to
open the valve to increase pressure. The number of steps was calculated by subtracting the
old value from the new value. The PWM was then set to stay open for the number of
required steps and closed at the end to stop the motor.
2. If the new value was smaller than the old value, the CW/CCW bit was set to high to
close the valve to decrease pressure. The number of steps was calculated by subtracting
the new value from the old value. The PWM was then set to stay open for the number of
required steps and closed at the end to stop the motor.
3. The final case was if the old value was equal to the new value, the PWM was not sent
and exits the function allowing the pressure to remain the same.
2.5.2.5 The Main Function
The main function contained the array values and the infinite while loop that ran the code.
The main function called the initialize function to setup the system and then entered the
while loop. The array contained all the values for the step size to open and close the valve.
The size of the array was used to set the size of the ‘for’ loop to call each function the
correct number of times.
A conditional statement was used to compare the value of the new position with the last
position to control the order in which the MoveSprinklerMotor and MoveValveMotor
functions were called. When increasing the pressure, the sprinkler moved to the new
position before adjusting spray distance. When decreasing the pressure, the valve motor
was activated first and was followed by the sprinkler.
For demonstration purposes, another conditional statement was added to ensure the
sprinkler changed direction when the main ‘for loop’ reached the end of the array.
A block diagram for the main program and the source code can be found in Appendix D
and E, respectively
15
3.0 Results
Going from the initial conception of the design to the end result, many problems were
encountered but the successes were far greater. As problems were encountered, the initial
design evolved and went through many iterations. The goal of regulating the water
pressure of an in-ground sprinkler to control the distance was accomplished. The
controllable range was approximately six feet. This value was respectable but not as large
as expected. Under optimal operating conditions, the distance was successfully controlled
anywhere between 19’ to 25’ at any desired angle over a full 360°. The sprinkler, if left
alone, would spin in circles continuously adjusting the distance at specific points as
programmed.
3.1.1 Demonstration Results
A demonstration routine was also setup for clear visual proof that the final product worked
as intended. This routine consisted of a quarter circle that had a section in the middle spray
at a shorter distance leading to a ‘V’ shape notch in the arc. This demonstration clearly
showed full control over the spray distance and angle. The results from this demonstration
made it easy to see that more intricate patterns could be implemented.
3.1.2 Mechanical Results
The mechanical design functioned as expected, but only at a specific water pressure.
During the demonstration at the Project Presentations in the Engineering Lab Wing the unit
was run off of the available water lines. These lines were found to be constantly changing
pressure, which lead to erratic output from the sprinkler. When the pressure was too high,
the sprinkler would be pushed backwards slightly adding extra resistance causing the gears
to occasionally skip. Besides the issue with varying water pressure the mechanical
systems functioned as expected.
3.1.3 Electrical Results
The electrical design almost functioned without any issues. The only problem encountered
with the electronics was purchasing and installing underrated resistors on the circuit board.
This problem was immediately corrected and the electrical system functioned as expected.
All problems that were encountered throughout the project were overcome and a working
prototype of the Smart-Spray sprinkler system was created. The Smart-Spray won first
place for the IEEE award based on poster presentation on July 23rd, 2010. With further
development the Smart-Spray could become more reliable, more adjustable, less
expensive, and more streamlined.
16
4.0 Problems Encountered
Many problems were encountered throughout the project ranging from sourcing parts to
being unable to get the motor to spin. Finding the parts required at a reasonable cost for
the design was a limiting factor for progress.
4.1 Mechanical
During the building process, piecing together the various components to build the sprinkler
system proved to be much harder than expected. Most of the parts had to be custom made
or modified, at an economical price, to perform the function needed.
4.1.1 Flow Control Valve
One major problem that was encountered was the inability to find an electronically
controllable flow valve at an affordable price. The typical price range that had been quoted
was roughly $1,100. This was out of budget for the project and obviously intended for
industrial application. To rectify this problem, a custom flow controller was created using
a standard gate valve controlled with a stepper motor.
4.1.1.1 Torque Requirements
After implementing the aforementioned solution, the motor controller valve did function as
expected; however, it was not able to achieve the desired range on the valve. The torque
requirement to fully close and open the valve was too large for the stepper motor being
used.
The criteria for choosing the valve was based on the minimum amount of torque required
to open and close it; manually tested by hand in the hardware store. Once a valve was
decided upon, lab measurements were taken to find the max torque required to open and
close the valve. The torque required was roughly measured to be 0.7 Nm. From this
number, an appropriately rated stepper motor (0.8 Nm torque rating) was purchased and
the assembly was completed.
After purchasing the motor and testing it to ensure full control, it was noticed that it was
unable to achieve the desired range. The laboratory measurements were taken at an
estimation of a fully closed position. With no water flowing through it and a requirement
to rotate to a high torque position, it was found that the stepper motor did not have the
required torque to achieve optimal results.
17
4.1.1.2 Water Pressure Control
Once the apparatus was fully assembled, a very small amount of water pressure control
was obtainable. Near the fully closed position, which was outside the controllable range,
the spray distance was greatly affected by very minimal adjustments of the valve. The
model was barely encroaching on the window of adjustable pressure, which is the main
reason why the controllable spray distances were not as drastic as expected. Despite this
shortcoming, the spray distance could be adjusted by a noticeable amount.
When using the Smart-Spray for the first time it became apparent that a consistent water
pressure was required for consistent results. This proved to be very difficult to achieve, as
water pressure is different at each location and changes frequently.
Initially the project proposal was setup to include a feedback system utilizing a flow sensor
and the control valve, which would ensure a consistent flow. This would effectively
eliminate the problems encountered with the changing pressures. However, the associated
cost of a flow sensor was out of budget (~$600) and thus could not be included.
The solution was to run tests on an isolated tap with no other sources running; this
situation was not available during the project demonstration.
4.1.1.3 Solution
Solutions for the flow control valve problems are outlined in the Recommendations section
(Section 5.1 specifically).
4.1.2 Sprinkler Rotation
Another main mechanical problem was the inability to rotate the sprinkler consistently.
The housing created to contain the sprinkler ended up being slightly misaligned which
unfortunately introduced too much play between the sprinkler and the sleeve. This
coupled with the sprinklers’ gear becoming slightly elliptical created meshing problems
with the gear drive.
Two points between the gears on opposite sides were very loosely connected due to the
misalignment of the housing and the slightly elliptical shape of the sprinklers’ gear.
Moreover, two more points, 90 degrees out of phase from the previous two, were very
firmly interconnected. The loosely interconnected teeth on the gears caused them to skip
and the tightly meshed teeth created friction in the system that the stepper motor could not
overcome.
18
4.1.2.1 Solution
The distance between the two gears was manipulated to find the optimal operating point
and we were able to find a spot that was perfect for the full rotation. This proved to be
quite temperamental and after the initial testing and some shifting some gear slippage
arose. Adjustments needed to be made each time the Smart-Spray system was moved.
4.1.3 Water Leakage
Water leakage from the Smart Spray unit proved to be a concern. After protecting the
electrical components with shielding, it was noticed that the source of the leakage was the
spinning coupler used to allow the sprinkler to spin while attached to a hose. This was a
pivotal component to the design and without it the sprinkler would not be able to spin. The
leak was not fixable as it is a byproduct of a spinning coupler when combined with water
pressure.
4.1.3.1 Solution
The water shielding built between the PCB and electronic valve setup and the sprinkler
proved to be quite effective. Another solution that reduces leakage is discussed in the
Recommendations section (Section 5.1.1).
4.2 Electrical & Programming
4.2.1 Shorted PCB Trace
There were some initial problems with the PCB design that were causing undesired results.
One trace had been shorted to another trace when the PCB had been manufactured. This
was causing the line to be pulled down to about 1.2V from 5V.
4.2.1.1 Solution
To remedy this issue the shorted trace was cut. The line was then operating at 5V again.
19
4.2.2 Pins Swapped in PCB Design
Two pins had been swapped in the PCB design.
4.2.2.1 Solution
Cutting the traces and connecting the proper pins with a small jumper wire fixed this.
4.2.3 L6208 Sense Resistors
The L6208 driver chips needed some low resistance sense resistors for proper operation.
The original resistors did not have a high enough power rating and burnt the first time the
motors were turned on.
4.2.3.1 Solution
Using large 5W resistors instead of 1/4W resistors fixed this.
4.2.4 Motor Rotation
A few problems were encountered while getting the motors to rotate. Initially the PWM
frequency was set too high for the motor. The motor would make a whining sound and
would not spin. The wires on the stepper motor were also not connected properly at first
that also caused the motor to whine and refuse to spin.
4.2.4.1 Solution
To lower the PWM frequency the MCU clock frequency had to be lowered to 250KHz.
This was low enough for the motor to operate without any problems once the motors were
wired correctly.
20
5.0 Recommendations
Throughout the course of this project several future plans and design improvements were
already being discussed. The primary problem to address would be to improve the
mechanics of the design to make it more reliable. A secondary initiative would be to
reduce the cost of the product to hopefully make a more economical solution that could be
marketed. Other improvements to be discussed are PCB positioning, USB functionality,
and a Graphical User Interface (GUI).
5.1 Mechanical Updates
5.1.1 Mechanical Drive System
The mechanical system driving the angular position of the sprinkler needs to be upgraded.
Ideally, a custom built sprinkler with an internal gear drive designed to be spun with an
external motor would be used. A shaft protruding from the body of the sprinkler would be
used for changing the angular position. Only the pop-up section of the sprinkler would
spin, which would provide isolation from the surrounding environment. This would ensure
that the torque required to spin the sprinkler stays constant, as no external factors would
come into play.
In the current design, the alignment of the housing and gears affected the torque and played
a major role in the reliability of the system. With the proposed design, the body of the
sprinkler would remain stationary and thus could be firmly secured in place. This would
eliminate the sleeve apparatus and the external driving gears. Furthermore, with the
elimination of the rotating sprinkler housing, the hose coupler, which allowed for the
spinning motion, could be eliminated. This would be a major benefit as the spinning
coupler was a major water leak source.
5.1.2 DC Motors with Optical Shaft Encoders
Costs are a major area for improvement. The stepper motors were expensive, but they
were chosen due to their precision and accuracy of their positioning. This was a major
requirement for the design.
A solution to this would be to replace the stepper motors with a combination of optical
shaft encoders coupled with DC motors. The optical shaft encoder would be implemented
to keep track of the exact location of the motor. Not only would this reduce the overall
cost but also it would allow the self-correction of the motor position. For example, with
the current design, if the sprinkler is stalled by an external source, such as someone
holding it, the processor has no way knowing this. With the optical shaft encoder;
21
however, the processor will be able to read in the exact position at all times eliminating
this problem.
The use of DC motors not only removes the costly stepper motors but also eliminates the
expensive hardware required to run them. The implementation of DC motors along with
the optical shaft encoders will drastically reduce costs of the design.
5.1.3 Control Valve Modifications
Improvements to the custom electronic control valve would be ideal. To eliminate the
helical coupler connecting the valve to the stepper motor, a worm gear driven system could
be used. The helical coupler was expensive so costs again would be reduced.
The shaft of the valve would be fitted with a normal gear and the motor shaft would have a
worm gear along the length of it. The motor would be mounted horizontally such that the
worm gear meshes with the normal gear on the valve.
The worm gear system would dramatically increase the driving torque, which would allow
valve to be controlled through a wider range of previously unattainable positions. Another
benefit to the worm gear drive would be that it gives a much higher position resolution.
The gear ratio would step down drastically, which results in a vast increase in the
precision and accuracy of the valve position.
5.1.4 Custom Built Valve
There was a flaw with the store-bought valve; the fact that the valve had a small window in
which the water pressure could be controlled. To correct this, rather than use an over the
counter garden hose valve, a custom valve should be built. This would require some
research and manufacturing; however, the results could greatly impact the performance of
the product.
The custom valve should be designed to offer a variable range of pressures over a larger
control range. This could be achieved using a knife valve and experimenting with various
flow apertures. With a more linear system in place operating over a larger range, it would
be simple to accurately control the spray radius.
22
5.1.5 Pressure Regulator
One problem that was encountered throughout the course of testing the Smart-Spray
system was the variability that exists in water pressure. Purchasing and incorporating a
pressure regulator into the design could correct this. These regulators already exist at most
hardware stores and it would be simple to include one, or custom build one into the final
product. This would ensure an accurate and consistent product.
5.2 Electrical & Programming Updates
5.2.1 Relocation of Electronics
To reduce the size of our sprinkler system and increase the safety, all of the PCB boards
could be relocated away from the sprinklers. The system would have a main control box
housing one PCB board and connectivity ports which would communicate with all the
sprinklers. From this control box, a small tech cable would be run underground, alongside
the water supply, to each sprinkler for the motor controls and optical encoder readings.
With the PCB boards removed, the size of the Smart-Spray housing can be greatly
reduced. The only components left in the housing would be the two driving motors with
their shaft encoders, the valve and the sprinkler itself. For a marketable version, this
housing would be custom molded out of plastic.
Another major benefit to relocating the circuit boards to a central unit would be the
improvement of safety and improved accessibility. With the boards away from the
sprinklers and water, there would be no concern about leakage and electrical shorts.
Furthermore with all the electronics in one place and on one board, troubleshooting and
repair are made much simpler. With an above ground control box, there would be no need
to ever dig up the sprinkler unit.
5.2.2 Program Loading Capabilities & GUI
With the current design, to change the pattern of the Smart-Spray the micro controller
programmer would need to be connected to the pins on the PCB and have the code
downloaded onto the microprocessor. This can be improved by using the USB port that is
currently connected to the PCB board. If the relocation of the electronics in the
aforementioned section included a control box a USB connection would be a lot more
practical than a micro controller programmer. A wireless chip could even be installed in
the control box to allow for updating the system from a desktop computer.
23
Currently the position values for either stepper motor are stored into an array in the main
program. A graphical user interface (GUI) could be created to allow someone without
programming knowledge to update the pattern being sprayed by the Smart-Spray. This
interface could be constructed in two different ways:
1.
A table of values that correspond to angular position and distance. The user would be
able to enter in as many or as few key points as they wanted. A program could be
created to interpolate between these points to allow for a smooth transition.
2.
A graphical approach could be considered and a simple program could be developed
to allow users to draw their lawn to scale, place sprinkler heads, and design the pattern
being sprayed from each.
Either of these methods could include an analysis program that measures the amount of
water being used by each sprinkler for user-defined time intervals. This would allow users
in areas where watering is metered or under restrictions to manage their consumption and
possibly avoid extra charges or fines.
24
6.0 Conclusions
The Smart-Spray prototype produced was able to spray a preprogrammed pattern by
controlling the angular position and the distance (via pressure). This leads to the ability to
increase the efficiency of lawn watering by lowering water consumption; which is an
important green initiative. With further developments this project could have very
practical applications, and possibly be an economical as well as green product.
The project was considered by the group members to be a success and a worthwhile
concept. The process proved to be extremely challenging but very rewarding.
25
7.0 References
[1] “Unipolar/Bipolar Connections,”. [Online].
Available:http://www.probotix.com/stepper_motors/unipolar_bipolar/ [Accessed: Jun. 5,
2010]
26
Appendix A – Electrical Schematic
27
Appendix B – PCB Layout
28
Appendix C – Valve Design Drawing
29
Appendix D – Block Diagram of Main Program
While
Sprinkler
CCW or
CW
For arraySize
No
Is Old > New
Yes
Move Sprinkler
Move Valve
Move Valve
Move Sprinkler
No
K<Arraysize
Yes
K++
30
Appendix E – Source Code
#ifndef MAIN_C
#define MAIN_C
// Global includes
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// Local
"stdio.h"
"stdlib.h"
"htc.h"
"pwm.h"
"delay.h"
"delay.c"
"timers.h"
"pw1open.c"
"pw2open.c"
"pw1setdc.c"
"pw2setdc.c"
"pw1close.c"
"topen.c"
includes
#include "HardwareProfile.h"
//__CONFIG(1, USBPLL & IESODIS & FCMDIS & HSPLL & CPUDIV6 & PLLDIV5);
__CONFIG(1, 0x0000111100111100);
// Config word 2
__CONFIG(2, VREGEN & PWRTDIS & BOREN & BORV20 & WDTDIS & WDTPS32K);
// Config word 3
__CONFIG(3,0x1000000);
// Config word 4
__CONFIG(4, XINSTDIS & STVREN & LVPDIS & ICPORTDIS & DEBUGDIS);
// Config word 5, 6 and 7 (protection configuration)
__CONFIG(5, UNPROTECT);
__CONFIG(6, UNPROTECT);
__CONFIG(7, UNPROTECT);
// local prototypes
static void InitialiseSystem(void);
static void MoveSprinklerMotor(int step);//int sprinklerSteps);
static void MoveValveMotor(int valveSteps, int oldstep);
// Main function
void main(void)
{
//Array of the steps from the zero position (negative values were
use to make sure the valve closed as much as possible)
int Steps[] = {0, -20, 120, 120, 120, 120, 120, 120,120, 120, -20
,-20 ,-20,-20, -20,-20,-20,120, 120, 120, 120, 120, 120, 120, 120, 20,0};
int arraysize = sizeof(Steps)/sizeof(int);
//Initialise System
InitialiseSystem();
int i;
int step=3;
//Set the defualt direction
CW_CCW =HIGH;
31
Appendix E – Source Code
//Start of while loop
while(1)
{
int k = 0;
i=1;
//Initialize for loop to move the motor
for (k; k < arraysize-1; k++){
//If the array has reached the end and the CCW is high set it
low
if((k==arraysize-2) && (CW_CCW==HIGH))
CW_CCW =LOW;
//If the array has reached the end and the CCW is high set it
high
else if((k==arraysize-2) && (CW_CCW==LOW)){
CW_CCW =HIGH;
}
//If the new value is less then old value move valve motor
first
if (Steps[k] >= Steps[k+1]){
MoveValveMotor(Steps[k+1],Steps[k]);
MoveSprinklerMotor(step);
}
//If the new value is more then old value move valve motor
second
else
{
MoveSprinklerMotor(step);
MoveValveMotor(Steps[k+1],Steps[k]);
}
}
}
}
// Initialise system function
static void InitialiseSystem(void)
{
OpenTimer2(TIMER_INT_OFF & T2_PS_1_16 & T2_POST_1_1); //Set timer2
prescaler to 1:16, set interrupts OFF
ADCON1 = 0x0F; // Default all pins to digital
// Configure ports as inputs (1) or outputs(0)
TRISA = 0b00000000;
TRISB = 0b00000000;
TRISC = 0b00000000;
TRISD = 0b00000000;
TRISE = 0b00000000;
// Clear all ports
PORTA = 0b00000000;
PORTB = 0b00000000;
PORTC = 0b00000000;
PORTD = 0b00000000;
32
Appendix E – Source Code
PORTE = 0b00000000;
}
static void MoveSprinklerMotor(int step){
RESETM = HIGH;
ENABLE = HIGH;
CONTROL = HIGH;
//Set the PWM frequency to 15Hz
OpenPWM1(255); //PWMperiod = (255+1)*4*(1/2.49e5)*16) = 1/15.2Hz
SetDCPWM1(33170); //Setting duty cycle: DC = 33170 *(1/20e6)) 50%DC
DelayMs(step);//motor moves 5.4 degrees for sprinkler to move 3.6
ClosePWM1();//Stop motor
}
static void MoveValveMotor(int valveSteps, int oldstep){
//Set the intiial state
CW_CCW1 = HIGH;
HALF_FULL1 = LOW;
RESETM1 = HIGH;
//Define the old value and new value and stepsize
int old = oldstep;
int new = valveSteps;
int stepsize = 0;
//compare the old value to new value
if (old > new) {
//close valve
CW_CCW1 = LOW;
stepsize = old - new;
ENABLE1 = HIGH;
}
else if (new > old){
CW_CCW1 = HIGH;
//open valve
stepsize = new - old;
ENABLE1 = HIGH;
}
else if (new == old){
// do nothing
stepsize = 0;
ENABLE1 = LOW;
}
JP3=1;
int index;
//Leave the motor on for the desired number of steps
for(index = 0; index < stepsize;index++){
OpenPWM2(255); //PWMperiod = (255+1)*4*(1/clock)*16)
SetDCPWM2(33170); //Set duty cycle: DC =33170*(1/20e6)) 50%DC
DelayMs(1);
}
ClosePWM2();//Close PWM stop motor
}
33
Appendix E – Source Code
#endif
#ifndef HARDWARE_PROFILE_H
#define HARDWARE_PROFILE_H
// Common useful definitions
#define HIGH
1
#define LOW
0
#define WRITE
0
#define READ
1
// PIC to hardware pin mapping
#define JP3 RB1
//Motor
#define
#define
#define
#define
#define
Driver L6208
CW_CCW RD5
CONTROL RE1
HALF_FULL RA4
ENABLE RE0
RESETM RA5
//Motor Driver 1 L6208
#define CW_CCW1 RA2
#define CONTROL1 RA3
#define HALF_FULL1 RB5
#define ENABLE1 RB4
#define RESETM1 RD6
// I/O pin definitions
//define INPUT_PIN 1
//#define OUTPUT_PIN 0
#endif
34
Appendix F – Progress Report #1
35
Appendix G – Progress Report #2
36
Download