controlling High Power leds with Microcontroller IC

Thread Starter

stage3-s4

Joined Oct 1, 2009
10
Im looking to control about 20 High power cree leds, probably around 3 watts each. I want to use a microcontoller to control the dimming effects of the leds, and a DS1307 RTC chip to control what time the leds turn on and turn off. I will be using an LM304 constant current regulator to allow 1amp of current into the leds. I was just wondering how I would go about interfacing the DS1307 with a PIC microcontroller such as a PIC16F84 and what type of programming I will need to do.
 

russ_hensel

Joined Jan 11, 2009
825
DS1307 is a real time clock. Do you need it. The microcontroller can do timing by itself unless you need real accurate time of day. Start with a simpler project, lower power led, and single led. Then move up. 20 pins is a lot, but in some ways simpler than using fewer pins with helper chips. A shift register would let you use a uC with fewer pins.

What uC are you using and why? How much experience do you have?
 

Thread Starter

stage3-s4

Joined Oct 1, 2009
10
I think I may have confused you on what im trying to accomplish. I do not need to connect every led to the microtroller, im simply using it for PWM purposes to turn on/off as well as dim the leds. Im going to be connecting the leds to the LM304, which has a pin on it for dimming. The DS1307 will be used so the leds can turn on say at 9 am and turn of at 6 pm. I would want to turn them on in such a way that they will gradually come on so that the reach 100 percent intesty say after 5 min. So at 9.05am, they will be at full brightness. Same will go for the turn off cycle. I really just need to know what PIC chip would be best and how I would connect the DS1307 in such a way to do what I want it to do.
 

amjad2000in

Joined Sep 3, 2009
14
Hi,

If you just want to make a time delay then you don't need to use the RTC chip. You can program the delay function inside the Microcontroller itself. You can choose PIC16F877A for this purpose which got sufficient number of pin out for your purpose.

If you still insist to to use the DS1307, then you must first learn how to interface the RTC with the PIC. THE DS1307 uses i2C protocol for data transffering. So, first you need to learn how to program the PIC16F877A for working with the i2C protocol. Programming the 16F877A is really simple as itself have a built in i2c module in it.
 

John Luciani

Joined Apr 3, 2007
475
Your question sounds like it is more about the RTC IC than LEDs.

Any PIC (or other uC) with an I2C port would work fine. You just need to add the
pullup resistors which are typically around 4.7K to 10K. You then need to
program the appropriate DS1307 commands.

I have a schematic that shows the connections of a DS1337 to an ATmega328
in my NB1A datasheet at http://tinyurl.com/y8exe7k
Also on the site is a software library for the DS1337 and two example programs.
The software is for the Arduino (ATmega) but could be adapted to a PIC.

(* jcl *)
 

Thread Starter

stage3-s4

Joined Oct 1, 2009
10
The diagram you linked to helps with the interfacing of the PIC and the RTC chip. I just have to figure out how to program it.
 

Markd77

Joined Sep 7, 2009
2,806
A quick word about those LEDs. The high power LEDs are pretty tricky to power because as they get hot (and they do) they draw more power so unless you have a current regulator for each one you are likely to burn some of them out. You can't just string them together in series or parallel with just 1 regulator for the lot and expect it to work properly.
 

Thread Starter

stage3-s4

Joined Oct 1, 2009
10
A quick word about those LEDs. The high power LEDs are pretty tricky to power because as they get hot (and they do) they draw more power so unless you have a current regulator for each one you are likely to burn some of them out. You can't just string them together in series or parallel with just 1 regulator for the lot and expect it to work properly.

I will be using one LM304 for 6 leds wired in series. This should regulate the voltage and has a 1amp current limit.
 

Thread Starter

stage3-s4

Joined Oct 1, 2009
10
I think I understand how to connect the RTC chip to the pic from the link provided a few posts up. The only thing I am unsure of, is how would I program the RTC to trigger the pwm of the pic?
 

thatoneguy

Joined Feb 19, 2009
6,359
You would need to set the clock, then poll the clock every so often to see if it is time to turn the LEDs on or off. At this point, an LCD display and 3 buttons, mode (date/time/other), advance/+, and backward/- to set the clock. This would use 7 or 8 pins in 4 bit mode on the LCD. With the right wiring to the LCD, you could update the time display on the same pins that you control the LED's, though that is a bit advanced.

Would it be simpler to have the uC detect the light, and turn on the LED's when it gets dark?

To drive the LED's, you'll want to use the uC output to a transistor to keep from killing the uC outputs. There are several threads posted with details on that, you need to know the working voltage and current needed.
 

Thread Starter

stage3-s4

Joined Oct 1, 2009
10
Just to update the thread, im still a bit unsure of how to go about doing this. I basically just want to use microcontroller to send a pwm output to the constant current driver of my leds with respect to the time of day. Im not sure what I would need to start programming. If anyone has any advice it would be appricated.
 

THE_RB

Joined Feb 11, 2008
5,438
Sounds like you are finding it difficult. I suggest you break the project into 2 halves and get each half working to give you some experience;

You could make a simple "clock" project, there is a ton of source code on the net. You don't need a DS1307, you don't even need to wire up a clock display, just get the PIC accurately counting seconds so it flashes a LED exactly every second and another LED exactly every minute etc. Then it will be pretty trivial to count enough minutes between turning your main project on and off once a day.

Then do a second project just make a PIC control your high power LEDs with PWM. So you press a button and the LEDs slowly ramp up to full brightness. Press the button again and the LEDs ramp back to off.

If you can get those 2 projects coded and working ok it will be easy enough to combine them to make your final project. You will also have 2 handy "building blocks" ie clock and PWM fader, that you can use as part of other projects in the future.
 

John Luciani

Joined Apr 3, 2007
475
The diagram you linked to helps with the interfacing of the PIC and the RTC chip. I just have to figure out how to program it.
There are two RTC examples and a RTC clock library at the same link.
Once you get the PIC I2C code going you should be able to use some of the code from the examples. If nothing else it could save you some typing.

(* jcl *)
 

John Luciani

Joined Apr 3, 2007
475
Just to update the thread, im still a bit unsure of how to go about doing this. I basically just want to use microcontroller to send a pwm output to the constant current driver of my leds with respect to the time of day. Im not sure what I would need to start programming. If anyone has any advice it would be appricated.
The PWM signal you would do with a counter-timer. In the PIC datasheet
there should be an example. The duty-cycle of the PWM signal is set using the
count.

The time is just read from the RTC. For the DS1337 you would either periodically
read the time or set an alarm to interrupt the uC at the appropriate time.

(* jcl *)
 

Thread Starter

stage3-s4

Joined Oct 1, 2009
10
The PWM signal you would do with a counter-timer. In the PIC datasheet
there should be an example. The duty-cycle of the PWM signal is set using the
count.

The time is just read from the RTC. For the DS1337 you would either periodically
read the time or set an alarm to interrupt the uC at the appropriate time.

(* jcl *)

that sounds helpfull. Do you think I should purchase the board on there?
 
Top