Announcement

Collapse
No announcement yet.

Changing baud rate using an ATMega 328 connected to a 128-G2 with Arduino platform

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

  • Changing baud rate using an ATMega 328 connected to a 128-G2 with Arduino platform

    I am trying to change the comms speed between the micro and the display, but every variation on the syntax just produces a blank display when the code is run.

    I can't use the Workshop facility because the display is now fixed into the device for which it was intended so I can only access the graphics processor using serial commands through the ATMega 328.

    The "setbaudWait" command is the problem area (i think)..

    The code I am trying to get working is as below, and is part of the void setup functions. The default 9600 baud is working fine but the added lines to change the baud rate just don't work. Any help greatly appreciated.


    Code:
    // Set the data rate to the OLED and initialise
      digitalWrite(OUTPUT_OLED_RST,0);
      delay(100);
      digitalWrite(OUTPUT_OLED_RST,1);
      delay(100);
      DisplaySerial.begin(9600);
      Display.SSTimeout(0);
      DisplaySerial.flush();
      DisplaySerial.end();
      Display.setbaudWait(BAUD_115200);
      delay(2000);
      DisplaySerial.begin(115200);
      delay(5000);

  • #2
    Hi MartyBoy,

    This forum post might help:

    How to change Baudrate in Serial mode
    http://forum.4dsystems.com.au/forum/...in-serial-mode

    You could try the GoldeloxBigDemo Arduino example. It also illustrated the Display.setbaudWait() command.

    Under 'File' - 'Samples' - 'Goldelox Serial'. Then in the Arduino Example folder, you could find the GoldeloxBigDemo.ino File.

    Best Regards,

    Comment


    • #3
      Hi Joseph

      Thanks for the reply.

      I have read and are familiar with the subject matter covered in your two suggestions, the app notes and the BigDemo example.

      As stated in my initial post I can't change the baud rate using the Workshop 4 utility, as the display is mounted in a device giving me the only connection through an ATMega 328 micro. I can no longer attach a USB cable and 4D Systems adapter to the display. The app notes don't cover this situation.

      The demo program will runs on the same device if the pins for SoftwareSerial are reassigned from the defaults. However, the part of the demo program that is supposed to demonstrate the baud rate changes does not work and the display is blank for that part of the demonstration. It then loops back to the rest of the demonstration showing graphics objects and text

      Any light you can shine on this appreciated. .

      Comment


      • #4
        Hi MartyBoy,

        Have you tried this part in the BigDemo? With 19200 baud Rate?
        Code:
          Display.gfx_Cls() ;
          setbaudWait(BAUD_19200) ;
          Display.putstr("Hi at 19200\n") ;
          setbaudWait(BAUD_9600) ;
          Display.putstr("Back to 9600\n") ;
          delay(5000);
        Did the display successfully printed something? you might want to delete some functions and testing in the BigDemo to thoroughly see just what you want. setbaudWait() should already be changing both the display and the Arduino in the correct order.

        Can you try adjusting your Microcontroller's Baud Rate to match the working Baud Rate? 9600 first then increase it a little it too see what is compatible. Setting it up on a very high baud rate all of the sudden may have problems such as buffers, line connection, etc..

        Best Regards,
        Last edited by Joseph Herrera; 28 December 2016, 03:28 PM. Reason: additional info

        Comment


        • #5
          Hi Joseph

          Yes I have the code as above working in conjunction with the two void statements that set the display and ATMega 328 comms speeds. However the change only works at either 8600 or 19200. I can't get the display to operate on any other speeds higher than 19200.

          Can you advise me on this please.

          Also is there a user or command reference manual for the SoftwareSerial library please?

          Regards

          Comment


          • #6
            Hi,

            Here is the GOLDELOX Serial Command Set Reference Manual:

            GOLDELOX_serialcmdmanual
            http://www.4dsystems.com.au/productp...nual_R_1_7.pdf

            Can you give us the reasons for the higher baud rate?
            As of the moment, higher baud rates such as 200,000 has not yet been added to the libraries of the displays such as 128-G2.

            Regards,

            Comment


            • #7
              Hello,
              I am a new user of a GEN4-ULCD-43DT-AR that I will use with an ARDUINO.
              I am currently exploring the SERIAL mode and the way to proceed seems quite clear to me, thank you for the very well done documentation.

              So I control the screen with the graphic primitives and I need the display to be reactive. For this purpose I want to increase the baud rate to its maximum value to save on transmission time.
              Is this a good strategy?
              What is the maximum value possible from an ARDUINO?

              I'm a little suspicious because if you lose communication with the screen, it's not a good deal!
              Can I safely use the code given as an example by Joseph Herrera?

              Thank you for your answer...
              Michel

              Comment


              • #8
                Hi Michel,

                Welcome to the forum!

                You can use a baud rate of 200K. If you are transferring large chunks of data then you can use this, however, if the data is small you will not notice a difference regardless of the speed.

                The discussion above is for changing the baudrate of the display using a host controller (during runtime).
                Can I safely use the code given as an example by Joseph Herrera?
                Yes, you can test the code above, that should demonstrate the baud rate change command on the display (Refer to the BiGDemo file on the Arduino to check for the method used)

                Though, you can also set the baud rate of the display using the Workshop4 (File-Options-Serial-Serial Environment Initial Baud Rate). With this, you can set the initial baud rate of the display to match with the baud rate on your host controller. Connect the display using the 4D Programming Cable or the uUSB-PA5-II programming adaptor, and Load the SPE application to set the new baud rate

                You may refer to this application note:
                AN-00110 Serial Diablo16 Getting Started - The SPE Application
                https://4dsystems.com.au/blog/4d-an-00110/

                I hope this helps.

                Best Regards,
                Kevin
                Last edited by John Kevin; 18 December 2019, 11:31 AM.

                Comment


                • #9
                  Thank you Kevin ...

                  Comment


                  • John Kevin
                    John Kevin commented
                    Editing a comment
                    Sure, no problem

                • #10
                  Hello,

                  Not everything is clear to me: -(
                  Is it this procedure (from BigDemo) that really acts on the screen to establish the baudrate with which it can communicate?

                  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() ;
                  }

                  In this case, can we write in setup() the following:

                  DisplaySerial.begin(9600) ;
                  setbaudWait(115200) ;
                  DisplaySerial.begin(115200) ;

                  With :

                  void setbaudWait(word Newrate)
                  {
                  DisplaySerial.print((char)(F_setbaudWait >> 8));
                  DisplaySerial.print((char)(F_setbaudWait));
                  DisplaySerial.print((char)(Newrate >> 8));
                  DisplaySerial.print((char)(Newrate))
                  }

                  Sorry for this beginner's question.

                  Michel


                  Comment


                  • #11
                    Hi Michel,

                    Did you also include the void SetThisBaudrate(int Newrate)? If you check the function, it has a serial flush on it. You need to flush the serial comms before sending a baud rate change. Also, for the setbaudWait(115200) ; you need to set the index of the baud rate that you want to use. For the 115200, the baud rate is 13. You can refer to the Diablo 16 Serial Commands Reference Manual for more information.

                    However, checking again the Diablo16 library, it seems that the indexes are already defined. For the baud rate of 115200, you can use BAUD_115200.

                    Alternatively, you can implement a change in baud rate this way:
                    Code:
                      Display.print("Hello"); // initial baud rate is 9600
                      Display.setbaudWait(BAUD_115200); // setting to 115200 baud rate
                      //Set the Host Baud Rate to 115200
                      DisplaySerial.begin(115200);
                      Display.print("Hello Again!"); //Sending another message on baud rate of 115200
                    Best Regards,
                    Kevin
                    Attached Files
                    Last edited by John Kevin; 19 December 2019, 05:48 PM.

                    Comment

                    Working...
                    X