AC Dimmer Module with Arduino | Phase-Angle Control for AC Load Dimming | Proteus Simulation

An AC dimmer module is typically used to control the brightness of an AC light bulb or other AC-powered devices using an Arduino. These modules often use a technique called phase-cut dimming to control the amount of power delivered to the load. Here's a breakdown of the key concepts involved:

Phase-Angle Control for AC Load Dimming

Introduction:

Phase-angle control, also known as phase cutting or leading edge dimming, is a fundamental technique for controlling the power delivered to AC loads. This technique involves delaying the activation of a triac, a powerful switch for AC power, after each zero-crossing point of the AC waveform. This delay effectively "cuts off" a portion of the sinusoidal voltage, resulting in a decrease in the average power delivered to the load. This decrease in power translates to dimming of lights, reduction in motor speed, or control of other AC devices.
AC Dimmer Module with Arduino


1. AC Waveform and Zero-Crossing:

The AC waveform is a sinusoidal wave that oscillates back and forth 50 or 60 times per second depending on your location. Each cycle of the wave has two zero-crossing points, where the voltage passes through zero, neither positive nor negative. These points mark the transitions between positive and negative half-cycles of the waveform.

2. Triac and its Activation:

A triac is a bidirectional switch that can control the flow of AC current. However, it does not turn on automatically. It requires a trigger signal to initiate conduction. This trigger signal can be a voltage pulse at the gate terminal of the triac.

3. Phase-Angle Control and Cut-Off Portion:

Phase-angle control involves precisely delaying the trigger signal applied to the triac after each zero-crossing of the AC waveform. This delay can be expressed as a phase angle, measured in degrees. The longer the delay (higher phase angle), the greater the portion of the sine wave that is cut off before the triac starts conducting.

Dimmer Circuit 220 VAC

4. Power Reduction and Dimming:

By cutting off a portion of the AC wave, the average power delivered to the load is reduced. This is because the triac is only conducting for a shorter duration within each cycle. This reduction in power manifests as dimming in incandescent lights, reduced brightness in fluorescent lamps, or slower speed in motors.

5. Benefits of Phase-Angle Control:

Simple and efficient: It is a straightforward and effective way to control AC power and achieve dimming.
Wide range of applications: It can be used to dim incandescent and fluorescent lights, control motor speed, and regulate power to various other AC loads.
Easy implementation: Phase-angle control circuits are relatively simple to design and implement using microcontrollers like Arduino.

6. Limitations of Phase-Angle Control:

Harmonic distortion: Cutting off portions of the AC wave can create harmonic distortion, which is the presence of unwanted frequencies in the power line. This can interfere with other electronic devices connected to the same power grid.
EMI/RFI noise: The switching action of the triac can generate electromagnetic interference (EMI) and radio frequency interference (RFI). This noise can potentially affect sensitive electronic devices.
Not suitable for all loads: Phase-angle control is not suitable for all types of loads, especially those with inductive or capacitive components. These loads may require different control methods to achieve desired performance.

7. Applications:

Phase-angle control is widely used in various applications, including:
Dimmer switches for lights
Variable-speed drives for motors
Fan speed controllers
Power regulators for heating elements

AC Dimmer Module with Arduino

Components:

Arduino Uno
AC Dimmer Module
AC Load (e.g., light bulb, AC motor)
Jumper wires
Breadboard (optional)

Connections:

Connect the VCC pin of the AC dimmer module to the 5V pin of the Arduino.
Connect the GND pin of the AC dimmer module to the GND pin of the Arduino.
Connect the ZC pin of the AC dimmer module to digital pin 2 of the Arduino.
Connect the PWM pin of the AC dimmer module to digital pin 3 of the Arduino.
Connect your AC load to the AC output terminal of the AC dimmer module.
Module Connection



Arduino Code:

This Arduino code is designed to control the brightness of an AC light using phase-cut dimming. It achieves dimming by delaying the firing of a TRIAC  after detecting a zero-crossing of the AC waveform. The zero-crossing detection is done using an interrupt that triggers the zero_crosss_int() function.

/*
 * Created:   mer ago 22 2018
 */

int AC_LOAD = 3;    // Output to Opto Triac pin
int dimming = 128;  // Dimming level (0-128)  0 = ON, 128 = OFF

void setup()
{
  pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
  attachInterrupt(0, zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above
}

//the interrupt function must take no parameters and return nothing
void zero_crosss_int()  //function to be fired at the zero crossing to dim the light
{
  // Firing angle calculation : 1 full 50Hz wave =1/50=20ms
  // Every zerocrossing thus: (50Hz)-> 10ms (1/2 Cycle)
  // For 60Hz => 8.33ms (10.000/120)
  // 10ms=10000us
  // (10000us - 10us) / 128 = 75 (Approx) For 60Hz =>65

  int dimtime = (75*dimming);    // For 60Hz =>65    
  delayMicroseconds(dimtime);    // Wait till firing the TRIAC
  digitalWrite(AC_LOAD, HIGH);   // Fire the TRIAC
  delayMicroseconds(10);         // triac On propogation delay (for 60Hz use 8.33)
  digitalWrite(AC_LOAD, LOW);    // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
}

void loop()  {
  for (int i=5; i <= 128; i++){
    dimming=i;
    delay(10);
   }
}

The provided code is designed to gradually control the dimming level of a light source. Here is the Simulation Result.

Gradually Control of Light


I have modified the code to include preset dimming levels controlled by multiple buttons. Here's an example with four buttons, each associated with a preset dimming level:
  
/*
 * Created:   mer ago 22 2018
 * Modified by: Usman [arduinomagix.blogspot.com] 10-DEC-2023
* Preset Control
 */

int AC_LOAD = 3;              
int zeroCrossInterruptPin = 2;  
int buttonPins[] = {5, 6, 7, 8};  
int dimming = 32;                
int _presets[] = { 40, 70, 100, 128};  

void setup() {
  pinMode(AC_LOAD, OUTPUT);        
  pinMode(zeroCrossInterruptPin, INPUT);  
  attachInterrupt(digitalPinToInterrupt(zeroCrossInterruptPin), zero_crosss_int, RISING);
 
  for (int i = 0; i < 4; i++) {
    pinMode(buttonPins[i], INPUT_PULLUP);
  }
}

void zero_crosss_int() {
  int dimtime = (75 * dimming);    
  delayMicroseconds(dimtime);      
  digitalWrite(AC_LOAD, HIGH);    
  delayMicroseconds(10);          
  digitalWrite(AC_LOAD, LOW);    
}

void loop() {
 
  for (int i = 0; i < 4; i++) {
    if (digitalRead(buttonPins[i]) == LOW) {  
      dimming = _presets[i];
    }
  }
}

Here is the Simulation Result in Proteus:

Preset Control
To control the dimming level using a potentiometer, you can replace the fixed dimming value in your code with a value read from the analog input of a potentiometer. Here's an updated version of code to incorporate a potentiometer:

/*
 * Created:   mer ago 22 2018
 * Modified by: Usman [arduinomagix.blogspot.com] 10-DEC-2023
 * Potentiometer Control
 */

int AC_LOAD = 3;          
int potentiometerPin = A0;  
int dimming = 0;            

void setup() {
  pinMode(AC_LOAD, OUTPUT);  
  attachInterrupt(0, zero_crosss_int, RISING);
}

void zero_crosss_int() {
  int dimtime = (75 * dimming);  
  delayMicroseconds(dimtime);    
  digitalWrite(AC_LOAD, HIGH);    
  delayMicroseconds(10);          
  digitalWrite(AC_LOAD, LOW);      
}

void loop() {
  dimming = map(analogRead(potentiometerPin), 0, 1023, 5, 128);
}

POT Control

Note: ⚠🦺🕱

Working with AC voltages can be dangerous. Please exercise caution and ensure you have the necessary knowledge and safety precautions before attempting any electrical projects. If you are not comfortable working with high voltages, consider seeking assistance from someone with experience.

Proteus Simulation and AC Dimmer Module Library

Take control of your simulated lighting with the AC Dimmer Module Library for Proteus! This Model provides you with the tools to easily design and simulate AC dimming circuit within the Proteus environment.

AC Dimmer Module for Proteus Simulation

To incorporate the AC Dimmer Module into your Proteus simulations, follow these simple steps for downloading and installing the library. The download link is provided below for a swift initiation. Integrating the AC Dimmer Module is a straightforward process, requiring just a few clicks to include it in your circuit. This allows you to observe its behavior alongside other components during the simulation.

1. Click the provided link to download the AC Dimmer Module Library .zip file.
2. Upon extracting the contents, you'll encounter two folders:
- LIB
- MODELS
3. Locate your Proteus library folder on your computer. The default path might differ depending on your Proteus software version. For Proteus 8 Professional, it's likely here:

C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\DATA\LIBRARY

4. Open the Proteus Library Folder and paste the files from the LIB Folder (extracted from the AC Dimmer Module Library Zip file).
5. Navigate to the Proteus Model folder, usually situated in the same directory as the Library Folder:

C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\DATA\MODELS

6. Within the Proteus Model Folder, copy and paste the files from the MODELS folder (also sourced from the AC Dimmer Module Library Zip file).
7. After adding these files, restart Proteus. Now, the AC Dimmer Module is accessible in the Pick Device Window, ready for effortless selection and integration into your simulation projects.

NOTE....⚠⚠⚠

For certain versions of Proteus, you might locate the DATA folder here:
C:\ProgramData\Labcenter Electronics\Proteus 8 Professional\DATA

Keep in mind that sometimes this folder (ProgramData) is hidden, so you may need to unhide it to access the specified location.

Proteus DATA Folder Location

Download the Library: The AC Dimmer Module Library for Proteus is available for download here.

Proteus Library : Proteus AC Dimmer Module
ZIP Password : ArduinoMagix