This post is also available in: Türkçe (Turkish)
- I wrote in mikroC , 4-wire resistive touch panel control library
- I used the mikroelektronika circuit to drive the panel. Below is the circuit diagram
- Guide and video watch ?
- Touch you can see in the video library “writing” and “pixel” functions belong to the library I have written. Therefore, if you are using standard mikroC library must write the functions that you can use the library or by downloading my library here (mikroC GLCD DISPLAY LIBRARY – (SAP1024B – T6963C))
- IMPORTANT! – Analog to Digital conversion reference the supply voltage is, therefore, noise must be removed or use this circuit (+5v -5v 3.3v SWITCH MOD REGULATOR)
- Question and error notifications send comment !
Materials Required for Circuit Construction
- 1 PCS – 4 Pin FPC Socket( for touch panel connection)
- 2 PCS- 100 nf Polyester Capacitors
- 2 PCS – 47K Resistor
- 8 PCS – 1K Resistor
- 2 PCS – 10K Resistor
- 3 PCS – BC546 Transistor
- 2 PCS – BC556 Transistor
Circuit Diagram
Codes
//DOKUNMATİK PANEL PİNLERİ////////// sbit surucu_a at RA5_bit; //touch panel driver_a pin sbit surucu_b at RB4_bit; //touch panel driver_b pin sbit analog_x at RA0_bit; //touch panel analog port end pin sbit analog_y at RA1_bit; //touch panel analog port end pin sbit surucu_a_Direction at TRISA5_bit; //surucu_a pini sbit surucu_b_Direction at TRISB4_bit; //surucu_b pini sbit analog_x_Direction at TRISA0_bit; //analog port ucu pini sbit analog_y_Direction at TRISA1_bit; //analog port ucu pini
//Calibration Pre-Function Codes //pixel fonksiyonu içerisinde yazan ölçüler en ideal kalibrasyon ölçüleridir(x,y) //kalibrasyon ölçüleri ile ilgili yukarıdaki resmi inceleyebilirsiniz void kalbire_et() { do { SAP1024_YAZI_YAZMA(1,8,"1.Noktaya Dokunun"); SAP1024_PIXEL((GENISLIK_D*20)/100,(YUKSEKLIK_D*80)/100,1); }while(D_PANEL_KALIBRASYON_NOKTA_1()!=1); sap1024_lcd_temizle(); do { SAP1024_YAZI_YAZMA(1,8,"2.Noktaya Dokunun"); SAP1024_PIXEL((GENISLIK_D*20)/100,(YUKSEKLIK_D*20)/100,1); }while(D_PANEL_KALIBRASYON_NOKTA_2()!=1); sap1024_lcd_temizle(); do { SAP1024_YAZI_YAZMA(1,8,"3.Noktaya Dokunun"); SAP1024_PIXEL((GENISLIK_D*80)/100,(YUKSEKLIK_D*20)/100,1); }while(D_PANEL_KALIBRASYON_NOKTA_3()!=1); sap1024_lcd_temizle(); do { SAP1024_YAZI_YAZMA(1,8,"4.Noktaya Dokunun"); SAP1024_PIXEL((GENISLIK_D*80)/100,(YUKSEKLIK_D*80)/100,1); }while(D_PANEL_KALIBRASYON_NOKTA_4()!=1); sap1024_lcd_temizle(); }
//Touchscreen Codes while(1) { x1=D_PANEL_KONUM_X();//dokunulan noktanın x konumunu verir y1=D_PANEL_KONUM_Y();//dokunulan noktanın y konumunu verir if(D_PANEL_DOKUNULDU_MU(50)==0)//panele dokunuldumu? { SAP1024_PIXEL(x1,y1,0); } SAP1024_PIXEL(x1,y1,1); delay_ms(5); }
//Button and Location Codes while(1) { if(D_PANEL_KORDINAT_KONTROL(100,100,10,10)==1) { SAP1024_YAZI_YAZMA(5,14,"resme bastin"); delay_ms(500); SAP1024_LCD_TEXT_TEMIZLE(); } inttoSTR(D_PANEL_KONUM_X(),yazi); SAP1024_YAZI_YAZMA(5,8,yazi); inttoSTR(D_PANEL_KONUM_Y(),yazi); SAP1024_YAZI_YAZMA(5,10,yazi); }
//Full Codes char SAPTRIS at trisd;//data portları char SAPDATA_giris at portd; char SAPDATA_cikis at latd; sbit SAP1024_RD at RC1_bit ; //GLCD RD UCU BAĞLANTI PİNİ sbit SAP1024_CE at rc2_bit ; //GLCD CE UCU BAĞLANTI PİNİ sbit SAP1024_CD at Rc3_bit ; //GLCD C/D UCU BAĞLANTI PİNİ sbit SAP1024_RST at Rc4_bit ; //GLCD RST UCU BAĞLANTI PİNİ sbit SAP1024_FS at Rc5_bit ; //GLCD FS UCU BAĞLANTI PİNİ sbit SAP1024_WR at RC0_bit ; //GLCD wr UCU BAĞLANTI PİNİ sbit SAP1024_RD_Direction at TRISC1_bit; //GLCD RD UCU BAĞLANTI PİNİ sbit SAP1024_CE_Direction at TRISC2_bit; //GLCD CE UCU BAĞLANTI PİNİ sbit SAP1024_CD_Direction at TRISC3_bit; //GLCD C/D UCU BAĞLANTI PİNİ sbit SAP1024_RST_Direction at TRISC4_bit; //GLCD RST UCU BAĞLANTI PİNİ sbit SAP1024_FS_Direction at TRISC5_bit; //GLCD FS UCU BAĞLANTI PİNİ sbit SAP1024_WR_Direction at TRISC0_bit; //GLCD FS UCU BAĞLANTI PİNİ //DOKUNMATİK PANEL PİNLERİ////////// sbit surucu_a at RA5_bit; //dokunmatik panel surucu_a pini sbit surucu_b at RB4_bit; //dokunmatik panel surucu_b pini sbit analog_x at RA0_bit; //dokunmatik panel analog port ucu pini sbit analog_y at RA1_bit; //dokunmatik panel analog port ucu pini sbit surucu_a_Direction at TRISA5_bit; // surucu_a pini sbit surucu_b_Direction at TRISB4_bit; // surucu_b pini sbit analog_x_Direction at TRISA0_bit; //analog port ucu pini sbit analog_y_Direction at TRISA1_bit; //analog port ucu pini void kalbire_et() { do { SAP1024_YAZI_YAZMA(1,8,"1.Noktaya Dokunun"); SAP1024_PIXEL((GENISLIK_D*20)/100,(YUKSEKLIK_D*80)/100,1); }while(D_PANEL_KALIBRASYON_NOKTA_1()!=1); sap1024_lcd_temizle(); do { SAP1024_YAZI_YAZMA(1,8,"2.Noktaya Dokunun"); SAP1024_PIXEL((GENISLIK_D*20)/100,(YUKSEKLIK_D*20)/100,1); }while(D_PANEL_KALIBRASYON_NOKTA_2()!=1); sap1024_lcd_temizle(); do { SAP1024_YAZI_YAZMA(1,8,"3.Noktaya Dokunun"); SAP1024_PIXEL((GENISLIK_D*80)/100,(YUKSEKLIK_D*20)/100,1); }while(D_PANEL_KALIBRASYON_NOKTA_3()!=1); sap1024_lcd_temizle(); do { SAP1024_YAZI_YAZMA(1,8,"4.Noktaya Dokunun"); SAP1024_PIXEL((GENISLIK_D*80)/100,(YUKSEKLIK_D*80)/100,1); }while(D_PANEL_KALIBRASYON_NOKTA_4()!=1); sap1024_lcd_temizle(); } void main() { char yazi[8]; int x1,y1; //GENEL PORT AYARLARI ADCON0=0x09; ADCON1&=0xF0; cmcon|=7; //------------------ SAP1024_INIT(240,128,8); ADC_Init(); D_PANEL_INIT(240,128,0,1); kalbire_et(); SAP1024_DORTGEN(100,100,110,110,1,1); while(1) { x1=D_PANEL_KONUM_X(); y1=D_PANEL_KONUM_Y(); if(D_PANEL_DOKUNULDU_MU(50)==0) { SAP1024_PIXEL(x1,y1,0); } SAP1024_PIXEL(x1,y1,1); delay_ms(5); if(D_PANEL_KORDINAT_KONTROL(100,100,10,10)==1) { SAP1024_YAZI_YAZMA(5,14,"resme bastin"); delay_ms(500); SAP1024_LCD_TEXT_TEMIZLE(); } inttoSTR(D_PANEL_KONUM_X(),yazi); SAP1024_YAZI_YAZMA(5,8,yazi); inttoSTR(D_PANEL_KONUM_Y(),yazi); SAP1024_YAZI_YAZMA(5,10,yazi); } }
Important Notes
- You must watch the video tutorials to see the implementation of the Code
Technical Documents
Document
- Calibration in touch-screen systems
- Calibration procedure for a resistive touchscreen system based on the STMPE811
- MMSE-Based Multipoint Calibration Algorithm for Touch Screen Applications
- Study on Calibration Algorithm of Embedded Touch Screen
- BC546 Datasheet
- BC556 Datasheet
- Mikroelektronika’s Touch Panel
This post is also available in: Türkçe (Turkish)