Announcement

Collapse
No announcement yet.

Slow upload speed when using Write.Object

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

  • Slow upload speed when using Write.Object

    Gen 4 uLCD 50DCT CLB and an Arduino Mega very slow upload speed when using Write.Object

    Initializing the screen using with recommended delays, serial communication already established and working fine. Baud set to 200000.
    Code:
     digitalWrite(SCREEN_RESET, 0);                                               
        delay(100);
        digitalWrite(SCREEN_RESET, 1);                                           
        delay (3500);                                                                              
    
       // upload inital variable system settings
        upload_tft();
    Then I call the upload_tft() function which uploads pre-defined variables from the Arduino to the display. These Objects exist and are located on separate forms. Ideally I only want to have to pass the variables from the Arduino once during startup.
    Code:
    void upload_tft()
    {
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 3, Setpoint_brew);                       
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 4, Setpoint_steam);                   
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 0, Kp_pump);                                  
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 1, Ki_pump);                                   
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 2, Kd_pump);                                  
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 7, consKp_brew);                           
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 6, consKi_brew);                           
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 5, consKd_brew);                           
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 10, consKp_steam);                      
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 9, consKi_steam);                       
        TFT.WriteObject(GENIE_OBJ_CUSTOM_DIGITS, 8, consKd_steam);                      
    }

    If I start both the Arduino and the display without calling the function upload_tft(), the program runs as expected with the 4ish second delay as defined in the code.

    If I call the upload_tft() function, the startup time is now 17 seconds, which is somewhat puzzling since in theory I'm only passing 12 variables from the Arduino to the display.

    I've verified that all of the Objects being called by WriteObject exist in the Genie Project.

    I believe everything is set up correctly, since the display works flawlessly with and without upload_tft() function being called. The issue is of course the slow upload speed.

    Probably missing something very simple

    Help would be appreciated.

  • #2
    good evening,

    while a writeobject is issued, arduino waits for the ACK response from the display before processing the next command, which should be ~40ms or less, depending on the objects/traffic usage. the display sends the ACK telling the arduino that its ready for the next command. if yiu skip this step, the display will get out of sync as while it's changing the screen layout of the widgets your sending another command and things WILL go wrong. there are better ways to handle this scenario, like writing that object when you switch to that form, and only change it when it actually changed, not when its the same

    Comment


    • #3
      Hi Tonton,

      Thanks for the reply and suggestions, my numbers don't add up if what you're saying is correct.

      If the response time is 40ms or less, my total wait time should be in theory less than a couple of seconds. This is the only active traffic/objects occurring at this point in the code.

      Thanks for the suggestion about only writing to the form once it's active, but from a simplicity point of view, if I transmit my variables only once, the code's simpler and smaller.

      I'm left wondering why it's taking over 17 seconds to transmit 11 integers to the display. This is concerning because I'm hoping to be able to move more data back and forth in larger chunks.

      Thank you for the suggestion tho.

      Comment


      • #4
        ideally you shouldn't be writing to objects not currently available in a different form. this can cause memory related issues, causing some, not necessarily the widget your writing to, but also cause corruption to other widgets you didnt write to

        try to write to the same custom digits displayed on the active form 11 times and report back the speed if its better

        i also am unaware of how the rest of your code is written as its possible other code can cause delays as well

        Comment


        • #5
          Okay, made an adjustment based on your recommendations.

          When a form is activated on the display, I set the following for the form:
          OnActivate > Report Message

          The screen then sends a message to the Arduino.

          The Event Handler routine sees it and then executes a WriteObject back sending the variables to the display.

          No real slowdown now, which is a great thing.

          The downside is the code overhead on the Arduino side. Instead of initializing the screen once, it must be done for each form. The code's easy enough to implement on the Arduino side, but it's just additional overhead.

          Thanks Tonton for your help.

          Comment

          Working...
          X