Go Down

Topic: Controlling Triac by Arduino (Read 4016 times) previous topic - next topic

kilian23

Jul 15, 2013, 01:11 pm Last Edit: Jul 23, 2013, 05:09 pm by kilian23 Reason: 1
Hello!

Because I want to avoid messing around with DMX, I decided to dim up and down some 220V lights with a triac instead. I have googled a little bit, but the codes I found so far are not clear to me. I have no schematics either. Can anyone help me out? Maybe someone has done that before. I would need specific parts number, a wiring diagram, and some code. Would be great! AC in my case means 220V, 50Hz, by the way. Dimming means increasing or decreasing the light intensity seamlessly between 0 and 100 percent. If someone has a code how to use values received from a regular 10K analog potentiometer on the input of the Arduino for the Triac's gate - then I can figure out the rest for my own purpose.

Thanks,

Kilian

PaulS

Quote
I have googled a little bit, but the codes I found so far are not clear to me. I have no schematics either. Can anyone help me out?

After googling, you have no schematic? That's hard to believe.

As for the code not being clear, you haven't shown any code or explained what isn't clear. So, clearing it up will be problematic.

Quote
If someone has a code how to use values received from a regular 10K analog potentiometer on the input of the Arduino for the Triac's gate - then I can figure out the rest for my own purpose.

What is the potentiometer to be used for? The analogRead() function already reads the data. How to use that data is up to you.

The amount of dimming you get from a triac is based on the time after the zero-crossing event occurs that you trigger the output. Short time == little dimming. Long time == lots of dimming.
The art of getting good answers lies in asking good questions.

DVDdoug

#2
Jul 15, 2013, 08:31 pm Last Edit: Jul 15, 2013, 08:35 pm by DVDdoug Reason: 1
The amount of dimming you get from a triac is based on the time after the zero-crossing event occurs that you trigger the output. Short time == little dimming. Long time == lots of dimming.
Which means you have to detect the AC zero-crossing.  It's usually easier to detect only the positive-going zero-crossing.   At 50Hz, you know the negative-going zero-crossing is comming 10 milliseconds later. 

I built a dimmer several years ago with a different microcontroller, so I can only give you some hints & concepts -

The most important thing is isolation.  You need to isolate yourself and the Arduino from the AC line voltage.  There are special optoisolators designed to drive TRIACS.  Do NOT get a "zero-crossing" optoisolator.  It won't work as a dimmer.

You'll also need to isolate your phase detection (zero crossing) circuit.   For that, you can use a "regular" optoisolator, or a transformer.  (In my circuit, I used the same transformer that was powering my microcontroller.)

Wikipedia has a little animation showing how a phase-controlled AC dimmer works with a TRIAC.

KeithRB

For my senior project in college I created a slide-projector dimmer. I used a transformer-isolated zero crossing detector that interrupted my CDP1802 microproccesor. It then counted down by a preset amount. small counts - like zero - would make for a bright bulb, while long counts would dim it. I always allowed for a small amount of power in the bulb to decrease in-rush current and lengthen bulb life.

kilian23

OK, thanks for your input.
If I reach more problems or any solutions, I will post them here.
K

joemcder

Check out this instructable:

http://www.instructables.com/id/Arduino-controlled-light-dimmer-The-circuit/

Note the safety warnings.  There MUST be an optoisolator in the circuit.


dc42

You can simplify the circuit in that instructable, by replacing the opto isolator used to detect zero crossings by one that accepts AC input, such as this http://uk.farnell.com/avago-technologies/hcpl-814-w60e/optocoupler-ac-wide-vde/dp/1604640. Then you don't need a bridge rectifier to feed it.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

kilian23

Quote
Check out this instructable:

http://www.instructables.com/id/Arduino-controlled-light-dimmer-The-circuit/

Note the safety warnings.  There MUST be an optoisolator in the circuit.


Thanks a lot!
I'm trying right now, based on your schematics and code.
I'll post my results.

Kilian

kilian23

Quote
You'll also need to isolate your phase detection (zero crossing) circuit.   For that, you can use a "regular" optoisolator, or a transformer.  (In my circuit, I used the same transformer that was powering my microcontroller.)


Yes, I'll use a transformer for isolating the AC power source from the zero detection circuit. For detection, I'm trying with an ET1102 right now.
Let's see...

kilian23

#9
Jul 24, 2013, 07:40 pm Last Edit: Jul 24, 2013, 09:23 pm by kilian23 Reason: 1
First of all: Thank you all very much for your help. I know very well, I'm just one more of those annoying noobs, and the more I appreciate your assistance.

Okay, as promised: results...

I have accomplished to detect the (falling) zero crossings and to drive my triac behind the optocoupler using the code on http://www.instructables.com/id/Arduino-controlled-light-dimmer-The-circuit/step3/Arduino-Controlled-Lightdimmer-The-Software-II/, as provided in the link posted by joe mcd. (For some reason, I could not get the code working that was written by the author personally, as available on http://www.instructables.com/id/Arduino-controlled-light-dimmer-The-circuit/step2/Arduino-controlled-light-dimmer-The-software/.)

At some point, I will post the schematics I'm using (zero-crossing as well as triac unit), as soon as I have all details figured out completely. In my final result, I will use a transformer to galvanically separate the 220V AC power source from the zero detection optocoupler, and I will use the power output from that same transformer (after rectifyer and capacitor) to feed my Arduino. So it will be an all-in-one-box dimmer solution with an Arduino, 220V plug input, 220V dimming outlet, a few indicator LEDs, switches and trimmers, and a connector to my external sensors (ultrasonic range finders SRF02).

Go Up