iPhone-controlled Dimmer/Sunrise Alarm

Thread Starter

MrDOfTheBay

Joined Oct 20, 2008
7
I hope this doesn't seem like an odd thing to want to build!

I've got an old "sunrise alarm clock" which is on its last legs and in need of replacement. I thought it would be nice to build my own and integrate it properly with the room (ie. install some up-lighters on the wall) instead of buying another bedside one.

I'm quite a bit into this project and starting to struggle so I thought I'd share it on here. I'm hoping there might be someone with enough experience to help me out.

I've broken this project down into 3 components:

1) Human Interface - originally I though about building something to sit on my bedside table (LCD+buttons+enclosure), but anything I've ever built before just looks terrible. Instead, I'd like to use my iPhone as a wireless touch remote.

2) Control Unit - basically a microprocessor. Software is my day job so I'm comfortable with this bit. This will run the alarm clock software and send appropriate signals to the dimmer unit. I've bought one of these: http://www.netburner.com/products/development_kits/network_development.html (the cheap one). I already have it and it's working well.

3) Dimmer Unit - bit of power electronics which dims ~300W of mains-voltage (230V) incandescent bulbs. This is where I'm stuck.

My first attempt was a phase-angle dimmer kit from Velleman. This is a DC (0-10V) controlled kit which can handle 400W. I hooked this up to my cpu using a 12-bit DAC (SPI bus) and an op-amp buffer to power the opto input on the dimmer kit. This works, but unfortunately the kit isn't good enough. Two notable problems:

a) It buzzes too much, and I really need it to be silent given its purpose.
b) The dimming motion is not smooth at all - at specific points in the curve it seems to get stuck and then "jump" noticeably to a higher brightness level.

So my next plan is to use a technique called "sine wave dimming". I've read-up on this a bit and the basic idea is to switch a power MOSFET at 20kHz+ with a varying duty cycle to control the power transfer.

I can't find any kits so I will need to build this myself.

I have two problems to solve:
1) My processor selection doesn't have a PWM output (unfortunately I made the selection with the intention of using the velleman kit).
2) I have NO idea how to build a MOSFET control circuit.

Ideally I'd use the least number of components possible. I am expecting to at least use a diode-bridge to get mosfet-compatible DC. As far as I'm aware my incandescent bulbs will be fine with this. I'm looking into using a mosfet driver IC but I don't really understand some of the concepts here. There is talk of high side/low side, half rectified, full rectified etc. I guess at full-rectified but looking at the typical usage diagram I'm not really sure it's for the the use case I'm thinking of.

For the PWM I'm looking for some kind of PWM interfacing chip with an I2C or SPI bus. Failing that I'll need to build some kind of PWM circuit that I can control somehow from my CPU. Perhaps with a 0-3.3V DC control voltage since I've already built that interface!

Any and all thoughts appreciated at this stage!

Let me know if more detail is required.

Ross.
 
Last edited:

Thread Starter

MrDOfTheBay

Joined Oct 20, 2008
7
Small update:

Think I've solved the PWM generation problem. I had a look around for a standalone PWM generator but couldn't find one. However, I did find an in-circuit programmable PIC which has a 10-bit PWM output so that should do the job. I should be able to bit-bang the programming and data from a couple of GPIOs on my main CPU.

That just leaves the MOSFET side of things.

I've noticed a couple of threads on this board about PWM-controlled mosfets so I'm going to read through those. I'll have a "first go" at making a circuit diagram later this week and post it on here for some feedback.

In the meantime, if anyone knows of any good primers on using MOSFET to control Mains AC then I'd be very grateful for a point in that direction.

I'm still unsure about this lowside/highside stuff and what my general options are (ie. here are the X most popular ways of doing it).

Cheers,
Ross.
 

Thread Starter

MrDOfTheBay

Joined Oct 20, 2008
7
Hi, thanks for the reply ...

I've actually read that page already! It ultimately describes phase-angle control, where-as I'm more interested in a newer technology called "sine wave dimming".

Obviously you can use a MOSFET to control AC since that is exactly how a switched-mode power supply works. I'm not sure I understand your concern.

http://en.wikipedia.org/wiki/Switched-mode_power_supply

I guess I'm really attempting to build a switched-mode power supply but with an AC output ranging from 0-230V instead of the more standard DC low-voltage output.
 

beenthere

Joined Apr 20, 2004
15,819
You should be aware that a switcher rectifies and filters the AC input to maks DC. The FET switches the DC through the transformer primary. The transformer simply couples the energy to the secondary as would be expected. When the FET shuts off, the current also stops. The field in the primary collapses, so the transformer will once again transfer energy to the secondary hen the FET conducts again.

If you tie the center tap of the secondary to circuit ground, the voltage out will be AC in nature, even though the primary is being driven by DC. Voltages are all realtive. Since the transformer isolates the primary from the secondary, the secondary can produce an AC voltage.

A power FET has an inherent diode between the source and drain. The diode is reverse biased with the proper DC voltages applied, but will conduct if the drain becomes negative with respect to the source in an N channel device. Placing an AC voltage across a FET will cause an immediate failure when the internal diode conducts.
 

Mike P

Joined Oct 26, 2008
1
I too am interested in making a sunrise alarm clock. The research I've been doing has turned up a lot of articles on PWM-controlled LED's, but I want to use a conventional incandescent lamp. PWM doesn't seem to be used much in incandescent dimming.
In the same Google search that led me to this forum, I stumbled across this link:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en025234
It describes a PIC-controlled triac circuit with a low component count.

Hope this helps,
Mike P
 

Thread Starter

MrDOfTheBay

Joined Oct 20, 2008
7
Hi Mike,

Thanks for replying. The PIC-controlled triac is an example of "phase angle control". It works by detecting the zero-crossing of the AC wave and delaying the turn on until a variable time after that crossing. When at about half-power, the amount of voltage being switched causes huge current spikes. A large inductor is required which buzzes at the mains frequency of 50Hz. In my circuit this was very audible and not suitable for a sunrise alarm clock - the light is supposed to wake me up, not the buzzing!! (although perhaps if you want to switch less lights you could get away with a smaller less audible inductor).

You are correct that PWM-controlled dimming isn't used much. It seems to be newer and typically used in theatres where the power switched is much much higher and the 50Hz hum interferes with their audio systems.

I am interested in this approach mainly as an intellectual excerise.


Re beenthere: I got my terms mixed-up in my last post. My intention is to switch rectified-AC (ie. DC) with the MOSFET. The MOSFET will not be reverse biased at any time.

I still intend to post up a circuit diagram, just been busier than I wanted.
 

Thread Starter

MrDOfTheBay

Joined Oct 20, 2008
7
Hi again!

I've put together a really simple diagram showing what I want to do (attached).
EDIT: Forgot to put on the diagram: PWM running at ~20kHz, AC input at 50Hz.

I've really tried to find out about lowside/highside/halfbridge/fullbridge but I can't find anything that explains the differences between these types of circuits. Is there anyone here who can help me out with that?

I've guessed at a TC4420 (http://docs-europe.electrocomponents.com/webdocs/0027/0900766b800279f8.pdf) as the driver I might be able to use but it gives no "typical usage diagram" so I have no idea if it can even be connected like this without blowing up.

There are a couple of other chips that explicitly state high voltage (such as this one http://docs-europe.electrocomponents.com/webdocs/0acd/0900766b80acd35e.pdf) but these require two MOSFETs and some kind of "dead time" setting which seems overkill for my needs.

Also, I presumably need some kind of output filtering, but I'm not sure what to do there. Some kind of cap seems appropriate to smooth the output voltage.
 

Attachments

Thread Starter

MrDOfTheBay

Joined Oct 20, 2008
7
Hi Folks,

Not sure if anyone is still following this but I could really do with some help.

I've built the circuit I attached above, with a couple of minor changes:

1) I'm running the MOSFET gate at 12V rather than 18V.
2) I've a cap across the rectifier output (0.47uF, largest I had to hand).
3) My output "filter" is a 1.5mH inductor in series with the load (with a flyback diode from ground).
4) There's no PWM for now - I'm switching the input by hand, either to 0V or 12V continuous.

It's not working well at all.

At 0V, everything is as expected - the MOSFET is off and there's nothing at the load.

At 12V, funny things happen :
1) My nearby subwoofer hums.
2) I can smell heat, coming from the MOSFET.
3) I get only 30V (AC setting on multimeter) at the load.

I really need to know if this is a fault in my circuit, or if the actual design is broken. Can anyone see anything obvious in my circuit that might cause this behaviour ?

Also: If I measure the voltage at the rectifier output I get 700+V (which is actually out of range for my multimeter).

This I find odd... could this just be my multimeter misreading? (ie. do cheaper meters not correctly read RMS from a rectified input?)

Any and all thoughts appreciated, I'm struggling to be honest.
 
Last edited:

Thread Starter

MrDOfTheBay

Joined Oct 20, 2008
7
Follow-up:

Figured out that my MOSFET is not rated for this kind of power. Seems there's a thing called a Safe Operating Area, so although it says max 800V, 3A, that doesn't actually mean 3A @ 800V!

I'm going to upgrade to a bigger MOSFET and see what comes from that.

Would I be correct in assuming I can safely have my drain-base (it's an N channel) reverse biased by about 15V? I'm feeding a rectified AC wave to the drain, so I can guarantee it will always be positive with respect to the source, but not to the gate (which may be "on" at 15V).

From what I can tell the MOSFET will simply run in a different "mode" where it will act more like an amplifier than a switch. I calculated the power I'm likely to dissipate if I end up dropping 15V across the MOSFET into a current-limiting load of 250ohm at <1watt, which should be fine.

My plan for the moment is to remove the smoothing capacitor I have across my rectifier and remove the inductor at my output stage and just see if I can switch the thing on and off with an old fashioned finger switch controlling the gate (ie. nothing fancy to go wrong).

PWM can come later, if I ever get the MOSFET conducting my rectified mains voltage.

================================================================================

PS. I'm toying with the idea of getting a scope, so I can see what kind of waveforms I'm generating - this might help me with filtering later on. I'm looking for something cheap but practical.

Any suggestions?

This one looks quite good :
http://www.picotech.com/ultracompact-oscilloscopes.html


Any help appreciated!

Ross.
 

JDT

Joined Feb 12, 2009
657
In the meantime, if anyone knows of any good primers on using MOSFET to control Mains AC then I'd be very grateful for a point in that direction.
You can use 2 MOSFETS back to back as an AC switch. See the attached diagram. The internal diode prevents the reversed MOSFET from being reversed biased. In fact, the reversed MOSFET still switches on, because the channel conducts in either direction when the gate is positive to the source. So for small currents the diode in the reversed device may not actually conduct. I have used this circuit for low-voltage 250W halogen lamps.

Make sure that there is suficient gate-source voltage so that the MOSFET is always switched fully ON. A partially driven MOSFET will fail due to internal heat generation. Watch this especially on power-up.

I am hoping to use this idea to make a sine-wave dimmer for stage lighting. I plan to chop at 10 - 20 kHz so that it above the audible range. The main problem is filtering the chopped wave before it goes out to the lamp. Otherwise it will cause interference. An inductor is needed but the circuit must be able to handle the recirculating current in the inductor (when the switch is off). This may need two of these switches and some careful control using a microcontroller.
 

Attachments

ROWIFI

Joined Mar 15, 2009
2
Just been reading this thread - I used to design dimmers professionally, and generally Triacs are the way to go. Sine wave dimmers are expensive to build and difficult to design correctly. Yes, they have their place, but if it was cheap and straightforward, there would be many many more sine wave dimmers on the market.

The buzzing is the mechanical movement of the choke and its windings - you could try a bigger choke, potting the windings to limit movement or placing the dimmer somewhere it won't be heard.
 
Top