This section of the code is heart of the project. Being able to detect each zero crossings and to interrupt the program appropriately is important. The read on the interrupt pin will be HIGH and drop to LOW when the sine wave crosses zero and rise back up to HIGH. On that rising edge, the program will be interrupted and will jump to the interrupt handler. Within the interrupt handler, the potentiometer analog input will be use to calculate the appropriate delay time before sending a pulse to the driver to allow the current through.
The heart of this circuit is the area between the full bridge rectifier and the TRIAC driver. This section of the circuit allows the user to find the zero crossings of the AC signal. The full bridge rectifier creates a fully rectified wave that inputs to an EL817 (photocoupler). This photocoupler sends an input to the Arduino that will trigger an interrupt at the zero crossing. A pulse is generated from the Arduino which is sent to the TRIAC driver which then sends a pulse to the gate of the main TRIAC which allows current to flow through. The potentiometer serves as a means of varying the amount of power sent to the connected load, in this case a blender. Depending on the position of the potentiometer, a proportional delay is implemented before the pulse is sent to the driver which translates to a change in motor speed on the blender.
The digital dimmer circuit created in this project is a more precise version of what most people have on the wall in their homes. Dimmer circuits utilize a device called a triac. A traic is a special thyristor that allows for current control over both halves of the AC waveform. The digital dimmer takes the analog input from the potentiometer and through the user’s code maps it to an output to a triac driver. Based on this input the driver’s output will open the gate of the triac which controls the dimming of the circuit. However, sending just any output to the driver can result is very inconsistent results. Using a full bridge rectifier coupled with a photocoupler, creates another input to the Arduino that maps all zero crossings. Using these inputs as well as delays, an output that times to the zero crossings of the AC wave allows for the user to create a typical dimming circuit that goes from zero to max. However, changing the timing of the outputs call allow for very precise and unique ways to control the output of the circuit.