Stability Arduino?

Discussion in 'UDOO NEO' started by Maurice, Apr 2, 2016.

  1. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I'm running into an issue that after a short while the Arduino seems to hang, and doesn't write any values to the serial port anymore. My linux part keeps on reading, but reports there is nothing to read.

    In the Arduino program I do check whether there is enough writeable buffer on the Arduino serial port, but it seems that the entire program hangs.

    This leads me to the question if there are stability issues in the Arduino part. The program itself is fairly simple, it reads a switch, and if the state changed it will update the leds and write that change to the serial.

    As I don't see a led change anymore it must be hanging somewhere. After a reboot it works for a couple of minutes.

    The worrying thing is that when I used the web based IDE I thought I ran into similar issues, I could use the Arduino for a short while and then it needed a reboot as it did not seem to respond anymore.
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,223
    Likes Received:
    561
    Serial output is very critical. I had it failing when I made a small typing error which passed the compiler. I just made a sample program a couple of days ago because of all the serial issues and I did not get it to fail. What also could help is a small delay(10) after a read end before the serial.write
     
  3. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    After some -semantically the same- changes it has been running all night. I wish I could somehow know what was wrong earlier so I can prevent it in next projects.
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,223
    Likes Received:
    561
  5. icce

    icce New Member

    Joined:
    Mar 13, 2016
    Messages:
    16
    Likes Received:
    3
    Actually, I think that Arduino porting here is not stable enough, sometimes I have to upload 2-3 times to make the program run while the sample programs work well. So be prepared for waiting the porting libraries (in months) or you have to code buy yourself.
     
  6. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,223
    Likes Received:
    561
  7. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I'm experiencing lots and lots of unstabilities. Simple programs like turning a led on and off stop to work after a couple of uploads, the Arduino doesn't respond, even the built in led doesn't work.

    When I declare pins for output, do a digitalWrite it may or may not work. If I switch the pin to a different port, they often work. If after a while I go back to the old pin, that pin just works fine again.

    It is getting rather frustrating, and for now I'm binning my second purchase until I find out better what is going on.
     
  8. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,223
    Likes Received:
    561
    I never have these kind of issues. I don't use PWM though. I also only use the Arduino IDE on the Neo Linux side.
     
  9. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I vented my frustration after this program didn't get uploaded to the Arduino, which I wrote when my previous program seemed not to work at all.

    #define PIN 10
    #define LED_BUILTIN 13
    #define INTERVAL 5000
    void setup() {
    pinMode(PIN, OUTPUT);
    pinMode(LED_BUILTIN, OUTPUT);
    }

    #define BLINK 32
    void loop() {
    digitalWrite(PIN, HIGH);
    digitalWrite(LED_BUILTIN, HIGH);
    delay(BLINK);
    digitalWrite(PIN, LOW);
    digitalWrite(LED_BUILTIN, LOW);
    delay(INTERVAL - BLINK);
    }

    I did some changes with INTERVAL and BLINK, and then no results with uploading whatsoever. The last few experiments did work though...
     
  10. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,223
    Likes Received:
    561
    #define is not a preferred method for defining constants, see also https://www.arduino.cc/en/Reference/Define
    See also the next quote from this page:
    This can have some unwanted side effects though, if for example, a constant name that had been #defined is included in some other constant or variable name. In that case the text would be replaced by the #defined number (or text).
     
  11. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    Yes better use

    static const unsigned int ...

    This is why I do not like arduino. It is c++ they are using, but they always try to hide it.

    Gesendet von meinem FP2 mit Tapatalk
     
  12. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I fail to understand why if I define
    const int LED_OUTSIDE = 10;

    it actually responds to pin 11, while in my previous test I defined 10 and the same led, same board responded to pin 10......
     
  13. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    So one reason maybe somewhere in the arduino code one defined LED_OUTSIDE as global variable this can lead to such a fun. This is why I suggested static. Which creates a namespace. So this is crude C world.

    Gesendet von meinem FP2 mit Tapatalk
     
  14. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,223
    Likes Received:
    561
    And there is a big in RC1 ( and perhaps earlier) were pin 10 and 11 are changed. So writing to pin 11 was setting hardware pin 10. To make it all easier :) In the just released Udoobuntu RC2 this should be fixed (not tested by me yet).
     
    graugans likes this.
  15. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    Last edited: Apr 5, 2016
  16. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,223
    Likes Received:
    561
    The Arduino IDE code with Neo settings is preinstalled in the image. So I hope it's fixed.
     
    graugans likes this.
  17. graugans

    graugans Administrator Staff Member

    Joined:
    Sep 17, 2015
    Messages:
    328
    Likes Received:
    141
    You are so right :). Due to the fact I rarely use UDOObuntu I forgot about this :)

    Gesendet von meinem FP2 mit Tapatalk
     
  18. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    @waltervl Let me know if you find it fixed... I downloaded the RC2 yesterday and when nothing seemed to boot I discarded it, not wanting to go deeper into the rabbit hole.
     
  19. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,223
    Likes Received:
    561
    I just installed RC2 (download from Sourceforge), it booted nicely and the pin 10/11 swap issue is solved!
     
    Maurice and graugans like this.
  20. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    I haven't been able to run Arduino->Serial->Linux stable for more than 24 hours... The code is actually quite simple, and I do check if there is room available on the serial stream, so if there would be an error on the Linux side, it should never block, should it?
     

Share This Page