2025-01-09 12:53 AM
i have written a driver code to run 4 wire resistive touch panel. I use only 1 adc and change its adc channel during runtime. Like i set X+ and Y+ as output high by default and X- and Y- set as low by default and set X- and y- pull down to make ADC read 0 when not pressed. Basically, I have few functions that change the configuration such as X+ and X- to output, set Y+ to analog and Y- to input to set Y+ and Y- as an output, set X+ to analog and X- to input. read x voltage in previous case and read y voltage in later case. ADC is only one to switch the configuration during runtime and its resolution is 16 bit with 810.5 cycles sampling time.
ISSUES:
1- gpio output 3.3v and ground but its adc measuring voltage is from (0.7 to 1.15 for x axis) and (0.55 to 2.8 for y axis)
2- if i move the wires then its voltage ranges change.
Is this issue related with the firmware developed for running the 4-wire touch panel or hardware issue?
I have connected decoupling capacitors of 0.33uF across X+ AND X- and Y+ and Y- as well to stablize the 3.3v source from the mcu gpios.
Looking for your precious advice and solution!!!!
2025-01-09 07:41 AM - edited 2025-01-13 01:13 AM
@Embedded_12engr wrote:I have connected decoupling capacitors of 0.33uF across X+ AND X- and Y+ and Y- as well to stablize the 3.3v source from the mcu gpios.
I think this influences the reading. The foil has capacitance and resistance and you cannot read it too fast because of this. The voltage needs to stabilize. Adding additional capacitance will make it worse. Also you are adding capacitance on MCU outputs which will load the pins. Remove the capacitors and try tweaking your sampling rate.
Also realize if the ADC measurement is ratiometric the exact supply voltage doesn't matter.
@Embedded_12engr wrote:ISSUES:
1- gpio output 3.3v and ground but its adc measuring voltage is from (0.7 to 1.15 for x axis) and (0.55 to 2.8 for y axis)
2- if i move the wires then its voltage ranges change.
You should not expect full range. You need to calibrate your measurement too.
Your measurement should produce 5 resistance values. One of them is the touch resistance which varies based on how hard you push.
2025-01-11 03:00 AM
Hi there,
Thank you so much for your response to my query.
Can you please explain following terms in detail or through example:
Also realize if the ADC measurement is radiometric the exact supply voltage doesn't matter. (Please explain radiometric term)
Please explain my touch code logic also ok or I need to change the logic?
Looking for your precious advice and solution!!
2025-01-11 03:37 AM - edited 2025-01-11 05:27 AM
ratiometric means the ADC uses the same reference as the signal. So if the reference is the power supply and the same power supply is used for a voltage divider the resulting measurement is a ratio. No need to calculate an absolute voltage or resistance.
Here is an application note. On page 4 you can see what I meant with the 5 resistors
https://ww1.microchip.com/downloads/en/AppNotes/doc8091.pdf
2025-01-11 05:25 AM
please share the application note!!
is it ok to measure two voltages using single adc by switching its configuration in runtime?
Looking for your reply
2025-01-11 05:30 AM
@Embedded_12engr wrote:please share the application note!!
Done. Somehow pasting the link didn't work.
@Embedded_12engr wrote:is it ok to measure two voltages using single adc by switching its configuration in runtime?
Yes. Not too quick though, because the voltage needs to stabilize and not too slow as the touch point may be moving or the touch event can be brief.
2025-01-11 05:48 AM
Can you please mention the optimum value of the sampling rate? not too fast or not too slow.
I shall be thankful to you.
2025-01-13 01:09 AM - edited 2025-01-13 01:24 AM
With sampling rate I meant measurement rate: the rate at which you measure including all the delays. Not the ADC sampling rate. That one needs to be fast enough for your measurement, but not too fast if that impacts the accuracy of the ADC. Read "Minimum sampling time vs RAIN" in your MCU datasheet. With high signal source impedance you need a longer sampling time. This is due to loading of the signal by the sample and hold circuit in the ADC.
Most resistive touch screens have time constants far below 1ms. If you give the touch foil a few time constants to settle after applying a voltage it should be fine to read it.
The measurement rate is too slow if it starts to impact response time from the user perspective. So it should be seen in relation to the frame rate. I wouldn't sample lower than the frame rate. Also take into account that the values may need to be debounced and the first reading when touched may be off.
In terms of calibration there are formulas in the application note. You need to do 3 or 4 point calibration (or more) and store the calibration values in non-volatile memory (or hardcode it if you only have 1 device).
2025-01-14 01:01 AM
Thank you so much for your help. I will let u know if I have any more questions.
2025-01-17 02:42 AM
Hi there,
I checked the datasheet and we have the same logic implemented for running the touch panel. It is also mentioned in the datasheet we can utilize decoupling capacitors of 0.11uF for noise immunity, it just increases the time constant.
Need suggestion:
1- Whenever I disconnect the wires of the touch panel and connect them again or I move the wires, it changes the voltage ranges but not too much like Voltage X: [0.5,2.85] to [0.5,2.7] or something else max value.
Can I solve this issue by replacing jumper wires with the PCB traces or tracks? like I make a PCB instead of the circuit on the breadboard?
This will lead to fixed conductive paths instead of moveable ones.
Looking for your precious advice .