Week 6
The assignment this week is to do someting with a DC
motor. At first I decided make the DC motor spin a fan on the depending on the
temperature reading of a thermistor. The idea came to me because last night I
busted out the comforter and ended up slow roasting myself. So I thought I
would make a fan to cool off the bed when it got overly toasty. While the
thought of a DC motor at the base of your bed kicking in at 3 am
may seem unappealing to some I thought there could be some unexplored potential
to the idea (and I'm generating precious few ideas for pcomp these days so...)
Well, since thermistors can be easily turned into a switch by using getADC I
built the thing pretty uneventfully. However, when I was done the general
blandness of the idea from a physical computing standpoint hit me (from a
marketing standpoint however I still think this thing's got legs. Don't be
surprised if you see the CryoBed 2000 undercover environment regulator in a
Sharper Image near you...) Basically, the thing is just a fancy switch and a
motor. So as I played with the thermistor trying to think of how to get this
thing to do something interesting, I noticed that if you just touched the
thermistor lightly the motor would sort of purr and twitch (the thermistor was
set to go off at a little less than skin temperature, so a light touch would
make it flicker on and off for a little while). So I had the more interesting
idea (well, from a pcomp perspective at least) to make a pet DC motor that
would purr and twitch when petted. One problem with the way the motor was
reacting now was that if you kept your hand on the thermistor for too long the
motor would go fully on and stay that way for a while (the thermistor has a
pretty high latency, i.e. it takes a while to get warmed up or cooled down.) So
I thought I could control this by writing some code that would make the motor
twitch and purr intentionally (rather than when the thermistor flickered), and
then have that code activated whenever the thermistor changed (rather than when
it reached a threshold). What ended up happening though was that after it was
touched the motor would just turn on and stay on for a couple of minutes.
Unfortunately after the motor had repelled a few attempts at debugging I ran
out of time and had to go work on my ICM midterm. The only thing that I could
think of as a potential problem was that the motor was somehow causing
interference that was making the thermistor values go out of whack.
(Unfortunately, I left my bag in a cab this week. My
breadboard, motor, BX etc. were in it so this is the best picture I got of
the setup. Don't worry though it wasn't much more interesting. Only difference
was it had a thermistor and an extra resistor plugged in)
(This is the last version of the code before I ran out
of time so it's not really final but it should give an idea of what I was up
to)
Option Explicit
dim Average as integer
Public Sub Main()
dim Counter as integer
call delay(0.5)
average = 0
Counter = 0
do 'Main loop begin
counter = 100
call calibrate
do while Counter > 0
if getADC(14) > average then
call jitter
end if
counter = counter - 1
loop
loop 'Main loop end
End Sub
Public Sub Calibrate()
dim avg as long
dim Count as integer
Count = 0
avg = 0
do while Count < 10
avg = clng(getADC(14)) + avg
Count = Count + 1
loop
avg = avg\clng(count)
average = cint(avg)
end Sub
Public Sub Jitter ()
call putpin(13,cbyte(getADC(20) mod 2))
call delay((csng(getADC(20) mod 20)+10.0)/100.0)
end sub