Programming resistive touch screen using pic

Discussion in 'Embedded Systems and Microcontrollers' started by wind_blast942, May 18, 2011.

  1. wind_blast942

    Thread Starter New Member

    Sep 7, 2010
    22
    0
    Hi

    I am currently doing a project that requires the use of a touchscreen. The one that I plan to use is this : http://singapore.rs-online.com/mobile/search/searchBrowseAction.html?method=getProduct&R=7105256

    However I am not sure for this kind of touchscreen, do I have to purchase ab additional driver chip to make it work or is it trivial enough to program the pic 16 that I already have? As I have budget constriants, I was hoping that the additional chip is not needed.

    Any help is much appreciated thanks.
     
  2. wind_blast942

    Thread Starter New Member

    Sep 7, 2010
    22
    0
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,395
    1,607
    While I believe Microchip does make some fine dedicated driver chips just for this, I've not used them as I designed a scheme (and bought the PCB's) long before they released them.

    Resistive touch screens are simple to read: If you put say +5V on X+ and ground on X-, when you touch it you make a contact to the Y+ and Y- terminals. The same voltage appears on both Y's and it is the ratio of the distance from X+ to the total, or if you poke it 1/4th from the bottom 1/4* 5V or 1.25V is on the Y's. Same holds if you drive the Y's and read the X's.

    And I have sever transistor dyslexia (the complete inability to keep simple things in order) so I may have that all backwards, but the general scheme still applies.

    My "driver" is just 4 transistors, 2 NPN's and 2 PNP's. I also use 4 pins from, the PIC, 2 I/O's and 2 A2D inputs. You can get by with just 1 I/O but you'll need an inverter from somewhere as the inputs are always opposite each other (though no harm occurs if both are the same high or low).

    [​IMG]

    With RX0 hi and RX1 low Q2 is on driving Y- low while Q3 is on and Y+ at Vdd; you can now read X- on the A2D at AN1. Q1 & Q4 are both off.

    With RX0 low and RX1 hi Q1 is on driving X+ to Vdd while Q4 is on driving X- low; you can now read Y- on the A2D at AN0. Q2 & Q3 are both off.

    When reading the A2D I set the reference to Vdd, as the signals vary between 0 and Vdd. You need to do a bit of calibration as zero on the A2D is not one edge and 256 (8 bits) or 1023 (10 bits) is not the other edge but once you cal it then you should be good till the thing dies.

    The graphic LCD I had under my touchscreen required two chip selects so I double purposed these to be my RX0 and RX1, as setting the screen and reading the touch are never done at the same time.
     
  4. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    You can do it with 4 PIC pins, you just need to set them to 5v and 0v on one axis and set the other 2 pins to inputs (and one needs to be a ADC of course).

    The only external hardware needed is a couple of 100k pulldown resistors on the 2 ADC pins.
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,395
    1,607
    Yup, 4 pins will work if you can switch the A2D when needed. The part I was using did not allow that, some more recent cores do.

    So it's check the data sheet time for the OP.

    And oh yeah, you need the pull downs else the sense outputs will ghost just about any voltage on an unpressed screen. 100K is fine, I used 50K in mine. Anything in the "much higher" (10x or so) range from the screen resistance should work.

    Thanks for the memory jog RB.
     
Loading...