AC Dimming and AC Motor Speed Control How to With Arduino/NodeMCU

by taste_the_code in Circuits > Arduino

14622 Views, 13 Favorites, 0 Comments

AC Dimming and AC Motor Speed Control How to With Arduino/NodeMCU

VID_20210604_200913.00_07_05_01.Still009.jpg
AC Dimming and AC Motor Speed Control How To with Arduino/NodeMCU

Controlling AC appliances with Arduino always comes with a challenge and when tr requirement is to control the speed of an AC motor or dim an AC light, the challenge is even greater.

In this Instructable, I'm going through the basics of achieving such AC control with the help of a triac and connecting a dimming module to an Arduino or NodeMCU board.

This post is sponsored by PCBWay. Get your custom PCBs, SMD stencils, or assembly services professionally done for cheap in less than 24 hours.
PCBWay also offers sponsorships for students and hobbyists where you can get your projects built for free.

Supplies

How to Achieve AC Dimming

VID_20210604_200913.00_01_43_12.Still002.jpg
VID_20210604_200913.00_02_10_25.Still003.jpg

To be able to successfully provide AC dimming and be able to provide sufficient current through the load on the output we use a technique called phase angle control.

With phase angle control, the overall minimum and maximums of the input voltage stay the same on the output but we terminate the output for part of the sinewave.

So for example, if we want to have the output at 50%, we need a circuit that can cut the first half of the positive part of the sinewave by staying off, and then turn it on for the second half. Then on the negative side, the same need to repeat, and the output should stay off for the first half, and turn on for the second.

Being able to precisely turn off the output based on the parts of the sinewave requires a signal from which we can know when the sinewave is at its zero-crossing point so we can then utilize timers and turn on the output at the right time.

Generating the Zero-crossing Signal

VID_20210604_200913.00_13_38_04.Still014.jpg

Depending on where you live the frequency of the AC mains voltage is either 50 or 60 Hertz. If we plot how that AC voltage changes over time, we will see that for any given cycle, the voltage starts from 0, goes positive to the peak, crosses 0 again and it then repeats the same cycle but now in negative.

Our signal needs to be isolated from the mains so we can use an optocoupler (LED with a receiver in a special package) that we can then connect across the mains with some resistors and a bridge rectifier.

The bridge rectifier will flip the negative side of the sinewave so we can ensure that the LED will only see positive voltage applied and be lit for the two halves of each cycle.

Connecting the AC Dimmer Module

VID_20210604_200913.00_03_17_24.Still004.jpg
VID_20210604_200913.00_04_05_20.Still007.jpg
VID_20210604_200913.00_04_23_27.Still008.jpg
VID_20210604_200913.00_11_33_11.Still013.jpg
VID_20210604_200913.00_00_07_09.Still001.jpg

The connections on the dimmer module are separated between the high and low voltage sides, where on the high voltage side we have two screw terminals.

On one of the terminals, we connect the AC input and on the other, we connect the AC load.

On the low voltage side, we have 4 pins. On two of them, we connect VCC and ground, the third one is the output zero-crossing signal generated from the module and the fourth is the PWM signal that we use to control the on-time of the triac.

It is important to note that it is absolutely necessary to connect the zero-crossing pin to an interrupt pin on the microcontroller so a proper signal can be generated. Depending on the microcontroller this can be various pins but some microcontrollers like the Uno have limitations where this can only be pin 2.

In my example, I use the NodeMCU board which can have multiple interrupts and I chose to use pin D2.

Programming the Arduino

VID_20210604_200913.00_09_14_29.Still012.jpg

To control the Arduino, I've used the official library provided by the AC dimmer manufacturer that can be found here.

The library provides several examples and I've used the one where the dim amount is controlled by specifying the percentage from the serial monitor as integers.

The full code is also attached to this step for your reference.

Testing the Circuit and Next Steps

VID_20210604_200913.00_07_16_09.Still011.jpg
VID_20210604_200913.00_07_42_06.Still010.jpg

The circuit worked like charm and I was able to dim both the light I had attached and the AC fan that I later plan to use on my pellet burner build.

Since the fan control on the burner is essential in providing the right amount of air to sustain the fire, I plan to build a special controller for it with Attiny85 and the dimmer module that will then communicate with the main controller through I2C as a slave device.

If that is something that you think is interesting, then be sure to subscribe to my YouTube channel so you don't miss it.

Thank you for reading and I'll see you in the next one.