2025-01-09 12:53 AM - last edited on 2025-03-24 1:48 AM by Amel NASRI
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-17 8:54 AM
The capacitance of those wires shouldn't make a significant difference. I suspect the delay between switching and sampling is too low. Please plot scope data.
2025-01-18 5:42 AM
Hi there,
Hope you are doing well.
I understood that we need to give some delay after reconfiguring the ADC channels and gpio, stop sampling, and start it just after switching before adc_start_conversion() for the initial channel and gpio configuration.
This is what I got.
Thanks for the precious advice.
Waiting for your response as well
2025-01-18 11:00 AM
Exactly. The foil has resistance and capacitance, so there is a delay. Not much, but if you sample right away the voltage hasn't stabilized yet.
2025-03-20 1:17 AM
Hi there,
Hope you are doing well.
I am able to debug the range change issue due to sampling during switching configurations.
I have observed following things in conclusion to 4 wire resistive touch coding and testing:
1- it values not changes but very minor like x axis voltage changes from [0.5,2.99] to [0.5,2.8] and y axis voltage changes from [0.58,2.82] to [1.1,2.82]. This happens when wires get loose from lcd connector or mcu headers due to moving wires rapidly intentionally.
2- Interesting thing is that whenever I reconnect the wires, it come to default values always such as:
x-axis voltage: [0.5,2.99]
y-axis voltage: [0.58,2.82]
so whenever issue occurs, reconnect them and things got resolved. This was not the case before stopping sampling during switching.
3- I am giving 5ms HAL_Delay() before starting sampling and giving 5ms delay as well after stopping sampling.
4- Current sampling rate is 1kHz AS CALLCULATED from timer pre-scaler and ARR values.
Questions:
1- Have it really solved that issue or still stuck with it?
2- will it resolve if wires get tight enough by soldering them or like in form of pcb tracks?
Please respond.
I am looking for your kind reply..
Thnaks
2025-03-20 3:37 AM
@Embedded_12engr wrote:1- Have it really solved that issue or still stuck with it?
It seems you don't have a solid connection of wires. Use good connectors or solder them to a PCB or protoboard.
What you can also do is use a multimeter and measure the resistances at various points when touching the panel. Then you know what values you should get when doing the measurement with your MCU. This will be your reference. If the values match then your code works.
Next you need to convert the raw values to coordinates. There are formulas for that online. Each foil is different so you either need calibration or you can hardcode the values for one foil in the code.
2025-03-22 12:56 AM
Thank you so much for your kind reply.
Please share any source/manual to know the context of the resistance because I am measuring direct voltage using mcu adc.
what do u mean by raw values ?
Are these values related to resistance or voltage?
Yes every foil will have different minimum and maximum values that we need to hardcode for specific foil. Am I right or not?
Waiting for your reply.
Thanks in advance
2025-03-23 1:33 PM
@Embedded_12engr wrote:Thank you so much for your kind reply.
Please share any source/manual to know the context of the resistance because I am measuring direct voltage using mcu adc.
Just search for 4-wire resistive touch application notes. Microchip has some good application notes on it. They have schematics and formulas: https://ww1.microchip.com/downloads/en/Appnotes/doc8091.pdf . Ti also has one: https://www.ti.com/lit/an/sbaa155a/sbaa155a.pdf . Infineon: https://www.infineon.com/dgdl/Infineon-AN2376_PSoC_1_Interface_to_Four-Wire_Resistive_Touchscreen-ApplicationNotes-v05_00-EN.pdf?fileId=8ac78c8c7cdc391c017d07342ccf57e5
There are also chips that do the measurement for you: https://www.ti.com/lit/ds/symlink/tsc2013-q1.pdf . But you want to use the ADC of the MCU and not an external chip correct?
@Embedded_12engr wrote:what do u mean by raw values ?
Unprocessed values. ADC counts.
@Embedded_12engr wrote:Yes every foil will have different minimum and maximum values that we need to hardcode for specific foil. Am I right or not?
Each foil type has different values, but different foils of the same type also have very different values. And over time the values may need to be re-calibrated. Hardcoding is fine for testing. But it's best to store them in non-volatile memory and allow re-calibration.