Announcement

Collapse
No announcement yet.

Arduino 140ms delay writing to 3 traces scope object

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

  • Arduino 140ms delay writing to 3 traces scope object

    Hello,

    I´m trying to log data (RPM. AFR, EGT). Arduino 32U4, SerCom is set to 200000baud.
    Runtime for processing RPM(digital), AFR(analogRead) and EGT(SPI) and writing to additional three more LedDigit/GaugeObjects, plus five further StringObjects and one WinButtonObject is averaged 130ms.

    But - writing to the scopeObject (RefreshIncrement set to 1, Traces set to 3) adds approx. 140ms runtime to my Arduino sketch.

    Any suggestions for speeding up ScopeObject write cycle?

  • #2
    Good day,

    You may have some other processes that slows it down. Can you post your codes/snippet of code here so that we that can see/check what can be improved, if not possible, you could email me the code at [email protected]

    Best Regards,

    Comment


    • #3
      This code snippet is suspect to cause the delay:

      if (RECFLAG == 1) {
      genie.WriteObject(GENIE_OBJ_SCOPE, 0, RPMS);
      genie.WriteObject(GENIE_OBJ_SCOPE, 0, AFRS);
      genie.WriteObject(GENIE_OBJ_SCOPE, 0, EGTS);
      }

      RECFLAG is set by:
      void myGenieEventHandler(void) {
      genieFrame Event;
      genie.DequeueEvent(&Event);
      if ((genie.EventIs(&Event, GENIE_REPORT_EVENT, GENIE_OBJ_WINBUTTON, 0)) &&
      (genie.GetEventData(&Event) == 1)) {
      RECFLAG = 1;
      }
      else {
      RECFLAG = 0;
      }
      }


      Any ideas?
      Complete "loop":



      void loop() {

      genie.DoEvents();
      ledYellow(0);
      OLDTIME = millis();

      // RPM CALC
      if (revCount >= 100) {
      runTime = ((micros() - prevTime) / 1000);
      RPM = ((60000 * revCount / runTime));
      revCount = 0;
      prevTime = micros();
      if (RPM > RPMMAX) {
      RPMMAX = RPM;
      }
      }
      else {
      RPM = 0;
      }
      genie.WriteObject(GENIE_OBJ_GAUGE, 0, RPM);
      genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, RPM);

      // ANALOG DATA
      VOLT = readBatteryMillivoltsSV();
      genie.WriteStr(3, VOLT);

      // AFR CALC
      AFR = analogRead(LAM);
      AFRI = map(AFR, 0, 1023, 68, 136);
      AFRG = map(AFR, 0, 1023, 0, 100);
      if (AFRI > MAXLEAN) {
      MAXLEAN = AFRI;
      }
      LAMBDAH = digitalRead(LAMHEAT);

      genie.WriteObject(GENIE_OBJ_LED_DIGITS, 1, AFRI);
      genie.WriteObject(GENIE_OBJ_GAUGE, 1, AFRG);
      genie.WriteObject(GENIE_OBJ_LED, 0, LAMBDAH);

      ledYellow(1);

      // SPI EGT DATA
      EGT = TC.readCelsius();
      if (EGT <= 100) {
      EGT = TC.readInternal();
      }
      if (EGT > EGTMAX) {
      EGTMAX = EGT;
      }
      genie.WriteObject(GENIE_OBJ_LED_DIGITS, 2, EGT);
      genie.WriteObject(GENIE_OBJ_GAUGE, 2, EGT);

      RPMS = RPM / 150;
      AFRS = AFRI / 2;
      EGTS = EGT / 10;

      if (RECFLAG == 1) {
      genie.WriteObject(GENIE_OBJ_SCOPE, 0, RPMS);
      genie.WriteObject(GENIE_OBJ_SCOPE, 0, AFRS);
      genie.WriteObject(GENIE_OBJ_SCOPE, 0, EGTS);
      }
      if (RECFLAG == 0) {
      genie.WriteStr(0, RPMMAX);
      genie.WriteStr(1, MAXLEAN / 100);
      genie.WriteStr(2, EGTMAX);
      }

      genie.WriteStr(4, SKTIME);
      SKTIME = millis() - OLDTIME;
      }
      Last edited by Matthias; 14 August 2020, 06:42 PM.

      Comment


      • #4
        Hi,

        As I see it, there is nothing to improve on the Arduino code. The scope update/draw speed is highly dependent to the data points and their closeness to each other, so it might not be able to reach your expected update speed, as also discussed in a previous post https://forum.4dsystems.com.au/node/51364.

        Best Regards,

        Comment


        • #5
          Data point closeness means writing example values like 10,50,100 to scope takes more time than 10, 12, 14, ? Effectively leading to scope y height affecting update speed capability?
          Will syncing RefreshIncrement to scope traces speed up the update process, like with 3 traces Refreshincrement set to 3, 6, 9...?

          Comment


          • #6
            Hi,

            This may help and might be a case of trial and error.

            One thing you could consider is making some time savings elsewhere. It might be possible in your project to use some of the Internal / Inherent widgets. Using these could lose quite a bit of time in the other widgets update allowing the scope to take some time to refresh.

            To use the new internal / inherent widgets you will need to update to latest version of Workshop 4.

            Best regards

            Paul

            Comment

            Working...
            X