Is it ok to connect a 4-wire resistive touch to MCU directly?

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On the net there are many examples or tutorials (especially for AVR) which they have connected a 4-wire resistive touch to MCU directly. is it ok totally?(for any kind of MCUs) if so, then why sometimes they use BJTs or MOSFETs to drive it?

Recently I was trying to do this on an STM32 but I failed to do this.

"One's value is inherent; money is not inherent"

 

Chuck, you are in my heart!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

According to app note AVR341 it's just fine, but there is a mention of it requiring between 5 and 25ma sink/source current capability from the driving pins.  Perhaps at the higher end of that range there's some concern about the impedance of the pins affecting the result, but that's just a wild guess on my part.  I'd wager it doesn't matter much for simple button pressing applications...maybe it's more relevant for capturing writing and the like?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With xMega, since the reference voltage can't be above VCC-0.6v, you get a section you can't reach. A BIG section if you use the VCC/1.6 reference.

274,207,281-1 The largest known Mersenne Prime

Measure twice, cry, go back to the hardware store

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Rezer and Tom

 

@Rezer

Rezer

That was always a question to me that how AVR consumers use an ADC pin of AVR to use 4-wire resistive touch. take a look here. for reading X or Y he has written:

 

Configure x1 (PA4) & x2 (PA2) as outputs. Set x1 (PA4) to high (+5V) state and x2 (PA2) to low (GND) state.

·         Read the analog voltage at y2 (PA3) using ReadADC(3) command. Store the discrete value in the variable “x”

·         Configure y1 (PA1) & y2 (PA3) as outputs. Set y1 (PA1) to high (+5V) state and y2 (PA3) to low (GND) state.

·         Read the analog voltage at x1 (PA4) using ReadADC(4) command. Store the discrete value in the variable “y”

But it must not work! let me explain it. e.g. let's read the position of X on the touch screen:

We configure x1 (PA4) & x2 (PA2) as outputs. Set x1 (PA4) to high (+5V) state and x2 (PA2) to low (GND) state. ok, so far so good. now we read Y. the above explanation says "Read the analog voltage at y2 (PA3) using ReadADC(3) command" but it's not enough! we must read y1 as well. look at this image:

 

 

X1 is a changeable resistor. the best way to use 4-wire touch screen is that read both side. I mean X1 and X2.

This is a question to me how AVR consumers use this defective way to read their 4-wire resistive touch! eyerolling!

 

@Torby

Tom

I want to use your circuit that you gave me here. I mean this:

 

 

Did you use it? was it working very well?

"One's value is inherent; money is not inherent"

 

Chuck, you are in my heart!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rohalamin wrote:

But it must not work! let me explain it. e.g. let's read the position of X on the touch screen:

We configure x1 (PA4) & x2 (PA2) as outputs. Set x1 (PA4) to high (+5V) state and x2 (PA2) to low (GND) state. ok, so far so good. now we read Y. the above explanation says "Read the analog voltage at y2 (PA3) using ReadADC(3) command" but it's not enough! we must read y1 as well. look at this image:

 

Why do you imagine that it's necessary to read y1 as well?  When getting the value for X, the resistances on sides x1 and x2 form a voltage divider and you use the ADC value read from either y1 or y2 to calculate the x position.  The resistor value at y1 (or y2) is irrelevant; it does not affect the ADC value for X.  That is to say, the ADC reading is identical at both y1 and y2 within a small margin of error.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A typical 240x320 Touch Panel has a resistance of 300R in the X direction.

When you apply a 3.3V voltage across XP, XM to read the ADC value on YP you are sourcing and sinking 11mA through the XP, XM pins.

This is outside the spec for most ARM chips.    And the ADC value might be outside the spec for an Xmega chip.

 

Yes,  you can reverse the voltage across XP, XM.   And compare the new YP ADC value.  e.g. 33% in positive direction would be 67% in the negative direction.

You can also read YM if it can be configured as an ADC pin.    Obviously it should give the same value as YP.

 

A regular AVR has no problems with the currents.   And no problem with the ADC.

You can try a Resistive Panel with ARM or Xmega.  The 320x480 panels have a higher resistance and hence less current.

 

In practice,  most Arduino 16-bit shields have a separate XPT2046 Touch Controller.    This does all the work for you.

 

Oh,   You can run a Resistive Touch Panel with 5V GPIO,    The accompanying TFT controller is 3.3V.    You must ensure that 5V does not get to the TFT pins.

 

David.

Last Edited: Wed. Jul 6, 2016 - 07:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rezer wrote:

Why do you imagine that it's necessary to read y1 as well?  When getting the value for X, the resistances on sides x1 and x2 form a voltage divider and you use the ADC value read from either y1 or y2 to calculate the x position.  The resistor value at y1 (or y2) is irrelevant; it does not affect the ADC value for X.  That is to say, the ADC reading is identical at both y1 and y2 within a small margin of error.

I don't know how to ask my question politely but have you driven/used any 4-wire resistive touch screen?

Pardon me.

We should read y1 and plus it to y2. in this way you can minus the affect of X axis's resistor.

david.prentice wrote:
...

Yes,  you can reverse the voltage across XP, XM.   And compare the new YP ADC value.  e.g. 33% in positive direction would be 67% in the negative direction.

You can also read YM if it can be configured as an ADC pin.    Obviously it should give the same value as YP.

...

I don't get what you're saying exactly David but I have a question to you and Rezer. let's assume we have a 4-wire resistive touch screen and we've wired it up like this:

 

Now we measure the voltage at +X and -X. are they the same?

I doubt!

 

"One's value is inherent; money is not inherent"

 

Chuck, you are in my heart!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, I haven't, but I understand the theory behind how they work.  You are familiar with the old V=IR, yeah?  Well let's take that and make an assumption.  Let's say the touch was at a Y value near the middle of the screen so the voltage is 1.7V at the center of your diagram, and we'll see if we can figure out what ADC1 and ADC2 will read.  ADC inputs are very high impedance (100M ohms according to the atmega datasheets I've looked at), so we know the current flowing across the resistors at X1 and X2:  approximately 0, so close in fact that we can just assume it's 0 for the small resistances used in resistive touch screens.  Since that is the case, let's pull out V=IR and figure out what the voltage drop from the center to ADC1 is.  Well would you look at that, the current is 0 so 0 times any possible value for resistance X1 is 0 and whaddya know, the voltage drop across the resistor at X1 is 0.  ADC1 = 1.7V - 0V = 1.7V, same as the value in the center.  I'll leave the calculations for ADC2 as an exercise for the reader.

Last Edited: Wed. Jul 6, 2016 - 09:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rezer wrote:
...

  ADC inputs are very high impedance (100M ohms according to the atmega datasheets I've looked at)...

For AVR as you said:

 

 

And for my STM32:

 

 

"One's value is inherent; money is not inherent"

 

Chuck, you are in my heart!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Amin,

I gave an example for reading X via the YP pin.
Your example is for reading the Y position via the XM (or XP) pin.
.
ADC1 (X1) and ADC2 (X2) will both read the same. Of course both X1, X2 must be high inpedance inputs. Otherwise there will be a current path from Y1, Y2 to the non-ADC X pin.
.
It is probably easier to experiment with a regular AVR. You will see how it reads the Y position. You will see how there is a variation. So it is wise to apply some statistical analysis of several ADC readings. Typically choosing the median value.
.
You can also make an estimate of the Touch pressure.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rohalamin wrote:

Thank you Rezer and Tom

 

@Rezer

Rezer

That was always a question to me that how AVR consumers use an ADC pin of AVR to use 4-wire resistive touch. take a look here. for reading X or Y he has written:

 

Configure x1 (PA4) & x2 (PA2) as outputs. Set x1 (PA4) to high (+5V) state and x2 (PA2) to low (GND) state.

·         Read the analog voltage at y2 (PA3) using ReadADC(3) command. Store the discrete value in the variable “x”

·         Configure y1 (PA1) & y2 (PA3) as outputs. Set y1 (PA1) to high (+5V) state and y2 (PA3) to low (GND) state.

·         Read the analog voltage at x1 (PA4) using ReadADC(4) command. Store the discrete value in the variable “y”

But it must not work! let me explain it. e.g. let's read the position of X on the touch screen:

We configure x1 (PA4) & x2 (PA2) as outputs. Set x1 (PA4) to high (+5V) state and x2 (PA2) to low (GND) state. ok, so far so good. now we read Y. the above explanation says "Read the analog voltage at y2 (PA3) using ReadADC(3) command" but it's not enough! we must read y1 as well. look at this image:

 

 

X1 is a changeable resistor. the best way to use 4-wire touch screen is that read both side. I mean X1 and X2.

This is a question to me how AVR consumers use this defective way to read their 4-wire resistive touch! eyerolling!

 

@Torby

Tom

I want to use your circuit that you gave me here. I mean this:

 

 

Did you use it? was it working very well?

 

Haven't tried it. You talked me into using a touch screen controler chip, but all time and money for the project have been cut off.

274,207,281-1 The largest known Mersenne Prime

Measure twice, cry, go back to the hardware store

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Those values do not represent the same thing between the two datasheets.  Refer to this diagram:

 

 

RAIN for the STM 32 is the max impedance you can have external to the chip and still be guaranteed less than 1/4 LSB error at the full 12 bits of resolution.  RADC is the internal resistance going into the sample and hold capacitor.  The total impedance of the ADC seems to be captured by IL at 1 uA, which sounds a lot more reasonable for an ADC input.

Last Edited: Wed. Jul 6, 2016 - 05:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Think about it.   The ADC is going to measure the Y position from message #7 correctly.

The STM32 is going to have a problem providing enough GPIO current to drive the 300R resistance.

 

The ADC has a high input impedance.   The 300R is certainly providing a low impedance source.    Even if your Touch pressure is not very hard,  the "series" input resistance is trivial compared to the ADC input.    Yes,  a light Touch will affect the SAH capacitor very slightly.

 

There is absolutely no point in worrying about a 12-bit ADC.   The Touch reading is not perfect.   I would not even trust a 10-bit without some statistical processing.

 

David.

Last Edited: Wed. Jul 6, 2016 - 07:27 PM