2009-07-28 11:59 PM
Change adc setup on the fly?
2011-05-17 04:18 AM
Dear All,
For my touchscreen i would like to change my adc ports *on the fly* Let me to explain my problem. I have a touchscreen panel which has 4 wires. In datasheet, to read x coordinate; connect 1st and 3rd wires to adc ports, 2nd to VCC and 4th to GND and read. To read y coordinate; connect 2nd and 4th wires to adc ports, 1st to VCC and 3rd to GND and read. Make them continuously. So i need to define adc ports and gpio ports continuously. I have adc init routine and port set routines. Should i define and init them in every cycle? Is there any example? optizyme2011-05-17 04:18 AM
We did similar implementation with ''standard'' 4-wire touch-screen in the past. We used just 2 A-D channels - and switched between power/A-D as you suggest.
Key points: a) You don't need much current - check/insure that STM32 A-D channel has sufficient output drive when placed in GPIO source mode b) We simplified our ''TS software loop'' by observing that we only had to check ''one'' of the X-Y channels - if it proved inactive we jumped from the TS loop. By the way - this reduced ''power/A-D'' switching provided the unexpected benefit of creating a faster scan/test TS rate. With our hardware we found 20-60Hz TS scan adequate - and we performed a sequence of 4 A-D reads (upon a valid ''hit'') and averaged the results - gaining accuracy.2011-05-17 04:18 AM
Hi jj, optizyme
Yes, I would say the same, you can use ADC Inputs and change them on the fly while scanning X, then Y and configuring VDD and VSS , You can even enhance the scan time by using DMA and Timers to do it in automatic way without CPU intervention and reach higher rates. Cheers, STOne-32.2011-05-17 04:18 AM
Hello jj.sprague and STone,
Thank you for your kind replies. I'm trying adc<->power conversion but i failed many times. I'm following this document :http://www.atmel.com/dyn/resources/prod_documents/doc8091.pdf
So ST1, i would kindly ask if you can supply some sample code (esp. related with dma configuration) please? Optizyme2011-05-17 04:18 AM
@Optizyme
Believe that you will get faster results - with much less effort/struggle - following this procedure. (which has worked repeatedly for me/my firm) a) As 20-60Hz ''T.S. read'' rate has proved adequate for us/clients - DMA may add2011-05-17 04:18 AM
Dear jj.sprague,
Thank you for your kind help, i really appreciate it. I took your advice and connected Top->Vcc and Bottom->Gnd. I started to read values from Left correctly and ignored Right. So i realized your ''2 analog input'' advice :) To read X axis it is ok to connect GND to Right, So for x axis Top->Vcc Bottom->GND Left->AN0 Right->GND and for y axis Top->AN1 Bottom->GND Left->Vcc Right->GND. So Bottom and Right can always be GND right? I didn't try to connect bottom and right to gnd because of my development kit problem but i think it will work. I will always change Top and Left pins to Analog<->VCC. Is it true? Optizyme2011-05-17 04:18 AM
@Optizyme
Glad you had success - simpler is most always better. I believe your ''fixing'' Bottom & Right to ground is ok - please do prototype & verify before you design pcb. Confirm that GPIO output ''holds up'' when you touch lowest resis