Announcement

Collapse
No announcement yet.

Touchscreen of gen4 43dct-clb NOT working connected to Arduino

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Touchscreen of gen4 43dct-clb NOT working connected to Arduino

    Hi everyone,
    I've a problem with a GEN4-ULCD43DCT-CLB (gen4 capacitive touch).
    LCD is connected to an Arduino Uno (with software serial, but I've tried with HW serial too and the problem is the same), with SPE loaded at 115200bps.
    Arduino sends command and creates the graphics, some writes, some rectangles etc..
    But when I implement the touch functions, doesn't work properly.
    The syntax of the touch control routine is this:
    Code:
    Display.touch_Set(TOUCH_ENABLE);
    unsigned int touchStat = Display.touch_Get(TOUCH_STATUS);
    if(touchStat == TOUCH_PRESSED){
    unsigned int x = Display.touch_Get(TOUCH_GETX);
    unsigned int y = Display.touch_Get(TOUCH_GETY);
    Display.gfx_MoveTo(10,10);
    Display.putstr("X= ");
    Display.putstr(x);
    Display.putstr("\nY= ");
    Display.putstr(y);
    }
    Graphics is ok, but I don't see any responses when touching the lcd.

    Trying with the example code on workshop ViSi environment (this: https://forum.4dsystems.com.au/node/61211) it works fine. Then it seems to be some issues with the Arduino communication or something in the Arduino code.

    Can someone help me to solve this?

    Thanks, Marco

  • #2
    Hi Marco,

    Welcome to the forum.

    This may be a comms issue. If the display is connected to the Arduino via the UPA or PA programming adapter then it may cause a comms issue. If you have a gen4-IB then it would be better to use this.

    If you don't have a gen4-IB then it is possible to set the display to use another set of GPIO for Serial and use COM1 as the port. You can set this by clicking on File then options and then the Serial tab,

    Click image for larger version

Name:	SerialOptions.png
Views:	86
Size:	45.8 KB
ID:	72208

    The relation of GPIO to PA numbers is shown here

    Click image for larger version

Name:	PA_Pins.png
Views:	38
Size:	192.9 KB
ID:	72209

    I hope this helps

    Best regards

    Paul

    Comment


    • #3
      Thanks Pauleilio for fast reply.
      I confirm that I have a Gen4-IB (this https://4dsystems.com.au/gen4-ib).
      I've seen the option page and it's options are the same of the screen that you've attached to your post (except baudrate that is 115200 in my options).
      I've tried to edit them but unsuccessfully.
      What can I try?

      Click image for larger version

Name:	opzioni 4d workshop.JPG
Views:	67
Size:	53.0 KB
ID:	72211

      Comment


      • #4
        I've tried to edit the baudrate (lower and higher) but doesn't work. Arduino seems to have difficult to receive data from lcd. With a serial monitor I see something, but nothing useful.
        Some times ago, I've worked with a ulcd43DT (the old version), and touchscreen was working fine.
        Now I don't understand why is not working. I've tried with both Arduino Uno and Mega, but nothing.
        I need help

        Comment


        • #5
          Hi Marco,

          I've just noticed this part which may be the reason


          Display.gfx_MoveTo(10,10);
          Display.putstr("X= ");
          Display.putstr(x);
          Display.putstr("\nY= ");
          Display.putstr(y);

          Should be

          Display.gfx_MoveTo(10,10);
          Display.putstr("X= ");
          Display.print(x);
          Display.putstr("\nY= ");
          Display.print(y);

          Please let me know it is the reason why


          Comment


          • #6
            I've tried to edit, but without success.
            Seems to be a missing reading by Arduino (Trasmission Display--->Arduino not work fine)

            Comment


            • #7
              Hi Marco,

              When you draw rectangles and other graphics is there a delay between between graphics appearing or do they just appear and does the code above actually print to the display.

              Comment


              • #8
                I do a list of operation to populate the display, there are about 100 commands (obviously executed only once, at the strartup), and from the first element to the last i think there are something like 5/10mS.
                Then I upload 6 parametrs every 100mS (code timer routines, not delay), and this is instantaneous.

                But for development (and to help me understand better this problem) I've write a small firmware without all graphics generation, only a few lines of code to manage the touchscreen.
                Last edited by marcoP; 4 June 2020, 01:06 AM.

                Comment


                • #9
                  Would you be able to send me that code. It looks to me that the display is communicating.

                  Comment


                  • #10
                    Here is the code I use for develop the touchscreen function.
                    There are some #defines not used, only some remains of old firmware. Some names are in Italian because I'm from Italy. I've commented some lines for better understanding.
                    Thanks a lot for support.


                    Code:
                    #include <Diablo_Const4D.h>
                    #include <Diablo_Serial_4DLib.h>
                    
                    #define DisplaySerial Serial2
                    
                    Diablo_Serial_4DLib Display(&DisplaySerial);
                    
                    //-----ENUMERATORI
                    #define BLU 1
                    #define ROSSO 2
                    #define VERDE 3
                    #define GRIGIO 4
                    #define PIU 1
                    #define MENO 2
                    #define OFF 3
                    #define SPFISSO 4
                    #define CICLOAUTO 5
                    #define CONFERMA 6
                    #define ANNULLA 7
                    
                    //-----DISPLAY
                    #define TEMPO_REFRESH_LCD 100
                    
                    boolean refreshReq = true;
                    byte actScreen = 0;
                    unsigned int timerRefresh = 0;
                    
                    int tempoCiclo = 0;
                    long tempoCicloPrecedente = 0;
                    
                    unsigned int touchStat = 9999;
                    
                    
                    void setup() {
                    Serial.begin(115200); //init serial0 for debug
                    DisplaySerial.begin(200000); //serial2 for lcd
                    pinMode(3, OUTPUT); //reset pin
                    digitalWrite(3, LOW); //reset lcd
                    delay(100);
                    digitalWrite(3, HIGH);
                    delay(2500);
                    Display.gfx_ScreenMode(0); //landscape screen
                    Display.gfx_Contrast(15); //max contrast
                    Display.gfx_Cls(); //clear
                    Display.txt_MoveCursor(0,0); //cursor at top of screen
                    Display.putstr("TEST TOUCHSCREEN");
                    
                    Display.touch_DetectRegion(0, 0, 200, 400); //enable detect region
                    Display.touch_Set(0); //enable touchscreen
                    
                    }
                    
                    void loop() {
                    
                    tempoCiclo = millis()-tempoCicloPrecedente; //calculate the cycletime
                    tempoCicloPrecedente = millis();
                    
                    touchStat = Display.touch_Get(0); //get status of touchscreen
                    if(touchStat > 0){ //if status > 0 (pressed or something else)
                    unsigned int x = Display.touch_Get(1); //get coordinates
                    unsigned int y = Display.touch_Get(2);
                    Display.gfx_MoveTo(10,10); //move cursor
                    Display.putstr("X= "); //print coordinates
                    Display.print(x);
                    Display.putstr("\nY= ");
                    Display.print(y);
                    }
                    
                    }

                    Comment


                    • #11
                      I've tried with the following code and it works. Then I suppose that there is some receive problem in the return functions of the Diablo16 library.
                      The main variables are:
                      "statoTouch": here is touch status (pressed released etc)
                      "cooX": X coordinate of the last touch
                      "cooY": same of cooX for Y.

                      PROBLEM is that if I add code for graphics management, doesn't work properly, because I read casual values (maybe dued to other data receive).

                      But why can I read directly from serial and not using library? Some bugs?



                      Code:
                      tempoCiclo = millis()-tempoCicloPrecedente;
                      tempoCicloPrecedente = millis();
                      
                      timerTest+=tempoCiclo;
                      if(timerTest > 20){
                      timerTest = 0;
                      
                      Display.touch_Get(TOUCH_STATUS);
                      ackLcd = DisplaySerial.read();
                      if (ackLcd == 6) {
                      unsigned int MSB = DisplaySerial.read();
                      unsigned int LSB = DisplaySerial.read();
                      statoTouch = word(MSB, LSB);
                      DisplaySerial.flush();
                      }
                      
                      Display.touch_Get(TOUCH_GETX);
                      ackLcd = DisplaySerial.read();
                      if (ackLcd == 6) {
                      unsigned int MSB = DisplaySerial.read();
                      unsigned int LSB = DisplaySerial.read();
                      cooX = word(MSB, LSB); //coordinata X
                      DisplaySerial.flush();
                      }
                      
                      Display.touch_Get(TOUCH_GETY);
                      ackLcd = DisplaySerial.read();
                      if (ackLcd == 6) {
                      unsigned int MSB = DisplaySerial.read();
                      unsigned int LSB = DisplaySerial.read();
                      cooY = word(MSB, LSB); //coordinata Y
                      DisplaySerial.flush();
                      }
                      Last edited by marcoP; 4 June 2020, 05:00 PM.

                      Comment


                      • #12
                        Hi Marco,

                        Thank you for the update.

                        I will look into this and test the Display.touch_Get(TOUCH_GETX); Display.touch_Get(TOUCH_GETY);functions.

                        Best regards

                        Paul

                        Comment


                        • #13
                          Hi Marco,

                          Could you please try to add this to your setup before any Display commands

                          Display.TimeLimit4D = 2000 ;

                          Best regards

                          Paul

                          Comment

                          Working...
                          X