Reading POT controls (Analog to Digital)
Oldbitcollector (Jeff)
Posts: 8,091
In reviewing the PEkit labs, I stumbled across something I missed...
There is a very nice demonstration of reading data from POT controls, TestRCdecay
that I thought would be nice for adaption to simple game controls since every PPDB has two of these.
I'm sure this is another obvious to everyone else, but here's an adaption of that code
that would lend itself to 20 position game control using it as a controller.
This adaptation trades uses a simple Propeller-->POT-->GND so it's returning single
decimal digits, perfect for this use and stupid simple to wire up.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
There is a very nice demonstration of reading data from POT controls, TestRCdecay
that I thought would be nice for adaption to simple game controls since every PPDB has two of these.
I'm sure this is another obvious to everyone else, but here's an adaption of that code
that would lend itself to 20 position game control using it as a controller.
This adaptation trades uses a simple Propeller-->POT-->GND so it's returning single
decimal digits, perfect for this use and stupid simple to wire up.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
I'm not sure if I understand your shematic in the spinfile correctly
do you mean it is enough to connect the pot like shown to a IO-Pin of the Prop ?
As there is no capacitor at all where is the element that needs time to "load up" until a threshold-point is reached ?
(delta-sigma principle of AD-conversion)
Is the capacitance of the IO-Pin enough ?
Shouldn't there be a capacitor ? In the name TestRCDelay I think the "C" stands for capacitor
In the PE-Kit-manual it is shown as in the picture attached
best regards
Stefan
I did start with the configuration as listed in the original instruction,
but the "what would happen if i?" in me (see my avatar) discovered
that it becomes a nice twenty position selector without the cap.
(I get less smoke with this attitude than you might think. <smirk>)
Thoughts as to why this works?
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
A good idea would be to add a series resistor to the propeller "pot" pin.
If not...maybe you'll get more smoke that you think, or you'll get a fried propeller pin instead. <grin>
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
I can't reproduce your results.· Can you provide a picture of your board and setup?·
I suspect that in addition to the normal I/O capacitance, you may also be contributing SBB capacitance.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Using the PPDB, I have a 3" wire from P17 to center of POT1.
Another 3" wire from the right (or left) of POT1 to GND.
That's it. Both of them work the same way here, and I can
even stack the POTs together (series) to have dual control
of the digit returned.
How interesting that this works here, but not elsewhere?
No smoke, but I can't imagine why this would stress
the pin more than pulling it low to ground without the
resistance.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
"How interesting that this works here, but not elsewhere?
No smoke, but I can't imagine why this would stress
the pin more than pulling it low to ground without the
resistance."
If your pot is in an extreme position, and the I/O pin is HIGH, then you could potentially sink more current than the I/O can handle.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
When I was reading through the PE-Kit-Counters lab I thought the same thing when I saw this explanation:
"Where is the current-limiting series resistor?
The Propeller chip’s I/O pin driver circuits do not need to be protected from the sudden initial current spike that
results when the I/O pin is taken from either output-low or input to output-high. The I/O pins’ output capacity
and current-limiting characteristics prevent any damage from occurring.
If you try to use this circuit with a different microcontroller, you will probably need to include a current-
limiting resistor between the I/O pin and the RC circuit. Make sure that it is large enough to prevent the I/O pin
from getting damaged. The decay time won’t be linear because the voltage divider created by the second
resistor causes the RC decay measurement’s starting voltage to vary. Choosing an R in the RC circuit that is
very large compared to the series resistor will help the decay time more closely resemble a linear behavior. "
It doesn't really discuss the case that an output could be driving "1" right into the ground plane. It could even
be for an extended period of time depending on what software is being run, and any bugs/crashes that may
occur. You might want to discuss this internally, and update the labs if appropriate.
Post Edited (KeithE) : 10/17/2008 5:01:58 AM GMT
What I don't understand is why a resistor would be used between
the I/O and the POT when the POT itself is simply a variable resistor?
If pulling a high I/O low is an issue, then it would only be a problem
at the lowest side of the POT where there is least resistance?
I'm willing to do some extended testing on this with my PPDB and
see what happens. (After all it is a socketed chip)
Was this reduplicated successfully by anyone else?
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS
Beau answered you doubt before.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
If you're worried about too much current when charging / discharging the cap, just use a smaller cap. The Propeller is a tough little beast.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."
- Bjarne Stroustrup