For something slow you can discharge a pulse charged cap, using the comparator feature of all Prop pins @ Vdd/2. Not VERY precise but useable within 2% I should say...
4 wire Touch screen have two resistor's X and Y. So basically I need a way to measure this two resistors, so I presume I need two AD channels (or comparators)....
Yes, it looks quite simple: connect the X and Y line to
(a) an appropriate cap (we come to that later) and the caps to + 3V3.
I assume the X and Y resistors are grounded at the other side...
(b) to a Prop pin each we shall call X and Y respectively
The program is at follows:
Set X and Y to high for a short time, enough to charge the caps by a 20mA pulse.
Set X and Y to input
WAITPNE for X or Y to have unloaded below V/2, save CNT
WAITPEQ that both have reached V/2, save CNT
Assess the precision. If not sufficient, use a real ADC
It you need the reading each T than C should be T/2R where R is the maximum resistance oft X and Y
I have used the prop to read a four-wire touch screen. I posted my code on one of the threads. Do a search. I don't have the code handy on this computer or I'd post it again for you now.
The "Microphone2VGA" example in "Object Exchange" is a really good example of ADC with just 2 pins, 2 caps, and 2 resistors. These are built into the demo board. You don't have to use counters to do it, but this gives the fastest conversion rates possible. Here's a snippet:
' At 80MHz the ADC sample resolutions and rates are as follows:
'
' sample sample
' bits rate
'
' 9 156 KHz
' 10 78 KHz
' 11 39 KHz
' 12 19.5 KHz
' 13 9.77 KHz
' 14 4.88 KHz
The code that I put up has a modified ADC object that does two ADC channels at once. It needs 8 pins to do the touch screen. Two for A/D for each axis (X & Y) and two for driving each axis. With additional hardware this pin requirement can be reduced somewhat. I developed the code using the touch panel that I pulled out of my old Palm Pilot. Make sure you put your 100K resistors and caps within 1" of the propeller if possible.
I have some explanation in my documentation about how the touch panel works. Hopefully it makes sense.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
Comments
The demo board is well equipped for this with two tiny caps and a resistor close to the microphone....
There is also software for it
Post Edited (deSilva) : 10/1/2007 12:07:54 AM GMT
(a) an appropriate cap (we come to that later) and the caps to + 3V3.
I assume the X and Y resistors are grounded at the other side...
(b) to a Prop pin each we shall call X and Y respectively
The program is at follows:
Set X and Y to high for a short time, enough to charge the caps by a 20mA pulse.
Set X and Y to input
WAITPNE for X or Y to have unloaded below V/2, save CNT
WAITPEQ that both have reached V/2, save CNT
Assess the precision. If not sufficient, use a real ADC
It you need the reading each T than C should be T/2R where R is the maximum resistance oft X and Y
Post Edited (deSilva) : 10/1/2007 12:08:42 AM GMT
AN001 - Propeller Counters (v1.1; 392 KB)
It talks about using the counters for fast ADC.
But the counters won't help you much. They are nice for D/A convertion. Or you need an opamp as well...
I have used the prop to read a four-wire touch screen. I posted my code on one of the threads. Do a search. I don't have the code handy on this computer or I'd post it again for you now.
[noparse][[/noparse]edit]
Here's the thread where I posted my code:
http://forums.parallax.com/showthread.php?p=669411
[noparse][[/noparse]/edit]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
Post Edited (Ken Peterson) : 9/30/2007 11:49:20 PM GMT
' At 80MHz the ADC sample resolutions and rates are as follows:
'
' sample sample
' bits rate
'
' 9 156 KHz
' 10 78 KHz
' 11 39 KHz
' 12 19.5 KHz
' 13 9.77 KHz
' 14 4.88 KHz
I have some explanation in my documentation about how the touch panel works. Hopefully it makes sense.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?