Announcement

Collapse
No announcement yet.

STM32 sends data only once after program starts (4D systems 35DCT-CLB)

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

  • STM32 sends data only once after program starts (4D systems 35DCT-CLB)

    Hello,

    I'm using a 35DCT display in a custom product I'm designing. Testing the project with a Arduino Uno connected to the display, everything works as expected. But on my custom circuit board I have a STM32F103C8T6. I'm using PA9 and PA10 for the serial connection. PA8 is the reset pin.
    Also I'm using the genieArduino library. I'm using Platformio.
    Here is what happens:

    1.- Board powers up, Display resets like it should
    2.- I press one button or I move the slider, data gets updated once
    3.- I press the button again or move the slider, nothings gets updated anymore.

    What I tried:

    1.- Checked the boards power supply to the MCU and Display --> all good. No dips in voltage. Used a oscilliscope for that.
    2.- Tried changing baud rate --> can only communicate at 9600 baud

    It looks like I have communication, but MCU freezes after updating first object. Is the library incompatible with STM32? Platformio tells me it is compatible since it shows a list of compatible platforms.

    Here is the code I'm using if you need it

    Code:
    #include <Arduino.h>
    #include <genieArduino.h>
    #include <SoftwareSerial.h>
    Genie genie;
    #define RESETLINE PA8  // Change this if you are not using an Arduino Adaptor Shield Version 2 (see code below)
    SoftwareSerial HMIserial(PA10, PA9);
    int SliderPreset = 0;
    int val = 0;
    // Setup function
    void setup()
    {
      genie.AttachEventHandler(HMIeventHandler);
      //Serial.begin(9600);
      HMIserial.begin(9600);
      genie.Begin(HMIserial);   // Use Serial0 for talking to the Genie Library, and to the 4D Systems display
      //pinMode(ledPin, OUTPUT);
      pinMode(RESETLINE, OUTPUT);
    
      digitalWrite(RESETLINE, 0);  // Reset the Display via D4
      delay(100);
      digitalWrite(RESETLINE, 1);  // unReset the Display via D4
      delay (5000); //let the display start up after the reset (This is important)
    }
    // Main loop
    void loop()
    {
      genie.DoEvents();
      val++;
      genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, val);
    }
    void HMIeventHandler(void) {
      genieFrame Event;
      genie.DequeueEvent(&Event);
      //If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
      {
        // RED WINBUTTONS
        if (Event.reportObject.object == GENIE_OBJ_WINBUTTON) // If a Winbutton was pressed
        {
          if (Event.reportObject.index == 1) // If Winbutton #0 START was pressed
          {
            genie.WriteObject(GENIE_OBJ_USER_LED, 0x00, 0);
          }
          if (Event.reportObject.index == 0) // If Winbutton #1 STOP was pressed
          {
            genie.WriteObject(GENIE_OBJ_USER_LED, 0x00, 1);
          }
        }
        // READ SLIDER VALUE    
        if (Event.reportObject.object == GENIE_OBJ_SLIDER) // If a Slider value was changed
        {
          if (Event.reportObject.index == 0) // If Slider #0 changed value
          {
            SliderPreset = genie.GetEventData(&Event);
            genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, SliderPreset);
          }
        }
      }
    }
    Thanks in advance!

    UPDATE: I changed

    Code:
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, val);
    to write to String object instead

    Code:
    genie.WriteStr(0, val);
    Now this works. The value printed to the String object increases as expected, but as soon as I press a button or move the slider, the program freezes. I'm suspecting it has to do with the library. I'll look into it to try to find the problem, but if someone could help it would be appreciated.
    Last edited by Elizandro99; 1 week ago.

  • #2
    Good day,

    In your main loop it looks like you are just sending to the string or digit continuously. Have you tried testing the buttons with the string/digit update in the main loop commented out? The display/host might get synchronization issues if the requests are too frequent.

    Best Regards,

    Comment


    • #3
      Hello,

      I can send Strings continuously but string becomes dim due to the frequent updates, fixed that by only updating if the variable had changed.

      Now about the digit update. I used the following code to only send an update to the digits every 5 seconds, but same thing happend, the program apparently freezes after sending the first update to the digits. Digits show the correct value tho.

      Code:
      if (currentMillis - previousMillis >= 5000)
        {
          previousMillis = currentMillis;
          genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, val);
        }
      Thanks for the reply.

      Comment


      • #4
        Hi,

        Maybe you can try the Beta library https://github.com/4dsystems/ViSi-Ge...o-Library-BETA for ViSi-genie and see if it helps with the freeze issue. Otherwise, there might be some other underlying issues regarding the STM32 serial UART implementation with Arduino.

        Best Regards,

        Comment


        • #5
          Hi,

          I haven't tested the beta libray yet but I'm going to. As soon as I know if it works I will let know. And I think it will have to do with the STM32 serial UART implementation. I have read on online forums that many have issues regarding STM32 serial communication.

          Regards

          Comment


          • #6
            Also what I want to mention is that I have been able to use only the animated buttons. Other buttons cause the program to freeze.
            Now the animated button also can cause the program to freeze, but only when I press it for more than 200 milliseconds or if I press it several times in a row, with 1 second (or faster) intervals .

            UPDATE:

            Now I have tested the BETA library and it looks like it works. I can now use the LED DIGITS and also the slider button and animated buttons I use in my project can be pressed as much and as long as I want without causing the system to freeze.

            If I find some other issue I will notify, but other than that it works.

            I won't be using the WinButton, since it didn;t work, but will find out if I can use it for feedbak purpose.

            Thanks for your help!
            Last edited by Elizandro99; 6 days ago.

            Comment


            • #7
              Hello,

              I want to mention that I'm using Platformio with VS Code, Now in the genieArduino.cpp file I had to change the following code on lines 807-808 and lines 1043-1044 from

              Code:
              // long N = n; // unused?
              n = abs(n);
              to the following code:

              Code:
              long N = n; // unused?
              n = abs(N);
              Before changing the code mentioned, it would not compile. After changing it would compile and it works. But in the Arduino IDE it compiles without the modifications.
              Had to do this with both, the released and beta library.

              Comment

              Working...
              X