Announcement

Collapse
No announcement yet.

Some question re the uLCD220RD

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

  • Some question re the uLCD220RD

    Hi All,

    Firstly nice product, easy to install, and the visual ide is nice.
    the language is tripping me up as its not quite c# and not quite VB, and im an old codger

    I have a few questions related to same project.. ill describe project first.

    PROJECT: Bike Telemetry display.
    I have hooked the uLCD220rd to a MEGA2560, and on the mega running a ublox6 GPS on serial3, the display on serial2 and storing serial1 for debug.
    I have 4 temp sensors and an accelerometer on various analog and digital pins. The code to read and display all that telemetry works properly. Guages and leddigits and strings all working as expected. video to date https://www.youtube.com/watch?v=buycC92q1Rk


    Problem1: The arduino has to poll the gps for 300ms to grab all the sentences properly, which of course means the acceleometer lean and wheely angle from X and Y are jerky.. I would like to add the accelerometer (and maybe the temp sensors) directly to the 220rd gpio, -BUT- since I am using Genie to create the screens I cannot easily access the code without saving as visi, meaning I can now no longer go backwards to edit the display.. but assuming i finalise my display in genie, then reopening in visi and trying to find the right place to inject the gpio code, I cannot find any simple to read examples of how to do this?

    Are you able to help with a simple code snippet for the accelerometer for e3xample, im a quick study

    5 pins : GND - X - Y - Z VIN(5v), X,Y and Z are analog pins and -90' Left would read 200, 90 degrees right would read 545 on X (lean angle) for example.

    Problem2: Customising your own guage. The current Coolguage is close to what I want, but i need to overlay other data on it, 4 x temp digits, and the accelerometer angles x 2
    While this can be setup in geniw and visi, the result is massive flickering on the actual display, near unreadable, is there a way around this, otherwise I have to cramp up the various telemetry in seperate smaller displays, effectively negating the point of having a nice speedo ready round display.

    Problem3: The IDE keeps warning me that because im writing to flash i will burn the device out (or something like that) but there is no other way to retain the display between power cycles while unplugging from programmer and taking back to arduino.. is there a way around this, perhaps an example of a stub that can stay permanently flashed, that will read the display code from a file on the SD? (what is the average flash lifetime cycle on these? Im pretty much near complete but id hate to have to buy another screen). The ardiuno breakout supplied with screen has a programming input as well, am I missing something about being able to program it while its actually still plugged into the arduino?

    Problem4: The datasheet advises the pins can be setup as tx/rx as well? Perhaps I was not following properly, but if that is the case, I can hook the gps into the screen directly at 9600bd and do my own string handling to extract what I need from the sentences. In your opinion will locking up the 220rd for that ~300ms seriously screw with it, and am I better just leaving that to the arduino.

    TIA, CB









  • #2
    Click image for larger version

Name:	1.jpg
Views:	1
Size:	158.9 KB
ID:	63359 Click image for larger version

Name:	2.jpg
Views:	1
Size:	182.0 KB
ID:	63358 Click image for larger version

Name:	3.jpg
Views:	1
Size:	157.7 KB
ID:	63360

    Comment


    • #3
      Hello,

      Very nice project and I particularly like your enlosure, very neat.

      As your GPS is a uBlox, there are ways to get a reading a lot faster but it would mean configuring the GPS using uBlox uCenter software to change it's configuration. By default it will be sending out NMEA strings at a slow buad rate. You can adjust the baud rate on the uBlox to get the strings in faster which will certanly help get the 300ms down. Another feature of the uBlox is the ability to switch from NMEA to UBX. UBX is a binary protocol and the Serial data length is much shorter. You can also configure it to just send the data you require eg speed. I have had a uBlox send out just speed at a rate of 10 times per second without interrupting the other moving graphics on the display.

      If you wanted to connect your sensors directly to the display then I would recommend doing this in Visi. As your accelerometer sends out analog values and no complicated maths it would be quite straight forward in Visi. Can you let me know the type of accelerometer you are using.

      If you would prefer to use Visi-genie then it would be easier to keep the Arduino connected which would look after all your sensors.

      The flickering of overlaying images can be fixed in a couple of ways. You could create your own gauge with all of the elements in it but can be quite time consuming as for every one value of the speedometer you would have to have a set of images for each angle movement. I will try to create an example of how this can be done. Or you could use Smart Widgets. In the Pro version of Workshop 4 we have a utility called Smart widgets which helps to create gauges like this. I will see if it is possible with a Smartwidget and get back to you on that.

      uBlox links

      https://www.u-blox.com/en/product/u-center-windows

      https://www.u-blox.com/sites/default...3005250%29.pdf

      Smart widgets demo

      https://www.youtube.com/watch?v=81cez-Ws4dQ

      I hope this helps

      Best regards

      Paul

      Comment


      • #4
        Hi,

        Also, I wouldn't worry about the number of flash cycles, I am still able to use and program my first uLCD-220RD which I have had for many years. We let you know that you are writing to flash as theoretically it can become unusable after many many writes to the flash but I haven't heard of an incident of this actually happening.

        I hope this helps

        Best regards

        Paul

        Comment


        • #5
          Originally posted by pauleilio View Post
          Hello,

          Very nice project and I particularly like your enlosure, very neat.

          As your GPS is a uBlox, there are ways to get a reading a lot faster but it would mean configuring the GPS using uBlox uCenter software to change it's configuration. By default it will be sending out NMEA strings at a slow buad rate. You can adjust the baud rate on the uBlox to get the strings in faster which will certanly help get the 300ms down. Another feature of the uBlox is the ability to switch from NMEA to UBX. UBX is a binary protocol and the Serial data length is much shorter. You can also configure it to just send the data you require eg speed. I have had a uBlox send out just speed at a rate of 10 times per second without interrupting the other moving graphics on the display.

          If you wanted to connect your sensors directly to the display then I would recommend doing this in Visi. As your accelerometer sends out analog values and no complicated maths it would be quite straight forward in Visi. Can you let me know the type of accelerometer you are using.

          If you would prefer to use Visi-genie then it would be easier to keep the Arduino connected which would look after all your sensors.

          The flickering of overlaying images can be fixed in a couple of ways. You could create your own gauge with all of the elements in it but can be quite time consuming as for every one value of the speedometer you would have to have a set of images for each angle movement. I will try to create an example of how this can be done. Or you could use Smart Widgets. In the Pro version of Workshop 4 we have a utility called Smart widgets which helps to create gauges like this. I will see if it is possible with a Smartwidget and get back to you on that.

          uBlox links

          https://www.u-blox.com/en/product/u-center-windows

          https://www.u-blox.com/sites/default...3005250%29.pdf

          Smart widgets demo

          https://www.youtube.com/watch?v=81cez-Ws4dQ

          I hope this helps

          Best regards

          Paul
          Hi Paul,

          its an old freetronics MMA7361, https://www.sparkfun.com/products/retired/9652 but in road testing its proving to be quite innacurate as it detects bumps as lean angle.. so probaly going ot turf it for a ACC+Compass+GYRO board, which communicates via i2c instead. still just the basic codes to anable the pins and take readings from the current unit would be good as the syntax and workflow woudl apply over most pins I assume. In so far as being similar to the arduino difference in handling the output. Just a simple example of THIS PIN = THIS, Write to pin, read from pin, etc.

          Had a read on the ublox UBX protocol, only NeoGPS arduino library supports it natively, and that library crashes in a dozen places when I try load it.. ill read through enabling only what I need and how to parse that info, might be easier to just pull what I need.

          Stopped in at Jaycar today to find a larger rectangular screen to use instead as I think I prefer the rectangular format with half of it being speedo and balance being telemetry readout, with touch to reset parameter etc, but they only had a very basic unit there, ill shop directly.

          Thank you.

          Comment


          • #6
            Hi

            The Invensense MPU9250 is a nice ACC+Compass+Gyro but it would need to be connected to an Arduino as it is a complex i2c device and there are Arduino linraries to support it. There is also the Bosch BNO055 which you can connect directly to the display as it has an on board processor which does all the calculations and will output Eular angles, I did find this one to gyro drift over time though but they might be better now.

            I can recommend the gen4-uLCD-43 displays for you project. It has a good size screen and also supports page swappiing, which means you can draw all your gfx on one page and then flip to another page allowing you to draw on top of an object on the unshown page and then swap to show that page.

            Best regards

            Paul

            Comment


            • #7
              Hi,

              You may find this library useful for your GPS.

              https://github.com/1oginov/UbxGps

              Best regards

              Paul

              Comment


              • #8
                Great link, TY, I could not get ubx protocol working right, but, the info on using ucenter is far more readable than their own help files. got nmea set to deliver only the two strings I need, hardcode 115200 baud and 10hz refresh and can poll in 10ms now, including the debug to serial 0 out. (minor misread every few seconds, but once im happy ill kill debug and that should also dissapear)

                the time bought allows for 5 polls of the acc for average jitter removal, far more stable and accurate over bumps now. bit of reading up also added the value from Z and X to determine a very rough gforce and help stabilize X. case is on the printer now, ill try grab some video of it in action on the bike tommorow.

                Comment


                • #9
                  Hopefully my last question

                  How can I trigger a different page based on feedback from an arduino sensor? For example I will display a general telemetry page, but if lean angle goes over 45 degrees, that should be replaced by ONLY a guage showing lean angle, fullscreen, or if speed goes over 150kmph ONLY a guage showing speedo for example? Can that be setup in visi genie as multiple forms, then triggered from the arduino code? (I will code ot display max lean and max speed as suits on those screens, and a user button to revert to regular screen), in this way you have time to review the relevant telemetry once you come out of the dangerous zone.

                  Not sure i can verbalise it properly so here is a vid : https://www.youtube.com/watch?v=BMJtFC3_HDk

                  current arduino and visi code here : http://ceebeeoddsandsods.blogspot.co...le-logger.html
                  (i removed the KML writer code for now, im changing SD adapters)

                  TIA
                  Last edited by CeeBee; 12th May 2018, 04:22 PM.

                  Comment


                  • #10
                    Hi,

                    You would have to create a Form2 and a Form3 in workshop and this code should work.

                    You would have to add if statements to update the widgets eg if(currentForm == 2) if(currentForm == 3)

                    and change the value of inputPin to suit the input of your button to switch back to the main display.

                    Code:
                    //hardware
                    //  MEGA 2560
                    //  UBX6 gps on serial2, configured via Ucentre for:
                    //    NMEA @ 115200, 10hz and ONLY rmc and gga sentences
                    //  uLCD 220rd on serial1, configured in 4d WS @9600
                    //  Accelerometer MMA7361, Y axis on pin A9
                    
                    #include <genieArduino.h>
                    #include <TinyGPS++.h>
                    #define RESETLINE 4
                    
                    TinyGPSPlus gps;
                    Genie genie;
                    unsigned long leanTimerLast = 0, leanTimerCurrent = 0;
                    const long interval = 300000; // reset max lean every 5 minutes
                    const int jittercorrect = 50; //poll period for bump averaging
                    float gpsLatitude, gpsLongitude;
                    double Speed, speedMax;
                    int AccY = A9, leanMax = 0, leanCurrent = 0, gpsLock = 0, dir = 0, alt = 0;
                    int currentForm = 1;
                    int inputPin = 5;
                    
                    void setup(){
                      Serial.begin(57600);
                      Serial1.begin(9600); genie.Begin(Serial1);
                      Serial2.begin(115200);
                      pinMode(RESETLINE, OUTPUT);
                      digitalWrite(RESETLINE, 1); delay(100);
                      digitalWrite(RESETLINE, 0); delay (3500);
                    }
                    
                    void loop(){
                      gpsUpdate();
                      readAcc();
                      if(currentForm == 1){
                      genie.WriteObject(GENIE_OBJ_COOL_GAUGE, 0, (int)Speed);
                      genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, (int)Speed);
                      genie.WriteObject(GENIE_OBJ_COOL_GAUGE, 1, map(leanCurrent, -90, 90, 0, 180));
                      }
                      updateMax();
                      if((leanCurrent < 30 || leanCurrent > 30) && currentForm != 2){
                        genie.form(2);
                        currentForm = 2;
                      }
                      if(Speed > 50 && currentForm != 3){
                        genie.form(3);
                        currentForm = 3;
                      }
                      if(digitalRead(inputPin) == HIGH && (currentForm == 2 || currentForm == 3)){
                        genie.form(1);
                        currentForm = 1;
                      }
                    }
                    
                    void updateMax(){
                      leanTimerCurrent = millis();
                      if (leanTimerCurrent - leanTimerLast >= interval) { //reset lean every 5 mins
                        leanTimerLast = leanTimerCurrent;
                        leanMax = 0;
                        if(currentForm == 1) genie.WriteStr(1, leanMax);
                      }
                      if (leanCurrent < 0)leanCurrent *= -1;
                      if (leanCurrent > leanMax) {
                        leanMax = leanCurrent;
                        if(currentForm == 1) genie.WriteStr(1, leanMax);
                      }
                      if (Speed > speedMax) {
                        speedMax = Speed;
                        if(currentForm == 1) genie.WriteStr(0, speedMax);
                      }
                    }
                    
                    void gpsUpdate() {
                      unsigned long start = millis();
                      do
                      {
                        while (Serial2.available())gps.encode(Serial2.read());
                      }
                      while (millis() - start < 10); //grab 10ms of gps info
                      Speed = gps.speed.kmph();dir = (int)gps.course.deg();
                      gpsLatitude = gps.location.lat();gpsLongitude = gps.location.lng();
                      gpsLock = gps.satellites.value();alt = (int)gps.altitude.meters();
                      if (gpsLock > 3) {
                        if(currentForm == 1){
                        genie.WriteObject(GENIE_OBJ_USER_LED, 0, true);
                        genie.WriteStr(5, SetCompass()); genie.WriteStr(4, dir);
                        genie.WriteStr(3, alt); genie.WriteStr(2, gpsLock);
                        }
                      }
                      else {
                        if(currentForm == 1) genie.WriteObject(GENIE_OBJ_USER_LED, 0, false);
                      }
                    }
                    
                    void readAcc() {   // RAW: L = 200 C = 385 R = 545
                      int jitter = 0;
                      for (int a = 0; a < 5; a++) {
                        jitter += map(analogRead(AccY), 200, 545, -90, 90);
                        delay(jittercorrect);
                      }
                      Serial.println(leanCurrent);
                      leanCurrent = (int)jitter / 5; //poll a few times and average
                      if (leanCurrent < -90)leanCurrent = -90; if (leanCurrent > 90)leanCurrent = 90;
                    }
                    
                    String compass = "-W-|-N-|-E-|-S-|-W-|-N-";
                    //index          01234567890123456789012
                    //index2                   1         2
                    String SetCompass() {
                      int offset = 0;
                      if (dir > 315 && dir < 45)offset = 2; //N
                      if (dir > 0 && dir < 90) offset = 4; //NE
                      if (dir > 45 && dir < 135) offset = 6; //E
                      if (dir > 90 && dir < 180) offset = 8; //SE
                      if (dir > 135 && dir < 225) offset = 10; //S
                      if (dir > 180 && dir < 270) offset = 12; //SW
                      if (dir > 225 && dir < 315) offset = 14; //W
                      if (dir > 270 && dir < 360) offset = 16; //NW
                      return compass.substring(offset, offset + 7);
                    }
                    I hope this helps

                    Best regards

                    Paul

                    Comment


                    • #11
                      Originally posted by pauleilio View Post

                      I hope this helps

                      Best regards

                      Paul
                      many thanks, it helps immensely! good news is the kml writer is done and google earth is ok with, so that hurdle out of the way , wiring in the 4 temp sensors tonight, 3dprint came good too.
                      Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	1.05 MB
ID:	63438

                      Comment


                      • #12
                        genie.form(1) is not a function in the arduinoGenie, changed the code to read

                        genie.WriteObject(GENIE_OBJ_FORM, 1, 0);

                        instead, also if you have two controls with teh same numbering, even if on different forms (ie: coolguage1 on form0 and a coolguage1 on form1) the 220rd reboots continually.

                        result till now, cannot test speedo fullscreen on form2 as im at a desk, but presumably it will work too, thankyou for your assistance.

                        https://www.youtube.com/watch?v=H5p6iKRy_p8
                        Last edited by CeeBee; 13th May 2018, 11:14 AM. Reason: readability of thread.

                        Comment


                        • #13
                          Hi,

                          That's great.Switches over nicely. Sorry for my mistake, I need to brush up on my genie

                          Paul

                          Comment


                          • #14
                            no worries mate, fyi, i had about a dozen hits so far for a parts list to build this from guys on a bike forum, is it cheaper to buy direct from you than Jaycar? I ask because this screen was $69 from jaycar but everyone else in aus is selling it 100+ dollars?

                            Comment


                            • #15
                              Hi,

                              It might be best to contact our Sales department here https://www.4dsystems.com.au/contact

                              Best regards

                              Paul

                              Comment

                              Working...
                              X