Go Down

Topic: 2.4 TFT LCD helpp (Read 2999 times) previous topic - next topic

JacksonJoe21

I downloaded and tried almost every examples but i still get a freakin white screen. Im feelin like I just wasted ny money helpp huhu im desperate haha. Also after that is it possible to display the voltage reading of a battery in our 2.4 tft lcd? Thanks!

david_prentice

If you want help, you should post a link to your actual display.   e.g. the Ebay sale.

Yes, of course you can read a voltage that is within the operating range of your Uno's ADC reference.
This means using a pair of resistors as a potential divider.

If you have a "high power" Solar array,  you probably run your Arduino at 5V and this is accurately held by the Arduino's voltage regulator.   If so,  you can use 5V as reference.

Low Power systems would run at a low voltage and use the 1.1V BandGap reference.

David.

JacksonJoe21

If you want help, you should post a link to your actual display.   e.g. the Ebay sale.

Yes, of course you can read a voltage that is within the operating range of your Uno's ADC reference.
This means using a pair of resistors as a potential divider.

If you have a "high power" Solar array,  you probably run your Arduino at 5V and this is accurately held by the Arduino's voltage regulator.   If so,  you can use 5V as reference.

Low Power systems would run at a low voltage and use the 1.1V BandGap reference.

David.
Good evening david! I bought mine at a shop here in the philippines, they gave me drivers but it didn't work so i tried other libraries but it doesn't work either. I tried this sample code.



#include <Adafruit_GFX.h>    // Core graphics library
#include <SWTFT.h> // Hardware-specific library
#include <TouchScreen.h>




#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 7   // can be a digital pin
#define XP 6   // can be a digital pin

#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);



// Assign human-readable names to some common 16-bit color values:
#define   BLACK   0x0000
#define   BLUE    0x001F
#define   RED     0xF800
#define   GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


SWTFT tft;

#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
  Serial.begin(9600);
  Serial.println(F("Paint!"));
 
  tft.reset();
 
  uint16_t identifier = tft.readID();

  Serial.print(F("LCD driver chip: "));
  Serial.println(identifier, HEX);
   

  tft.begin(identifier);

  tft.fillScreen(BLACK);

  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN);
  tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, BLUE);
  tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA);
  // tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, WHITE);
 
  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
  currentcolor = RED;
 
  pinMode(13, OUTPUT);
}

#define MINPRESSURE 10
#define MAXPRESSURE 1000

void loop()
{
  digitalWrite(13, HIGH);
  // Recently Point was renamed TSPoint in the TouchScreen library
  // If you are using an older version of the library, use the
  // commented definition instead.
  // Point p = ts.getPoint();
  TSPoint p = ts.getPoint();
  digitalWrite(13, LOW);

  // if sharing pins, you'll need to fix the directions of the touchscreen pins
  //pinMode(XP, OUTPUT);
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  //pinMode(YM, OUTPUT);

  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!

  if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
    /*
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
    */
   
    if (p.y < (TS_MINY-5)) {
      Serial.println("erase");
      // press the bottom of the screen to erase
      tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK);
    }
    // scale from 0->1023 to tft.width
    p.x = tft.width()-(map(p.x, TS_MINX, TS_MAXX, tft.width(), 0));
    p.y = tft.height()-(map(p.y, TS_MINY, TS_MAXY, tft.height(), 0));
    /*
    Serial.print("("); Serial.print(p.x);
    Serial.print(", "); Serial.print(p.y);
    Serial.println(")");
    */
    if (p.y < BOXSIZE) {
       oldcolor = currentcolor;

       if (p.x < BOXSIZE) {
         currentcolor = RED;
         tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*2) {
         currentcolor = YELLOW;
         tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*3) {
         currentcolor = GREEN;
         tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*4) {
         currentcolor = CYAN;
         tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*5) {
         currentcolor = BLUE;
         tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, WHITE);
       } else if (p.x < BOXSIZE*6) {
         currentcolor = MAGENTA;
         tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, WHITE);
       }

       if (oldcolor != currentcolor) {
          if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
          if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
          if (oldcolor == GREEN) tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN);
          if (oldcolor == CYAN) tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN);
          if (oldcolor == BLUE) tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, BLUE);
          if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA);
       }
    }
    if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
      tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
    }
  }
}



Here's also photos of my 2.4 tft. Hope you can help me. Appreciate it! Thank you :)

david_prentice

Thanks for the photo of the pcb.

Your Shield looks like a regular Red 2.4" Mcufriend Uno Display Shield.
i.e. with two 74HC245 buffers and a microSD holder

I have never seen your pcb in real life.
Most of them have a AMS1117 regulator for the Backlight LED and do not have a footprint for a Flash chip.

I suggest that you install the MCUFRIEND_kbv library from the IDE Library Manager.

Run the LCD_ID_readreg.ino from the Examples.   Copy-Paste the output from the Serial Terminal to your message.

David.

JacksonJoe21

This is the actual look of the TFT LCD.. 

JacksonJoe21

Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 05 01   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 08 08 08 08 08   Status Register
reg(0x000A) 0F 0B   Get Powsr Mode
reg(0x000C) 08 08   Get Pixel Format
reg(0x0061) 60 60   RDID1 HX8347-G
reg(0x0062) 67 63   RDID2 HX8347-G
reg(0x0063) 62 62   RDID3 HX8347-G
reg(0x0064) 60 60   RDID1 HX8347-A
reg(0x0065) 60 60   RDID2 HX8347-A
reg(0x0066) 62 62   RDID3 HX8347-A
reg(0x0067) 62 62   RDID Himax HX8347-A
reg(0x0070) 75 71   Panel Himax HX8347-A
reg(0x00A1) A0 A0 A0 A0 A0   RD_DDB SSD1963
reg(0x00B0) B5 B1   RGB Interface Signal Control
reg(0x00B4) B0 B0   Inversion Control
reg(0x00B6) B2 B2 B2 B2 B2   Display Control
reg(0x00B7) B2 B2   Entry Mode Set
reg(0x00BF) BA BA BA BA BA BA   ILI9481, HX8357-B
reg(0x00C0) C5 C1 C5 C1 C5 C1 C5 C1 C5   Panel Control
reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8   GAMMA
reg(0x00CC) C8 C8   Panel Control
reg(0x00D0) D5 D1 D5   Power Control
reg(0x00D2) D2 D2 D2 D2 D2   NVM Read
reg(0x00D3) D2 D2 D2 D2   ILI9341, ILI9488
reg(0x00DA) DA DA   RDID1
reg(0x00DB) DA DA   RDID2
reg(0x00DC) D8 D8   RDID3
reg(0x00E0) E5 E1 E5 E1 E5 E1 E5 E1 E5 E1 E5 E1 E5 E1 E5 E1   GAMMA-P
reg(0x00E1) E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0   GAMMA-N
reg(0x00EF) EA EA EA EA EA EA   ILI9327
reg(0x00F2) F7 F3 F7 F3 F7 F3 F7 F3 F7 F3 F7 F3   Adjust Control 2
reg(0x00F6) F2 F2 F2 F2   Interface Control

Here's the result of the serial monitor...

david_prentice

It looks as if you have a 16-bit non-MIPI controller with ID=0x0501.   e.g. like an ILI9320

I have no idea what model or make this is.

I can only suggest that you edit the setup() function in the graphictest_kbv.ino sketch from the examples:
Code: [Select]

    ...
    uint16_t ID = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    if (ID == 0xD3D3) ID = 0x9481; // write-only shield
    ID = 0x9320;             // try with 0x9320, 0x9325, 0x7783, 0x0154, ...
    tft.begin(ID);
}


Try each of the ID values.  Report back if or how any of them work.
I am not very hopeful.   0x0501 is an unlikely ID value.

You can always ask the shop if they know which controller.   Or they could ask their Supplier.
If I know the part number and can find a datasheet,  I will make the library work with it.

David.

JacksonJoe21

It looks as if you have a 16-bit non-MIPI controller with ID=0x0501.   e.g. like an ILI9320

I have no idea what model or make this is.

I can only suggest that you edit the setup() function in the graphictest_kbv.ino sketch from the examples:
Code: [Select]

    ...
    uint16_t ID = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    if (ID == 0xD3D3) ID = 0x9481; // write-only shield
    ID = 0x9320;             // try with 0x9320, 0x9325, 0x7783, 0x0154, ...
    tft.begin(ID);
}


Try each of the ID values.  Report back if or how any of them work.
I am not very hopeful.   0x0501 is an unlikely ID value.

You can always ask the shop if they know which controller.   Or they could ask their Supplier.
If I know the part number and can find a datasheet,  I will make the library work with it.

David.
awwww... already ask them but they dont know it either. :( .. I'm just really new here,studying this tft for our thesis haha.. I can't move forward.... Thank you for your help man! Appreciate it :)

david_prentice

Well,  you can ask them again.   

You can give them my name if you want.   It is good for their shop sales to have a library for their customers.    It is good for their Wholesale Supplier to have a library for their Retail customers.

David.

JacksonJoe21

It looks as if you have a 16-bit non-MIPI controller with ID=0x0501.   e.g. like an ILI9320

I have no idea what model or make this is.

I can only suggest that you edit the setup() function in the graphictest_kbv.ino sketch from the examples:
Code: [Select]

    ...
    uint16_t ID = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    if (ID == 0xD3D3) ID = 0x9481; // write-only shield
    ID = 0x9320;             // try with 0x9320, 0x9325, 0x7783, 0x0154, ...
    tft.begin(ID);
}



Okay, one last question davidd.. do you have any idea what do I need to display the the voltage? and where to connect the arduino pins... by the way we also need to display the ampere rating of our battery and the internal resistance.. we still don't have ideas haha. thank you for your help david! highly appreciated :)

david_prentice

I answered that in #1.

If you are doing a thesis,  you can work out the resistors for a potential divider.

You can Google how to read your Arduino supply voltage with the ADC.   e.g. to check that you have got 5V via the regulator from your Solar Array.

If you are not sure of something,  post a schematic.   A pencil drawing is fine.

David.

JacksonJoe21

I answered that in #1.

If you are doing a thesis,  you can work out the resistors for a potential divider.

You can Google how to read your Arduino supply voltage with the ADC.   e.g. to check that you have got 5V via the regulator from your Solar Array.

If you are not sure of something,  post a schematic.   A pencil drawing is fine.

David.
Hi david is my connection correct? is this gonna work? btw our 2.4 tft lcd is now working :) thank you for your help. Now im more concern with the program :D



david_prentice

Your schematic does NOT match your Red 2.4" Mcufriend Shield.   A5 is the only spare Analog pin.

The 10k, 15k divider is not correct.    The 12.7V will produce (15 / (10 + 15)) * 12.7 = 7.62V
7.62V is too high for the ADC to read correctly.

You need to use different resistor values.

I am pleased that your TFT is working now.   You should always plug the Shield into the Uno.
What ID is reported by the graphictest_kbv.ino sketch? 

You can snip off the A5 pin from the Shield.   This will mean that you can access the A5 hole on the Uno header socket.

David.

JacksonJoe21

Your schematic does NOT match your Red 2.4" Mcufriend Shield.   A5 is the only spare Analog pin.

The 10k, 15k divider is not correct.    The 12.7V will produce (15 / (10 + 15)) * 12.7 = 7.62V
7.62V is too high for the ADC to read correctly.

You need to use different resistor values.

I am pleased that your TFT is working now.   You should always plug the Shield into the Uno.
What ID is reported by the graphictest_kbv.ino sketch? 

You can snip off the A5 pin from the Shield.   This will mean that you can access the A5 hole on the Uno header socket.

David.
Hi david! I updated my schematic.. I don't have my 2.4 tft lcd here right now my classmate borrowed it. but here's my new schematic. I used 3-30kohms resistor because that's the only resistor available in the shop we went. Also in another picture, batteries of our generator is arranged just like whats on the schematic. Is it also possible to measure the internal resistance of the battery bank? 1 ,2 and 3? thank you David!

david_prentice

With your new schematic,   the 12.7V will produce (10 / (10 + 90)) * 12.7 = 1.27V
1.27V is ok to read with your ADC.

But if you used a single 30k resistor:   the 12.7V will produce (10 / (10 + 30)) * 12.7 = 3.175V
3.2V is ok to read with your ADC.   You also have a safe margin when your batteries are overcharged.

I know nothing about linking multiple battery cells.   I am sure that there are plenty of Application Notes from the battery manufacturers.    I am sure that there are many safety considerations.

I always advise that you study proven commercial designs.   Then copy their schematic.   Copy their choice of components.

This may not be ethical but it works!
Note that many designs are public.   The commercial company may be using public designs.

For the purpose of your thesis,  I suggest that you explain how the schematic works.    I suggest that you explain how you calculated the values of the components.   And how / why you chose critical components like batteries,   capacitors,   cable sizes,  ...

Good Luck with your project.

David.

Go Up