Mbed controlled dimmer

12 Nov 2010 . Edited: 12 Nov 2010

Hello,

I want to make a dimmer for some lights and want to control the power output with the mbed. My idea was to use a transfo for the zero detection and connect that to an input of the mbed. Next I want to use an output pin to generate a trigger pulse for a TRIAC (by using a opto-coupler) so that I can dim 230V with a power rate of 6A (I still have to see whic TRIAC I will use). The general idea behind this little project is that I can control the light at my home over the internet. I already succeeded in controlling the LED's of the mbed board over the internet with a JAVA program. So now I was thinking about writing some extra code on my mbed for the zero-crossing detection en generating of the trigger pulse (because this should be 'real time') and use the RPC server code that's now already running on the mbed just to communicate with the java program to update the 'dimmer value'. This value is going from 0 to 100 and represents the output power.

Is this the best way to do this? And can somebody maybe help me with the C++ code for the dimmer itself (I'm still not so familiar with C++ and all the mbed library's) and a good schematic to realise my concept in practise (high efficiency, robuust, safe). I already found alot of schematics for this kind of application but I was wondering which is a really good one so that I can get started as soon as possible.

Already thanks in advance

Friendly greetings,

Kristof Geerts

13 Nov 2010

Just have a variable delay between zero crossing and SSR turn on.

13 Nov 2010

M tought about that to, but how about the circuit and maybe also taking into account that the transfo for zero crossing also introduces a fase shift...

13 Nov 2010

At 50/60 Hz there shouldn't be much of a phase shift between the primary and secondary voltage of the transformer.

As for the dimmer circuit. The simple ones you see on the net are leading edge dimmers which can't be used with CFL's. Trailing edge dimmers are more complicated, but they are ok to be used with CFL's.

A good article regarding dimmers: http://sound.westhost.com/lamps/dimmers.html

More info on dimmers: http://www.epanorama.net/documents/lights/lightdimmer.html

I would recommend you try this. It uses a small transformer for the zero crossing detection and an opto-isolator for the gating. The 555 timer is used to generate the delay between the zero crossing and the gating pulse. You will obviously use the mbed in place of the 555. Note that the zero crossing detector outputs 0-12V.

Also, your requirements of 230V, 6A scare me... You might need to employ a more complicated circuit at those power levels. The noise and harmonics generated by these simple circuits could be severe enough to damage the dimmer circuit itself.

Hope that helps!

15 Nov 2010

I have designed a 120V, 15A phase angle controller (simple analog control) for general purpose power control. You just need symmerical drive and a snubber for inductive loads.

16 Nov 2010 . Edited: 16 Nov 2010

Hi, if your dimmer project is only for home use and you don´t want to lose time studing how to do a decent light dimmer you shoud go for a Velleman kit K8064 that is a DC controlled dimmer, it´s low cost and reliable dimmer with RF supressing filter (dimming generates lots os RF interferences, because of fast pulses ON-OFF aplied to high current circuit and should have a coil to supress that).

This kit costs only about 22euros and only you have to do is connect it to DAC on mbed (the dimmer has opto-coupler no worry about driving high voltage circuit to mbed)  and connect it to AC and lights to control.

Like controlling a simple LED on DAC :)

For educational purposes should consider to study dimming process and do the circuit yourself .

Regards

17 Nov 2010 . Edited: 17 Nov 2010

Hi,

Thank you all very much for the many reply's

The idea behind the kind I find very interesting, especially because then I don't need the Mbed for the zero-crossing-detection and to send out the trigger signal. If I use the velleman circuit, the dimmer becomes a universal piece of electronics that can be controlled with all kind of things (Mbed, other µC,regular potentiometer,...) and this I find very interesting. But I want to re-make the circuit myself without ordering the kit itself. This mainly because I already have lot's of components myself and I also ordered some free samples of the pic16f676.

@ Vitor M (or somebody else): does anybody know where I can find the C or ASM code for the pic16f676 that is used in the circuit of the velleman kit? I really want to focues on the analog/power part and not loose to much time with the programming of the µC. I have an ICD2 pic programmer so putting the code on the pic is no problem.

Greetings,

Kristof

17 Nov 2010

 

user Kristof Geerts wrote:

Hallo,

Alvast bedankt voor de vele reacties!

Het idee achter de kit vind ik wel interessant, vooral omdat de Mbed dan niet nodig is voor het hele zero-crossing-detectie gedeelte en het uitsturen van de PWM. Dan is de dimmer zelf meer een universeel stukje electronica dat de Mbed (of iedere andere controller of zelf gewoon pot-meter) aan te sturen is. Nu zou ik echter dat circuit gewoon willen namaken ipv de kit zo te bestellen. Ik heb hier namelijk nog heel wat componenten liggen en heb al graties samples besteld van de pic16f676.

@ Vitor M (of iemand anders) weet iemand waar de C code of ASM voor de pic16f676 die gebruikt wordt in dit project te verkrijgen is. Ik wil me namelijk vooral focussen op het analoge power gedeelte (en dit optimaliseren) en niet teveel bezig houden met het 'programmeer' gedeelt. Heb een pic programmer ICD2 dus de code erop zetten is geen probleem.

Mvg

Kristof

Please keep it in English...

Especially when you want some answers. This way it will be useful for not Dutch natives too.

 

17 Nov 2010

Hi Ben,

 

Sorry, my mistake. Forgot it for a moment. I changed my original post so now everything should be fine.

 

Greetings

17 Nov 2010

Hehe, bedankt!

 

No hard feelings ;)

 

Ben

02 Dec 2010

 

user Igor Martinovski wrote:

At 50/60 Hz there shouldn't be much of a phase shift between the primary and secondary voltage of the transformer.

As for the dimmer circuit. The simple ones you see on the net are leading edge dimmers which can't be used with CFL's. Trailing edge dimmers are more complicated, but they are ok to be used with CFL's.

A good article regarding dimmers: http://sound.westhost.com/lamps/dimmers.html

More info on dimmers: http://www.epanorama.net/documents/lights/lightdimmer.html

I would recommend you try this. It uses a small transformer for the zero crossing detection and an opto-isolator for the gating. The 555 timer is used to generate the delay between the zero crossing and the gating pulse. You will obviously use the mbed in place of the 555. Note that the zero crossing detector outputs 0-12V.

Also, your requirements of 230V, 6A scare me... You might need to employ a more complicated circuit at those power levels. The noise and harmonics generated by these simple circuits could be severe enough to damage the dimmer circuit itself.

Hope that helps!

Hi again,

A little bit more about that circuit you recommand (this), I almost finished building it but now I was wondering about how much the resistor for the trigger pulse must be (on the right side of the opto-coupler). They use just 2k ohm but if I use another TRIAC, the TIC206M, would it also work? I ask this because I don't want to destroy my traic the first time I test the circuit. Can somebody maybe help me with the calculations/reasoning about that resistor. I know that the other small one, together with the capactor forms a snubber circuit so this is not so critical.

Thanks in advance,

 

Greetings

Kristof

 

05 Dec 2010 . Edited: 05 Dec 2010

I don't have a lot of experience with TRIACs, but with SCR's, you have to stay above the threshold gate current and below the maximum threshold current limit. I would imagine its similar for TRIACs.. The gate resistor is to limit the gate current to the device.

According to the datasheet here, the maximum peak gate current is +/-200mA. The peak gate trigger current with 12V at the terminals is at most 10mA. That means that the we need at least 10mA and no more than 200mA of gate current. I would say that 50mA should be a suitable value for the gate, but there is no way to tell. You also have to take into account that the maximum forward current for the opto-coupler is not exceeded.

As an example, with a dead short as the load, the gate current in that circuit would be around 170mA. That's fairly close to the limit of the device that you want to use, so you definately should increase the gate resistance before attempting to run the circuit.

EDIT: There appears to be an error in the application note schematic. I seems that the TRIAC is backwards. The load is supposed to be on M2 and not M1 as shown, see here for more info

05 Dec 2010

user Igor Martinovski wrote:

I don't have a lot of experience with TRIACs, but with SCR's, you have to stay above the threshold gate current and below the maximum threshold current limit. I would imagine its similar for TRIACs.. The gate resistor is to limit the gate current to the device.

According to the datasheet here, the maximum peak gate current is +/-200mA. The peak gate trigger current with 12V at the terminals is at most 10mA. That means that the we need at least 10mA and no more than 200mA of gate current. I would say that 50mA should be a suitable value for the gate, but there is no way to tell. You also have to take into account that the maximum forward current for the opto-coupler is not exceeded.

As an example, with a dead short as the load, the gate current in that circuit would be around 170mA. That's fairly close to the limit of the device that you want to use, so you definately should increase the gate resistance before attempting to run the circuit.

EDIT: There appears to be an error in the application note schematic. I seems that the TRIAC is backwards. The load is supposed to be on M2 and not M1 as shown, see here for more info

Hi,

Thanks for the note about the direction of the TRIAC. This spares me alot of 'searching for an error' time if I had tested the circuit. But nog I'm still wondering, for the opto-triac I use the one of the schematic which has an Output on-state current, total rms value (50-60 Hz, full sine wave) of 100 mA and a Output driver nonrepetitive peak on-state current of 1,2A. But so what do you suggest to use for the resistor because if you calculate a resistor value for a sin wave of 325V peak you get a large resistor value if you calculate it for 50mA of trigger current but if the sin wave is then at is minimum, let's say 4V then their almost flows no current anymore so can it be triggered again then? I'm a little bit confused for the moment and don't see which resistor I should use now and why..