Announcement

Collapse
No announcement yet.

uOLED_160-G2 baud rate issues

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

  • uOLED_160-G2 baud rate issues

    Hi,

    I'm using a UOLED-160-G2 module on an arduino UNO with the arduino shield adapter.

    I have everything working and can talk to the display at 9600 baud and using the setBaudWait() function I can set the baud rate to 19200 successfully. However, any other higher rates I get NAK failures.

    I have tried on both the hardware serial ports and soft serial but have no luck getting higher than 19200. Any help appreciated.

    Matt.

  • #2
    Hello Matt,

    Welcome to the forum

    Could you please let me know which baud rates you used above 19200 that are shown in th table on page 79 of the datasheet https://www.4dsystems.com.au/product...nual_R_2_0.pdf

    The next baud rate up from 19200 would be 31250 which I am sure you can set the UNO to after the setBaudWait() command has been issued.

    Best regards

    Paul

    Comment


    • #3
      Hi Paul,

      I tried 38400, 57600, 115200 etc. I didn't try 31250.

      I have subsequently changed my hardware setup to an Arduino M0, and now all the higher baud rates work up to 128000 baud.

      However, I did find an issue with the library when compiling for M0. Maybe this should be a separate thread, but here it is anyway. The following line upon the object creation kills the M0 operation:

      Code:
      _virtualPort->flush();
      Contained in the constructor as follows:

      Code:
      //Goldelox_Serial_4DLib::Goldelox_Serial_4DLib(Stream * virtualPort) { 
      Goldelox_Serial_4DLib::Goldelox_Serial_4DLib(Stream* virtualPort) { 
      
          _virtualPort = virtualPort; 
      
      #ifndef _SAM3XA_
          // Only done on non Arduino Due Boards
          _virtualPort->flush(); 
      #endif
      }
      I have removed the _virtualPort->flush(); code and now the library works on the M0. Maybe the #ifndef needs more definition for the SAMD21 devices? Or removed altogether as I don't see why you would need to flush a port that has not been opened yet?

      Matt.

      Comment


      • #4
        Hello Matt,

        Thanks for the feedback, glad you got it working. Thank you also for the info on _virtualPort->flush()

        Best regards

        Paul

        Comment


        • #5
          I am also having trouble with baud rates above 128000 with the uOLED_160-G2 (using display shield)
          They are not working with the Arduino Due (no display and LED flashing)

          I modified the Display_print demo with some code from the GoldeloxBigDemo to have variable baud rate for testing.
          changing the lin `setbaudWait(BAUD_128000) ;` updates the baud rate (default is 9600)
          Anything above 128k fails.


          ```
          //Simple Demo that demonstrates 'print' and 'println' new functionality.

          #define DisplaySerial Serial

          //-------Picaso DISPLAYS-------

          #include "Goldelox_Serial_4DLib.h"
          #include "Goldelox_Const4D.h"

          //use Serial0 to communicate with the display.
          Goldelox_Serial_4DLib Display(&DisplaySerial);

          //---------END-----------------

          void setup() {
          //For handling errors
          Display.Callback4D = mycallback ;

          //5 second timeout on all commands
          Display.TimeLimit4D = 5000 ;


          DisplaySerial.begin(9600) ;

          //--------------------------------Optional reset routine-----------------------------------
          //Reset the Display using D4 of the Arduino (if using the new 4D Arduino Adaptor - Rev 2)
          //If using the old 4D Arduino Adaptor (Rev 1), change D4 to D2 below.
          //If using jumper wires, reverse the logic states below.
          //Refer to the accompanying application note for important information.
          pinMode(4, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
          digitalWrite(4, 1); // Reset the Display via D4
          delay(100);
          digitalWrite(4, 0); // unReset the Display via D4
          //-----------------------------------------END---------------------------------------------

          delay (5000); //let the display start up

          Display.gfx_ScreenMode(LANDSCAPE);
          Display.SSTimeout(0) ;
          Display.SSSpeed(0) ;
          Display.SSMode(0) ;

          //Display.gfx_BGcolour(WHITE) ; //change background color to white
          Display.gfx_Cls(); //clear the screen

          setbaudWait(BAUD_128000) ;
          Display.putstr("D_baud set at 128k\n") ;
          delay(2000);

          char a = 'A';
          char a2 = 'B';
          int b = 1234;
          int b2 = -1234;
          long c = 123456;
          long c2 = -123456;
          String string = "This is string class";
          char charr[30] = "This is const char array";
          float d = 123.456789;
          float d2 = -123.456789;
          float nan = NAN;
          float inf = INFINITY;
          float ovf1 = 5294967040.0;
          float ovf2 = -5294967040.0;

          Display.print(a); Display.print(' ');
          Display.println(a2);
          Display.print(b); Display.print(' ');
          Display.println(b2);
          Display.print(c); Display.print(' ');
          Display.println(c2);
          Display.println("This is String");
          //Display.println(F("This is Flashstring")); // COMMENT OUT FOR ARDUINO DUE, NOT SUPPORTED
          Display.println(string);
          Display.println(charr);
          Display.println(d,6);
          Display.println(d2, 3);
          Display.println(nan);
          Display.println(inf);
          Display.println(ovf1);
          Display.println(ovf2);

          }

          void loop()
          {

          }

          void mycallback(int ErrCode, unsigned char Errorbyte)
          {
          // Pin 13 has an LED connected on most Arduino boards. Just give it a name
          int led = 13;
          pinMode(led, OUTPUT);
          while(1)
          {
          digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
          delay(200); // wait for 200 ms
          digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
          delay(200); // wait for 200 ms
          }
          }

          // commands to set dispay baud rate
          void SetThisBaudrate(int Newrate)
          {
          int br ;
          DisplaySerial.flush() ;
          DisplaySerial.end() ;
          switch(Newrate)
          {
          case BAUD_110 : br = 110 ;
          break ;
          case BAUD_300 : br = 300 ;
          break ;
          case BAUD_600 : br = 600 ;
          break ;
          case BAUD_1200 : br = 1200 ;
          break ;
          case BAUD_2400 : br = 2400 ;
          break ;
          case BAUD_4800 : br = 4800 ;
          break ;
          case BAUD_9600 : br = 9600 ;
          break ;
          case BAUD_14400 : br = 14400 ;
          break ;
          case BAUD_19200 : br = 19200 ;
          break ;
          case BAUD_31250 : br = 31250 ;
          break ;
          case BAUD_38400 : br = 38400 ;
          break ;
          case BAUD_56000 : br = 56000 ;
          break ;
          case BAUD_57600 : br = 57600 ;
          break ;
          case BAUD_115200 : br = 115200 ;
          break ;
          case BAUD_128000 : br = 133928 ; // actual rate is not 128000 ;
          break ;
          case BAUD_256000 : br = 281250 ; // actual rate is not 256000 ;
          break ;
          case BAUD_300000 : br = 312500 ; // actual rate is not 300000 ;
          break ;
          case BAUD_375000 : br = 401785 ; // actual rate is not 375000 ;
          break ;
          case BAUD_500000 : br = 562500 ; // actual rate is not 500000 ;
          break ;
          case BAUD_600000 : br = 703125 ; // actual rate is not 600000 ;
          break ;
          }
          DisplaySerial.begin(br) ;
          delay(50) ; // Display sleeps for 100
          DisplaySerial.flush() ;
          }

          void setbaudWait(word Newrate)
          {
          DisplaySerial.print((char)(F_setbaudWait >> 8));
          DisplaySerial.print((char)(F_setbaudWait));
          DisplaySerial.print((char)(Newrate >> 8));
          DisplaySerial.print((char)(Newrate));
          SetThisBaudrate(Newrate); // change this systems baud rate to match new display rate, ACK is 100ms away
          Display.GetAck() ;
          }

          ```

          Comment

          Working...
          X