Touch signal acquisition method for five-wire resistance touch screen
Technical Field
The invention relates to a touch signal acquisition method for a touch screen, in particular to a touch signal acquisition method for a five-wire resistance touch screen.
Background
In the industrial control industry (such as injection molding), due to strong professional and high requirement on operators, the industry hopes to reduce the operation difficulty through a more humanized man-machine communication mode. The conventional man-machine interaction mode is mostly a button type operation box, and an operation panel with a display screen is developed later. In order to meet the continuously-improved requirement of customers on easy operation, a touch screen is introduced on a human-computer interaction interface.
The basic requirements of industrial control are reliability and stability, and in order to meet the basic requirements, resistive touch panels are often used. The current commonly used resistive touch screen generally has four-wire resistive touch screen and five-wire resistive touch screen, and five-wire resistive touch screen is more superior than four-wire resistive touch screen in linearity and life-span, is fit for using in industrial field more. The five-wire resistance touch screen is formed by attaching a flexible FPC flat wire to a rectangular piece of glass in appearance, and 4 input ends and an output end are arranged on FPC lead wires. The five-wire resistance touch screen mainly depends on a resistance layer (ITO GLASS) and a conduction layer (ITO FILM) which are arranged in the five-wire resistance touch screen, the resistance layer and the conduction layer are separated by a DOT point, 4 corners (upper left corner, lower left corner, upper right corner and lower right corner) of the resistance layer are correspondingly connected with 4 input ends on an FPC lead wire one by one, and the conduction layer is connected with an output end of the FPC lead wire. Currently, an input signal inputted to an input terminal connected to the upper left corner of the resist layer in the FPC lead is generally denoted as UL, an input signal inputted to an input terminal connected to the lower left corner of the resist layer in the FPC lead is denoted as LL, an input signal inputted to an input terminal connected to the upper right corner of the resist layer in the FPC lead is denoted as UR, an input signal inputted to an input terminal connected to the lower right corner of the resist layer in the FPC lead is denoted as LR, and a signal outputted from an output terminal of the FPC lead is denoted as S.
In order to acquire the position of a touch point of a user on the five-wire resistive touch screen, a touch signal of the five-wire resistive touch screen needs to be acquired. Currently, the touch signals of the five-wire resistive touch screen are mainly collected by a special AD chip, such as ADs7845E of TI. The AD chip is connected with four input ends and one output end of the five-wire resistance touch screen FPC respectively, and the CPU is connected with the AD chip through a digital interface (such as SPI). The CPU controls the AD chip to acquire touch signals of the five-wire resistance touch screen through instructions, and coordinate data of actual positions of touch points are obtained after subsequent conversion processing. However, the types of the special AD chips are not many in the market, the supply period is long, the price of a single AD chip is high, and the cost pressure is applied to mass production type products.
Disclosure of Invention
The invention aims to provide a five-wire resistance touch screen touch signal acquisition method which is suitable for being used in the field of industrial control and has low cost.
The technical scheme adopted by the invention for solving the technical problems is as follows: a touch signal acquisition method for a five-wire resistance touch screen comprises the following steps:
(1) each input end of an FPC lead of the five-wire resistive touch screen is respectively connected with a driving module, each driving module is controlled by a CPU, each driving module can output high level or low level under the control of the CPU, and the output end of the FPC lead of the five-wire resistive touch screen is connected to an AD pin of the CPU through an RC series circuit;
(2) taking the long side direction of the five-wire resistive touch screen as the X-axis direction, taking the short side direction as the Y-axis direction, taking the intersection point of the X-axis and the Y-axis as an origin to construct a two-dimensional coordinate system, wherein in the constructed two-dimensional coordinate system, all coordinate positions on the five-wire resistive touch screen are in a first quadrant;
(3) when a touch signal exists on the five-wire resistance touch screen, the acquisition condition of the X coordinate is set, and the specific mode for setting the acquisition condition of the X coordinate is as follows: the CPU sets the high and low levels of 4 input signals on the five-wire resistance touch screen through the 4-path driving module, sets UL and LL to be high levels, sets UR and LR to be low levels, and enables the five-wire resistance touch screen to form a current flow direction from left to right;
(4) after the acquisition condition of the X coordinate is set, the CPU continuously acquires voltage signals output by the output end of the FPC lead of the five-wire resistance touch screen for 10 times through the RC series circuit after delaying for 3ms to 6ms, and the acquired voltage signals are used as X coordinate data to obtain 10X coordinate data;
(5) the specific mode for setting the acquisition condition of the Y coordinate is as follows: the CPU sets the high and low levels of 4 input signals on the five-wire resistance touch screen through the 4-path driving module, sets UL and UR to be high levels, sets LL and LR to be low levels, and enables the five-wire resistance touch screen to form a current flow direction from top to bottom;
(6) after the acquisition condition of the Y coordinate is set, the CPU continuously acquires voltage signals output by the output end of the FPC lead of the five-wire resistance touch screen for 10 times through the RC series circuit after delaying for 3ms to 6ms, and the acquired voltage signals are used as Y coordinate data to obtain 10Y coordinate data;
(7) respectively arranging the 10 acquired X coordinate data and 10 acquired Y coordinate data according to a sequence from small to large, and if equal data appear in the 10X coordinate data or the 10Y coordinate data, randomly determining the sequence of the equal data;
(8) acquiring X coordinate data arranged at 5 th bit, 6 th bit and 7 th bit in the sequenced 10X coordinate data, and recording the X coordinate data arranged at 5 th bit in the sequenced 10X coordinate data as X5And the X coordinate data arranged at the 6 th bit in the sorted 10X coordinate data is recorded as X6And the X coordinate data arranged at the 7 th bit in the sorted 10X coordinate data is recorded as X7The mean value of the X-coordinate data arranged at the 5 th, 6 th and 7 th bits among the 10 sorted X-coordinate data is denoted as XavgWherein x isavg=(x5+x6+x7) 2 division of 3, calculating x respectively5、x6And x7And xavgThe absolute value of the difference between;
acquiring the Y coordinate data arranged at the 5 th bit, the 6 th bit and the 7 th bit in the sequenced 10Y coordinate data, and recording the Y coordinate data arranged at the 5 th bit in the sequenced 10Y coordinate data as Y5And the Y coordinate data arranged at the 6 th bit in the sorted 10Y coordinate data is recorded as Y6And the Y coordinate data arranged at the 7 th bit in the sorted 10Y coordinate data is recorded as Y7The mean value of the 5 th, 6 th and 7 th Y coordinate data in the sorted 10Y coordinate data is recorded as Yavg. Wherein y isavg=(y5+y6+y7) Div 3, calculate y separately5、y6And y7And yavgThe absolute value of the difference between;
(9) judgment of x5And xavgAbsolute value of the difference between, x6And xavgAbsolute value of the difference between, x7And xavgDifference between themAbsolute value of value, y5And yavgAbsolute value of the difference between, y6And yavgAbsolute value of the difference between and y7And yavgWhether the absolute values of the differences are all less than 40, if all are less than 40, then the current (x) is obtainedavg,yavg) And (3) if at least one of the acquired touch signals of the five-wire resistive touch screen is not less than 40, returning to the step (3) for re-acquisition until all the touch signals are less than 40 or the touch signals on the five-wire resistive touch screen disappear.
Each driving module comprises a diode, a first triode, a second triode, a NOT gate, a first resistor, a second resistor, a first capacitor and a second capacitor, the diode is a transient suppression diode, the first triode is a PNP type triode, the second triode is an NPN type triode, the NOT gate is provided with an input end, an output end, a power end and a grounding end, the anode of the diode, one end of the second capacitor, the collector of the first triode and the collector of the second triode are connected, the connecting end of the first triode and the collector of the second triode is the output end of the driving module, the output end of the driving module is used for being connected with the input end of an FPC lead of a five-wire resistance touch screen, the cathode of the diode and the other end of the second capacitor are grounded, the emitter of the first triode, the power end of the NOT gate and one end of the first capacitor are connected, and the connecting end of the first capacitor is connected with a power supply, the base of the first triode and one end of the first resistor are connected, the emitting electrode of the second triode is grounded, the base of the second triode and one end of the second resistor are connected, the other end of the first resistor, the other end of the second resistor and the output end of the NOT gate are connected, the grounding end of the NOT gate is grounded, the input end of the NOT gate is the input end of the driving module, the input end of the driving module is used for connecting a CPU, and the other end of the first capacitor is grounded. In the circuit, the driving module is formed by the diode, the first triode, the second triode, the NOT gate, the first resistor, the second resistor, the first capacitor and the second capacitor, the driving module is completely realized by discrete components, the life cycle of the discrete components is long, the similar products can be selected in the market, the cost is low, the discrete components are easy to obtain, the service life of the driving module is guaranteed, and the cost can be effectively controlled.
Compared with the prior art, the invention has the advantages that the high and low levels of 4 input signals on the five-wire resistive touch screen are set by setting four driving modules, the RC series circuit is arranged between the output end of the FPC lead wire of the five-wire resistive touch screen and the AD pin of the CPU, the CPU sets UL and LL to be high levels and UR and LR to be low levels through 4 driving modules, so that the current flow direction from left to right is formed on the five-wire resistive touch screen, the acquisition condition setting of X coordinates is realized, the delay is 3ms to 6ms to ensure the voltage stability of the output signal S of the five-wire resistive touch screen, the voltage signal output by the output end of the FPC lead wire of the five-wire resistive touch screen is continuously acquired for 10 times through the RC series circuit to obtain 10X coordinate data, the CPU sets UL and UR to be high levels and sets LL and LR to be low levels through the 4 driving modules, the method comprises the steps of enabling a current flow direction from top to bottom to be formed on a five-wire resistive touch screen, realizing the setting of a Y coordinate acquisition condition, delaying 3ms to 6ms to ensure the voltage stability of a signal S output by the five-wire resistive touch screen, continuously acquiring 10 times of voltage signals output by an FPC lead wire output end of the five-wire resistive touch screen through an RC series circuit to obtain 10Y coordinate data, subsequently respectively sequencing the 10X coordinate data and the 10Y coordinate data to obtain 5 th, 6 th and 7 th data, judging whether the data are in accordance according with the mean value and the absolute difference value to realize the acquisition of the touch signals of the five-wire resistive touch screen, replacing a special AD chip with four driving modules, one RC series circuit and an AD conversion function module in a CPU to realize the acquisition of the touch signals of the five-wire resistive touch screen, wherein the driving modules and the RC series circuit are easy to acquire, is suitable for being used in the field of industrial control and has low cost.
Drawings
FIG. 1 is a schematic diagram of X coordinate acquisition in a five-wire resistive touch screen touch signal acquisition method according to the present invention;
FIG. 2 is an equivalent diagram of X coordinate acquisition in the method for acquiring touch signals of a five-wire resistive touch screen according to the present invention;
FIG. 3 is a schematic diagram of Y coordinate acquisition in the method for acquiring touch signals of a five-wire resistive touch screen according to the present invention;
FIG. 4 is an equivalent diagram of Y coordinate acquisition in the method for acquiring touch signals of a five-wire resistive touch screen according to the present invention;
FIG. 5 is a schematic diagram illustrating the principle of the touch signal acquisition method of the five-wire resistive touch screen according to the present invention;
FIG. 6 is a circuit diagram of a driving module of the method for acquiring touch signals of a five-wire resistive touch screen according to the present invention;
Detailed Description
The invention is described in further detail below with reference to the accompanying examples.
Example (b): as shown in fig. 1 to 5, a signal acquisition method for a five-wire resistive touch screen includes the following steps:
(1) each input end of an FPC lead of the five-wire resistive touch screen is connected with a driving module respectively, each driving module is controlled by a CPU respectively, each driving module can output high level or low level under the control of the CPU, and the output end of the FPC lead of the five-wire resistive touch screen is connected to an AD pin of the CPU through an RC series circuit;
(2) taking the long side direction of the five-wire resistive touch screen as the X-axis direction, taking the short side direction as the Y-axis direction, taking the intersection point of the X-axis and the Y-axis as an origin to construct a two-dimensional coordinate system, wherein in the constructed two-dimensional coordinate system, all coordinate positions on the five-wire resistive touch screen are in a first quadrant;
(3) when a touch signal exists on the five-wire resistance touch screen, the acquisition condition of the X coordinate is set, and the specific mode for setting the acquisition condition of the X coordinate is as follows: the CPU sets the high and low levels of 4 input signals on the five-wire resistance touch screen through the 4-path driving module, sets UL and LL to be high levels, sets UR and LR to be low levels, and enables the five-wire resistance touch screen to form a current flow direction from left to right;
(4) after the acquisition condition of the X coordinate is set, the CPU continuously acquires voltage signals output by the output end of the FPC lead of the five-wire resistance touch screen for 10 times through the RC series circuit after delaying for 3ms to 6ms, and the acquired voltage signals are used as X coordinate data to obtain 10X coordinate data;
(5) the specific mode for setting the acquisition condition of the Y coordinate is as follows: the CPU sets the high and low levels of 4 input signals on the five-wire resistance touch screen through the 4-path driving module, sets UL and UR to be high levels, sets LL and LR to be low levels, and enables the five-wire resistance touch screen to form a current flow direction from top to bottom;
(6) after the acquisition condition of the Y coordinate is set, the CPU continuously acquires voltage signals output by the output end of the FPC lead of the five-wire resistance touch screen for 10 times through the RC series circuit after delaying for 3ms to 6ms, and the acquired voltage signals are used as Y coordinate data to obtain 10Y coordinate data;
(7) respectively arranging the 10 acquired X coordinate data and 10 acquired Y coordinate data according to a sequence from small to large, and if equal data appear in the 10X coordinate data or the 10Y coordinate data, randomly determining the sequence of the equal data;
(8) acquiring X coordinate data arranged at 5 th bit, 6 th bit and 7 th bit in the sequenced 10X coordinate data, and recording the X coordinate data arranged at 5 th bit in the sequenced 10X coordinate data as X5And the X coordinate data arranged at the 6 th bit in the sorted 10X coordinate data is recorded as X6And the X coordinate data arranged at the 7 th bit in the sorted 10X coordinate data is recorded as X7The mean value of the X-coordinate data arranged at the 5 th, 6 th and 7 th bits among the 10 sorted X-coordinate data is denoted as XavgWherein x isavg=(x5+x6+x7) 2 division of 3, calculating x respectively5、x6And x7And xavgThe absolute value of the difference between;
acquiring the Y coordinate data arranged at the 5 th bit, the 6 th bit and the 7 th bit in the sequenced 10Y coordinate data, and recording the Y coordinate data arranged at the 5 th bit in the sequenced 10Y coordinate data as Y5And the Y coordinate data arranged at the 6 th bit in the sorted 10Y coordinate data is recorded as Y6The Y seat arranged at the 7 th position in the sorted 10Y coordinate dataMarking data as y7The mean value of the 5 th, 6 th and 7 th Y coordinate data in the sorted 10Y coordinate data is recorded as Yavg. Wherein y isavg=(y5+y6+y7) Div 3, calculate y separately5、y6And y7And yavgThe absolute value of the difference between;
(9) judgment of x5And xavgAbsolute value of the difference between, x6And xavgAbsolute value of the difference between, x7And xavgAbsolute value of the difference between, y5And yavgAbsolute value of the difference between, y6And yavgAbsolute value of the difference between and y7And yavgWhether the absolute values of the differences are all less than 40, if all are less than 40, then the current (x) is obtainedavg,yavg) And (3) if at least one of the acquired touch signals of the five-wire resistive touch screen is not less than 40, returning to the step (3) for re-acquisition until all the touch signals are less than 40 or the touch signals on the five-wire resistive touch screen disappear.
As shown in fig. 6, in this embodiment, each driving module includes a diode D1, a first transistor Q1, a second transistor Q2, a not gate U1, a first resistor R1, a second resistor R2, a first capacitor C1, and a second capacitor C2, the diode D1 is a transient suppression diode D1, the first transistor Q1 is a PNP transistor, the second transistor Q2 is an NPN transistor, the not gate U1 has an input terminal, an output terminal, a power supply terminal, and a ground terminal, the anode of the diode D1, one end of the second capacitor C2, the collector of the first transistor Q1, and the collector of the second transistor Q2 are connected, and the connection terminal thereof is the output terminal of the driving module, the output terminal of the driving module is used for connecting to the input terminal of the FPC lead of the five-wire resistive touch screen, the cathode of the diode D1 and the other end of the second capacitor C2 are both grounded, the emitter of the first transistor Q1, the power supply terminal of the non-gate 1, and one end of the first capacitor C1 are connected to the connection, the base of the first triode Q1 is connected with one end of the first resistor R1, the emitter of the second triode Q2 is grounded, the base of the second triode Q2 is connected with one end of the second resistor R2, the other end of the first resistor R1 and the other end of the second resistor R2 are connected with the output end of the NOT gate U1, the ground end of the NOT gate U1 is grounded, the input end of the NOT gate U1 is the input end of the driving module, the input end of the driving module is used for being connected with a CPU, and the other end of the first capacitor C1 is grounded.
In this embodiment, the not gate U1 used in the four driving modules may be implemented by using a chip with model 74HC14, a power supply terminal of the chip is used as a power supply terminal of the not gate U1, a ground terminal of the chip is used as a ground terminal of the not gate U1, and a pair of an input terminal and an output terminal of the chip are used as an input terminal and an output terminal of the not gate U1.