Announcement

Collapse
No announcement yet.

Car dashboard

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

  • Car dashboard

    Hello!

    I'm currently building a dashboard for a formula student car. For this I'm using a gen4-uLCD-50D-SB screen. An arduino is used to read the "CAN" messages from the car then translating them to the correct information, rpm, oil temp and so on. This works fine with a led bar and 7-digit display and it updates data very fast. So this part works. When the same thing is tried on the LCD the updating speed of the CAN messages becomes very slow. There is also a delay from the CAN being read in the arduino until it shows up on the screen, this delay is varies but it takes somewhere between 4-10 seconds.

    This is the current code for the screen, all help is appreciated!

    #include <genieArduino.h>
    #include<stdio.h>
    #include<stdlib.h>

    #include <SoftwareSerial.h>
    SoftwareSerial mySerial(8, 9); // RX, TX

    Genie genie;
    //#define DEBUGGING
    #define RESETLINE 4 // Change this if you are not using an Arduino Adaptor Shield Version 2 (see code below)
    void initScreen()
    {
    // NOTE, the genieBegin function (e.g. genieBegin(GENIE_SERIAL_0, 115200)) no longer exists. Use a Serial Begin and serial port of your choice in
    // your code and use the genie.Begin function to send it to the Genie library (see this example below)
    // 200K Baud is good for most Arduinos. Galileo should use 115200.
    mySerial.begin(200000); // Serial0 @ 200000 (200K) Baud
    genie.Begin(mySerial); // Use Serial0 for talking to the Genie Library, and to the 4D Systems display

    // Reset the Display (change D4 to D2 if you have original 4D Arduino Adaptor)
    // THIS IS IMPORTANT AND CAN PREVENT OUT OF SYNC ISSUES, SLOW SPEED RESPONSE ETC
    // If NOT using a 4D Arduino Adaptor, digitalWrites must be reversed as Display Reset is Active Low, and
    // the 4D Arduino Adaptors invert this signal so must be Active High.
    pinMode(RESETLINE, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
    digitalWrite(RESETLINE, 1); // Reset the Display via D4
    delay(100);
    digitalWrite(RESETLINE, 0); // unReset the Display via D4

    delay (3500); //let the display start up after the reset (This is important)

    // Set the brightness/Contrast of the Display - (Not needed but illustrates how)
    // Most Displays, 1 = Display ON, 0 = Display OFF. See below for exceptions and for DIABLO16 displays.
    // For uLCD-43, uLCD-220RD, uLCD-70DT, and uLCD-35DT, use 0-15 for Brightness Control, where 0 = Display OFF, though to 15 = Max Brightness ON.
    genie.WriteContrast(15);
    }


    void loopScreen()
    {
    static long waitPeriod = millis();
    genie.DoEvents(); // This calls the library each loop to process the queued responses from the display
    if if (millis() >= waitPeriod)
    {
    // CANparameters ={lambdaVal1, lambdaVal2, lambdaTarget, rpm, ESCut, coolantTemp, oilTemp, oilPressure, RequestedGear, Gear, wheelSpeed};

    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, oilPressure*10); //oil pressure oilPressure
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 1, oilTemp*10); //oil temp.
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 2, coolantTemp*10); //water temp.
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 4, Gear); //Gear
    currentMillis = millis()+50;

    }
    }

  • #2
    Hello Elsebbe,

    Welcome to the forum!

    From the snippet of code you attached, I do not see any reason for a delay of 4-10 seconds to happen.
    Maybe something else is causing a delay in your program.

    On a side note, I think your 'voidloopScreen' should be like this:

    Code:
    void loop() {
      static long waitPeriod = millis();
      genie.DoEvents(); // This calls the library each loop to process the queued responses from the display 
      
      if (millis() >= waitPeriod){ 
        // CANparameters ={lambdaVal1, lambdaVal2, lambdaTarget, rpm, ESCut, coolantTemp, oilTemp, oilPressure, RequestedGear, Gear, wheelSpeed};
    
        genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, oilPressure*2); //oil pressure oilPressure
        genie.WriteObject(GENIE_OBJ_LED_DIGITS, 1, oilTemp*2); //oil temp. 
        genie.WriteObject(GENIE_OBJ_LED_DIGITS, 2, coolantTemp*2); //water temp. 
        genie.WriteObject(GENIE_OBJ_LED_DIGITS, 4, Gear); //Gear
    
        waitPeriod  = millis()+50;
      }
    }
    Best Regards,
    Kevin

    Comment

    Working...
    X