Hello everyone,
thank you in advance for taking the time to read and answer my question. Mainly I am a forum lurker, not a contributor. I have experience in electrics, less so in programming. But I can`t seem to find the correct solution to my problem, so I have decided to ask it here.
The project:
I have 14 meters of 24V led strip dimmable through arduino. The led strips are being fed halfway at both sides ( so at 7 meters) which is enough.
Led strip specs: 18W/m, 24V, CV.
Schematic:
note: the mosfet is capable of handling 5V TTL logic to switch. The led strips are CV, and have resistors built in. So the load on the mosfet isnt drawed correctly, it includes resistors.
The code:
/*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on the value obtained
by analogRead().
The circuit:
- potentiometer
center pin of the potentiometer to the analog input 0
one side pin (either one) to ground
the other side pin to +5V
- LED
anode (long leg) attached to digital output 13
cathode (short leg) attached to ground
- Note: because most Arduinos have a built-in LED attached to pin 13 on the
board, the LED is optional.
created by David Cuartielles
modified 30 Aug 2011
By Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/AnalogInput
*/
#include <ResponsiveAnalogRead.h>
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 3; // select the pin for the LED
int datapin = 6;
int sensorValue = 0; // variable to store the value coming from the sensor
int PWMled = 0;
ResponsiveAnalogRead analog(sensorPin, true);
void setup() {
TCCR2B = TCCR2B & B11111000 | B00000110;
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
pinMode(datapin, OUTPUT);
bitSet(TCCR1B, WGM12);
}
void loop() {
analog.update();
// turn the ledPin on
PWMled = map(analog.getValue(), 0 , 1023, 0, 200);
analogWrite(ledPin, PWMled);
datapin = 0;
}
note: simple circuit, reading an analogvalue and stabilising it with a library that uses an algorythm, then mapping it to the PWM output. No problem here.
- I am using a PC power supply with stable 5V for the arduino, but also for pixelleds also present (whom need alot of current, hence the PC power supply). The power supply is stable.
- I am using a separate 24V phoenix contact power supply capable of giving up to 10A. In the code the max PWM is 200 (instead of 255) and even this is too bright even for the room ( slight overkill ). This draws about 6A.
My problem:
First of all, this circuit works. It does what it should, it sends PWM to the led strip, I can dim it.
My problem is, that it flickers alot. Due to my overkill, I am dimming it alot, with very low duty cycles.
These are scope measurements on the gate and the output. Gate switches on 5V (channel B), output is 24V (channel A). The top measurement shows the led strips on minimum PWM, where they flicker alot.
Flickering is visible as 50-60Hz somewhere, although not sure of that. It becomes alot less visible with higher PWM, but is still present.
I realise there is a minimum duty cycle for the leds. This can be configured in the project when necessary, I am not talking about this ( the min PWM moment is shortly visible in the video).
What have I tried:
- playing with the frequency of the PWM. I tried upping it, but it only increased the flickering. Upon lowering, strangely enough it diminishes..
- online I see all buck circuitry have coils and extra diodes. yet these are usually only designed for up to 1 Amps. putting a series coil through a circuit that draws 8 amps... well, havent got such a coil laying around. And a simple circuit suddenly becomes complex. Then I would need a premade board etc, and those are hard to find. The LM3421 is capable of doing this, but I would need to design and calculate everything myself as no pre made stuff exists for this kind of currents..
What I havent tried:
- adding capacitors. This would require adding a diode over the mosfet to protect it, and probably make the leds brighter. Might this work to smoothen the flickering?
- interference problem?
I think this is a current problem. My voltage is a good PWM, but the current isnt constant and enough for the led strips.
Does anyone have any suggestions? I am thinking of remaking it with a constant voltage, but this has its inherent drawbacks as well...
Thank you very much in advance!
krullebolle
AnalogInput.ino (1.49 KB)