当前位置:网站首页>Xpt2046 four wire resistive touch screen
Xpt2046 four wire resistive touch screen
2022-07-02 15:45:00 【Bitongo】
List of articles
One 、 brief introduction
XPT2046 Four wire resistive touch screen , It is mainly plated with ITO Film composition of the coating . One layer has a vertical bus on the left and right edges of the screen , The other layer has a horizontal bus at the bottom and top of the screen , If voltage is applied to two buses of a thin film , stay ITO A uniform electric field will be formed on the coating . When the user touches the touch screen , At the point of contact, two layers of film will contact , The voltage at the contact point can be measured on another layer of film .
The following figure for XPT2046 Functional block diagram , so XPT2046 There is a multiplexer inside , Able to measure battery voltage 、AUX voltage 、 Chip temperature . One 12 Bit ADC Used for analog-to-digital conversion of the selected analog input channel , Get the digital quantity , Then it is sent to the control logic circuit , For master control CPU To read , meanwhile , Which channel to choose for conversion , It is also controlled by the master CPU Send commands to the control logic to set .
XPT Support stroke interruption , That is, when the touch screen detects that the touch is pressed , It can immediately produce stroke interruption , Inform the main controller that it can control the start of conversion and read data . In the process of transformation , adopt busy The signal indicates the current busy state , To avoid the master sending a new command to interrupt the previous command .
Two 、 Pins and their functions
XPT2046 adopt SPI Interface communicates with the main controller , Its interface with the main controller includes the following signals :
PENIRQ_N: Stroke interrupt signal , When the stroke interrupt signal is set to be valid , Whenever the touch screen is pressed , This pin is pulled low . When the main control detects the signal , You can send a control signal to prohibit the interruption of strokes , So as to avoid triggering the controller interrupt by mistake in the conversion process . This pin is internally connected with a 50K The pull-up resistance of .
CS_N: Chip select signal , When CS_N When pulled down , It is used to control the conversion sequence and enable serial input / Output registers to move data out or in . When this pin is high , chip (ADC) Enter power down mode .
DCLK: External clock input , This clock is used to drive SARADC And drive numbers IO Serial data transmission on .
DIN: The data serial input pin of the chip , When CS Low power level , The data is on the serial clock DCLK The rising edge of is latched to the on-chip register .
DOUT: Serial data output , In the serial clock DCLK The falling edge data of is moved out of this pin , When CS_N Pin is high power level , This pin is in high resistance state .
BUSY: Busy output signal , When the chip receives the command and starts the conversion , This pin generates a DCLK High level of cycle . When the pin changes from high level to low level , The highest data of the conversion result is shown in DOUT On the pin , The master can read DOUT Value . When CS_N Pin is high power level ,BUSY Pin is in high resistance state .
3、 ... and 、 working principle
XPT2046 It is a typical successive approximation analog-to-digital converter (SARADC), Including sampling / keep 、 A / D conversion 、 Serial port data output and other functions . At the same time, the chip integrates a 2.5V Internal reference voltage source 、 Temperature detection circuit , Use external clock when working .XPT2046 It can be powered by a single power supply , The power supply voltage range is 2.7V~5.5V. The reference voltage value is directly determined ADC Input range of , The reference voltage can use an internal reference voltage , You can also input directly from the outside 1V~VCC Reference voltage in the range ( Low output impedance of external reference voltage source is required ).X、Y、Z、VBAT、Temp and AUX The analog signal enters after being selected by the on-chip control register ADC,ADC It can be configured as single ended or differential mode . choice VBAT、Temp and AUX It can be configured as single ended mode ; As a touch screen application , It can be configured as differential mode , This can effectively eliminate the measurement error caused by parasitic resistance of driving switch and external interference , Improve conversion accuracy .
The following figure for XPT2046 Typical working circuit :
XPT2046 There are four pins , For connecting to a four wire resistive screen FPC On , Respectively XP、XN、YP、YN, Connected to the corresponding four wire resistance screen X The positive end of the electrode 、 Negative end and Y The positive end of the electrode 、 Negative end . Each of these four pins can work in two states , They are power supply /GND Output 、ADC Input . For example setting ADC Working in differential mode , When measuring X Coordinate of direction ,XP Output VCC、XN Connect to GND, here ,YP and YN As ADC The differential input pin of is connected to ADC On , By measuring YP and YN To get the current touch point X Location . Empathy , When measuring Y Coordinate of direction ,YP Output VCC、YN Connect to GND、 here ,XN and XP As ADC The differential input pin of is connected to ADC On , By measuring YP and YN To get the current touch point Y Location .
Four 、 internal structure
5、 ... and 、 Function and use
Typical applications :
24 Clock cycle conversion
Read write timing
I understand XPT2046 The interface circuit , Then we can control MCU or FPGA To control the chip to read the coordinates . To read correctly X、Y coordinate , It is necessary to read and write data according to the control protocol specified by the chip .XPT2046 Make it happen once X、Y The reading of coordinates requires two transformations , A single conversion can only get a single X or Y Coordinates of , therefore , We have to control twice to get the result . The object of each conversion is X or Y coordinate , Determined by the control word sent by the controller .ADC It can be configured as single ended or differential mode during conversion , The specific control word is at the beginning of each transmission , Controlled by master MCU drive DIN Signal transmission . The following figure for XPT2046 Typical 24 Clock cycle conversion control timing :
XPT2046 The data interface is a serial interface , Its typical working sequence is shown in the figure above , The signal shown in the figure comes from a single chip microcomputer or data signal processor with a basic serial interface . Communication between the processor and the converter requires 8 Clock cycles , May adopt SPI、SSI and Microwire Isochronous serial interface . A complete transformation requires 24 A serial synchronization clock (DCLK) To complete .
front 8 A clock is used to pass DIN Pin input control byte . When the converter gets enough information about the next conversion , Then, the input multiplexer and the reference source input are set according to the obtained information , And enter the sampling mode , if necessary , The touch panel drive will start .3 After several clock cycles , Control byte setting is complete , The converter enters the conversion state . At this time , Input sampling - The holder enters the hold state , The touch panel driver stops working ( Single ended operating mode ). And then 12 A clock cycle will complete the real analog-to-digital conversion . If it is a measurement ratio conversion method (SER/DFR——=0), The drive will work all the time during the conversion , The first 13 A clock will output the last bit of the conversion result . The rest 3 Multiple clock cycles will be used to complete the last byte ignored by the converter (DOUT Buy low ).
6、 ... and 、 Sample code
XPT2046 Read AD value
unsigned int XPT2046_ReadAD(unsigned char Command)
{
unsigned char i;
unsigned int Data=0;
XPY2046_DCLK=0;
XPY2046_CS=0;
for(i=0;i<8;i++)
{
XPY2046_DIN=Command&(0x80>>i);
XPY2046_DCLK=1;
XPY2046_DCLK=0;
}
for(i=0;i<16;i++)
{
XPY2046_DCLK=1;
XPY2046_DCLK=0;
if(XPY2046_DOUT){
Data|=(0x8000>>i);}
}
XPY2046_CS=1;
return Data>>8;
}
边栏推荐
- Deux séquences ergodiques connues pour construire des arbres binaires
- 数组和链表的区别浅析
- 解决BASE64Encoder报错的问题
- /bin/ld: 找不到 -lgssapi_krb5
- 树-二叉搜索树
- 动态规划入门一,队列的bfs(70.121.279.200)
- 微信支付宝账户体系和支付接口业务流程
- Golang MD5 encryption and MD5 salt value encryption
- 6091. Divide the array so that the maximum difference is K
- 6095. 强密码检验器 II
猜你喜欢
Leetcode question brushing - parity linked list 328 medium
Party History Documentary theme public welfare digital cultural and creative products officially launched
XPT2046 四线电阻式触摸屏
蚂蚁集团大规模图计算系统TuGraph通过国家级评测
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
Leetcode skimming -- incremental ternary subsequence 334 medium
PostgresSQL 流复制 主备切换 主库无读写宕机场景
《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究
[experience cloud] how to get the metadata of experience cloud in vscode
密码学基础知识
随机推荐
04. Some thoughts on enterprise application construction after entering cloud native
[leetcode] 577 reverse word III in string
folium地图无法显示的问题,临时性解决方案如下
动态规划入门二(5.647.62)
【LeetCode】977-有序数组的平方
Summary of the first three passes of sqli Labs
Moveit 避障路径规划 demo
《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究
Pyinstaller打包exe附带图片的方法
奥比中光 astra: Could not open “2bc5/[email protected]/6“: Failed to set USB interface
[experience cloud] how to get the metadata of experience cloud in vscode
SQL FOREIGN KEY
Bing. Com website
[leetcode] 1254 - count the number of closed Islands
Leetcode skimming -- count the number of numbers with different numbers 357 medium
Basic knowledge of cryptography
/bin/ld: 找不到 -lpam
List of sergeant schools
解决BASE64Encoder报错的问题
《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究