Announcement

Collapse
No announcement yet.

Display slowing down randomly

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

  • Display slowing down randomly

    Hi, I am currently working on a digital dashboard for my race car, using an Arduino UNO and a Gen4-uLCD-50D-SB display.

    I have written a little program just to change gear and RPMs (using Userimages widget).

    As you will see in the video below, the screen is slowing down (real slow...), and it's doing it randomly, sometimes the program loops 4/5 times, sometimes, the display becomes slow in the first loop. The only way to get it back at full speed is to reboot the Arduino UNO.

    Am I doing something wrong ... ?

    Thanks in advance for your time, I would greatly appreciate your help

    https://www.youtube.com/watch?v=NIvRYQp17zU

    Code:
    #include <genieArduino.h>
    #include <SoftwareSerial.h>
    
    Genie genie;
    SoftwareSerial mySerial(3, 4);
    
    #define RESETLINE 5
    
    void setup() {
       mySerial.begin(9600);
       genie.Begin(mySerial);
       pinMode(RESETLINE, OUTPUT);
       digitalWrite(RESETLINE, 0);
       delay(100);
       digitalWrite(RESETLINE, 1);
       delay(3500);
    }
    
    void loop() {
    
      genie.DoEvents();
      for (int i = 0; i < 7; i++)
      {
        genie.WriteObject(GENIE_OBJ_USERIMAGES, 0, i);
      }
      for (int i = 0; i < 176; i++)
      {
        int centaine = i / 100;
        int dizaine = (i / 10) % 10;
        int unite = i % 10;
    
        genie.WriteObject(GENIE_OBJ_USERIMAGES, 1, unite);
        if (i < 10)
          genie.WriteObject(GENIE_OBJ_USERIMAGES, 2, 0);
        else
          genie.WriteObject(GENIE_OBJ_USERIMAGES, 2, dizaine + 1);
        if (i < 100)
          genie.WriteObject(GENIE_OBJ_USERIMAGES, 3, 0);
        else
          genie.WriteObject(GENIE_OBJ_USERIMAGES, 3, centaine + 1);
      }
    
    }
    Attached Files

  • #2
    Hello,

    One guess would be due to you writing to software serial at 9600 baud, but forcing data to the display every loop of the Arduino. The Arduino I am guessing is 16Mhz, so loops really fast, yet your 9600 baud rate comms are significantly slower. I am guessing you are filling up your software buffer and then its just overflowing, and 1 or 2 bytes per message are able to fit now and again, resulting in corrupted messages getting to the display, of which most it will reject but now and then one may result in a valid combination. You are pouring data as fast as the Uno can do, yet the pipe to the display is slow and small diameter, essentially.

    Have you tried the whole 'blink without delay' type delay loop, where instead of writing genie.WriteObject every single loop of the loop(), to do it every 50ms or 100ms for example?

    You could increase your Baud rate a little too, I think software serial is OK up to 38400 or something near that figure, so that could help also.

    Let me know if that does anything positive for you

    Regards
    James

    Comment


    • #3
      Well, first, thank you for you answer.

      I used to set the baudrate to 115200 but it was behaving the same.

      About the 'blink without delay' I didn't try, I'll do it and let you know but when putting a delay(200) at the end of the main loop, nothing changes, the display always slows down at a point...

      I have another problem, when using hardware serial, every time a command is sent to the display, the display reboots, that's why I'm using software serial

      Also, can you confirme that the writeObject function is waiting for the ACK/NACK or do I have to write a function to handle this ?

      Comment


      • #4
        So I have increased my baud rate up to 115200, still using software serial, problem was still there, then I've tried the Beta genie arduino library without changing anything to my code (baud rate still at 115200 though), and it runs quite longer, but then it stops updating (by debugging with serial, I can see that the program is still looping, just the display not updating)

        The blink without delay loop doesn't change anything even with 50ms delay (as delay(50)).

        I would like to try with hardware serial but I don't know why it is rebooting my screen each time a command is sent 😔

        Comment


        • #5
          Well, it seems you're not going to help me....

          At least, could you enlighten me about the fact that using hardware serial is rebooting the screen each time a command is sent ?

          Many thanks.

          Comment


          • #6
            Hi,

            I tried to run the snippet of code above and I haven't encountered any issue as seen on the video you have attached.
            Is it possible that the other part of your program is causing the issue?

            If you haven't yet try to implement a non-blocking delay, maybe you can test this code:
            Code:
            #include <genieArduino.h>
            #include <SoftwareSerial.h>
            
            Genie genie;
            SoftwareSerial mySerial(3, 4);
            
            #define RESETLINE 5
            int i,j;
            void setup() {
               mySerial.begin(9600);
               genie.Begin(mySerial);
               pinMode(RESETLINE, OUTPUT);
               digitalWrite(RESETLINE, 0);
               delay(100);
               digitalWrite(RESETLINE, 1);
               delay(3500);
            }
            
            void loop() {
              static long waitPeriod = millis();
              genie.DoEvents();
            
              if (millis() >= waitPeriod){
                if (i==7) i=0;
                genie.WriteObject(GENIE_OBJ_USERIMAGES, 0, i);
                i++;
            
                int centaine = j / 100;
                int dizaine = (j / 10) % 10;
                int unite = j % 10;
            
                genie.WriteObject(GENIE_OBJ_USERIMAGES, 1, unite);
            
                if (j < 10){
                  genie.WriteObject(GENIE_OBJ_USERIMAGES, 2, 0);
                }
                else{
                  genie.WriteObject(GENIE_OBJ_USERIMAGES, 2, dizaine + 1);
                }
                if (j < 100){
                  genie.WriteObject(GENIE_OBJ_USERIMAGES, 3, 0);
                }
                else{
                  genie.WriteObject(GENIE_OBJ_USERIMAGES, 3, centaine + 1);
                }
            
               j++;
            
               if (j>176) j=0;
            
               waitPeriod = millis() + 50; // 50 ms
              }
            
             }
            For reference, you may find this forum thread useful: https://forum.4dsystems.com.au/node/40596

            I have another problem, when using hardware serial, every time a command is sent to the display, the display reboots, that's why I'm using software serial
            This seems odd, can I ask for your hardware setup? Describing the connections, and providing some images may be useful.

            Best Regards,
            Kevin

            Comment


            • #7
              Hi Kevin, thank you very much for you help,

              So, after spending my whole week-end searching for solutions for both issues, I've finally get my display working smoothly :

              - Issue #1 (hardware serial resetting display) : I am using an external psu for the display, and using usb to power my arduino, without a common ground, and that's what was causing the issue. So adding a common ground solved this issue.

              ​​​​- Issue #2 (display slowing down randomly) : It turns out that using hardware serial has solved this issue too, I think the display doesn't like software serial 😅😅.

              So for now, my setup is working fine 😃

              Thank you very much for you help, I appreciate it.

              Comment


              • John Kevin
                John Kevin commented
                Editing a comment
                Hi Falcao,

                Thank you for getting back to us.
                I am glad that you have resolved your issues.

                If you still have any concerns, please don't hesitate to ask.

                Best Regards
            Working...
            X