Announcement

Collapse
No announcement yet.

Newbee problem. Arduino does not update leddigits

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

  • Newbee problem. Arduino does not update leddigits

    Hi.. I have a simple arduino program that reads temperature from a DHT sensor and sends it out to a uLCD-28PTU. My problem is that the leddigits shows only 00.
    I know the Arduino sends the temperature because if i load the AppNote "4D-AN-00018" program to the uLCD and change to genie.WriteObject(GENIE_OBJ_FORM, 0x03,0); it will show correct temperature on form 3 of the demo program. I can't see how it is possible to do something wrong when using genie wysiwyg interface. Excepts maybe baud rate which is set to 9600

    . Click image for larger version

Name:	Skjermbilde 2015-12-03 kl. 23.56.09.png
Views:	68
Size:	119.6 KB
ID:	49830

    .......................
    .......................
    if (screen == 1) {
    navigate to Form0
    genie.WriteObject(GENIE_OBJ_FORM, 0x00,0);
    }
    // Reading temperature or humidity takes about 250 milliseconds!
    // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
    float hum = dht.readHumidity();
    // Read temperature as Celsius (the default)
    float temp = dht.readTemperature();

    // Check if any reads failed and exit early (to try again).
    if (isnan(hum) || isnan(temp) ) {
    return;
    }
    //write temp to a LED digits 0
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, temp);

    //write hum to a LED digits 1
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x01, hum);

    ........................
    ........................

  • #2
    Hello,

    Can you please post your full Arduino code, and full WS4 program.
    Bit hard to see what could be going on from a snippet and a screenshot.

    Thanks
    James

    Comment


    • #3
      Sorry for not giving you all the needed information.. Here´s my latest attempt of the arduino code and ws4 program. I´m using a Mega2560 and the shield but TX2/RX2. Arduino does´t like the LCD connected to TX0/RX0 when I program it.
      Attached Files

      Comment


      • #4
        Hello,

        Your program works fine for me...

        I don't have a DHT sensor so I just forced 2 values and both displayed immediately.

        Code:
        float hum = 45.7; //dht.readHumidity();
          // Read temperature as Celsius (the default)
          float temp = 67.6; //dht.readTemperature();
        How have you wired your display up to your Arduino?
        You have put jumper wires from RX2 and TX2 to the centre pins of the J3 and J4 headers on the 4D Arduino Adaptor I assume?
        Are you sure you are programming each device successfully?

        Arduino does´t like the LCD connected to TX0/RX0 when I program it.
        Well that is because the Mega USB port talks to the Atmel processor using TX0/RX0, and then if you have the display connected to that also then you have Atmel processor and Display both listening in to the programming commands coming from your Arduino IDE via USB. The Arduino Atmel is trying to be programmed, and the Display is going to be saying "What? What? I dont understand" and killing your attempts to program the Arduino. You can only have 1:1 on a Serial port. So if you want to use TX0/RX0 for your display, then you need to disconnect it each time you program the Arduino.

        You must be doing something fundamentally wrong for your program not to work, so please check you are actually writing each program to each device successfully to start with, and then check you have it wired up to Serial2 on the Mega successfully. Both Arduino and WS4 code you sent me have the baud of 9600 so there is no problem there.
        As I say, it works fine here, so there is something wrong with how you have it set up on your end

        I guess one thing to do is do what I did, and force 2 values in, rather than reading from your sensor, to try and isolate that from the picture. If that works then you know its nothing to do with the display, and it related to the library of the sensor or something like that. I know those sensors are slow, I have used one my self a few years ago. I just wonder if the library is blocking and causing problems. Isolate it and find out I guess.

        I hope this helps somewhat

        Regards
        James

        Comment


        • #5
          Hi James. Thank you for all you effort to help me You telling med that it should work was what i needed to go ahed and experiment a bit more. I tried to follow you example replacing temp with a fixed value. No change. Pretty sure the TX/RX cabling was ok, since it worked with the AppNote program loaded in the uLCD but tried to change it to TX0/RX0. Still no change. Then I added a few more forms, so that I could try to write to LED_DIGITS on form 3 like in the AppNote. For some reason I was now able to update LED_DIGITS on both form 0 and form 3 Must have been something wrong with the program uploaded to the uLCD?

          Comment


          • #6
            Hello

            Either that or wrong program loaded, or something similar with the Arduino.

            So you are all OK now?

            Regards
            James

            Comment


            • #7
              Hi James
              I wish I could say yes. I´ve managed to make some forms and a change between them with a button. But everything is very slow. Arduino uses between 1 and 2 seconds on one loop trough this very striped down program.

              #include <genieArduino.h>
              Genie genie;
              #define RESETLINE 4 // Change this if you are not using an Arduino Adaptor Shield Version 2 (see code below)


              unsigned long count = 0;
              void setup()
              {
              Serial.begin(200000); // Serial0 @ 200000 (200K) Baud
              genie.Begin(Serial); // Use Serial2 for talking to the Genie Library, and to the 4D Systems display

              // attachInterrupt(digitalPinToInterrupt(2), RPM_get, FALLING);

              //genie.AttachEventHandler(myGenieEventHandler); // Attach the user function Event Handler for processing events
              //Reset the Display (change D4 to D2 if you have original 4D Arduino Adaptor)
              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

              }

              void loop()
              {
              count = count+1;

              //write temp to a LED digits 0
              genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, 23);
              genie.WriteStr(0, count);

              //write hum to a LED digits 1
              genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x01, 20);
              }
              Attached Files

              Comment


              • #8
                Works fine here...

                What Arduino do you have?
                What microSD card are you using in your display? Maybe you have a slow one and you need to increase your delay from 3500 to say 5500.

                Here is a clip of it running here.



                Regards
                James

                Comment


                • #9
                  Hi James
                  I´m using the SD card that came with the uLCD starter kit. Seems like performance issue has something to do with the serial port used. I have a arduino mega clone. Probably from china.
                  Speed is ok when using Serial1. So at the moment I have no issues. I can see that the loop time is slightly higher when the DHT updates data but I guess that is expected. Thank you James

                  Comment


                  • #10
                    Hi again

                    Hmm, Mega clone shouldnt matter as the processor would still be the same one would think, unless that is a clone too, but I wouldn't think so.

                    If it works well on Serial1 but not on Serial0, then that suggests you have other things going on with Serial0.

                    Does it only do this when you use the DHT or include the DHT library, or does it do it when its totally bare bones as you pasted above?
                    You cannot, and other libraries cannot, write to the same serial port as the display is connected to, or it will make it all go horribly wrong.
                    So if you have any Serial.print statements, or if you have a library doing debugging Serial Print statements (as Serial.print is typically used to debug to the Arduino IDE's Terminal window), then that will screw this all up. By changing the display to use Serial1 and that all works, indicates something is writing to the serial port.

                    Serial1 is probably better to use anyway, as that then frees up Serial0 to be used to debug on, and also means you dont have to unplug the display each time you program your Arduino.

                    Maybe worth having a peek at your DHT library, if you are including that when the problems happen, and see if it is doing any Serial.print or Serial.write statements.

                    Regards
                    James

                    Comment

                    Working...
                    X