Chapter 12 - Mains Dimmer

RobotDyn AC Light Dimmer Module, 50/60hz, 220V/110V

  • Voltage (control) : 3.3V - 5V
  • Control current microcontroller: ~10 mA
  • AC voltage: 110/230VAC RMS
  • Maximum AC current: 2A

2 Amp x 230 Volt (Europe) = 460 Watts resistive load
  • Suitable for dimming incandescent lamps
  • Controlling temperature of heating elements
  • Motor speed control
As well as the single module shown, there are also 2 and 4 channel versions available.

The module produces a zero crossover reference signal by detecting the moment when each half cycle voltage drops to zero before reversing polarity.
The triac is an AC switch which is triggered to conduct by a signal on its gate. It acts in a similar way to a latching relay, in that after being triggered it continues to conduct even when the gate trigger is removed, until losing holding power at the next zero crossover.
Thus the gate only needs a trigger switch it on, and it will then stay on for the remainder of  the half cycle.
If the gate is triggered immediately after a zero crossing, the triac would switch on for the full half cycle, giving full output power.
if the gate is not triggered until later in the half cycle, then it would only conduct for the remaining part of the half cycle.
If the gate is triggered at the peak of the half cycle it will only conduct for the last half of the half cycle, thereby reducing the averaged output power by half, even though the peak voltage would still be the same.So it is not the output voltage which is being controlled, it is the averaged output power. This form of averaged 'power' control is mainly for resistive loads.

All the projects in this chapter use the same basic Mains Dimmer module connections as shown below.
Only the actual dimmer module and its connections are necessary, the other items labelled 'Optional' may be used in some of the projects if wished.

Notice the Optional PWM LED which is shown connected to gpio15 as an optional visual pwm power indicator. Don't be tempted to just connect it to the modules PWM pin though, which is not actually a standard pwm variable mark/space ratio input, but instead uses a short trigger pulse generated by Annex which can be precisely delayed relative to the zero crossing sync reference... the greater the delay, the later the triac trigger, the less the resulting power output to the load,  50Hz AC mains is 20ms peak to peak, or 10ms per half-cycle, so the gate trigger delay can vary from 0ms (fully ON) to 10ms (fully OFF). 60Hz AC gate trigger delay can vary from 0ms (fully ON) to 8.33msec (fully OFF).
Note: the trigger cannot be delayed for the entire half-cycle because it has a finite pulse width and the trailing edge of the pulse must also occur during that half-cycle, else it will still be high at the zero crossover and trigger the triac fully On instead of fully Off.
I found that in practice my 50Hz mains was effectively fully Off with a delay of 9500us (9.5ms)
Once the required max and min delay values have been specified with the  DIMMER.LIMITS min, max.instruction (which offers possibility for a reduced working range within the limits), the working range is translated into a DIMMER.BRIGHTNESS  control value between 0 to 100 which is mapped to your specified min and max extremes.

So to summarise in plain English: specify the max delay according to your mains frequency and whether you wish to control all the way down to fully OFF, and specify the min delay which will be 0 if you wish to control up to fully ON, then control your device output power between your specified limits by sending it a brightness value between 0 (min output) to 100 (max output)..