Hello all,
I am quite new to programming and electronics. At the moment I am trying to design a light alarm clock that lights up multiple LED strips on top of my wardrobe over the course of an hour throught the different ranges of color of the sunrise. The main code is already written and works with single LEDs as placeholders connected to the PMW dimmable output pins of my Arduino Uno.
To get better resolution in the beginning of the fade (so I don't have an abrupt start of the LED in the morning potentially waking me up) I opted to use the adafruit tlc59711 for its 16bit resolution. I combined it with a formula to make the fade up linear to the perception of the human eye - hence the bits of code that calculate the R Value and the log function in the main loop. I used this test sketch to test the dimming behaviour an it looks like this:
#include "Adafruit_TLC59711.h"
#include <SPI.h>
// How many boards do you have chained?
#define NUM_TLC59711 1
#define data 12
#define clock 13
Adafruit_TLC59711 tlc = Adafruit_TLC59711(NUM_TLC59711, clock, data);
//Adafruit_TLC59711 tlc = Adafruit_TLC59711(NUM_TLC59711);
const int pwmIntervals = 4000;
float R;
void setup() {
// Serial.begin(9600);
// Serial.println("TLC59711 test");
R = (pwmIntervals * log10(2))/(log10(65535));
// Uncomment this line if using UNO/AVR since 10 has to be an output
// for hardware SPI to work
//pinMode(10, OUTPUT);
tlc.begin();
tlc.write();
}
void loop() {
unsigned int brightness=0;
for (int interval = 0; interval <= pwmIntervals; interval++) {
// Calculate the required PWM value for this interval step
brightness = pow (2, (interval / R)) - 1;
// Set the LED output to the calculated brightness
tlc.setPWM(2, brightness);
tlc.write();
//Serial.println(brightness);
if (brightness >= 65500){
break;
}
}
for (int interval = 4000; interval >= 0; interval--) {
// Calculate the required PWM value for this interval step
brightness = pow (2, (interval / R)) - 1;
// Set the LED output to the calculated brightness
tlc.setPWM(2, brightness);
tlc.write();
//Serial.println(brightness);
if (brightness==0){
break;
}
}
}
This simple fade up and fade down works with a single LED on output No.2 , as long as the adafruit is connected to the arduino as shown on the adafruit website:
After this test I put one of these MOSFET driver boards on PWM Output No. 2 for driving a 30V 30W LED (the LED and the driving Voltage is not yet connected. Only the PWM voltage is connected to the driver):
It has a PWM input that accepts everything from 3.3 to 20V as a PWM voltage. It has a little LED that indicates the duty cycle and it dimms up and down as expected.
So far so good.
When I now build the complete circuit (exemplary for one LED strip) it looks like this (I apologize for errors this is the first schematic I ever drew - I can redraw it if anything is unclear):
The main power source is a 30V 4A power supply. It is connected to the input of the driver module. When I drive the arduino with USB power (not like in the diagram) it works okay (I get some little flickering in the dimming process but I don't know if that will also be the case when the LED dimms over the course of several minutes so this problem doesn't concern me, yet). The LED on the driver dimms in sync with the main LED that it is driving.
To make it more compact I want to power the Arduino with the same power supply and as you can see in the diagram I use a DC-DC Buck converter to power the Arduino and the adafruit with 12V - and then nothing works. The PWM is stuck at 100% duty cycle (to my eye at least the LED is at full blast).
What I have tried:
- putting everything (apart from the AC source) on a common ground rail
- sharing the V+ from the Adafruit with the Vin on the Arduino
- "isolating" the adafruit by giving it its own DC-DC converter from the same AC-DC source
- Using DC barrel jack on the arduino
- using capacitors (100microfarad and also 10 microfarad) at the LED input, the adafruit power input and the driver DC input
- letting the arduino generate a PWM sweep on pin 3 directly to the driver - this works
What I noticed while experimenting (with the adafruit generating the PWM again):
- When I let the Arduino generate a 1 second switching 100-0-100-0 duty cycle the LED on the driver stays on, then starts to become a little dimmer, then stays on (instead of on-off-on-off)
- this problem only occurs when the arduino is NOT powered through the USB port
- this leads me to believe, that it has something to to with the reference voltage of the adafruit driver.
I went on a search an stumbled upon forum entries discussion ground bounce and decoupling capacitors but I couldn't quite figure out how to adapt these infos to my situation.
Does anyone have an idea what the problem could be? Sorry if I missed any information this is my first post.