Tuesday, July 23, 2013

high power LED retrofit (part 5)

So it's been a while since I showed progress on my LED retrofit project. I've been mostly busy preparing the madparts 1.2 release, which should happen "real soon now".

PCBs

As discussed in the previous post, while I had everything working for one lamp, it was a total mess of cables and really not acceptable to be a permanent part of the home. Also I wanted to decouple the functionality in two parts:
  1. LED PWM, relay control and Lux sensing
  2. fan PWM and temperature measurement
Main reason being that fan PWM and temperature measurement need to be done relatively close to the actual lamp, while the others should be done close to the LED driver.

To avoid having to run cables between the two boards, and because I'm using RF already anyway, I decided to let both boards talk directly over wireless.

Schematics & board design


I'm hoping to switch to KiCAD soon, but these boards were still designed with Eagle CAD.

LED PWM, relay control and Lux sensing

Overal schematic:



Let's look at the different sections in detail:


12V is taken in with a standard power connector. Diode D3 is used to protect against reverse polarity. F1 is a re-settable polyfuse, which combined with the TVS diode D4 provides further overloading protection.


The 12V rail is converted to a 5V and 3.3V rail by means of MCP1703 voltage regulators.


Headers are provided for Debug TX/RX serial interface, I2C bus for the Lux sensor and the standard 6-pin ISP programming header.

The I2C bus is actually connected to 5V, but the Lux sensor I'm using runs on 3.3V only. (It dies on 5V :( ) This means I had to do some bodge wiring to get 3.3V instead of 5V on that connector.

The Lux sensor is only connected to one of the two boards I've created because they'll be together anyway.


The main workhorse is an Atnel AVR atmega328p microcontroller clocked at 16Mhz. A conservative choice but it allowed me to spent minimal time making the firmware as it is fully Arduino compatible. I also broke out the other pins just to be sure but I did not end up using those.

 The wireless connection is provided by a cheap RFM12B module. It is connected to the SPI bus of the main processor. This module runs on 3.3V hence the simple voltage divider action for MOSI, SCK and SS signals that go from the processor to the RFM12B. The other way around nothing is needed as 3.3V is still above the high-threshold for the processor.


The relay used is a neat little latching relay to avoid constantly powering the relay when the lamp is on. The relay is driven from the micro-controller via the NPN transistors T1 and T2 and flyback protection diodes D1 and D2 are provided around the relay coils to absorb possible inductive kicks.



Finally an adjustable voltage regulator together with a trim pot is used to set the peak voltage of the PWM signal towards the LED driver. This can be used to limit the maximum current provided by the LED driver. This works because internally the LED driver just converts the PWM signal to a voltage anyway with a low-pass filter. This adds another safety mechanism to limit the LED current if your setup is not capable of dissipating all the heat the LED die produces when it is running at it's maximum current rating.

The PWM signal provided by the micro-controller is then first inverted an then brought up to almost the voltage level provided by the voltage regulator. In practice a small drop is still seen causing a 10V maximum output signal when the voltage regulator is set to 10.5V.

R12 ensures that the LED drops to 10% dimming instead of going full on if for some reason the board dies and the lamp is still on as the LED driver also supports programming the current with a resistor.

Finally this gives rise to the following board layout:


The code has also been rewritten. I will not further explain the code.
You can find code and eagle schematic and board files at https://github.com/andete/blog-stuff/tree/master/HPLEDRF2/relay_pwm .

Note that I mirrored the power connector. Luckily I could just cut off the side pin and it still works fine.

Fan PWM and temperature sensing


Overal schematic:


Many parts are the same as the other board and I will not go in them again. These are different:

The fan PWM is just directly driven from the micro-controller as the FAN has 5V PWM compatible. The fan also provides a pulse signal which is connected to the INT1 interrupt pin of hte micro-controller.




Temperature sensing is provided by the AD8495 k-type thermocouple amplifier. I did not write my own driver for it, I just used code already made available by http://adafruit.com/ .

This is the board layout:


For this board, the code and files can be found at https://github.com/andete/blog-stuff/tree/master/HPLEDRF2/temp_fan .

Boards

I ordered boards from http://seeedstudio.com. They took slightly longer then 2 weeks to arrive counting from first order date which is very reasonable given that they have to come from China. Pricing is also extremely competitive.

.
The boards look reasonably well. The silk screen is a bit poor at places. I did not find any electrical errors (besides my own :p ). Copper does tends to peel of when you do rework, so don't use to much heat.

In the meanwhile I have also other boards in progress from http://oshpark.com/. I'm quite curious how long they'll take to get in Europe and make a comparison of the quality.

Assembly


Here is a picture of a fan-temperature board hand assembled. It went pretty well.


Here I'm testing temperature measurement with a k-type thermocouple.



Here you can see the relay PWM board sitting on top of the LED driver for testing. the Lux sensor is mounted on the lid of the case sensing through a hole.


Here I'm testing the entire setup with LED driver and LED PWM board below and temperature-fan board sitting on top of the stairs.

It's all starting to work!



As I want two of these lamps in my living, I started on assembly of the second lamp. I've slight changed the mounting. in the first lamp I used screws and aluminium to put the LED die in place. Here I've used termo-conductive glue to place the die on the plate. This has a big advantage that there are no screws in the way and the heat sink sits snugly on the other side of the plate. Also I've opted to mount the fan directly on the heat sink for simplicity.

On the top picture you can nicely see the thermocouple mounted on the LED die. Insulated with kapton tape.



With both lamps working fine, it's time to clean up the assembly for their final wiring. Wiring is always such a mess...


Here is the final wiring for the LED PWM boards and the LED drivers. Wires will of course be flattened when they're at their final location, and the cases will be closed. At this point I finished up the firmware as once the lamps are in place it will be next to impossible to reach the boards.

So all that is left is mounting them on a piece of wood and hanging the lamps on their final spot!

No comments: