Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[moved] PWM LED drive bad function of brightness with Arduino Nano

Status
Not open for further replies.

roof55

Newbie level 5
Joined
Jan 18, 2016
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
77
Hi folks, new in this forum!

I was design a circuit using as pilot strobe lights for my UVA/drone.

When power on, all LED light up with 100 % brightness level. Ater 3-4 second, the pattern from my Nano started, but only with 20 % brightness. If connected other power supplies, else two 3400 mAh Li-Ion battery in serie connection, just a little change, 30 %.

The LED drivers **broken link removed**.
A buck step up convrerter **broken link removed**.

Any who can see what might DIAGRAM-2.3A-Flash-light-ArduinoLED-DRIVER-14.01.2016-2.pngwrong with my project, pleas leave information.

My code here:
Code:
const int ledPin1 =  11;      // Set pin's in use :
const int ledPin2 =  10;
const int ledPin3 =  9;
const int ledPin4 =  6;

// Variables will change :
int ledState1 = LOW;             //
int ledState2 = LOW;
int ledState3 = LOW;             // ledState used to set the LED LED STATUS :
int ledState4 = LOW;
long previousMillis = 0;        // will store last time LED was updated :
long count = 0;

long interval = 140;           // interval at which to blink (milliseconds) lower faster blinks :

void setup() {
  // set the digital pin as output :

  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
}
void loop()
{

  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa :
      if (ledState1 == LOW ) {
        ledState1 = HIGH;
        ledState2 = LOW;
      }
      else {
        ledState1 = LOW;
        ledState2 = HIGH;
        count++;
        // set the LED with the ledState of the variable :
      }
      analogWrite(ledPin1, ledState1); 
      analogWrite(ledPin2, ledState2);
    }
  } while (count < 3); //sets how many blinke, GREEN LED :
  ledState2 = LOW;
  analogWrite(ledPin2, ledState2);
  count = 0;
  //=========================================================
  delay(1000); // PAUSE and sets the time beteewen set green and read
  //=========================================================
  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState3 == LOW) {
        ledState3 = HIGH;
        ledState4 = LOW;
      }
      else {
        ledState3 = LOW;
        ledState4 = HIGH;
        count++;
        // set the LED with the ledState of the variable:
      }
      analogWrite(ledPin3, ledState3);
      analogWrite(ledPin4, ledState4);
    }
  } while (count < 2);  //sets how many blinke, RED LED :
  ledState4 = LOW;
  analogWrite(ledPin4, ledState4);
  count = 0;
  //=========================================================
  delay(1400);  //sets the time between set green and read
  //=========================================================
}
 

Re: Any helps for PWM LED drive bad function of brightness with Arduino Nano

Assuming that LED driver is working correctly I would do two experiments:
1. Try with only one driver and LED.
2. Try using PWM library for Arduino (not sure if it is availabe for Nano though).
 

Re: Any helps for PWM LED drive bad function of brightness with Arduino Nano

Hi,

Check voltages with a dvm.
Check voltage stability with a scope.
Check pwms with a scope. Frequency, levels, duty cycle.


Klaus
 

Re: Any helps for PWM LED drive bad function of brightness with Arduino Nano

Try inverting the LED outputs in the code, if the code is wrong,, they will come on at 80% brightness, if they stay dim then is a power problem.
Frank
 

Re: Any helps for PWM LED drive bad function of brightness with Arduino Nano

Try inverting the LED outputs in the code, if the code is wrong,, they will come on at 80% brightness, if they stay dim then is a power problem.
Frank

Thank you Frank (and other member with help!). Circuit has been tested with 10A Switch mode PSU. Same result. But, the test was done before Buck converter. I try with a direct power connected to the PWM's. I also change code (if no + result in first try out testing), I will report.
 

Re: Any helps for PWM LED drive bad function of brightness with Arduino Nano

When power on, all LED light up with 100 % brightness level. Ater 3-4 second, the pattern from my Nano started, but only with 20 % brightness. If connected other power supplies, else two 3400 mAh Li-Ion battery in serie connection, just a little change, 30 %.

This suggests that the problem could be related to the firmware, and the standard procedure is mirror the variable that controls the LED at some pin and probe it with an oscilloscope. Anyway, had you added a small ceramic capacitor in parael with the LED ?
 

Re: Any helps for PWM LED drive bad function of brightness with Arduino Nano

Unfurlable, did not have a oscilloscope. My schematic diagram view no ceramic capacitor wired in parallel with diode's. The cap. value? 1nF? 100nF? Thank you.
 

Re: Any helps for PWM LED drive bad function of brightness with Arduino Nano

Too complex:

Code:
 if (ledState3 == LOW) {
        ledState3 = HIGH;
        ledState4 = LOW;
      }
      else {
        ledState3 = LOW;
        ledState4 = HIGH;
...
count++
}
is just equivalent to:

ledState3=-ledState3;
ledState4=-ledState4;

Can you print out the time values from within the loop? That will give you some indication. It looks to be a software glitch...

Also put the count++ AFTER the curly braces...
 
Last edited by a moderator:

Re: Any helps for PWM LED drive bad function of brightness with Arduino Nano

Thanks for beeing first one to commit the code, an improvement. Well, to be completely honest, this code is not produced by me personally. Others argue delays achieved easily using currentMillis, with replacement of code that delay (). And to put frankly quite probing the grain, Arduino code I am absolutely blown to understand structure. Syntax I understand them their code numbers and opinions, but structure, what is needed, what comes first, and after, not my strongest side.

I have now tried the circuit without this buck converter, from 7.6 volts to 13 volts ca. directly connected 13 volt, max current 30 Ampere. This gave no improvements.

I do not understand why I get full illumination for 3-4 seconds, then the pattern begins flashes, with ca. 30% brightness. I check my wire connections again. Could be wrong when I employ @ input Vcc 5-16 volt input, positive voltage to pin 30?

- - - Updated - - -

This suggests that the problem could be related to the firmware, and the standard procedure is mirror the variable that controls the LED at some pin and probe it with an oscilloscope. Anyway, had you added a small ceramic capacitor in parael with the LED ?

Oscilloscope would be great in use, if I own one. So, it could correctly be some pins change, else I have observed this factum in different web page with diagram for nano PIC circuit. I check with this seller of arduino. Wath value of capacitor?
 

Can you just try to move the count++ outside the brace? I mean, instead of count++; } use } count++;

Also check the semicolons carefully. I find that my most common mistakes are with semicolons and braces...
 

Re: Any helps for PWM LED drive bad function of brightness with Arduino Nano

Wath value of capacitor?

It depends on the period of the PWM you selected as well as what has within the blocs of schematics representing the LED driver, therefore, in order to avoid drain excessive peak currents, why not make a blind attempt, experimenting some options close the range of some houndred nF's, increasing the value on a scale 3x each new test, and finally select the one for which you perceive no brightness change ?
 

Did you solve your problem? I am just curious.
 

Did you solve your problem? I am just curious.

Thank you!
Due to minimal of time for use to track this error, not solved jet. I was post and inquiry to the Chinese salles man, view schematic diagram and sketch. Ave to wait one day i think. But, I was removed the power wired from buck step up converter, and plug in directly 13 volts Vcc to the PWM LED driver and Arduino. Just to eliminated this Buck step up converter to give any problems, same result. That's so far.
 

Forget:

"Can you just try to move the count++ outside the brace? I mean, instead of count++; } use } count++;. Well, as mention before Arduino is not my best language. Sketch programmed by another person, but you think I can change the count ++; } Just as } count ++;. I will try this. Keep in touch.

- - - Updated - - -

So, this are after change place for count++. Only green led flashing, until i also moved this count++ after } for red led, this also "died". So, when moving count++, the sketch stopt running for flashing. Just for remaining, sketch doing a well jobs before this PWM LEd driver take place. At this point the argument analogWrite, take place for DigitalWrite. Also, I was using a MOSFET array as on/off connected to four different step down Buck's.
 

Oh my dear :) So after to sent my inquiry to an Arduino codex expert above wrong form into my sketch, or any other syntax error, the following change was needed. My sketch contains analogWrite. When using PWM the correct command code to use are digitalWrite. And suddenly 100 % brightness was obtain!
 

I know C but little about arduino. Thanks for sharing the solution.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top