Basic schematic.


Read this Safety Warning and Disclaimer

Using Hardware Interrupts to Control A.C. Power

The purpose of this project is to demonstrate the use of a hardware interrupt to control AC power levels to a load such as a lamp or small AC motor. Also see Hardware Interrupts Demo and Tutorial for ATMEGA168/Arduino


In an AC sine wave the voltage drops to zero at 180 and 360 degrees.
By triggering on a triac or SCR at critical points in between we control power output
to a load. The longer the delay on the trigger pulse, the lower the power output.


This illustrates to process with full-wave unfiltered D.C. but the process is identical with A.C.

For this experiment one can use 24 volts A.C. and a 24 volt lamp. If the circuit is wired properly when the
control is adjusted the circuit should act as a lamp dimmer or speed control for a motor.
If the lamp dims as the control is adjusted clock-wise reverse the two outer connections on R3.

Uses

A circuit such as this can can do far more than a $3 lamp dimmer. By connecting a thermistor to measure temperature (or an appropriate thermocouple circuit) to one of the analog inputs we have a proportional heat controller saving energy costs. We could control a heating element or the speed of a blower fan proportional to temperature. By connecting a photocell we could control light intensity of lamps in proportion to natural light, saving energy costs with say sky lights. I use a version of this on my water heater to control a narrow temperature range.

In a proportional controller for heat as an example as the desired temperature is reached, power input is reduced automatically (delaying the firing point on the triac) and enough energy is added to maintain temperature. In a cheap mechanical thermostat power is all on or all off producing overshoot and undershoot. This is unacceptable in many industrial applications.


Sample circuit for photocell or thermistor
connection to ADC (analog to digital converter) sensor pin.





// LED must be connected between digital pin and ground

#define triac_control 5
#define powerIndicator 12 // indicator
#define sensorPin 0 // potentiometer 
#define irq_Pin 2 
#define powerOn 4

// when using values in the main routine and IRQ routine must be volatile value

volatile byte flag_bit1 = LOW; // declare IRQ flag
int analogValue = 0;

// HIGH = 1, LOW = 0

void setup()  {
  pinMode(triac_control, OUTPUT);  
  pinMode(powerIndicator, OUTPUT);
  digitalWrite(triac_control, 0); // LED off
  digitalWrite(powerIndicator, 0); // LED off
  pinMode(irq_Pin, INPUT);
  pinMode(powerOn, INPUT);
  digitalWrite(irq_Pin, 1); // pull up on
  digitalWrite(powerOn, 1); // pull up on
  attachInterrupt(0, flag1, FALLING);  // interrupt 0 digital pin 2 connected ZC circuit

}


void loop() {

  if (!digitalRead(powerOn)) digitalWrite(powerIndicator, 1); 
  else digitalWrite(powerIndicator, 0);  
  if ((flag_bit1 == 1) && (digitalRead(powerOn)== 0)) {
    analogValue = analogRead(sensorPin);
    delayMicroseconds(analogValue * 7);
    digitalWrite(triac_control, 1); //triac on
    delayMicroseconds(100); 
    digitalWrite(triac_control, 0);  //triac off
    flag_bit1 = 0; // clear flag
  } 


} // end loop


void flag1() // set bit
{
  flag_bit1 = 1; 
} 




----------------------------------------------------------------

switch connection
Bare Bones Kit from Modern Device Company.
This is an example of what is out there, most do the same thing.
This doesn't include the DS1307, switches, etc.

atmega168/arduino in connections

[ My Homepage ] [ Electronics Mainpage ]

ATMEGA168 Arduino Micro Controller

For more technical details on this see ATMEGA168 Arduino Micro Controller Projects


[ Home ] [ Electronics ] [ Religion 1 ] [ Religion 2 ]
[ Racism ] [ Environmentalism as Religion ]
Guestbook Archive
E-Mail
Visitors since March 2002
counter


google
Search WWW Search www.sullivan-county.com