NHD‐2.4‐240320SF‐CTXL#‐FTN1 touch-screen problem
I connected my PIC32 with a NHD‐2.4‐240320SF‐CTXL#‐FTN1.
I do not have touch controller. Instead I am using the ADCs of PIC.
I was trying to handle the touch screen controller with a basic test code. I get the sampling points from ADC for all values, like X and Y coordinate, Z1 and standby values.
I wrote a simple test program which firstly makes a 5 point calibration, then draws the point that I touched on the screen.
Interesting things happened then.
There is a region on the screen where I cannot touch at all (of course I can physically touch but I get the pixel values out of the region). It looks like a plus sign. I re-checked my code and the calibration values. Everything seems fine. Out of the untouchable(!) region, things works fine and smooth.
BTW, LCD works fine. I can draw a full-size png file without any problem.
What could be the reason?
No one has any idea?
This is not a calibration problem. Out of the untouchable region everything works fine. I can even write or draw.
But when I touch at the untouchable region (!), it occurs either at the left or the reight hand side of the region.
I think this is because of the touch screen system inside LCD. I am not an expert on LCDs or touch screens, so I cannot tell the exact problem. But it seems like something is wrong.
In order to see the voltage values while sampling X coordinate, I connected the YU (Y-) pin to the oscillator and get some results.
Sampling right hand side of the untouchable region. Everything seems OK. YU acts like a square wave while sampling.
Sampling left hand side of the untouchable region. OK but YU (Y-) decays like an exponential.
Sampling on the untouchable region. I think problem occurs because of the mixture of square wave and exponential decaying.
Do you have another display to try? I'm curious to see if this is also occurring on another display, and if the "untouchable region" remains the same or changes.
If you do, please try it and let me know. If you do not have another to try, you may either try purchasing another one to test, or emailing firstname.lastname@example.org to set up an RMA.0
Thanks for your reply,
Yes I have a couple of LCDs. And yes I tried changing it. And yes it remains at the same place.
I make 5 point calibration based on TI's "Calibration in Touch Screen Systems" document.
void touch_Screen_Calibrate( void )
... // 5 point calibration
void touch_Screen_Calibration_Calculate(int x1, int x2, int x3, int x4, int x5,
int y1, int y2, int y3, int y4, int y5)
double a = 0, b = 0, c = 0, d = 0, e = 0, n = 0,
X1 = 0, X2 = 0, X3 = 0, Y1 = 0, Y2 = 0, Y3 = 0,
det = 0, detX1 = 0, detX2 = 0, detX3 = 0, detY1 = 0, detY2 = 0, detY3 = 0;
a = x1*x1 + x2*x2 + x3*x3 + x4*x4 + x5*x5;
b = y1*y1 + y2*y2 + y3*y3 + y4*y4 + y5*y5;
c = x1*y1 + x2*y2+ x3*y3 + x4*y4 + x5*y5;
d = x1 + x2 + x3 + x4 + x5;
e = y1 + y2 + y3 + y4 + y5;
n = 5;
X1 = x1*CAL_POINT_X1 + x2*CAL_POINT_X2 + x3*CAL_POINT_X3 + x4*CAL_POINT_X4 + x5*CAL_POINT_X5;
X2 = y1*CAL_POINT_X1 + y2*CAL_POINT_X2 + y3*CAL_POINT_X3 + y4*CAL_POINT_X4 + y5*CAL_POINT_X5;
X3 = CAL_POINT_X1 + CAL_POINT_X2 + CAL_POINT_X3 + CAL_POINT_X4 + CAL_POINT_X5;
Y1 = x1*CAL_POINT_Y1 + x2*CAL_POINT_Y2 + x3*CAL_POINT_Y3 + x4*CAL_POINT_Y4 + x5*CAL_POINT_Y5;
Y2 = y1*CAL_POINT_Y1 + y2*CAL_POINT_Y2 + y3*CAL_POINT_Y3 + y4*CAL_POINT_Y4 + y5*CAL_POINT_Y5;
Y3 = CAL_POINT_Y1 + CAL_POINT_Y2 + CAL_POINT_Y3 + CAL_POINT_Y4 + CAL_POINT_Y5;
det = n*(a*b-c*c) + 2*c*d*e - a*e*e - b*d*d;
detX1 = n*(X1*b-X2*c) + e*(X2*d-X1*e) + X3*(c*e-b*d);
detX2 = n*(X2*a-X1*c) + d*(X1*e-X2*d) + X3*(c*d-a*e);
detX3 = X3*(a*b-c*c) + X1*(c*e-b*d) + X2*(c*d-a*e);
detY1 = n*(Y1*b-Y2*c) + e*(Y2*d-Y1*e) + Y3*(c*e-b*d);
detY2 = n*(Y2*a-Y1*c) + d*(Y1*e-Y2*d) + Y3*(c*d-a*e);
detY3 = Y3*(a*b-c*c) + Y1*(c*e-b*d) + Y2*(c*d-a*e);
alpha_X = detX1 / det;
beta_X = detX2 / det;
det_X = detX3 / det;
alpha_Y = detY1 / det;
beta_Y = detY2 / det;
det_Y = detY3 / det;
Then I get
alpha_X = -0.271
beta_X = -0.011
det_X = 268.399
alpha_Y = -0.005
beta_Y = -0.339
det_Y = 349.629
And this is the code while printing the touch points on screen
void debug_print_touch_points(int x_val, int y_val)
x = ( alpha_X * (double)x_val ) + ( beta_X * (double)y_val ) + det_X;
y = ( alpha_Y * (double)x_val ) + ( beta_Y * (double)y_val ) + det_Y;
xi = (int)floor(x); yi = (int)floor(y);
Draw_One_Pixel(xi, yi, YELLOW());
Things are very smooth outside the "untouchable region". I can write, draw etc.
I also double checked the code.
Is this sth about the product? Or is this a special case for resistive touch screens?0
I haven't seen this issue, nor have I heard any customers asking about it as of yet. The fact that you have multiple displays makes it very doubtful that it has to do with a defective display. Also, since the "untouchable region" pattern shown on the display is the same from display to display, it makes it even more unlikely. I'm guessing it is something with your software (I know it works everywhere else but that doesn't mean there is some anomaly or special case happening in those areas). Do you have a resistive touch panel controller IC you could try using instead of handling it manually via software?0
Please sign in to leave a comment.