1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

AR1020 Touch Controller

Discussion in 'Microcontrollers' started by AtomSoft, Mar 26, 2010.

  1. edman222

    edman222 Member

    Joined:
    Jan 3, 2011
    Messages:
    70
    Likes:
    2
    Location:
    Everywhere
    No problem :) Let me know if you ever figure out how to do the screen calibration, I couldn't get mine to work..

    Good luck with your project!
     
  2. 2 minutos

    2 minutos New Member

    Joined:
    Jan 12, 2011
    Messages:
    8
    Likes:
    0
    Edman i have a question, in your data packet do you got data smaller to 1 byte? because the smallest data that i get is 9 bits. Thanks.
     
  3. edman222

    edman222 Member

    Joined:
    Jan 3, 2011
    Messages:
    70
    Likes:
    2
    Location:
    Everywhere
    Uhh i'm not sure what you mean. When I receive the touch data its 8 bits (0000 0000) I don't know why you would get a 9th one, that may be an i2c issue.. are you sure you are not in 10bit mode on your i2c or something..?
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. 2 minutos

    2 minutos New Member

    Joined:
    Jan 12, 2011
    Messages:
    8
    Likes:
    0

    Oh yes i receive the (0000 0000) data but when i touch the right border i get (11 1111111) 9 bits and when i touch the left border i get ( 1111 11111111) 12 bits, i think that i need to calibrate the system. Did you get another data, for example in the right border a data near to zero. i think that in the right border i should get data near to zero.
     
  6. 2 minutos

    2 minutos New Member

    Joined:
    Jan 12, 2011
    Messages:
    8
    Likes:
    0
    i need to calibrate the system, i read the datasheet and it is the problem. im trying to calibrete the system. thanks
     
  7. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    Why not just use 2 PIC ADC channels?

    You don't need a touch controller chip.
     
  8. edman222

    edman222 Member

    Joined:
    Jan 3, 2011
    Messages:
    70
    Likes:
    2
    Location:
    Everywhere
    Perhaps, but that would require more math and cpu time if you wanted to do something more complicated then just simple pen movements. The ar1020 can detect Penup,down,location,screen calibration,speed of pen moving and adjust pen sensitivity, and you only need to read it when its touched, ( no need to keep sampling it ).
    But yea i was considering going to the ADC but got a bit lazy with how the code would integrate.... :p
     
  9. 2 minutos

    2 minutos New Member

    Joined:
    Jan 12, 2011
    Messages:
    8
    Likes:
    0
    edman, i calibrate the driver and it is perfectly working thanks.
     
  10. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    Edman222-
    Most of those features are available from a 2chan ADC solution. You just use an interrupt to sample the X adc then the next interrupt to sample the Y adc, and after the second interrupt you have the X and Y values of where the pen is. If there is no pen contact both adc values read 1023. All that is needed is a couple of resistors, and 4 PIC pins where 2 of the pins have adc capability.
     
  11. mobbster

    mobbster New Member

    Joined:
    Jan 23, 2011
    Messages:
    1
    Likes:
    0
    2 minutos: Can you please post the source code to show how you calibrated the driver? I've been struggling with it for what seems like months. I've had one successful calibrate but haven't been able to reproduce it.
     
    Last edited: Jan 23, 2011
  12. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    This is like the worst touch sensor i know heh.. you have to read a address then calculate the new address to write to ? wtf is that :D

    I should have read this good before buying it. Ima order me some new touch sensors... non Microchip! heh

    I hear TI has some good ones!
     
  13. edman222

    edman222 Member

    Joined:
    Jan 3, 2011
    Messages:
    70
    Likes:
    2
    Location:
    Everywhere
    you only do that once... when you boot it up, not every time you read/write to it. At least thats how iv'e used it.
     
  14. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    It seems like a huge hassle to me. Why couldnt microchip have it with a default address ?

    Touch Screen
     
  15. JLSWISS

    JLSWISS New Member

    Joined:
    Apr 5, 2011
    Messages:
    1
    Likes:
    0
    Ar1020 i2c

    Has anybody a working I2C solution for the AR1020? I'm now working 2 days on different issues and at this point of time I'm able to get at least some acknowledges from the circuit, but not able to get data back. My feeling is that I'm doing something wrong subject to the command settings.
    Is there any boddy willing to provide me some sample code (C or ASM) for the I2C operation?
    Thanks
     
  16. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    Hey ive been trying this IC still with some progress but no luck! Ill attach a image of my logic analyzer result... the data returned is wrong... or should be that... why am i getting this? faulty IC ? from all the testing ?

    This is my SPI Code... (Mixed from microchips sw lib and my own code)

    Code (text):

    unsigned char WriteSWSPI( unsigned char output)
    {
        char BitCount;                  // Bit counter
        volatile char input=0;
       
        BitCount = 8;                   // Do 8-bits
       
        SW_SCK_PIN = 0;
        SW_DOUT_PIN = 0;                // Set the Dout pin according to
       
        for(BitCount=0;BitCount<8;BitCount++)
        {
              input <<= 1;
              SW_SCK_PIN = 1;
             
              if(output&0x80)
                SW_DOUT_PIN = 1;
              else
                SW_DOUT_PIN = 0;
                       
              if(SW_DIN_PIN == 1)
                input|=1;
              else
                input&=0xFE;

              SW_SCK_PIN = 0;
             
              output <<= 1;

        }    
       
        return(input);                  // Return the received data
    }

     
     

    Attached Files:

  17. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    Juts taking a guess, but shouldnt the data output pin be stable for the entire time the SCK is high? So you should output the bit and allow a couple uS for the pin voltage to stabilse then do the SCK pulse.

    Like this;
    set output pin
    2uS wait
    make SCK hi
    appropriate delay see datasheet for SCK hi period?
    read input pin
    make SCK low
    appropriate delay see datasheet for SCK low period?
     
  18. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    the datasheet sucks heh i dont see SPI timing ... exact timing at least.. i tried your code with no change but i altered my original code and got this which is correct... but the next time i try to do a command i get crap...

    OK:
    [​IMG]

    BAD:
    [​IMG]

    Code (text):

    unsigned char WriteSWSPI( unsigned char output)
    {
        char BitCount;                  // Bit counter
        volatile unsigned char input=0;
       
        SW_SCK_PIN = 0;
        SW_DOUT_PIN = 0;                // Set the Dout pin according to
       
        for(BitCount=0;BitCount<8;BitCount++)
        {
              input <<= 1;
             
              if(output&0x80)
                SW_DOUT_PIN = 1;
              else
                SW_DOUT_PIN = 0;

              SW_SCK_PIN = 1;
                                 
              if(SW_DIN_PIN == 1)
                input|=1;

              SW_SCK_PIN = 0;
              output <<= 1;

        }    
       
        return(input);                  // Return the received data
    }
     
     

    Attached Files:

    Last edited: Apr 9, 2011
  19. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    I notice i wasnt polling the SIQ line but i am now and it stops at 0x55, 0x02

    I send this:
    [​IMG]

    This is what i get back,...
    [​IMG]

    Supposed to be 0x55,0x02,0x00,0x13

    Why the heck is this causing so many issues. Am i the only one to think this IC is crap ? It cant just be me. To have to work so hard to get a simple touch screen ic working is a shame. Ive gotten harder things working (no nasty intentions :D )
     

    Attached Files:

    • send.jpg
      send.jpg
      File size:
      13.7 KB
      Views:
      341
    • rec.jpg
      rec.jpg
      File size:
      29.6 KB
      Views:
      351
    Last edited: Apr 9, 2011
  20. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    See my post #29. I do a heap of touchscreen stuff. It's so easy and 4 PIC pins and 2 resistors are all that is needed. Your's probably already using 4 PIC pins for that SPI mess. :)

    You just read the ADC twice, once for X once for Y. Then you have XY of where it was pressed. Sample it in an interrupt every 2mS or so. Then just add some simple debounce etc in software so you need to get 2 very similar XY readings in a row to equal a valid read.

    I have no idea why someone would want to use a pain in the butt specialty IC to do something as simple as read an XY touchpanel. It's like using a specialty chip to read 2 pots. ;)
     
    Last edited: Apr 9, 2011
  21. AtomSoft

    AtomSoft Well-Known Member

    Joined:
    Feb 7, 2008
    Messages:
    5,670
    Likes:
    41
    Location:
    Brooklyn, NY US
    I had it working using the pics adcs but wanted to get it working using the ic since i bought 2. Ill still check your post to see how you did it though thanks... Check my blog for a video on it working with adc pins..
     

Share This Page