Stamp Works #5
Archiver
Posts: 46,084
I am working on Experiment #5 from the StampWorks book.
I have the experiment working properly; however, I am falling a little short of
really understanding the path the electricity is taking accross the breadboard.
I see where to goes from +5 Vdd to the the Capacitor but then it seem s to me
that it branches to both the potentiometer and back to p15 on the stamp via
resistor.
I understand that what is happening is the Capacitor is charging, discharging,
charging, discharging as fast as it can.
I understand that the rctime command in the code is measuring this charge -
discharge time.
I understand that the rctime command monitors the pin condition until it changes
and that is how it can tell the discharge time.
The two things I am not certain of are:
1. p15 is declared as an Output pin and the code sets it as high. How is it
that the state changes? My natural though is the code sets an Output pin to
High, it should stayHigh until it is set otherwise. Since code never sets the
state to low is it just the nature of this circut that pulls the voltage off of
p15 and makes it low, or does rctime inherently set it to low when the capacitor
charges/discharges?
2. How exactly does the potentiometer affect the amount of time the capictator
takes to charge/discharge?
Matt
[noparse][[/noparse]Non-text portions of this message have been removed]
I have the experiment working properly; however, I am falling a little short of
really understanding the path the electricity is taking accross the breadboard.
I see where to goes from +5 Vdd to the the Capacitor but then it seem s to me
that it branches to both the potentiometer and back to p15 on the stamp via
resistor.
I understand that what is happening is the Capacitor is charging, discharging,
charging, discharging as fast as it can.
I understand that the rctime command in the code is measuring this charge -
discharge time.
I understand that the rctime command monitors the pin condition until it changes
and that is how it can tell the discharge time.
The two things I am not certain of are:
1. p15 is declared as an Output pin and the code sets it as high. How is it
that the state changes? My natural though is the code sets an Output pin to
High, it should stayHigh until it is set otherwise. Since code never sets the
state to low is it just the nature of this circut that pulls the voltage off of
p15 and makes it low, or does rctime inherently set it to low when the capacitor
charges/discharges?
2. How exactly does the potentiometer affect the amount of time the capictator
takes to charge/discharge?
Matt
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
Original Message
From: "Matt Lorenz" <mklorenz@c...>
To: <basicstamps@yahoogroups.com>
Sent: Saturday, November 09, 2002 6:11 PM
Subject: [noparse][[/noparse]basicstamps] Stamp Works #5
| I am working on Experiment #5 from the StampWorks book.
|
| I have the experiment working properly; however, I am falling a
little short of really understanding the path the electricity is
taking accross the breadboard.
|
| I see where to goes from +5 Vdd to the the Capacitor but then it
seem s to me that it branches to both the potentiometer and back to
p15 on the stamp via resistor.
|
| I understand that what is happening is the Capacitor is charging,
discharging, charging, discharging as fast as it can.
|
| I understand that the rctime command in the code is measuring this
charge - discharge time.
| I understand that the rctime command monitors the pin condition
until it changes and that is how it can tell the discharge time.
|
| The two things I am not certain of are:
|
| 1. p15 is declared as an Output pin and the code sets it as high.
How is it that the state changes? My natural though is the code sets
an Output pin to High, it should stayHigh until it is set otherwise.
Since code never sets the state to low is it just the nature of this
circut that pulls the voltage off of p15 and makes it low, or does
rctime inherently set it to low when the capacitor charges/discharges?
|
****
The RCTIME places the pin into "input" mode, and uses the state of
this pin to measure the charge time of the capacitor (in this case,
the time needed to switch from HIGH level to LOW level). After the
measurement, the pin stays into "input" mode. That's why you need to
discharge the capacitor by setting the pin into "output" mode and
putting a HIGH for 1 ms.
****
| 2. How exactly does the potentiometer affect the amount of time the
capictator takes to charge/discharge?
****
When the Stamp reads the pin as an input, a current is flowing thru
the capacitor AND the potentiometer, decreasing as the capacitor is
charging. The charge time depends on this current, by the way on the
potentiometer value. When the capacitor is fully charged, the current
is zero.
****
|
| Matt
|
PAUSE gives the cap plenty of time to be discharged.
RCTIME makes P15 an input and starts a counter. When P15 becomes an input,
current can flow through the pot to the cap. As the capacitor charges
through the pot, the voltage on P15 will move from +5 toward ground. The
rate at which this happens is controlled by the RC value -- since the cap is
fixed, the pot is in control. When the voltage on P15 reaches about 1.4
volts, the counter will stop and the counter value will be reported.
Specifically, the pot controls the charge current for the capacitor. A lower
pot value means a higher charge current and faster charge time.
-- Jon Williams
-- Parallax
In a message dated 11/9/02 11:13:06 AM Central Standard Time,
mklorenz@c... writes:
> 1. p15 is declared as an Output pin and the code sets it as high. How is it
> that the state changes? My natural though is the code sets an Output pin
> to High, it should stayHigh until it is set otherwise. Since code never
> sets the state to low is it just the nature of this circut that pulls the
> voltage off of p15 and makes it low, or does rctime inherently set it to
> low when the capacitor charges/discharges?
>
> 2. How exactly does the potentiometer affect the amount of time the
> capictator takes to charge/discharge?
>
>
[noparse][[/noparse]Non-text portions of this message have been removed]