controlling High Power leds with Microcontroller IC

Discussion in 'Embedded Systems and Microcontrollers' started by stage3-s4, Oct 1, 2009.

  1. stage3-s4

    Thread Starter New Member

    Oct 1, 2009
    10
    0
    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.
     
  2. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Start with using a PIC with more I/O pins. One for each LED would be a good idea.
     
  3. russ_hensel

    Well-Known Member

    Jan 11, 2009
    818
    47
    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?
     
  4. stage3-s4

    Thread Starter New Member

    Oct 1, 2009
    10
    0
    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.
     
  5. amjad2000in

    New Member

    Sep 3, 2009
    14
    0
    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.
     
  6. John Luciani

    Active Member

    Apr 3, 2007
    477
    0
    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 *)
     
  7. stage3-s4

    Thread Starter New Member

    Oct 1, 2009
    10
    0
    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.
     
  8. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    A popular replacement for the ancient 16F84 with I2C and built in osc is the 16F88
     
  9. stage3-s4

    Thread Starter New Member

    Oct 1, 2009
    10
    0
    do you think the 16f88 would be better for my needs in this case?
     
  10. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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.
     
  11. stage3-s4

    Thread Starter New Member

    Oct 1, 2009
    10
    0

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

    Thread Starter New Member

    Oct 1, 2009
    10
    0
    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?
     
  13. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    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.
     
  14. stage3-s4

    Thread Starter New Member

    Oct 1, 2009
    10
    0
    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.
     
  15. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    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.
     
  16. John Luciani

    Active Member

    Apr 3, 2007
    477
    0
    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 *)
     
  17. John Luciani

    Active Member

    Apr 3, 2007
    477
    0
    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 *)
     
  18. stage3-s4

    Thread Starter New Member

    Oct 1, 2009
    10
    0

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