Go Down

Topic: what is wrong here? schematic attached.  (Read 1 time) previous topic - next topic

Grumpy_Mike

#15
Jun 04, 2019, 03:53 pm Last Edit: Jun 04, 2019, 03:53 pm by Grumpy_Mike
its a usb3.0 port with SS letters on it(superspeed). i have tested over 5 times and with USB it works as it should. the brightness on all 60 leds is 250 plus the animation, and i had no issue with it.
Well for USB 3 the current is increased but in no way matches what you need, so even though you think you have no issue you have. Have you measured voltages or looked at waveforms? Very odd things could be happening that will bite you later, not all electronic abuse shows itself by failing immediate, it could take weeks months or even a year before you get a loss of function.

Quote
In the USB 1.0 and 2.0 specs, a standard downstream port is capable of delivering up to 500mA (0.5A); with USB 3.0, it moves up to 900mA (0.9A).
Quote
"Daylights cable" is the cable that i get the power source to power up the arduino. since its daylights that cable always has voltage, when scooter is running. so i thought a good way to power up the arduino.
So this is a wire on your scooter that has permanent power on it?

Smajdalf

Did you measure the voltage on the daylights cable? With connected Arduino? What is voltage between 5V and GND pins of Arduino?

There is no reason to have "daylights" trigger when Arduino is powered from the daylights. It will be HIGH as long as Arduino is powered.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

mitsakos

#17
Jun 04, 2019, 05:58 pm Last Edit: Jun 04, 2019, 06:05 pm by mitsakos
Well for USB 3 the current is increased but in no way matches what you need, so even though you think you have no issue you have. Have you measured voltages or looked at waveforms? Very odd things could be happening that will bite you later, not all electronic abuse shows itself by failing immediate, it could take weeks months or even a year before you get a loss of function.
So this is a wire on your scooter that has permanent power on it?
as stated i know "nothing" like John Snow :P so i havent measured voltaged or wavesforms. have no knowledge to do so. i only measured the volts of the power cables i am modifying.

Yes!. "daylights" wire has permanent power when the scooter is running. (~12V)

mitsakos

Did you measure the voltage on the daylights cable? With connected Arduino? What is voltage between 5V and GND pins of Arduino?

There is no reason to have "daylights" trigger when Arduino is powered from the daylights. It will be HIGH as long as Arduino is powered.
the voltage on daylights cable is ~12V bit higher when scooter is running. then i use a voltage regulator too drop it 5V so i can supply it to the DC jack. from what i read that is wrong. i will try to power the arduino from the 5V pin.


Grumpy_Mike

Quote
as stated i know "nothing" like John Snow :P so i havent measured voltaged or wavesforms
Yes I know that is why I am telling you that when you say "it works" you are deluding yourself and it actually doesn't. It might appere to function but it is not right and will go wrong eventually.

Smajdalf

Yes I know that is why I am telling you that when you say "it works" you are deluding yourself and it actually doesn't. It might appere to function but it is not right and will go wrong eventually.
It depends on the application. If for example the project is for some running light with at most 5 LEDs turned on at the same time there is no need for power supply to provide more current. If the program crashes and tries to turn on all the LEDs it deserves the brownout reset.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

mitsakos

i will post a video of the setup in the next coming days, i have to get away for business.

including power from usb/battery/dc jack.

meanwhile here is the code i used. its not mine, credits to "Think small, build big!".

Code: [Select]
//Modern turn lights v.1.0.0 with arduino and ws2812b by Fedaceag Ionut
#include <FastLED.h>                        //FastLed library version 3.2.1 - https://github.com/FastLED/FastLED/wiki/Overview or http://fastled.io/ with NEOPIXEL or WS2812B
#define NUM_STRIPS 2                        // number of led strips (in this example are front left and front right)
#define NUM_LEDS_PER_STRIP 30               // number of leds per each strip
CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP];
uint8_t gHue = 0;                           // rotating "base color" used by many of the patterns

const int buttonPinL = 2;                   // turn left
const int buttonPinR = 3;                   // turn right
const int buttonPinEng = 4;                 // engine on to start day lights
const int buttonPinKnightRider = 5;         // knight rider lights

int buttonStateL = 0;
int buttonStateR = 0;
int engineOn = 0;
int KnightRiderState = 0;

int stateL = 0;
int stateR = 0;

uint8_t gBrtL = 0;
uint8_t gBrtR = 0;
int maxBrt = 120;                           // maxim brightness day lights - from 0 to 255

int delayTurnLedAnim = 5.7; //delay of each led in turn light animation
int delayTurnLedOff = 250; //delay from animation to black (is used twice)
int delayLedToDayLight = 100; // delay from animation to day light on
int nrAnimAfterOff = 3; // number of animations for a single impulse

void setup() {
  //Serial.begin(9600);
  pinMode(buttonPinL, INPUT);
  pinMode(buttonPinR, INPUT);
  pinMode(buttonPinEng, INPUT);
  pinMode(buttonPinKnightRider, INPUT);
 
  FastLED.addLeds<NEOPIXEL, 6>(leds[0], NUM_LEDS_PER_STRIP); //led strip for front left
  FastLED.addLeds<NEOPIXEL, 7>(leds[1], NUM_LEDS_PER_STRIP); //led strip for front right
 
  attachInterrupt(digitalPinToInterrupt(buttonPinL),btnPressL,RISING); // we use interrupt for instant reaction of turn lights
  attachInterrupt(digitalPinToInterrupt(buttonPinR),btnPressR,RISING); // we use interrupt for instant reaction of turn lights

  fill_solid(leds[0], NUM_LEDS_PER_STRIP, CRGB::Red); // some led strips are all on at power on, so let's power them off at boot
  fill_solid(leds[1], NUM_LEDS_PER_STRIP, CRGB::Red); // some led strips are all on at power on, so let's power them off at boot
  FastLED.show();
}

void loop() {
  // read the input state
    buttonStateL = digitalRead(buttonPinL);
    buttonStateR = digitalRead(buttonPinR);
    KnightRiderState = digitalRead(buttonPinKnightRider);
    EVERY_N_MILLISECONDS( 1 ){
      engineOn = digitalRead(buttonPinEng);
    }

  //function for hazard lights
  if(stateL != 0 && stateR != 0){
   
    for(int dot = 0; dot < NUM_LEDS_PER_STRIP; dot++) {
        leds[0][dot] = CRGB(255, 66, 0); // color for left turn light
        leds[1][dot] = CRGB(255, 66, 0); // color for right turn light
        FastLED.show();
        delay(delayTurnLedAnim);
    }
   
    delay(delayTurnLedOff);
    fill_solid(leds[0], NUM_LEDS_PER_STRIP, CRGB::Black);
    fill_solid(leds[1], NUM_LEDS_PER_STRIP, CRGB::Black);
    FastLED.show();
    delay(delayTurnLedOff);

    if(buttonStateL != HIGH || buttonStateR != HIGH){
     
      if(buttonStateL == HIGH){
        stateL = 1;
      }else{
        stateL = 0;
        gBrtL = 0;
      }
     
      if(buttonStateR == HIGH){
        stateR = 1;
      }else{
        stateR = 0;
        gBrtR = 0;
      }
     
      if(buttonStateL != HIGH && buttonStateR != HIGH){
        delay(delayLedToDayLight);       
      }
     
    }

  //function for left turn lights
  }else if(stateL != 0){
   
    if(KnightRiderState == HIGH && engineOn == LOW){
      fill_solid(leds[1], NUM_LEDS_PER_STRIP, CRGB::Black);
    }
   
    for(int dot = 0; dot < NUM_LEDS_PER_STRIP; dot++) {
        leds[0][dot] = CRGB(255, 66, 0); // color for left turn light
        FastLED.show();
        delay(delayTurnLedAnim);
    }
   
    delay(delayTurnLedOff);
    fill_solid(leds[0], NUM_LEDS_PER_STRIP, CRGB::Black);
    FastLED.show();
    delay(delayTurnLedOff);

    stateL++;
    if(stateL >= nrAnimAfterOff && buttonStateL != HIGH){
      stateL = 0;
      gBrtL = 0;
      delay(delayLedToDayLight);
    }

  //function for right turn lights
  }else if(stateR != 0){
   
    if(KnightRiderState == HIGH && engineOn == LOW){
      fill_solid(leds[0], NUM_LEDS_PER_STRIP, CRGB::Black);
    }
     
    for(int dot = 0; dot < NUM_LEDS_PER_STRIP; dot++) {
        leds[1][dot] = CRGB(255, 66, 0); // color for right turn light
        FastLED.show();
        delay(delayTurnLedAnim);
    }
   
    delay(delayTurnLedOff);
    fill_solid(leds[1], NUM_LEDS_PER_STRIP, CRGB::Black);
    FastLED.show();
    delay(delayTurnLedOff);

    stateR++;
    if(stateR >= nrAnimAfterOff && buttonStateR != HIGH){
      stateR = 0;
      gBrtR = 0;
      delay(delayLedToDayLight);
    }
   
  }else{
   
    if(stateL == 0 && engineOn == HIGH){
      if(gBrtL <= maxBrt){
        EVERY_N_MILLISECONDS( 1 ) { gBrtL++; }
        fill_solid( leds[0], NUM_LEDS_PER_STRIP, CHSV(255,255,gBrtL));
        FastLED.show();
      }
    }else{
      if(gBrtL > 0){
        EVERY_N_MILLISECONDS( 1 ) { gBrtL--; }
        fill_solid( leds[0], NUM_LEDS_PER_STRIP, CHSV(255,255,gBrtL));
        FastLED.show();
      }else{
        if(KnightRiderState == HIGH){         
          gHue = 0;
          //EVERY_N_MILLISECONDS( 20 ) { gHue++; }
          fadeToBlackBy( leds[0], NUM_LEDS_PER_STRIP, 20);
          int pos = beatsin16( 30, 0, NUM_LEDS_PER_STRIP-1 );
          leds[0][pos] += CHSV( gHue, 255, 192);
          FastLED.show();
        }
      }
    }

    if(stateR == 0 && engineOn == HIGH){
      if(gBrtR <= maxBrt){     
        EVERY_N_MILLISECONDS( 1 ) { gBrtR++; }
        fill_solid( leds[1], NUM_LEDS_PER_STRIP, CHSV(255,255,gBrtR));
        FastLED.show(); 
      }     
    }else{
      if(gBrtR > 0){       
        EVERY_N_MILLISECONDS( 1 ) { gBrtR--; }
        fill_solid( leds[1], NUM_LEDS_PER_STRIP, CHSV(255,255,gBrtR));
        FastLED.show();
      }else{
        if(KnightRiderState == HIGH){         
          gHue = 0;
          //EVERY_N_MILLISECONDS( 20 ) { gHue++; }
          fadeToBlackBy( leds[1], NUM_LEDS_PER_STRIP, 20);
          int pos = beatsin16( 30, 0, NUM_LEDS_PER_STRIP-1 );
          leds[1][pos] += CHSV( gHue, 255, 192);
          FastLED.show();
        }
      }
    }
  }
}

void btnPressL(){
  stateL = 1;
  for(int nr = 0; nr < 500; nr++) {
    buttonStateR = digitalRead(buttonPinR);
    if(buttonStateR == 1){
        stateR = 1;     
      }
  }
}

void btnPressR(){
   stateR = 1;
   for(int nr = 0; nr < 500; nr++) {
     buttonStateL = digitalRead(buttonPinL);
     if(buttonStateL == 1){
        stateL = 1;
      }
   }
}

Grumpy_Mike

#22
Jun 04, 2019, 11:37 pm Last Edit: Jun 04, 2019, 11:38 pm by Grumpy_Mike
It depends on the application. If for example the project is for some running light with at most 5 LEDs turned on at the same time there is no need for power supply to provide more current.
I agree with you.

I so much agree with you, that I agreed with you on this point in reply #10, that is how much I agree with you.

So I am very happy to agree with you in reply #22 as well.

Paul__B

its a usb3.0 port with SS letters on it(superspeed). i have tested over 5 times and with USB it works as it should. the brightness on all 60 leds is 250 plus the animation, and i had no issue with it.
If you want to know what your are doing using USB ports for power, you need one of these:


cbaker391

I think you might simply be under applying power (5v) through the DC input jack, which should be at least 6v.  I'd simply swap out your voltage regulator (LM7805?) with an LM7809 to give the arduino 9v to work with. 

Power is going through two phases of regulators (your external one and then onboard the arduino) and there is voltage loss when it goes through the aduino's onboard regulator, hence it needs at the very least, 6v.  I think the USB skips over the 5v onboard regulator since PC's regulate the heck out of 5v for everything.


And add a couple caps to the external regulator .33uf (input) .1uf (output) I think they recommend, to make the power cleaner.

Grumpy_Mike

Quote
I think they recommend, to make the power cleaner.
No, these capacitors are needed to stop the regulator from oscillating.

Quote
.33uf (input) .1uf (output)
The exact values to use are given in the manufacturer's data sheet. This changes from manufacturer to manufacturer even though you have the same part number. Generally speaking too much capacitance is better than too little.

mitsakos

Mike, i did some math and more digging around to understand some stuff, prior continue install the project.

So. WS2812B is 20mA per RGB color of led. that means that if i use Red (255) for daylight color on the led strip at 120 Brightness i am consuming 10mA per led x 60 leds, thats 0.6A in total. the LM7805 covers 1.5A current.

if i have hazard lights on full brightness i use 255 , 66, 0 color pallete that means that i will be consuming 20mA of Red led color, and 5mA of the green one. all of them on at once are 1.5A. still fine.

i am thinking to use an optocoupler instead the regulator cause opto's cant oscilate from what i read.

what i dont know yet is how much current do the daylight cable have which i am going to power the arduino uno and the led strips.

and a question. the most current draw is when hazard lights are on and thats 1.5A. i read that arduino does 200mA max. does this have to do anything with the current of the led strips? i am powering the arduino and the leds from the 5V pin.


Grumpy_Mike

Quote
that means that if i use Red (255) for daylight color on the led strip at 120 Brightness i am consuming 10mA per led x 60 leds, thats 0.6A in total.
So are you saying that you are only lighting 60 LEDs red colour at half brightness? If so then that is correct.

Quote
the LM7805 covers 1.5A current
Yes but if you are regulating down from 12V to 5V that regulator is burning (12-5) * 0.6 = 4.2 Watts of power.

Quote
if i have hazard lights on full brightness i use 255 , 66, 0 color pallete that means that i will be consuming 20mA of Red led color, and 5mA of the green one. all of them on at once are 1.5A. still fine.
No not still fine, running a regulator at the limit is not fine, you should never run a component at more that 80% of the maximum rated value. Also that means you are burning 10.5 Watts of power. Look up the power dissipation of that package in the data sheet. It is not a simple matter of the current you have to factor the power dissipation of the regulator. A data sheet I have for a T0-220 package shows a thermal resistance of junction to ambient of 19°C/W. That means the junction temperature will be 199.5 °C hotter than the ambient. So a 25 °C ambient will have the junction temperature running at 224.5 °C. You will see from the data sheet the absolute maximum junction temperature is only 150°C. And a note says:-
Quote
Operating at the absolute maximum TJ of 150°C can affect reliability.
And the recommended maximum is 125°C.
Note that is with an infinite heat sink.

See http://www.thebox.myzen.co.uk/Tutorial/Power.html for a further explanation. And http://www.thebox.myzen.co.uk/Tutorial/Power_Examples.html for some worked examples.

Quote
i am thinking to use an optocoupler instead the regulator cause opto's cant oscilate from what i read.
Yes that is a good idea.

Quote
i read that arduino does 200mA max. does this have to do anything with the current of the led strips?
No, that refers to current from the power pins, that is the total current the combined processor pins can source or sink. There are other limits that come into play before this one. However you are not powering the LEDs from the processor pins but the 5V regulator that also happens to be connected to the regulator.

Quote
what i dont know yet is how much current do the daylight cable have
This is probably fused somewhere, so trace your wires, or check the scooter's schematic.


Go Up