Escolar Documentos
Profissional Documentos
Cultura Documentos
UNIVERSITY OF DUNDEE
DIEGO VARALDA DE ALMEIDA -
LIST OF SYMBOLS
Current, [A]
Resistance, [ ]
Voltage, [V]
LIST OF FIGURES
Figure 1 - Diagram fragment ................................................................................................................................... 6
Figure 2 - LED indicating device ON ......................................................................................................................... 7
Figure 3 - 7-Segment display ................................................................................................................................... 8
Figure 4 - Display connected with the BASIC stamp ................................................................................................ 9
Figure 5 - Diagram fragment ................................................................................................................................. 12
Figure 6 - Diagram fragment ................................................................................................................................. 14
Figure 7 - A garden sprinkler rotated by the reaction of the water jets. ............................................................... 17
SUMMARY
1
INTRODUCTION ......................................................................................................................... 5
1.1
1.2
DEVELOPMENT.......................................................................................................................... 6
2.1
SPRINKLER ...................................................................................................................................... 6
2.2
2.2.1
2.2.2
2.2.3
2.2.4
2.2.5
Timer ............................................................................................................................... 12
2.2.6
3.2
3.3
1 INTRODUCTION
Electronics nowadays is present in most products used by people. Some are more
advanced, such as mobile and computers, provides convenience, entertainment and leisure for
the consumer, and most of these devices have a microcontroller incorporated.
A microcontroller (sometimes abbreviated C, uC or MCU) is a small computer on a
single integrated circuit containing a processor core, memory, and programmable input/output
peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on
chip, as well as a typically small amount of RAM.
A very used microcontroller is the Basic Stamp. Produced by the Parallax Inc., the Basic
Stamp is a tiny microcontroller easily programmable and widely used in technology education
and in industries including manufacturing, process control, and robotics
2 DEVELOPMENT
2.1 SPRINKLER
Since the number of pins in a Basic stamp microcontroller is limited, the functionalities
of the project is limited as well. The features that the sprinkler will have are the following:
Setting working time: the sprinkler will turn off after the set time is up.
Setting sprinkler velocity: The motor that controls the rotation of the sprinkler
will have many a range of rotation speed. The rotation of motor will determine
how far the water will reaches. The water sweep radius will be larger for a
higher motor speed
Setting Automatic speed for the sprinkler
In section 3, will be discussed some improvements that the sprinkler device may have.
(Author)
All section of the program needs to verify if the switch is in the on position, if not the
microcontroller needs to turn off all output pins. The command that checks the value of a pin
in a microcontroller is the IN[pin_number] command. This command basically transform a pin
in input and checks if the value is low or high. The value is stored in a variable.
Program Fragment 1
Because the program needs to check whether the switch is on or not multiple times, a
subroutine was used to write that part of the program.
A subroutine is a set of instructions designed to perform a frequently used operation
within a program. In PBasic it is possible to call a subroutine at any time by using the command
GOSUB [tag].
(Author)
V IxR
(2.1)
For a green LED a common resistance used is 470. This resistor will be used for all
LED within the device.
Since this LED is related with the slide switch and only turns on if the pin which the
switch is connected (Pin4) is accusing 1, then the code that turns the LED on will be together
in the same subroutine of the slide switch (see Program Fragment 1).
Another application for this LED will be discussed on section 2.2.4
The DP shown in Figure 4 - Display connected with the BASIC stamp is a dot point, an
application for this segment is presented in section Error! Reference source not found.. The
igure below shows the diagram for the display connected with the microcontroller.
If we wanted, for example, the number 2 to be displayed we could turn on the segments
A, B, G, E, and D and turn off all the other, the program for the number two would be:
Program Fragment 2
Although simpler to understand, this approach is laborious and time consuming, besides
it lets the code slow to be read by the BASIC stamp. There is a better alternative for displays.
We first clean the display, then we set the pins 8 to 15 to be output, as can be seen below.
Program Fragment 3
10
Then the command LOOKUP is used to search a number stored in a variable in a set of
binary codes. The binary code correspondent to the number is then read by the microcontroller,
setting the pins 8 to 15 high or low depending on the binary number. The fragment below shows
another subroutine with the Lookup command that display the number on the 7-segment
display.
Program Fragment 4
Each number in the binary sequence correspond to a pin in the microcontroller. For
instance the first number that is displayed is the number zero and corresponds to 11101111.
The first 1 of this sequence of character is the pin 8, the second number (1) corresponds to the
pin 9 and so on until the last number that correspond to the pin 15.
If we wanted the letter A to be displayed, we would have to set as HIGH (1) the pins 8,
9, 10, 11, 13 and 15. All the other would be LOW (0). The signal % is to notify the
microcontroller that the sequence of digits is in binary form, rather than hexadecimal.
The table below shows all characters used by the sprinkler device and the corresponding
binary code.
#
CHARACTER
BINARY CODE
CHARACTER
BINARY CODE
0
1
2
3
4
5
6
7
8
9
10
11
0.
1.
2.
3.
4.
5.
6.
7.
8.
9.
0
1
%11101111
%10001100
%11011011
%11011110
%10111100
%01111110
%01111111
%11001100
%11111111
%11111110
%11100111
%10000100
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
A
S
t
%11010011
%11010110
%10110100
%01110110
%01110111
%11000100
%11110111
%11110110
%11110101
%01110110
%00110011
11
Program Fragment 5
12
2.2.5 Timer
Another feature of the device is a timer which has the function to turn the sprinkler off
after a time set by the user. When the user chooses the sprinklers rotation and presses the push
button Set Parameter, the display changes immediately and starts to exhibit a letter t,
indicating the user to choose how long he wants the sprinkler to be working.
Once the microcontroller detects a variation of the potentiometer (when the user starts
spinning the potentiometer to select the time) the display will change from the letter t to a
number going from 1 to 9. Since the display is limited for one digit only, the DP will represent
the number zero, so when the user rotates the potentiometer to choose the time, the first 9
numbers shown will have the DP segment on. If the DP is on it means that the time chosen is
the number shown on the display times 10 (E.g.: suppose the user chooses the number 3
3x10 =30 minutes). If the DP is not on (it will be off after the user exceed 90 minutes), it means
the time shown on the display is in hours rather than in minutes and will start from 2 hours to 9
hours. This increases significantly the range of choices.
After selecting the minutes or hours that the user wants the device to be working, he
must to press the button Set Time again, so then the time chosen will be stored in the
microcontrollers memory as a variable (working_time). The figure below shows the electronic
diagram for the Set time button connected with the microcontrollers Pin2.
13
Program Fragment 6
14
The PWM is a command which Converts a digital value to analogue output via pulse-width
modulation. The syntax of the command is: PWM Pin, Duty, Cycles, where:
Pin is a variable/constant/expression (0 15) that specifies the I/O pin to use. This pin will be
set to output mode initially then set to input mode when the command finishes.
Duty is a variable/constant/expression (0 - 255) that specifies the analog output level (0 to
5V).
Cycles is a variable/constant/expression (0 - 255) that specifies the duration of the PWM
signal.
The program below show the command PWM applied to vary the rotation of the motor
15
Program Fragment 7
Program Fragment 8
16
3 PROJECT IMPROVEMENTS
In this chapter will be discussed some of the improvements this project may have, to
become smarter and effectively marketable. Since some of these improvements are too complex
to demonstrate practically, the group decided not to deploy in the physical prototype, therefore,
it will be discussed theoretically only.
The following improvements, together with the other features in the circuit, require more
than 16 pins from the microcontroller, therefore a change of microcontroller to one with more
than 16 pins or the use of more than one microcontroller, should be considered in order to admit
all necessary features.
1 - Use a LCD display instead of a 7-segment display
2 - Controlling Output;
3 Moisture Sensor: To turn the device on and off automatically depending on the soil
humidity.
17
using a stepper motor, but nothing has been said about the water output. The original
mechanical sprinkler created in 18was designed to use the water for propulsion, letting the water
output generate a torque that would rotate the sprinkler. It means that the sprinklers rotation
can be controlled by the water output. The figure bellow shows the water leaving the sprinkler
and the direction of the force that the water propulsion applies in the sprinkler.
As illustrated, each arm of the sprinkler works as a jet that propels the arm in the
opposite direction of the water, rotating the sprinkler. This is the mean reason for avoiding the
use of motor in this region of the sprinkler, the motor should be strong enough to resist the
propulsion force, which would increase the energy consumption.
To control the output instead of the rotation is a more efficient approach and should be
considered as an improvement.
18
BIBLIOGRAPHY
Hood, Alan - Lecture Notes - University of Dundee, 2014.
Dr Jon Rogers - Components Notes - University of Dundee, 2014.
BASIC Stamp Syntax and Reference Manual V2.2 Parallax Inc. -
http://rotorywing.wikispaces.com/JET+PROPULSION+THEORY
November 8th
Accessed
on
19
20
21
22