Arduino Forum

Using Arduino => General Electronics => Topic started by: PelleS on Jan 11, 2019, 01:54 pm

Title: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 01:54 pm
I just wanted to ask whether or not this is a good circuit for an MCU controlled triac dimmer. I am very unsure about the optimum values for R2 and R3. Right now they are very high, so I think you could actually short the load pins without problems. I consider adding a thermal fuse as well, but where would I place it, and what value should it have? Are there any other obvious issues here or something that I should improve upon? Mains here are 230 AC 60 Hz.

Title: Re: Dimmer and correct circuit
Post by: wvmarle on Jan 11, 2019, 02:37 pm
Those 250k resistors are in the wrong place. They should connect to an opto that provides the zero crossing signal.

Lots of working circuits on Google. Frequency is not really important for the circuit (it is for your programming of course), voltage is for proper current limiting for your zero detector.

Without zero crossing the best you can do is on/off.

That said, if you don't know what you're doing don't mess with line voltages. It can cause fire, explosions, and death by electrocution. There are lots of light dimmer modules out there that you can buy and just connect to your Arduino. Much safer that way (you still have to be careful to not touch the dimmer when in use, best to place it in an enclosure).
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 02:45 pm
The opto is on the drawing (MOC3020). It has an inbuilt zero crossing circuit. As for the voltage you mentioned; i know that, hence R1 before the opto.
Title: Re: Dimmer and correct circuit
Post by: wvmarle on Jan 11, 2019, 02:52 pm
the datasheet (https://www.mouser.com/ds/2/149/MOC3020M-195880.pdf) doesn't mention this. So I don't think it does, and even if it did, you didn't connect it back to your Arduino. Without zero crossing signal your Arduino doesn't know when to fire the opto (and with it the triac).
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 03:06 pm
I see. I can switch it with a MOC3041. As far as I understand, the zero-crossing circuitry inside the MOC3041 only activates the internal triac on zero-crossing. So, if a signal goes in, it won't activate the triac before the signal crosses. Or am I wrong?
Title: Re: Dimmer and correct circuit
Post by: wvmarle on Jan 11, 2019, 03:26 pm
You're wrong. Completely.

Even if it worked like that, you would have NO control whatsoever.

This is how it's done (https://playground.arduino.cc/Main/ACPhaseControl).
Title: Re: Dimmer and correct circuit
Post by: MarkT on Jan 11, 2019, 03:30 pm
I just wanted to ask whether or not this is a good circuit for an MCU controlled triac dimmer. I am very unsure about the optimum values for R2 and R3. Right now they are very high, so I think you could actually short the load pins without problems. I consider adding a thermal fuse as well, but where would I place it, and what value should it have? Are there any other obvious issues here or something that I should improve upon? Mains here are 230 AC 60 Hz.


Your triac is across the AC mains, it will explode with considerable violence and take several fuses with it.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 03:39 pm
Your triac is across the AC mains, it will explode with considerable violence and take several fuses with it.
On almost all circuits I've seen on triac dimmers, they have been wired like this (like here: https://www.instructables.com/id/Arduino-controlled-light-dimmer-The-circuit/). And I've done several spice simulations. I must have seriously misunderstood then.

Edit: I've probably been a little quick with the connectors to the mains and load on the right, I think. I might have gotten them switched. Can this be the issue? Just been struggling a little with placing them because I'm learninig the software. So, if that might be the reason, please let me know.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 03:51 pm
I attached an image of my circuit in LTspice. The load is R4. If this is not about the same circuitry, then I just made a mistake in the other software.

Edit: ofc a resistor in series with the load (forgot to add in LTspice).
Title: Re: Dimmer and correct circuit
Post by: wvmarle on Jan 11, 2019, 03:55 pm
On almost all circuits I've seen on triac dimmers, they have been wired like this (like here: https://www.instructables.com/id/Arduino-controlled-light-dimmer-The-circuit/). And I've done several spice simulations. I must have seriously misunderstood then.
The circuit in that post looks good at a first glance.

It has little resemblance to your circuit. Do note the second optocoupler for a start (for the zero crossing) and how the triac is wired very differently.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 03:58 pm
The circuit in that post looks good at a first glance.

It has little resemblance to your circuit. Do note the second optocoupler for a start (for the zero crossing) and how the triac is wired very differently.
I can only see one optocoupler at any circuit in that article.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 04:53 pm
According to LTspice, there is just about 1.2 mA peak current through the triac in the second circuit I posted. I don't think that is too much, or is it?
Title: Re: Dimmer and correct circuit
Post by: wvmarle on Jan 11, 2019, 06:19 pm
That's because you have a 300k resistor where your load should go. A halfway decent triac can do a few amps at least.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 06:39 pm
That's because you have a 300k resistor where your load should go. A halfway decent triac can do a few amps at least.
Will the circuit be correct if I increase the resistor to the opto? 20k, for instance?
Title: Re: Dimmer and correct circuit
Post by: wvmarle on Jan 11, 2019, 06:53 pm
No.

Did you actually read (and make sure you understand the circuit in) the tutorial I linked to? Or one of the thousands of other tutorials about the subject...
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 07:05 pm
No.

Did you actually read (and make sure you understand the circuit in) the tutorial I linked to? Or one of the thousands of other tutorials about the subject...
Yes, I read it very thoroughly. I didn't mean to offend you. I am sorry.
Title: Re: Dimmer and correct circuit
Post by: wvmarle on Jan 11, 2019, 07:36 pm
Your circuits don't make sense. It's not even a copy of what's posted in that tutorial.
That particular resistor is where normally your load would be.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 11, 2019, 07:40 pm
Your circuits don't make sense. It's not even a copy of what's posted in that tutorial.
That particular resistor is where normally your load would be.
Maybe we are talking about different things. The resistor that's where the load would be, I put it there in order to simulate the load in LTspice. So it is the load.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 12, 2019, 12:44 pm
Could someone please take a look at the image I attached. Without the ZC, what is the difference between this and the circuit in the page I linked to? I really can't see it. Maybe I'm just too stupid for this.
Title: Re: Dimmer and correct circuit
Post by: TomGeorge on Jan 12, 2019, 12:48 pm
Hi,
What load do you want to switch with the Triac?

Thanks.. Tom.. :)
Title: Re: Dimmer and correct circuit
Post by: wvmarle on Jan 12, 2019, 02:57 pm
That looks good - except for that ground connection on the mains voltage side. That has to go.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 12, 2019, 11:44 pm
That looks good - except for that ground connection on the mains voltage side. That has to go.
Super! :) The difference between this circuit and my previous one is that I replaced the resistor with the word "Load". I had the resistor there to simulate load (fail on my side). Same with ground, so that will be removed.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 12, 2019, 11:49 pm
Hi,
What load do you want to switch with the Triac?

Thanks.. Tom.. :)
Hi, Tom :)
Halogen and incandescent loads. I would like to dim LED bulbs as well, if possible, but I don't know much about that. Can it be done the same way, with the same circuit? I know they have some inbuilt circuitry themselves, so that might complicate things.
Title: Re: Dimmer and correct circuit
Post by: wvmarle on Jan 13, 2019, 02:18 am
Incandescents: no problem.
LEDs: may or may not work depending on how the LED's circuit reacts to the load.
Halogen: normally has a transformer, making it a HIGHLY inductive load, and that's a problem, unless you connect this on the halogen (low voltage) side of the transformer. You'd have to adapt the circuit, especially the zero crossing, to the lower voltage.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 13, 2019, 03:27 am
Incandescents: no problem.
LEDs: may or may not work depending on how the LED's circuit reacts to the load.
Halogen: normally has a transformer, making it a HIGHLY inductive load, and that's a problem, unless you connect this on the halogen (low voltage) side of the transformer. You'd have to adapt the circuit, especially the zero crossing, to the lower voltage.

Thank you for the info. Do you know how dimmers can work with both Incandescent and Halogen lights and still be wired the same way? I have a dimmer here where it says it works with both.
Title: Re: Dimmer and correct circuit
Post by: Paul__B on Jan 13, 2019, 08:10 am
Thank you for the info. Do you know how dimmers can work with both Incandescent and Halogen lights and still be wired the same way? I have a dimmer here where it says it works with both.
This is the most mind-bending discussion I have seen here for some time!

A Halogen lamp with a transformer is essentially a resistive load.  The only inductance of concern is the leakage inductance of the transformer.  The common series-wired two wire dimmer does not even notice the difference.  A microprocessor-controlled phase controlled dimmer should work just as well.

If however you have halogen down-lights, the best thing is to replace them with LED luminaires - much more efficient means less heating; you can get dimmable ones which will work just fine with phase dimming if they are so specified.

A zero-crossing optocoupler such as the MOC3041 completely prevents phase control for dimming.
Title: Re: Dimmer and correct circuit
Post by: PelleS on Jan 13, 2019, 02:43 pm
This is the most mind-bending discussion I have seen here for some time!

A Halogen lamp with a transformer is essentially a resistive load.  The only inductance of concern is the leakage inductance of the transformer.  The common series-wired two wire dimmer does not even notice the difference.  A microprocessor-controlled phase controlled dimmer should work just as well.

If however you have halogen down-lights, the best thing is to replace them with LED luminaires - much more efficient means less heating; you can get dimmable ones which will work just fine with phase dimming if they are so specified.

A zero-crossing optocoupler such as the MOC3041 completely prevents phase control for dimming.
I guess "mind-bending" in this setting is negative? :D I know I can't use a zero-crossing opto as soon as the zero-crossing circuit was being mentioned. I probably should have said that.

I do think most people here are replacing the halogen ones for led. I didn't know phase control dimming could be used for leds as well.
Title: Re: Dimmer and correct circuit
Post by: Paul__B on Jan 13, 2019, 10:20 pm
I didn't know phase control dimming could be used for leds as well.
"Mind-bending" in terms of the zero crossing matter, dodgy circuits dredged from who-knows-where and somewhat misguided attempts to use circuit simulation software.  :smiley-eek:

There are better and worse approaches to the circuits in LED luminaires.  If they use simple capacitive "ballasts", then their power factor is bad and phase control becomes very difficult; they are generally labelled as "non-dimmable".

If they use a switchmode regulator with a reservoir capacitor (like a computer PSU), then that capacitor charging to the peak voltage resists phase control and again, the power factor is undesirable.

The best design for both dimmability and power factor, is a switchmode regulator without a reservoir capacitor.  This simply makes do with the instant voltage at each point in the waveform and behaves more like a resistive load.  And leaving out the capacitor is actually cheaper.

I have not yet dissected any LED bulbs (if for one, because they rarely "burn out"!) so I cannot say what circuit they are using.  I do however have two failed LED downlights - non-dimmable - awaiting my attack.  They have this pattern of lighting almost fully, dimming progressively out, waiting and then "popping" back on.  Presumably heat cycling of a switchmode converter IC.  That they failed within two years in service is most disappointing.