[BUG] Some weird problems, Arduino (SainSmart) crashes (3 Viewers)

Dragy

Portal Pro
April 27, 2009
778
333
31
Home Country
Netherlands Netherlands
That is a good idea. Unfortunately this is not something I can test right now because I don't have a spare led.

But I am sure the Arduino IS crashing sometimes, because it executes the setup() again at this point.
 

Lightning303

MP Donator
  • Premium Supporter
  • September 12, 2009
    798
    577
    Home Country
    Germany Germany
    But I am sure the Arduino IS crashing sometimes, because it executes the setup() again at this point.

    I see. What about power consumption? Is your powersupply big enough? With 64 leds you would need a power supply that provides 3,84A. The arduino could cut out if there is no current to drive it left.

    Or maybe the voltage is dropping to much sometimes (fast and bright changes) so the arduino cuts out and after a while reboots again. Do you have a capacitor between power and ground? This cap can make sure something like this does not happen. If this is the cause of the problem that is.

    https://learn.sparkfun.com/tutorials/ws2812-breakout-hookup-guide
     

    Dragy

    Portal Pro
    April 27, 2009
    778
    333
    31
    Home Country
    Netherlands Netherlands
    Yes, the power supply is sufficient, 4A, but may handle even more because I think it is of good quality.

    I now have a resistant on the data line, but it doesn't work. Also, I'm using another Arduino board now, the Arduino Nano w/ ATmega328. Still the same problem with this board, so I'm sure there's something wrong in the leds, software, drivers or power supply. I will test further, but if anyone here has a good idea, please tell because I like to know! :D
     
    Last edited:

    Dragy

    Portal Pro
    April 27, 2009
    778
    333
    31
    Home Country
    Netherlands Netherlands
    Yes, I was pretty sure (before) that wasn't going to solve the problem, because it doesn't crash with sudden changes in brightness when using Live view or something. Instead it crashes with small changes in using the sliders, not giving sudden power drops or requests.

    I think the problem lies in the software, drivers or leds instead. I will test the separate led thing soon!
     

    HomeY

    Test Group
  • Team MediaPortal
  • February 23, 2008
    6,475
    4,645
    49
    ::1
    Home Country
    Netherlands Netherlands

    Dragy

    Portal Pro
    April 27, 2009
    778
    333
    31
    Home Country
    Netherlands Netherlands
    Okay, the capacitor did not solve the problem, it's still the same. I even encountered flickering of the leds at the beginning, but not anymore.

    I am now using my Arduino Uno to debug. I have 1 WS2812B led on pin 13 and one "debug" led on pin 10. I am not using an external power supply in this setup, so I can rule out a lot of factors. The result is that the problem also occur with this setup. The leds get stuck when playing with the static color. What I can see is that the Arduino still gets serial code (RX led flashes) when playing with it, but the RGB led does not change. I am also testing this code:
    Code:
    #include <FastLED.h>
    
    // Set the number of leds in the strip.
    #define NUM_LEDS  64
    #define DATA_PIN  13
    #define BRIGHTNESS  255
    #define LED_TYPE  WS2812B
    #define COLOR_ORDER GRB
    CRGB leds[NUM_LEDS];
    
    void setup(){
      Serial.begin(115200);
      pinMode(10, OUTPUT);
      pinMode(11, OUTPUT);
      //sanity check delay - allows reprogramming if accidently blowing power w/leds
      delay(2000);
      FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
      FastLED.setBrightness(BRIGHTNESS);
    
      setupLEDs();
      loopLeds();
      clearLeds();
      //blinkLeds();
    }
    
    int readByte(){
      while (Serial.available() == 0){ /* wait for data */ }
      return Serial.read();
    }
    
    void loopLeds(){
    for(int j = 0; j < 3; j++) {
      for(int i = 0 ; i < NUM_LEDS; i++ ) {
      memset(leds, 0, NUM_LEDS * 3);
      switch(j) {
      case 0: leds[i].r = 255; break;
      case 1: leds[i].g = 255; break;
      case 2: leds[i].b = 255; break;
      }
      FastLED.show();
      delay(5);
      }
      }
    }
    
    
    void clearLeds(){
      for(int dot = 0; dot < NUM_LEDS; dot++){
      leds[dot] = CRGB::Black;
      };
      FastLED.show();
    }
    
    // shows colored LEDs for 500ms then blanks out ready to go
    void setupLEDs()
    {
      memset(leds,150, sizeof(leds));
      FastLED.show();
      FastLED.delay(500);
      memset(leds,0, sizeof(leds));
      FastLED.show();
    }
    
    void loop() {
    
      if(readByte() == 0xFF){
      if(readByte() == 0x00){
      if(readByte() == 0x00){
      int channels = readByte();
      for(int dot = 0; dot < channels; dot++){
      leds[dot].r = readByte();
      leds[dot].g = readByte();
      leds[dot].b = readByte();
      }
      FastLED.show();
    
      digitalWrite(10, HIGH);
      delay(300);
      digitalWrite(10, LOW);
    
    
      }
      }
      }
    }

    This works fine, the RGB led (WS2812B) gets data once in a while and after that it has to wait 300ms to be able to receive a new signal. The failure is less likely to occur, but still happens after a while. The Arduino still gets serial data, but as it seems, never the "right" data. The RGB led and the normal LED never change/flash anymore.


    EDIT:
    What?! I just placed the led code in front of the FastLED code and the problem does not happen anymore!
    Like this:
    Code:
    void loop() {
       if(readByte() == 0xFF){
      if(readByte() == 0x00){
      if(readByte() == 0x00){
      
      digitalWrite(10, HIGH);
      delay(150);
      digitalWrite(10, LOW);
    
      int channels = readByte();
      for(int dot = 0; dot < channels; dot++){
      leds[dot].r = readByte();
      leds[dot].g = readByte();
      leds[dot].b = readByte();
      }
      FastLED.show();
        }
      }
      }
    }

    Maybe it's because of the delay?

    Edit:
    I tested it, the lowest I could get is 6ms delay. I can put it anywhere before the FastLED.show(), but the output is not okay. The leds don't lock up, but it's not the right solution because the output to the leds is not okay. I get different colors or flashes when playing with the static color sliders. Color changer mode is okay.

    I have no idea what's going on.
     
    Last edited:

    Dragy

    Portal Pro
    April 27, 2009
    778
    333
    31
    Home Country
    Netherlands Netherlands
    Yeah I know, but adding the delay does prevent the leds from locking up as it seems.. But will try that method too of course.
     

    Dragy

    Portal Pro
    April 27, 2009
    778
    333
    31
    Home Country
    Netherlands Netherlands
    Well, I just ended up using Adafruit's NeoPixel library. It works fine! Feel free to use my AtmoDuino code! I think it's just some bug in FastLED or something.

    Code:
    #include <Adafruit_NeoPixel.h>
    
    #define NUM_LEDS  64
    #define DATA_PIN  3
    #define COLOR_ORDER NEO_GRB
    #define STRIP_RATE  NEO_KHZ800
    
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, DATA_PIN, COLOR_ORDER + STRIP_RATE);
    
    void setup(){
      Serial.begin(115200);
    
      strip.begin();
      strip.show(); // Initialize all pixels to 'off'
      loopLeds;
      strip.clear();
      strip.show();
    }
    
    int readByte(){
      while (Serial.available() == 0){ /* wait for data */ }
      return Serial.read();
    }
    
    void loopLeds(){
    for(int j = 0; j < 3; j++) {
      for(int i = 0 ; i < NUM_LEDS; i++ ) {
      switch(j) {
      case 0: strip.setPixelColor(i, strip.Color(255, 0, 0)); break;
      case 1: strip.setPixelColor(i, strip.Color(0, 255, 0)); break;
      case 2: strip.setPixelColor(i, strip.Color(0, 0, 255)); break;
      }
      strip.show();
      delay(5);
      }
      }
    }
    
    
    void loop() {
      if(readByte() == 0xFF){
      if(readByte() == 0x00){
      if(readByte() == 0x00){
     
      int channels = readByte();
     
      for(int dot = 0; dot < channels; dot++){
      int r = readByte();
      int g = readByte();
      int b = readByte();
     
      strip.setPixelColor(dot, strip.Color(r, g, b));
      }
     
      strip.show();
      }
      }
      }
    }
     

    Users who are viewing this thread

    Top Bottom