Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Synteza SPHM DDS
#68
jak robiłem testy to "zawijanie" i zniekształcanie ekranu objawiało się jak były za duże kondensatory na liniach "touch" obecnie dałem 68pF ( miały byc 100pF)

Jak widać na filmie wystarczy proste
y=y_factor*y_adc+y_ofs
v=x_factor*x_adc+x_ofs

i jest OK




bo z 10 nF to była pomyłka...- nawet nie ma sensu pokazywac obrazków... podobnie robiłem próby z bardzo szybkim czytaniem po SPI - też robiły sie "banany" na wykresie - zamiast prostokąta...

(...testy na kodzie C by sp5fcs)

warto tu zajrzeć ;-) na pierwszym linku źródła w C do pobrania do noty aplikacyjnej

http://www.psocdeveloper.com/docs/appnot...n2173.html

tu też duzo wzorów http://www.ti.com/lit/an/slyt277/slyt277.pdf

Myśle że przy dobrze dobranych C i kondensatorach - program z filmu "paint na LCD " rozwiewa niepewnośc czy ekran dziala dobrze... czy źle.




... i jeszcze ten link - z kodami do metody 3 punktowej

http://www.circuitidea.com/Article/Calib...duino.html

Arduino code
Kod:
/*
  Calibrate call touch_calibrate(). Routine set calibrate matrix and save to eeprom.
  Calibrate using 3 point calibrate.
  First point is 24,32.
  Second point is 215,160.
  Third point is 120,287.
  
  Touch screen api will read matrix at init class. No need to call calibrate again.

*/
lcdFont LCD;
touchscreen TS;

void showPoint(void)
{
  char sTemp[8];

  TS.readPoint();
  if (TS.screenPoint.x > 0)
  {
    LCD.Color = WHITE;
    LCD.FgColor = GREEN;    // text foreground color
    LCD.BkColor = RED;    // text background color
    
    ltoa(TS.screenPoint.x, sTemp, 10);
    LCD.TextBox(  0, 280,  59, 310, sTemp, ALINE_CENTER | BORDER_RECT | BORDER_FILL | BEVEL(8));
    ltoa(TS.screenPoint.y, sTemp, 10);
    LCD.TextBox( 60, 280, 119, 310, sTemp, ALINE_CENTER | BORDER_RECT | BORDER_FILL | BEVEL(8));
    ltoa(TS.displayPoint.x, sTemp, 10);
    LCD.TextBox(120, 280, 179, 310, sTemp, ALINE_CENTER | BORDER_RECT | BORDER_FILL | BEVEL(8));
    ltoa(TS.displayPoint.y, sTemp, 10);
    LCD.TextBox(180, 280, 239, 310, sTemp, ALINE_CENTER | BORDER_RECT | BORDER_FILL | BEVEL(8));
  }
}

int setCalibrationMatrix( POINT * displayPtr,
                          POINT * screenPtr,
                          MATRIX * matrixPtr)
{

    int  retValue = 1 ;


    
    matrixPtr->Divider = ((screenPtr[0].x - screenPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) -
                         ((screenPtr[1].x - screenPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ;

    if( matrixPtr->Divider == 0 )
    {
        retValue = 0 ;
    }
    else
    {
        matrixPtr->An = ((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) -
                        ((displayPtr[1].x - displayPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ;

        matrixPtr->Bn = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].x - displayPtr[2].x)) -
                        ((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].x - screenPtr[2].x)) ;

        matrixPtr->Cn = (screenPtr[2].x * displayPtr[1].x - screenPtr[1].x * displayPtr[2].x) * screenPtr[0].y +
                        (screenPtr[0].x * displayPtr[2].x - screenPtr[2].x * displayPtr[0].x) * screenPtr[1].y +
                        (screenPtr[1].x * displayPtr[0].x - screenPtr[0].x * displayPtr[1].x) * screenPtr[2].y ;

        matrixPtr->Dn = ((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].y - screenPtr[2].y)) -
                        ((displayPtr[1].y - displayPtr[2].y) * (screenPtr[0].y - screenPtr[2].y)) ;
    
        matrixPtr->En = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].y - displayPtr[2].y)) -
                        ((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].x - screenPtr[2].x)) ;

        matrixPtr->Fn = (screenPtr[2].x * displayPtr[1].y - screenPtr[1].x * displayPtr[2].y) * screenPtr[0].y +
                        (screenPtr[0].x * displayPtr[2].y - screenPtr[2].x * displayPtr[0].y) * screenPtr[1].y +
                        (screenPtr[1].x * displayPtr[0].y - screenPtr[0].x * displayPtr[1].y) * screenPtr[2].y ;
    }

    return( retValue ) ;

}


void touch_calibrate(void)
{
  unsigned char press;
    
  POINT screenSample[3];   //array of input points
  POINT displaySample[3] = {{24,32},{215,160},{120,287}};  //array of expected correct answers  TS.getMatrix();
  POINT capturePoint;      //array of valid input points

  LCD.Color = WHITE;    // graphic color
  LCD.FgColor = WHITE;  // text foreground color
  LCD.BkColor = BLACK;  // text background color
  
  LCD.TextBox(0, 0, LCD.getMaxX(), 30, "Calibrate", ALINE_CENTER);
  for (uint8_t i=0; i<3; i++)
  {
    // draw touch point
    LCD.Color = RED;
    LCD.Circle(displaySample[i].x, displaySample[i].y , 4);

    press = 0;
    TS.screenPoint.x = 0;
    TS.screenPoint.y = 0;
    while(!press)
    {
      capturePoint.x = TS.screenPoint.x;
      capturePoint.y = TS.screenPoint.y;
      TS.sampling(&TS.screenPoint, 50);
      if (TS.screenPoint.x > 0)
      {
        // Is stable point?
        if ((capturePoint.x == TS.screenPoint.x) && (capturePoint.y == TS.screenPoint.y))
          press = 1;
      }
    }
    // got a point
    screenSample[i].x = TS.screenPoint.x;
    screenSample[i].y = TS.screenPoint.y;

    // mark complete point
    LCD.Circle(displaySample[i].x, displaySample[i].y,3);
    delay(20);
    LCD.Circle(displaySample[i].x, displaySample[i].y,2);
    delay(20);
    LCD.Circle(displaySample[i].x, displaySample[i].y,1);
    delay(60);
    LCD.Color = WHITE;
    LCD.Circle(displaySample[i].x, displaySample[i].y,4);
    delay(20);
    LCD.Circle(displaySample[i].x, displaySample[i].y,3);
    delay(20);
    LCD.Circle(displaySample[i].x, displaySample[i].y,2);
    delay(20);
    LCD.Circle(displaySample[i].x, displaySample[i].y,1);
    delay(250);
  }

  LCD.Clear(BLACK);
  LCD.TextBox(0, 0, LCD.getMaxX(), 30, "Calibrating", ALINE_CENTER);
  setCalibrationMatrix(&displaySample[0], &screenSample[0], &TS.matrix);  // calibration
  TS.setMatrix();                                                         // save matrix to eeprom
  LCD.Clear(BLACK);
  LCD.TextBox(0, 0, LCD.getMaxX(), 30, "Calibrated", ALINE_CENTER);
  delay(1000);
}

void setup()
{

  LCD.Reset();
  LCD.Clear(BLACK);
  LCD.Font(f20x19);

  TS.Reset();
  touch_calibrate();  // use for calibrate only

  LCD.Color = WHITE;    // graphic color
  LCD.FgColor = GREEN;  // text foreground color
  LCD.BkColor = RED;    // text background color

  LCD.TextBox(  0, 250,  59, 279, "scrX", ALINE_CENTER | BORDER_RECT | BORDER_FILL | BEVEL(8));
  LCD.TextBox( 60, 250, 119, 279, "scrY", ALINE_CENTER | BORDER_RECT | BORDER_FILL | BEVEL(8));
  LCD.TextBox(120, 250, 179, 279, "lcdX", ALINE_CENTER | BORDER_RECT | BORDER_FILL | BEVEL(8));
  LCD.TextBox(180, 250, 239, 279, "lcdY", ALINE_CENTER | BORDER_RECT | BORDER_FILL | BEVEL(8));

}

void loop()                    
{
  showPoint();
}
Odpowiedz


Wiadomości w tym wątku
Synteza SPHM DDS - przez SP5FCS - 10-08-2011, 21:15
RE: Synteza SPHM DDS - przez SQ8NVF - 10-08-2011, 21:47
RE: Synteza SPHM DDS - przez SP3SWJ - 11-08-2011, 17:07
RE: Synteza SPHM DDS - przez SQ8NVF - 11-08-2011, 19:13
RE: Synteza SPHM DDS - przez SP5FCS - 11-08-2011, 21:17
RE: Synteza SPHM DDS - przez SP3SWJ - 11-08-2011, 21:18
RE: Synteza SPHM DDS - przez SQ8NVF - 12-08-2011, 9:20
RE: Synteza SPHM DDS - przez SP3SWJ - 12-08-2011, 10:47
RE: Synteza SPHM DDS - przez SQ8NVF - 12-08-2011, 11:23
RE: Synteza SPHM DDS - przez SP3SWJ - 12-08-2011, 11:44

Skocz do:


Użytkownicy przeglądający ten wątek: 1 gości