Documente Academic
Documente Profesional
Documente Cultură
=
2
2
1
2 (Equ: 1)
This can be simplified to:
( )
+ =
A
L
R I T T S N Q
C H C
2 (Equ: 2)
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 9
4.4 TEC selection criteria
Because the actual differential equations are particularly unique for every system and have no
closed-form solution equations 1 and 2 are meant to only show the basic idea behind the
calculations. S, R and K are all temperature dependent and an assumption of constant properties can
result in large errors. (12)
To design a system using TECs manufacturing companies use powerful software to model the
complete system at the expected operating temperatures.(8) For the purposes of creating a prototype
a chart can be used to select a TEC that will operate in the desired range of expected temperatures.
For a small enclosed space to be effectively cooled in a temperature range typically found on earth
the Tellurex CZ1-1.4-127-1.14 was chosen. This device will easily operate from 20C to 30C for
our application. The Tellurex TEC is made up of 127 thermocouples and will pump 40 watts of heat
at 12 Volts with a current of 7 Amps. This should produce a 30C temperature drop across the TEC.
(13)
TEC manufactures provide a chart that helps in choosing an appropriate TEC. For the project
decisions for the operating voltage, current, temperature difference and heat moved were all made
from Figure 7. It is also possible to construct a similar graph using equations 1 or 2.
Figure 7: Performance of selected TEC (13)
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 10
The Basic dimensions of the Tellurex TEC are 44x40x3.3mm (LxWxH) and pictured below.
Figure 8: Tellurex TEC dimensions (13)
When choosing a TEC it is important to consider the device performance vs. input power. The
diagram below shows the relation ship between the two. Input power can be, Voltage (V), Current
(I) or the product of the two, P=IV. The performance of the device can be stated as (Th-Tc), QC or a
combination of these two parameters which is the case most of the time.
The terms T
MAX
, Q
MAX
, I
MAX
or V
MAX
refer to the point where the curve peaks. Operating at or
close to the peak of this curve is inefficient and devices should be designed to operate from 40% to
80% of maximum performance. (8)
Figure 9: Diagram of performance vs. Input power (8)
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 11
4.5 TEC cooling system design
The TEC cooling device used 4 TECs connected in a series cascade. This arrangement allows one
TEC to be cooled by the TEC placed directly on top. The results of a series cascade are the lower
TEC will perform closer to the expected performance regardless of deficiencies in the attached
heatsink.
Figure 10: TEC Cooling Overview
Figure 11: Picture of TEC Assembly
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 12
4.6 Housing and feeding system
The Design uses a coil to move the food to the dispensing hole. The food storage area is kept below
freezing by the TEC cooling device. In the front compartment the controlling electronics and LCD
display are housed. The housing has been constructed out of 11mm Plexiglas. The Plexiglas will
provide substantial insulation for the refrigerated area and is much easier to work with than metal.
For the prototype, the internal helical coil is made of brass due to limited supply of stainless steel
rods. The coil on the final product will be made of stainless steel.
Figure 12 is a diagram showing the principal mechanical components of the Automatic fish feeder.
The Plexiglas feeder housing has an opening on the base to dispense the food into the tank (the food
cubes fall into the tank). Two TECs are stacked together to obtain the required temperature
difference (-10C) between the cold plate inside the feeder housing and the heat sink outside. 4 TEC
units are used in total (two sets of stacked TECs). The TECs are firmly attached to both the stainless
steel cold plate inside the tank and the heat sink to maximize the heat transfer and cooling efficiency
(nylon screws are used to secure the cold plate to the heat sink). The gap between the cold plate and
heat sinks is sealed with foam to prevent condensation around the TECs. To avoid transferring heat
back to the cold plate nylon screws will be used to secure the cold plate to the heat sink. The stepper
motor is mounted into the housing using nylon screws as well. Silicone is used to seal off the gap
between the motor and Plexiglas isolating the inner chamber from the outside air. The lid of the cold
chamber is connected to the 12V power supply as required by the TECs inside. A two-pins pressure
socket mounted over the Plexiglas unit will connect to the heat sink assembly allowing for easy
maintenance of the food area.
The solvent used to glue the Plexiglas effectively welds the Plexiglas together; this is preferable to
drilling holes into the Plexiglas, which may weaken the material and cause cracks to form in this
area of higher mechanical stress.
The holes for the LCD display and buttons are cut from the front faceplate before it is welded. The
wall between of the electrical compartment is insulated to prevent condensation and improve the
LCD operation. Adequate room was left to accommodate a thin layer of neoprene foam if needed.
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 13
Figure 12: Mechanical drawing
FRONT VIEW
TOP VIEW
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 14
Figure 13: Automatic fish feeder housing and heatsink assembly
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 15
Figure 14: Automatic fish feeder - fully assembled
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 16
5. ELECTRICAL DESIGN
The AFF is controlled by a programmable microcontroller; this is a necessity for a design that
features an alphanumeric LCD display that interacts with the user. The design requires a stepper
motor to control screw forward/backward motion precisely
5.1 Component selection
5.1.1 LCD Display
The user interacts with the unit through a display/keyboard combination. A backlit LCD character
display will be used at it offers effective communication of words at a minimal cost. An LCD works
like a light valve Liquid crystals change lights polarization angle when subject to a voltage
differential. Figure 15 shows the structure of an LCD display.
Figure 15: Structure of a transmissive LCD display (16)
All LCD character displays are sold as modules. The most common LCD controllers used in these
modules are the Hitachi HD44780 and the Samsung KS0066 controllers.
1 Fr ont gl ass subst r at e
2 Ter mi nal
3 Segment el ect r ode
4 Common el ect r ode
5 Back gl ass subst r at e
6 Upper pol ar i zer
7 Or i ent at i on l ayer
8 seal ant
9 Li qui d cr yst al
10 Conduct i ng mat er i al
11 Seal ant
12 I nl et
13 Vi ewi ng Ar ea
Figure 16: HD44780-based 2x16 character display
The HD44780 controller is extensively
used in the industry and features a 4-bit or
8-bit parallel interface. Documentation and
sample code is provided for all
microcontroller families. KS0066-based
controllers offer both parallel and serial
communications, however, LCD displays
based on this controller are not very
common. Prices for HD44780-based
displays are lower and offer similar
performance to those based on the
KS0066.
The chosen module is a 16-character by 2-
line, transmissive backlit LCD display.
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 17
5.1.2 Microcontroller
Four types of Microcontrollers will be analyzed here. These microcontroller types were chosen due
to their low price, wide availability, and abundant support. All these microcontrollers are offered
with multiple built-in devices, memory types and sizes.
8051-based Microcontrollers
The 8051 is an 8 bit microcontroller originally developed by Intel in 1980. It is the world's most
popular microcontroller core, made by many independent manufacturers.
The 8051 is widely supported, with a a full range of free and commercial products available, its
architecture matches control system problems (boolean logic). This microcontroller is also the one
that is offered at the lowest cost, with multiple options integrated into the same chip.
Due to its internal architecture, the 8051 is difficult to program in machine language. Most of the
development products feature a C compiler. Development kits are priced from $50 to $100 U.S. (14)
PIC Microcontroller
The PIC microcontrollers were the first RISC microcontrollers. Although having few
instructions (e.g. 33 instructions for the 16C5X line versus over 90 for the Intel 8048), the PIC
line has a wealth of features included as part of the chip. The benefits of design simplicity are a very
small chip, small pin count, and very low power consumption.(15)
Unusually for microcontrollers, the Microchip PIC data books include complete documentation on
how to program the chips -- information that other manufacturers do not disclose easily. Parallax
offers PIC microcontrollers with a tokenized BASIC interpreter for fast development times
68xx series by Motorola
The popular 68hc11 is a powerful 8-bit data, 16-bit address microcontroller from Motorola (the sole
supplier) with an instruction set that is similar to the older 68xx parts (6801, 6805, 6809). The
68hc11 has a common memory architecture in which instructions, data, I/O, and timers all share the
same memory space.(15)
This microcontroller is widely used and extensively supported by Motorola. Machine programming
is much easier than the 8051nad PIC, and it can also be programmed in C.
The main characteristics of all microcontroller families can be seen in Table 2. From Table 2 we can
conclude that the Basic stamp module is excellent for fast prototyping, but it is unsuitable for mass
production due to its cost. Although Motorolas microcontroller is easy to program and use, the
development costs are steep, it is single sourced and programming information is secret. The 8051-
base microcontrollers and the PIC microcontrollers are used widely and are fully documented with a
great number of free development tools these two microcontrollers will be the most suitable for a
commercial low-scale project.
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 18
Table 2: Microcontroller characteristics (all prices in US$)
Device Price Ease of use Comments
8051-Based (ATMEL)
Software programming tools 0.00 Medium Freeware assembler and C compiler
available
Programming device Easy Included in Demo board
Demo Board 132.00 Easy AT89STK-08 Starter Kit
MCU (chip only - mass product) 2.47 AT89C51-33PI-ND (40 pin DIP) 4k Flash 32
I/O pins
Freescale MC68HCxx series
Software programming tools 499.00 Easy Metrowerks Codewarrior "basic". Freescale
proprietary undisclosed
Programming device 30.00 None available for DIP MCUs
Demo Board 30.00 Easy Lowest cost programmer/demo board -
includes SMT QFP MCU
MCU (chip only - mass product) 3.00 MC68HRC98J L3ECP (28-pin DIP)
MCU,128RAM,4K FLASH,A/D
Microchip PIC RISC MCU
Software programming tools 0.00 Medium Freeware assembler and C compiler
Programming device 199.00 Easy Public programming info: Multiple
programming circuits available
Demo Board 99.00 Easy Multiple sources, might not be needed
MCU (chip only - mass product) 1.65 SX28AC-DP+(16 pin DIP) / other models
available
Parallax PIC w/ BASIC
Software programming tools 0.00 Extremely easy Freeware basic tokenizer
Programming device Easy Included in demo board/ same as PIC
Demo Board 50.00 Easy BS2-SX OEM module
MCU (chip only - mass product) 12.00 SX28AC-DP+(16 pin DIP); No internal
memory for programs
EEPROM for MCU (required) 5.00 Required
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 19
5.1.3 Stepper Motor
A stepper motor is required to perform precise screw movements (in degrees) as the screw must
move 360 exactly in each feeding operation. A stepper motor will also allow for forward/backward
motion to prevent the product from freezing into the screw and housing.
Stepper motors can be of two types: Permanent Magnet and Variable reluctance. Variable reluctance
motors run freely when no current is applied while permanent magnet motors have a tendency to
show some resistance to movement. Permanent magnet steppers are heavier but easier to
manufacture; this explains their widespread use.
Unipolar motors
Figure 17: Unipolar motor structure (17)
Unipolar stepping motors can be controlled
using 6 wires and are usually wired as shown
in Figure 17, with a center tap on each of two
windings. The center taps of the windings are
typically wired to the positive supply, and the
two ends of each winding are alternately
grounded to reverse the direction of the field
provided by that winding
Bipolar Motors
Figure 18: Bipolar motor structure (17)
Bipolar motors are constructed just like
unipolar motors, but the two windings are
replace with a single winding and the center
tap is eliminated. The motor itself is simpler
but the drive circuitry needed to reverse the
polarity of each pair of motor poles is more
complex (See Figure 18).
The drive circuitry for such a motor requires an H-bridge control circuit for each winding. An H-
bridge allows the polarity of the power applied to each end of each winding to be controlled in
dependently
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 20
Other types of stepper motors:
Bifilar Motors
Similar to the bipolar motor, but instead of winding each coil in the stator with a single wire, two
wires are wound in parallel with each other. Motors with bifilar windings are always powered as
either unipolar or bipolar motors.
Multiphase Motors
Multiphase motors are used in power/torque applications are very different from the unipolar/bipolar
construction as seen in Figure 19.
Figure 19: Bipolar motor structure (17)
Control of either one of these multiphase motors in either the Delta or Y configuration requires 1/2
of an H-bridge for each motor terminal. It is noteworthy that 5-phase motors have the potential of
delivering more torque from a given package size because all or all but one of the motor windings
are energized at every point in the drive cycle. Some 5-phase motors have high resolutions on the
order of 0.72 degrees per step (500 steps per revolution).
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 21
5.1.4 Motor Selection- Bipolar stacked (1 W/coil)
The Bipolar motor was selected due to its easy construction, widespread use and low price. A
stacked bipolar motor was selected to allow for more even operation and greater angle control. A
stacked bipolar is just two bipolar stepper motors stacked together with a common rotation axis
allowing for standardization of parts and lower manufacturing costs. The selected motor electrical
schematic can be seen on Figure 20.
Figure 20: Stacked stepper specifications (Danaher Motion)
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 22
5.2 Power requirements
Table 3 shows the electrical power requirements for the AFF. TECs and Heatsink fans are connected
directly to the 12V power supply, as they have builtin control elements.
Table 3: AFF Power requirements
ELEMENT I V R POWER
TEC 8.00 12.00 ** 96.00
STEPPER 0.80 5.00 6.25 4.00
SOLENOID 1.00 12.00 ** 12.00
S.T. POWER 4.30 ** ** 46.00
LOGIC 0.30 5.00 N/A 1.50
TOTAL 4.60 159.50
5.3 Microcontroller selection
The Input/Output requirements for the microcontroller can be found in Table 4:
Table 4: TEC Input/Output requirements
Component Pin requirements
Inputs Outputs
Stepper 0 4 2-coil bipolar stacked stepper
Push buttons 3 0 Momentary contact type
LCD display 1 11 Hitachi-based; 7 outputs for 4-bit operation
Total 4 15 19 Total I/O pins
The Basic Stamp 2SX OEM model was selected among the microcontrollers listed in Table 2. This is
due to the very limited amount of resources available to build a single prototype. The Basic Stamp
Module integrates a fully functional microcontroller board with programming, debugging and
development tools for $50 US. The Basic Stamp does not have the required number of pins to
control all functions unless the LCD is operated in 4-bit parallel mode.
Figure 21 shows the schematic diagram for the BS2-SX module.
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 23
Figure 21: BS2-SX Module schematic
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 24
5.4 Electrical schematics
A block diagram of the electrical design is shown in Figure 22 and detailed electrical schematics on
Figure 23.
Figure 22: Automatic fish feeder electrical block diagram
B
a
s
i
c
S
t
a
m
p
2
S
X
O
E
M
(
M
i
c
r
o
c
o
n
t
r
o
l
l
e
r
m
o
d
u
l
e
)
H
B
r
i
d
g
e
I
/
O
b
u
f
f
e
r
s
L
C
D
M
o
d
u
l
e
1
2
V
D
C
P
o
w
e
r
s
u
p
p
l
y
H
B
r
i
d
g
e
I
n
p
u
t
s
w
i
t
c
h
e
s
V
.
R
e
g
.
T
E
C
u
n
i
t
T
E
C
u
n
i
t
T
E
C
u
n
i
t
T
E
C
u
n
i
t
S
t
a
c
k
e
d
s
t
e
p
p
e
r
M
o
t
o
r
F
a
n
F
a
n
1
2
V
D
.
C
.
5
V
D
.
C
.
C
O
N
T
R
O
L
F
e
e
d
i
n
g
m
e
c
h
a
n
i
s
m
B
a
s
i
c
S
t
a
m
p
2
S
X
O
E
M
(
M
i
c
r
o
c
o
n
t
r
o
l
l
e
r
m
o
d
u
l
e
)
H
B
r
i
d
g
e
I
/
O
b
u
f
f
e
r
s
L
C
D
M
o
d
u
l
e
1
2
V
D
C
P
o
w
e
r
s
u
p
p
l
y
H
B
r
i
d
g
e
I
n
p
u
t
s
w
i
t
c
h
e
s
V
.
R
e
g
.
T
E
C
u
n
i
t
T
E
C
u
n
i
t
T
E
C
u
n
i
t
T
E
C
u
n
i
t
S
t
a
c
k
e
d
s
t
e
p
p
e
r
M
o
t
o
r
F
a
n
F
a
n
1
2
V
D
.
C
.
5
V
D
.
C
.
C
O
N
T
R
O
L
F
e
e
d
i
n
g
m
e
c
h
a
n
i
s
m
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 25
Figure 23: Electrical Schematic
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 26
5.5 Software
The prototype system can deliver one frozen food blocks per day at a preprogrammed time. The
system runs a counter to derive a 1minute pulse which is used to run the real time clock (the clock
returns to zero at midnight). Feeding times are stored on a table (feed time table- FTT), which the
main loop checks constantly.
During normal operation (not during programming), the 2x24 LCD will display:
Standby
HH:MM
Software modules:
5.5.1 Main module:
The main loop runs when the unit is not being programmed or not dispensing food. The main
functions of the main loop are:
Maintains a counter that is used to estimate the time (loop counter)
Polls the buttons and enters programming loop if any of the buttons is pressed.
Displays the time on the LCD display
Controls feeding events - enters the feed module when feeding time occurs
5.5.2 Set module:
The main module calls the programming module when the 'SET' button is pressed. This module is
the only module that interacts with the user. User programmable functions are:
Administers the FTT
Sets the time of day
Forced feed
The user interface is designed to use a 2x24 alphanumeric display and three buttons. The interface is
structured as hierarchical lists - the user navigates through the lists using the 'LEFT' and 'RIGHT'
buttons, and selecting options using the 'SET' button. The values are changed using the 'LEFT' and
'RIGHT' buttons. New values take effect by pressing 'SET' (which also returns the user to 'Stand by'
mode)
The following options can be set in programming mode:
TIME OF DAY: Used to set the time, (in 24-hour format) that the unit uses to control feed times.
Internal clock mis estimated through a loop. During setup the LCD screen shows the following:
TIME OF DAY <> (set)
00:00 +hrs +mins (set)
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 27
Where 00:00 is the current time that the user adjusts using the left button for hours and right
button for minutes. The user sets the time by pressing set once the right time is displayed on the
LCD screen. Once set, the unit will display the following message for 1 second:
SETUP SUCCESSFUL
FEED TIME: Allows the user to set the time of day at which the unit will feed one block of frozen
food. Further software improvements will permit multiple feed times per day. When setting feed
time the LCD display shows:
FEED TIME <> (set)
00:00 +hrs +mins (set)
The 00:00 text changes with the desired feed time. The user adjusts the feed time using the left
button for hours and right button for minutes just as with time of day. The user sets the time by
pressing set once the right time is displayed on the LCD screen. Once set, the unit will the
following message for 1 second:
SETUP SUCCESSFUL
SET TEMPERATURE: Will control the TEC current and therefore control the temperature. This
option requires an analog input and thermistor. This function is not implemented in the current
design.
FEED NOW: Will activate the feeding mechanism immediately, dispensing one block of frozen
food. The unit will display the following display while feeding:
** FEEDI NG **
EXIT SET MENU: Returns to Standby mode. And waits for the next programmed feeding event.
5.5.3 Motor movement:
The motor movement modules move the motor for a single feed (360 rotation forward). The PLC
generates the signals that control the two H-Bridges for the 2-unit-stacked stepper motor.
The complete source code can be found in Appendix A
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 28
6. PRODUCT COSTS
6.1 Bill of Materials
The total cost of components required to assemble the prototype board can be found in Table 5:
Table 5: AFF Prototype Material Costs
Part Description Amount Unit Cost Total Cost
ELECTRICAL
74LS05N Hex Inverter 2 0.69 $1.38
2N6124 PNP 4 1.49 $5.96
2N6121 NPN 4 1.49 $5.96
108-4100 4x10 Breadboard 1 13.08 $13.08
-- Metal film resistor 10k 20 0.24 $4.80
-- Metal film resistor 1k 5 0.24 $1.20
BS2SX Basic Stamp B2SX OEM 1 62.50 $62.50
529PB-ND Momentary SPDT 3 1.37 $4.11
LED 3mm LED 1 0.82 $0.82
1NS3xx Diode 5W T18 8 1.55 $12.40
-- Wire. etc. -- -- $10.00
SMT-75
2
Airpax stepper, 5V, 7.5deg 1 3.44 $3.44
LCD-107
2
2x24 Parallel LCD w/EL 1 5.00 $5.00
MC78M05BT 500mA, 5V Regulator 1 0.89 $0.89
-- 12V 3000RPM Fan 2 7.50 $15.00
PJ T-2
2
Thermo Electric cooler 4 18.38 $73.50
MECHANICAL
-- Helical feeding screw $0.00
-- Plexiglas Housing $50.00
-- Heat sinks 2 4.38 $8.75
TOTAL COST $278.79
Prices per unit from Digikey Canada, AllElectronics.com
2
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 29
6.2 Total costs and expected selling price
This is a unique product targeted at the enthusiast aquarist. There is no product in the market capable
of automatically dispensing frozen food to an aquarium. This item should be sold as a novelty/luxury
item.
We believe the enthusiast aquarist will be willing to pay about $70 extra for the capability to handle
frozen food. A luxury automatic fish feeder with similar characteristics to the AFF (without freezing
capabilities) has a retail value of $65/US$50 (see Figure 2). Therefore, we believe the suggested
retail price (MSRP) for this unit should be $130 as an absolute minimum.
If mass production of the AFF is achieved the cost reduction can typically be one fifth of the
prototype cost which is only $55. With a MSRP of $130, a profit of $75 per unit can not actually be
expected; distribution costs, packaging and advertising costs will reduce the over all profit but not
too the extent that the AFF would be an unattractive business venture.
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 30
7. CONCLUSIONS
Fish and aquariums are the world's largest hobby. Aquarists spend much more money in
accessories and maintenance products than any other type of pet owner. The profits from
aquarium related equipment exceeds that of any other pet type.
This is a novelty/luxury product that can be sold to enthusiasts for much a higher price than
current dry food automatic fish feeders. Manufacturing costs will have to be reduced to meet
suggested price target
The Automatic frozen food feeder depends on the availability of frozen food for fish. Current
availability is very limited.
8. RECOMMENDATIONS
The total cost should be reduced to $55 with mass production. From Table 2, more than 50%
of the total cost is due to the TECs and BS2SX microcontroller. Cost reductions should be
possible by targeting these areas.
Replace the BS2SX-OEM module ($75) with a single-chip microcontroller and integrate this
chip into the circuit. There are simpler microcontrollers available for less than $10US
More efficient heat insulation on the feeding chamber to allow for smaller more efficient
TECs.
Add a door to the food chamber to reduce cold air loss and reduce cooling requirements.
Add an extra LED and a LED/photodiode detector pair to sound an alarm when the system
has run out of product.
Patrick Audet / Tomas Martin 2005
Automatic Fish Feeder Final Report 31
9. REFERENCES
(1) Hynes, Angela, Natural Health; Mar2005, Vol. 35 Issue 3, p72, 6p, 10c, 2bw
(2) http://en.wikipedia.org/wiki/Pet
(3) American pet product manufacturing Association (APPMA); Statistics page,
http://www.appma.org/press_industrytrends.asp
(4) Alderman, Lesley; Money Magazine; Sep94, Vol. 23 Issue 9, p154, 1/4p, 1c
(5) Business Week; 9/23/2002 Issue 3800, p128, 1p, 1 graph, 3c
(6) Petsmart; http://www.petsmart.com (fish fish feeder section)
(7) Omega, Thermoelement Material-T30-Z,
http://www.omegaeng.nl/temperature/z/pdf/z021-032.pdf
(8) Steinbrecher, Tillmann; The Heat sink guide,
http://www.heatsinkguide.com/content.php?content=peltierinfo.shtml
(8) http://www.melcor.com/handbook.html
(10) http://www.digit-life.com/articles/peltiercoolers/
(11) http://www.electracool.com/basics.htm
(12) TE Technology, Inc.; http://www.tetech.com/techinfo/#1
(13) Tellurex Corporation; http://www.tellurex.com/cz1-1.4-127-1.14cm.html
(14) Internet FAQ Archives; 8051 Microcontroller, www.faqs.org/faqs/microcontroller-
faq/8051/
(15) Internet FAQ Archives; Microcontroller FAQs, http://www.faqs.org/faqs/microcontroller-
faq/primer/
(16) http://www.displaytech-us.com/pdf/ol_lcd/LCDConstruction.PDF
(17) Douglas, Jones (Ph.D.); Control of Stepping Motors
(18) A Tutorial, http://www.cs.uiowa.edu/~jones/step/types.html
Patrick Audet / Tomas Martin 2005
APPENDIX A Automatic Fish Feeder Final Report A-1
APPENDIX A
AFF Software for BSX2-OEM
' {$STAMP BS2sx}
' {$PBASI C 2. 5}
#SELECT $STAMP
#CASE BS2
#ERROR " BS2e or gr eat er r equi r ed. "
#CASE BS2E, BS2SX
Sl ot CON 63
#CASE BS2P, BS2PE, BS2PX
Sl ot CON 127
#ENDSELECT
' def i nes var i abl es t o use i n t he pr ogr am
l cdchar VAR Byt e ' char act er t o be out put by t he LCD r out i ne
l cd_l ow VAR l cdchar . LOWNI B ' br eak up byt e f or 4 bi t l cd i nt er f ace
l cd_hi VAR l cdchar . HI GHNI B ' br eak up byt e f or 4 bi t l cd i nt er f ace
i dx VAR Byt e ' count er f or pr i nt out l oopi ng
hour s VAR Byt e ' hour s - t i me ( mai n l oop)
mi ns VAR Byt e ' count s mi nut es t o keep t i me ( mai n l oop)
f d_hour s VAR Byt e ' f eed t i me hour s
f d_mi ns VAR Byt e ' ' f eed t i me mi nut es
secs VAR Byt e ' seconds - t i me ( mai n l oop)
t mp VAR Byt e ' t empr ar y st or age f or cal cul at i ons
set st at e VAR Byt e ' cur r ent st at e t hat we ar e set t i ng
' I / O def i ni t i ons
' Thr ee push but t ons ( I N )
sw1 VAR I N0
sw2 VAR I N1
sw3 VAR I N2
' Mot or Cont r ol
mt out VAR OUTB
' LCD cont r ol l i nes
L_ENA VAR OUT13
L_RS VAR OUT14
L_NI BOUT VAR OUTC ' Ni bbl e f or out 8- out 11
L_RW VAR OUT12
' const ant s
debounce CON 200 ' 200 ms debounce
st pdl y CON 30 ' del ay bet ween st eps
Patrick Audet / Tomas Martin 2005
APPENDIX A Automatic Fish Feeder Final Report A-2
st p1 CON %1001 ' st epper mot or h- br i dge combi nat i ons
st p2 CON %0101
st p3 CON %0110
st p4 CON %1010
mof f CON %1111 ' t ur n mot or of f
I ni t : ' Reset s Di r ect i on r egi st er s, mot or out put s t o 1 ( i . e. 0)
' pr ogr amt he I O di r ect i on r egi st er t o our needs
' i nput =0 out put =1
' 5432109876543210
DI RS = %1111111111111000
' - - - RDDDDREMot Swt
' r eset s out put s ( i nver t er buf f er s on mot or t r ansi st or s)
' 5432109876543210
OUTS = %0000000000111000 ' mot or out put l ow
' - - - RDDDDREMot Swt
' i ni t mot or
GOSUB f wd
' i ni t i al i ze LCD di spl ay
PAUSE 1000
L_RS=%0
L_RW=%0
L_ENA=%0
L_NI BOUT=%0011
GOSUB l cdout ' 1
PAUSE 6 ' wai t f or mor e t han 4. 1ms
L_NI BOUT=%0011
GOSUB l cdout ' 2
PAUSE 1 ' wai t f or mor e t han 100us
L_NI BOUT=%0011
GOSUB l cdout ' 3
L_NI BOUT=%0010 ' l ast i ni t ni bbl e t hi s i s a 8- bi t i nst r uct i on
GOSUB l cdout ' 4
L_NI BOUT=%0010 ' 001x: 0= 4bi t i nt er f ace
GOSUB l cdout ' 5a
L_NI BOUT=%1000 ' N=1( 2 l i nes) F=0 ( 5x8dot s)
GOSUB l cdout ' 5b
L_NI BOUT=%0000 ' Di spl ay on
GOSUB l cdout ' 6a
L_NI BOUT=%1111 ' 1DCB di spl ay, cur sor and bl i nk on=1/ of f =0
GOSUB l cdout ' 6b
L_NI BOUT=%0000 ' Di spl ay cl ear
GOSUB l cdout ' 7a
L_NI BOUT=%0001 ' =0001
GOSUB l cdout ' 7b
L_NI BOUT=%0000 ' Ent r y mode set
GOSUB l cdout ' 8a
Patrick Audet / Tomas Martin 2005
APPENDIX A Automatic Fish Feeder Final Report A-3
L_NI BOUT=%0110 ' 0 1 I / D S cur sor behavi our and shi f t i ng
GOSUB l cdout ' 8b
L_RS=%1 ' we ar e assumi ng pr i nt i ng al l t i mes, no commands
l cdchar =0 ' pr i nt s wel come message
GOSUB set pos
i dx=wel cm_msg
GOSUB pr t _st r
PAUSE 1000 ' wai t s f or 5 seconds and goes t o st andby
st dby:
l cdchar =0 ' pr i nt s st andby
GOSUB set pos
i dx=st andby
GOSUB pr t _st r
st dbyl oop:
GOSUB pr i nt t i m' pr i nt s t i me on second l i ne
' det ect but t ons
FOR secs = 0 TO 5 ' seconds
PAUSE 980 ' 980ms del ay
I F ( sw1 | sw2 | sw3) THEN GOTO ui set ' j umps t o set up ui i f pr essed
NEXT
' updat e cl ock
mi ns=mi ns+1
I F mi ns>59 THEN
hour s=hour s+1
mi ns=0
ENDI F
I F hour s>23 THEN hour s=0
' checks f eed t i me
I F ( ( f d_hour s=hour s) & ( f d_mi ns=mi ns) ) THEN
GOSUB f eednow
GOTO st dby
ENDI F
GOTO st dbyl oop ' br anches back
' ****************************************
' *** UI SET user i nt er f ace t o set opt s ***
' ****************************************
ui set :
set st at e=0 ' Opt i on cur r ent l y bei ng set up = 0
t opui l oop:
GOSUB cl r s
Patrick Audet / Tomas Martin 2005
APPENDIX A Automatic Fish Feeder Final Report A-4
LOOKUP set st at e, [ set _f eed, set _t i me, set _t emp, set _f eednow, set _end] , i dx
GOSUB set pos
GOSUB pr t _st r ' pr i nt message f or set st at e
PAUSE debounce
l up1:
I F ( sw1 | sw2 | sw3) =0 THEN GOTO l up1
set st at e=( set st at e- sw1+sw2)
I F set st at e>4 THEN set st at e=0
l cdchar =0 ' adj ust s posi t i on of message
I F sw3=0 THEN GOTO t opui l oop ' l oops nt i l set pr essed
I F set st at e=4 THEN GOTO st dby ' EXI TS TO STANDBY LOOP
I F set st at e=3 THEN GOSUB f eednow ' f eeds t he
I F set st at e=3 THEN GOTO ui set
I F set st at e=0 THEN ' set f eed
hour s=f d_hour s
mi ns=f d_mi ns
ENDI F
' set s opt i on ( = set s t i me)
l cdchar =64 ' but t on oper at i on t xt on 2nd l i ne
GOSUB set pos
i dx= set _t i m_msg
GOSUB pr t _st r
set _t i m_opt :
GOSUB pr i nt t i m' pr i nt s t i me t o be set
PAUSE debounce
l up2:
I F ( sw1 | sw2 | sw3) =0 THEN GOTO l up2
mi ns=mi ns+sw2
I F mi ns>59 THEN
hour s=hour s+1
mi ns=0
ENDI F
hour s=hour s+sw1
I F hour s>23 THEN
hour s=0
ENDI F
I F sw3=0 THEN GOTO set _t i m_opt ' l oops unt i l set pr essed
I F set st at e=0 THEN
f d_hour s=hour s
f d_mi ns=mi ns
ENDI F
GOSUB cl r s
i dx= set success
GOSUB pr t _st r ' pr i nt message f or set st at e
PAUSE 1000
GOTO ui set
Patrick Audet / Tomas Martin 2005
APPENDIX A Automatic Fish Feeder Final Report A-5
' ****************************************
' *** Usef ul r out i nes ***
' ****************************************
f eednow: ' pr i nt s message and r ot at es f or war d 360
GOSUB cl r s
i dx= f eedi ng
GOSUB pr t _st r
GOSUB f wd
RETURN
pr i nt t i m: ' pr i nt s t he t i me ( f r omhour s: mi ns)
l cdchar =64 ' set s posi t i on second l i ne
GOSUB set pos
t mp=( hour s/ 10) ' f or masci i char ( hour s 1st di gi t )
l cdchar =t mp+48
GOSUB pr t _char
t mp=( hour s- ( t mp*10) ) ' f or masci i char ( hour s 2nd di gi t )
l cdchar =t mp+48
GOSUB pr t _char
l cdchar =%00111010 ' col on
GOSUB pr t _char
t mp=( mi ns/ 10) ' f or masci i char ( hour s 1st di gi t )
l cdchar =t mp+48
GOSUB pr t _char
t mp=( mi ns- ( t mp*10) ) ' f or masci i char ( hour s 2nd di gi t )
l cdchar =t mp+48
GOSUB pr t _char
RETURN
cl r s: ' cl ear s t he LCD scr een
l cdchar =%00000001 ' cl ear s t he scr een
L_RS=%0 ' command
GOSUB pr t _char
l cdchar =%00000000 ' posi t i on zer o
GOSUB set pos
RETURN
pr t _st r : ' pr i nt s a zer o- t er mi nat ed st r i ng on t he LCD l ocat ed at i dx
READ i dx, l cdchar
i dx=i dx+1
I F l cdchar =0 THEN RETURN
L_NI BOUT= l cd_hi
GOSUB l cdout
L_NI BOUT= l cd_l ow
GOSUB l cdout
GOTO pr t _st r
pr t _char : ' out put s a byt e t o t he LCD
Patrick Audet / Tomas Martin 2005
APPENDIX A Automatic Fish Feeder Final Report A-6
L_NI BOUT= l cd_hi
GOSUB l cdout
L_NI BOUT= l cd_l ow
GOSUB l cdout
RETURN
l cdout : ' 4bi t t r ansf er t o l cd r out i ne
PAUSE 1
L_ENA=%1
PAUSE 1
L_ENA=%0
RETURN
set pos: ' set s t he posi t i on of t he next char act er t o be pr i nt ed LCD
L_RS=%0 ' Changes mode t o command
L_NI BOUT= %0000 ' r et ur n home
GOSUB l cdout
L_NI BOUT= %0010
GOSUB l cdout
' move t o desi r ed pos
L_NI BOUT= ( l cd_hi | 8)
GOSUB l cdout
L_NI BOUT= l cd_l ow
GOSUB l cdout
L_RS=%1 ' And back t o dat a
RETURN
f wd: ' moves t he mot or 360deg f wd ( f eedi ng mot i on)
FOR t mp=0 TO 12
mt out = st p1
PAUSE st pdl y
mt out = st p2
PAUSE st pdl y
mt out = st p3
PAUSE st pdl y
mt out = st p4
PAUSE st pdl y
NEXT
mt out = mof f ' t ur ns of f cur r ent t o coi l s
RETURN
' Messages
' 1 2
' 123456789012345678901234
wel cm_msg DATA " ** GUPPY LUV **" , 0
st andby DATA " STANDBY - ( Pr ess t o set ) " , 0
set _t i me DATA " TI ME OF DAY <> ( set ) " , 0
set _f eed DATA " FEED TI ME <> ( set ) " , 0
set _t emp DATA " SET TEMPERATURE <> ( set ) " , 0
set _f eednow DATA " FEED NOW " , 0
Patrick Audet / Tomas Martin 2005
APPENDIX A Automatic Fish Feeder Final Report A-7
set _end DATA " Exi t set menu " , 0
set _t i m_msg DATA " +hr s +mi ns ( set ) " , 0
set success DATA " SETUP SUCCESSFUL " , 0
f eedi ng DATA " ** FEEDI NG ** " , 0
Patrick Audet / Tomas Martin 2005