(A)
■ FIGURE 8
■ FIGURE 7
according to the accompanying instructions, then download and install the
free Dios compiler.
dim irqcount as integer
‘Start INT0 IRQ
irqglobalstart ‘enable global IRQ’s
irqINT0start ‘enable INT0 IRQ
loop:
irqcount=DishTest(13)
print irqcount
pause 100
goto loop
endfunc
Insert the Dios
Pro chip into the
carrier, then plug the
EZRS232 driver into
the five-pin female
connector on the
(B) carrier and connect
the battery connector as shown in
Figure 12. Make
sure the orientation
of the black and red
wires is correct. If
they are not, you will
damage the DiosPro chip.
Connect the carrier to your PC by
using a nine-pin serial cable. All new
DiosPro chips contain
a small test program
that will display a test
message on the debug
terminal.
Now connect each
of the sensor pad
female headers to the
single pin male headers
on I/O ports 7 and 13
that we installed earlier.
Schematic 1 shows the
complete hookup for
this experiment.
Program the code
from Listing 1 into the
DiosPro. For the Dios
Carrier 1, you will need
to use an EZRS232 driver. The Dios Workboards
have the RS-232 driver
built in so experimentation is much easier.
LISTING 1
DiosPro
‘—————————————————————————————————————————————————-
‘DDishP1 Simple Water Level Test Program
‘—————————————————————————————————————————————————-
func main()
Once you run the program, it
should start reporting 0 in the debug
window. Start to fill the jar or container
and as the water reaches the top, the
sensor pad reading should change to 50.
The program is simple enough.
The startirqasm is a simple assembly
routine that fires each time there is a
change from low to high on port 7.
The routine increments the global variable dishvarb. The DishTest routine is
called each time you want to test the
water level. What it does is toggle port
13 100 times. This is 50 low to high
transitions and 50 high to low transitions. Upon entry to the routine, I set
the global variable dishvarb to 0 so we
get a fresh count with each call.
Play with the location of the
sensor pads, as well as the 100K
resistor. I have found that you may
also place the two sensors across from
each other on the container.
‘—————————————————————————————————————————————————-
‘Sensor Test Program
‘Will Return 50 if IRQ catches all
‘ port toggles
‘—————————————————————————————————————————————————-
func DishTest(tport as integer)
global dishvarb as integer
dim x as integer
output tport
dishvarb = 0
for x = 1 to 100
toggle tport
next
exit dishvarb
endfunc
• STEP 5 — Doggy Dish Assembly. Dish
selection is important. You need to
select a dish that has some sort of
chamber on the under side. This chamber will be used to house the DiosPro,
FireCracker, and battery pack. The bowl
shown in Figure 13 is very common,
available at most pet and department
stores and is available in many sizes and
colors. You may also make your own
bowl by attaching two bowls as shown
in Figure 14. The best way to attach the
two is with some industrial double stick
foam tape or hot glue or both.
Remove the sensor pads from the
jar and, using cellophane tape, attach
the two pads near the bottom of the
doggy dish bowl across from each
■ FIGURE 10
‘—————————————————————————————————————————————————-
‘IRQ handler for INT0 irq
‘—————————————————————————————————————————————————-
startirqasm INT0
movlb .2 ;Need this to access global variables
infsnz G_dishvarbl,f
incf G_dishvarbh,f
endirqasm
‘—————————————————————————————————————————————————-
■ FIGURE 9
38
May 2007