Pages: [1]   Go Down
Author Topic: Drive a 230VAC Lamp from a TRIAC with Arduino  (Read 874 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi to all, i've read something about TRIAC and i tried to drive a 230VAC Lamp with it in order to change the intensity with arduino.
First of all i have tried a circuit with only a 5V battery with a variable resistance connected to the gate of the TRIAC.
It worked well. From 4 to 5 V the Lamp light intensity changed a lot.
After that, i've tried to use an Atmega328U with a minimal circuit and i wrote this simple code:

  analogWrite(gatePin, val); //100-255
  delay(30);
  val = val+sign;
  if(val == 255)
    delay(3000);
  if(val == 255 || val == 100)
    sign = -sign;

to have the gatePin fluctuating between about 4 and 5V.
When i connected the 230VAC, the gate of the triac went from 4V to about 1-2V and the Atmega became hot (it burned  smiley-confuse).
So i've tried to add a diode of non return (As you can see in the attachment).
When i connected the 230VAC the gate of the triac jumped to an high value of voltage (i think over 20V) so i disconnected immediatly the main source.

What am i doing wrong?

Thank you


* Foto 09-07-13 21 45 18.jpg (2977.41 KB, 3264x2448 - viewed 63 times.)
Logged

Pays de la betise
Offline Offline
Sr. Member
****
Karma: 3
Posts: 417
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

you have to isolate your arduino from the triac by using an optocoupler like MOC3020.
I made some 230vAC lamp controls, but always with a zero detection circuit (TLP620 AC optocoupler): http://forum.arduino.cc/index.php/topic,33490.0.html (sorry, in french)

Gromain
Logged

"pour résoudre un gros problème, il est souvent plus facile de le diviser en petits problèmes élémentaires..."

projet domotique xPLDuino
IRC: freenode #xplduino

Offline Offline
Edison Member
*
Karma: 20
Posts: 2107
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if it got hot the pin may have damaged..

use a 1k resistor to the triac.... that should do it, but for safety reasons it's better to use an opto
isolator that way there's no direct path from the 240v supply to the arduino or you..

(but if you wanted to anyway, 1k resistor out to your gate (with the diode if that's all you got), that will stop the arduino getting hot)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks to all. I'll try an optocoupler smiley-wink
Daniele
Logged

Pages: [1]   Go Up
Jump to: