led lighting not behaving how i wanted

Thread Starter

scrumpydc

Joined Jan 23, 2018
49
Hello all ime new to the forum and was wondering if you would be able to help out in my little problem

so i have a led driver with pwm well this one https://futureeden.co.uk/collection...able-constant-current-led-driver-650ma-21-31v i have created the circuit as shown on the page made a prototype circuit board and have it all soldered up ime using an arduino nano to control the pwm what i was hoping is that when the nano goes off the lighting would stay off yet !!! it jumps to full power super bright leds not good i wanted to use a dc dc relay from a raspberry pi (web controlled ) to switch the nano on and off to restart the sketch rather then having it running all the time i have figured that the driver requires 10v across to keep the lights off witch to me is a bit backwards and the nano and my circuit provides this when on but dose not when off
To the point is there any way to make it so when the nano goes off the wires from the driver will connect to keep the lights off and the circuit connected
,like some low voltage switch other than a relay i was thinking mosfet but not sure how to implement it and if it is possible without the lighs going on
and help or ideas would be amazing
 

wayneh

Joined Sep 9, 2010
17,498
You might try a pull-down resistor to ground on the PWM output, so that it is pulled down when the nano is powered down. Experiment with different values in the range of 1K to 10K and use the biggest value that works. Make sure the nano can drive the combined current of the pulldown resistor and the base current. I'm assuming 1K is fine but I don't know anything about your nano.
 

ebeowulf17

Joined Aug 12, 2014
3,307
You might try a pull-down resistor to ground on the PWM output, so that it is pulled down when the nano is powered down. Experiment with different values in the range of 1K to 10K and use the biggest value that works. Make sure the nano can drive the combined current of the pulldown resistor and the base current. I'm assuming 1K is fine but I don't know anything about your nano.
If I've read the original description right, it sounds like the logic may be backwards of that. I'm probably over complicating things, but I'm imagining a second NPN between the Arduino output and the existing transistor base - it could be used to invert the logic so that a pull down on its base would get the job done when the Arduino was off.

Here's a snip of the original referenced circuit for anyone who doesn't want to click through:
IMG_4297.JPG
I'm on my smartphone on the train right now, so I can't share a schematic of my idea right now, but if no one else comes through I'll try to add one later tonight.
 

sghioto

Joined Dec 31, 2017
5,392
Apparently the output of the Nano is at 5 volts when the PWM is turned off. I assume you are using the transistor driver as provided in the link.
You just need to rewrite the software.
SG
 

Thread Starter

scrumpydc

Joined Jan 23, 2018
49
I will have a look at my code when I finish work and will see if I can post it I thought it may be the driver because when you increase the power the lights get dimmer witch is the problem I was hoping that when I cut power it would keep the LEDs
 

ebeowulf17

Joined Aug 12, 2014
3,307
I may have misunderstood what exactly your current setup is, but I *think* that if I've understood you correctly, you can add one transistor and two resistors (all same parts you used to build the first part of the circuit, so maybe you still have some more on hand?) in order to invert the signal:

PWM-inverter.png
 

Attachments

Thread Starter

scrumpydc

Joined Jan 23, 2018
49
I may have misunderstood what exactly your current setup is, but I *think* that if I've understood you correctly, you can add one transistor and two resistors (all same parts you used to build the first part of the circuit, so maybe you still have some more on hand?) in order to invert the signal:

View attachment 144341
I will give it a try see if it works but yes that's what I needed to invert the signal when the power drops from the Arduino to keep the driver connected and the lights off
 

ebeowulf17

Joined Aug 12, 2014
3,307
I will give it a try see if it works but yes that's what I needed to invert the signal when the power drops from the Arduino to keep the driver connected and the lights off
Cool. I hope it does the trick. Let me know how it goes.

If it doesn't work, then there's either a wiring error or I've misunderstood how the recommended PWM interface circuit interacts with the LED driver. If that's the case, please upload detailed pics of your current circuit and wiring, as well as sharing the NPN part number you used (if you've used a different NPN than the part shown in the drawing, we'd need to know that in order to confirm pin order.)
 

Thread Starter

scrumpydc

Joined Jan 23, 2018
49
IMG_20180124_185920.jpg IMG_20180124_185918.jpg ok I did that and it did not work it just stopped the fade cycle from happening (it was worth a shot)


here is my code ime using I want it to run once then stop and wait for a relay to turn it off then for the relay to turn it on again in the morning and the cycle to start again
Code:
// Fading LED
// by scrumpy
int value = 255;                            // variable to keep the actual value
int ledpin = 10;                           // light connected to digital pin 10

void setup()
{ for(value = 255; value >=0; value-=1)   // fade out (from max to min) over 30 min
  {
   analogWrite(ledpin, value);           // sets the value (range from 0 to 255)
   delay(7058);                            // brightens up over 30 mins
}
{
delay(39600000);                 // waits 11 hours
}
  for(value = 0 ; value <= 255; value+=1) // fade in (from min to max)
{
   analogWrite(ledpin, value);
   delay(7058);
}
}

void loop()
{

}
the code works up till the point I turn the nano off then the lights come on where I don't want them to
and ime not the best coder
I do not know if there is a way for me to tell the nano that when it reads a voltage it does one thing and when it doesn't detect it dose another because this way I could keep the nano on and bypass the problem and just use the SSR from the pi to act as a 5v switch
 

ebeowulf17

Joined Aug 12, 2014
3,307
View attachment 144360 View attachment 144361 ok I did that and it did not work it just stopped the fade cycle from happening (it was worth a shot)


here is my code ime using I want it to run once then stop and wait for a relay to turn it off then for the relay to turn it on again in the morning and the cycle to start again
Code:
// Fading LED
// by scrumpy
int value = 255;                            // variable to keep the actual value
int ledpin = 10;                           // light connected to digital pin 10

void setup()
{ for(value = 255; value >=0; value-=1)   // fade out (from max to min) over 30 min
  {
   analogWrite(ledpin, value);           // sets the value (range from 0 to 255)
   delay(7058);                            // brightens up over 30 mins
}
{
delay(39600000);                 // waits 11 hours
}
  for(value = 0 ; value <= 255; value+=1) // fade in (from min to max)
{
   analogWrite(ledpin, value);
   delay(7058);
}
}

void loop()
{

}
the code works up till the point I turn the nano off then the lights come on where I don't want them to
and ime not the best coder
I do not know if there is a way for me to tell the nano that when it reads a voltage it does one thing and when it doesn't detect it dose another because this way I could keep the nano on and bypass the problem and just use the SSR from the pi to act as a 5v switch
What are the part numbers for the NPN transistors?
 

Thread Starter

scrumpydc

Joined Jan 23, 2018
49
IMG_20180124_192506.jpg IMG_20180124_192718.jpg
a before and after soldering as I say it works how it should except when the nano is off the driver is backwards and I need to figure a way to make it work with the raspberry pi and the nano

And Thank you all for your help so far
 

ebeowulf17

Joined Aug 12, 2014
3,307
If that transistor on your soldered circuit board is the spec'd SS8050, or a 2N2222, or any other model sharing the EBC pinout, then I think you have your transistor installed backwards.
 

ebeowulf17

Joined Aug 12, 2014
3,307
No, I wouldn't expect that, but that doesn't mean much - I really know very little about how a transistor behaves outside of its normal operating parameters.

You may have damaged the transistor by exceeding the emitter-base voltage limit of 6V. If I'm understanding the LED driver properly, it's feeding 10V into your circuit? If so, installing the NPN backwards would've meant an emitter-base voltage of 10V when the Nano's pin was at ground (0V) potential.

I'm really not sure... I'm constantly doubting myself here because I have no hands-on experience with LED drivers like the one you're interfacing with... but amplifying and/or inverting PWM signals is pretty straightforward stuff, so hopefully we can figure this out. Still, it is entirely possible that I'm misunderstanding what kind of signal your LED driver expects and that I'm going about this all wrong.

If I were you, I'd eliminate my add-on inverter circuit for the moment and build a fresh copy of the original recommended circuit on your breadboard with a new transistor that hasn't been reverse biased.Then we can see if it works as expected or if it still has the backwards behavior that your first circuit had. If a fresh build works backwards of how you want, then my inverter circuit really should reverse that (make sure to verify transistor orientation on that circuit as well, and replace the transistor if it's been reverse biased, just in case.)
 

philba

Joined Aug 17, 2017
959
Assuming that your GNDs are properly connected, you have good source of 10V and your circuit is working correctly, here's what I think is going on - the PWM input to the power supply is inverted. High (10V) is off, Low (0V) is on. You can confirm this by directly connecting the input to 10V or 0V. If it is as I suspect, you will need a pullup (10K minimum) resistor to pull the input to 10V when not driven by your circuit.

In your code, you can invert the analog write value (256-value or just run you loop count backwards).

Also, I assume you are trying to simulate a 1/2 hr sunrise and sunset. I don't believe the brightness curve of actual SR/SS is linear so you might want to create a brightness map. Plus your lights probably don't respond linearly to PWM so you may have to map that. All easy to do once you know the actual curve but hard to figure out the curve.

[edit] by the way, for debugging, you can shorten up the delay to something that gives you a full cycle in 30 seconds rather than 30 minutes. If you use a #define DELAYTIME 7058 and replace 7058 with DELAYTIME. Then you can fiddle with it in one spot in your code. In general, it's a good idea to use defines (or constant decls) for constants so you can name the value and make your code more meaningful.
 
Last edited:

Thread Starter

scrumpydc

Joined Jan 23, 2018
49
ok renewed the circuit brand new transistor in the opposite way around to the way I had it I think you were right I had it backwards good spot the code still works leds fade as should and go off but when no power is on the leds the lights are on I think ime gonna have to rewrite the code and use the SSR as a 5v switch yes it is to simulate the sunrise and sunset and the lights do flicker a tiny bit when coming on but not annoyingly so its more the problem with the lights staying on when the nano goes off this is the first of 5 sets of lights the power supply is the issue it reqiers 10v for the power to go out I was hoping that when it was connected the lights would come on diagram to show what I mean and the new pics of the curcuitto show wirs.jpg IMG_20180124_220500.jpg IMG_20180124_220452.jpg
I know its messy but it works lol :)
 

ebeowulf17

Joined Aug 12, 2014
3,307
Assuming that your GNDs are properly connected, you have good source of 10V and your circuit is working correctly, here's what I think is going on - the PWM input to the power supply is inverted. High (10V) is off, Low (0V) is on. You can confirm this by directly connecting the input to 10V or 0V. If it is as I suspect, you will need a pullup (10K minimum) resistor to pull the input to 10V when not driven by your circuit.

In your code, you can invert the analog write value (256-value or just run you loop count backwards).

Also, I assume you are trying to simulate a 1/2 hr sunrise and sunset. I don't believe the brightness curve of actual SR/SS is linear so you might want to create a brightness map. Plus your lights probably don't respond linearly to PWM so you may have to map that. All easy to do once you know the actual curve but hard to figure out the curve.

[edit] by the way, for debugging, you can shorten up the delay to something that gives you a full cycle in 30 seconds rather than 30 minutes. If you use a #define DELAYTIME 7058 and replace 7058 with DELAYTIME. Then you can fiddle with it in one spot in your code. In general, it's a good idea to use defines (or constant decls) for constants so you can name the value and make your code more meaningful.
Correct me if I'm wrong, but wouldn't we also want an extra transistor (whether like I've drawn or in some other configuration) so that the Arduino isn't interfacing directly with the 10V pull up?
 
Top