Announcement

Collapse
No announcement yet.

Changing baud rate using an Arduino Mega 2560 connected to a gen4-uLCD-32DT

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

  • Changing baud rate using an Arduino Mega 2560 connected to a gen4-uLCD-32DT

    Hello ,

    I am working on a project which was originally only an internship project, and which has become very important for a critical application.
    It includes a 4D Systems screen reference "gen4-uLCD-32DT", controlled by an Arduino Mega 2560, which communicate in UART at 9600 Bauds on the Serial 3 port of the Arduino.
    I’m using Diablo_Serial_4Dlib.

    This weak Baudrate causes delays that I am really forced to reduce. A baudrate at 115,200 Bauds would be great.
    But I have never managed to increase this, despite forum research and testing.

    I am enclosing the program below only intended to test an increase in baudrate.

    Result:
    I have the display "9600 Bauds OK"
    Monitor displays : Serial 4D Library reports error NAK returned data = 249
    The LED flashes to indicate the error.
    I don't know what the 249 answer is (= 0xF9).

    Any help would be welcome.

    Olivier





    //*********************************************************************
    // Test increase baudrate (doesn't work)
    // Arduino MEGA 2560 + 4D Systems gen4-uLCD-32DT (UART on Serial3)
    //*********************************************************************

    // Monitor : Serial 4D Library reports error NAK returned data = 249 (= 0xF9)


    #define DisplaySerial Serial3
    #define ResetLCD A3
    #define led 13

    #include <Diablo_Const4D.h>
    #include <Diablo_Serial_4DLib.h>
    Diablo_Serial_4DLib Display(&DisplaySerial) ;

    void setup( ) {

    pinMode( ResetLCD , OUTPUT ) ;
    pinMode( led , OUTPUT ) ;

    Serial.begin ( 115200 ) ; // Monitor
    DisplaySerial.begin ( 9600 ) ; // LCD default baudrate
    Display.Callback4D = mycallback ;
    Display.TimeLimit4D = 5000 ;

    // Reset LCD
    digitalWrite ( ResetLCD , 0 ) ;
    delay( 100 ) ;
    digitalWrite ( ResetLCD , 1 ) ;
    delay ( 5000 ) ;

    Display.gfx_ScreenMode ( LANDSCAPE ) ;
    Display.gfx_BGcolour ( BLUE ) ;
    Display.gfx_Cls() ;
    Display.txt_BGcolour ( RED ) ;
    Display.txt_FGcolour ( BLACK ) ;
    Display.txt_Height ( 2 ) ;
    Display.txt_Width ( 2 ) ;

    // Display 9600 baud OK
    Display.gfx_MoveTo ( 10 , 100 ) ;
    Display.print ( " 9600 Bauds OK" ) ;
    delay ( 5000 ) ;

    // Increase baudrate (doesn't work)
    Display.setbaudWait( BAUD_19200 ) ;
    DisplaySerial.begin( 19200 ) ;
    delay( 3000 ) ;

    // Display 19200 baud OK (doesn't work)
    Display.gfx_MoveTo ( 100 , 10 ) ;
    Display.print ( "19200 Bauds OK" ) ;
    }


    void loop ( ) {
    }

    void mycallback( int ErrCode, unsigned char Errorbyte ) {
    const char *Error4DText[] = { "OK\0", "Timeout\0", "NAK\0", "Length\0", "Invalid\0" } ;
    Serial.print( F ( "Serial 4D Library reports error " ) ) ;
    Serial.print( Error4DText[ ErrCode ] ) ;
    if ( ErrCode == Err4D_NAK ) {
    Serial.print( F ( " returned data = " ) ) ;
    Serial.println( Errorbyte ) ;
    }
    // Led blinking
    while ( 1 ) {
    digitalWrite( led, HIGH) ;
    delay( 200 ) ;
    digitalWrite( led, LOW) ;
    delay( 200 ) ;
    }
    }

  • #2
    Hello,

    Welcome to the forum. Apologies for the delayed reply.

    Kindly check this appnote for your reference:
    AN-00092 Serial Connection to an Arduino Host
    https://4dsystems.com.au/blog/4d-an-00092/

    You can change the baud rate in WS4 IDE, File > Options > Serial. You will have to create a new Serial Environment project, then reload the SPE Application:

    Click image for larger version  Name:	SPE load.JPG Views:	0 Size:	22.7 KB ID:	72117

    BR,
    Sherwin
    Last edited by sherwin4D; 1 day ago.

    Comment

    Working...
    X