Background color
Background image
Border Color
Font Type
Font Size
  1. [1]: Motivation
    AC loads are everywhere around us because at least home appliances are supplied with the mains power. Therefore, we always face the situations that we want to have full control (dimming) over an AC load such as a lamp, a motor, vacuum cleaner … etc.
    We should know that controlling an AC load is not identical with a DC load. So we should use different electronic circuits for this purpose.

    [2]: Schematics
    The figure-1 shows the mains sinusoidal wave with the frequency of 50Hz (sometimes 60Hz). To build a dimmer, the zero crossing points (the points where the wave changes its polarity) are important. To grab these points, we have to use a zero crossing detector. The figure-2 demonstrates the schematic diagram of the whole circuit.

    Figure-1, Mains sine wave (Green arrows show the zero crossing points)

    Figure-2, Schematic diagram of the digital AC dimmer

    [3]: Circuit Analysis and Introducing Components
    R1, R2, IC1, D1, and C3 build the zero crossing detector circuit. It is designed to make proper isolation (optically) with the mains voltage. So we can expect to get a noise-free signal which can be safely connected to the Arduino I/Os. The figure-3 demonstrates the zero-crossing detector output signal (Pin-4 of the IC1). According to the TLP521-1 datasheet: “The TOSHIBA TLP521-1, -2 and -4 consist of a phototransistor optically coupled to a gallium arsenide infrared emitting diode.” For sure you can use similar optocouplers as well, but I use this part for other designs as well and it does the job quite well.

    Figure-3, The output signal of the zero crossing detector circuit

    So as it is clear, we gonna use the zero crossing pulse as a trigger for the main controlling circuit. Exactly after a trigger (a zero cross), in a simple term, we have to decide how much power we want to deliver. It is easier to understand by demonstrating the Arduino code and output wave later.

    IC3 is a BT138 Triac. The load is in series with the Triac and the AC line, so the Triac determine the amount of power that should be delivered to the load. According to the BT138 datasheet: “Planar passivated four quadrant Triac in a SOT78 (TO-220AB) plastic package intended for use in applications requiring high bidirectional transient and blocking voltage capability and high thermal cycling performance. Typical applications include motor control, industrial and domestic lighting, heating and static switching.”

    [3-1]: Satefy Warning

    Attention: the mounting base of the BT138 Triac (by default it is used to attach a heatsink) is connected to the Pin-2. It means you should never touch the heatsink or screw it to a metal enclosure!

    R4, R5, and C2 implement a snubber circuit [3] for the IC2 and C1 and R7 make a snubber circuit for IC3. These parts help the device to be compatible with a variety of loads, such as inductive loads.

    IC2 is an Opto-Triac component which makes proper galvanic isolation between the digital side and the AC line. The selected part number is MOC3021. You can use similar part numbers also, but be careful not to use the parts with embedded zero crossing detector. Those parts are useful for switching the AC loads (ON/OFF), not for dimming.

    [3-2]: PCB design
    I did not have the footprint and schematic symbols of the IC1, IC2, and IC3. So instead of designing the libraries from scratch and wasting the time, I used the free SamacSys Altium Designer plugin to install the libraries directly in the document. The figure-4 shows the selected parts in the plugin’s UI.

    Figure-4, The selected schematic symbol and footprint libraries for IC1, IC2, and IC3
    The figure-5 shows the designed PCB layout. The AC lines which are supposed to carry a high amount of current have drawn thicker and double sided. In addition, both track sides have reinforced by some Vias to reduce the resistance and increase the current transmission capability of the PCB track.

    Figure-5, The PCB layout of the AC dimmer

    [4]: Circuit Assembly
    All components are Dip. Therefore it is easy for everyone to solder the components quickly and use the circuit as a module. R2, R4, R5, and R7 are 1W resistors. R1 are R6 are 1/4W. C1 and C2 can be selected from MKT or Polyester type capacitors, but make sure that they are at least 400V rated. The 250V rated capacitors seem to be okay, but 250V is a bit close to the input voltage boundaries. Therefore 400V is a wise selection for the capacitors’ voltages. C1 has a 10mm pitch size. This number is 10.5mm for the C2. K1 is an MKDSN connector with 5.08mm pitch size (MKDSN-2.5/4-5.08). P1 is a traditional 4 pins male header connector.

    The PCB board has a cutout under the IC1 and IC2. It provides better galvanic isolation between two sections of the circuit board.

    The figure-6 demonstrates the first prototype of the circuit board. The provided PCB layout and Gerber file in this article are the final versions [8].

    The mounted heatsink is just for a short test. For an actual long term use, you must use a bigger heatsink. The location of IC3 (near the PCB border) makes the heatsink installation task much easier.

    Figure-6, The first prototype of the circuit
    [5]: Code

    Now it's the time to connect the circuit to an Arduino board and control the AC load. I selected an Arduino Nano which introduces enough resources for this project, but you can use other boards as well. A sample Arduino code for the AC dimmer is as follows:

    Code (Text):
    1. const byte ZCP = 2;
    2. const unsigned int dim = 9000;
    4. void setup() {
    6.   pinMode(ZCP, INPUT);
    7.   pinMode(10, OUTPUT);
    8.   digitalWrite(10, LOW);
    9. }
    11. void loop() {
    13.   if (digitalRead(ZCP) == HIGH)
    14.     Zero_Cross();
    16. }
    18. void Zero_Cross() {
    20.   digitalWrite(10, LOW);
    21.   delayMicroseconds(dim);
    22.   digitalWrite(10, HIGH);
    24. }
    It is not necessary to write complex code to test our dimmer. There are two methods to sniff the zero crossing detector pulses: polling and interrupt. In the first attempt, I fixed this using an interrupt, but I faced the load flickering in some situations. The flickering is an annoying situation which happens with some dimmers. The reason is the wrong timing. As I mentioned earlier, the zero crossing points are quite important and any random time-shift will cause instability. Using an interrupt was introducing some jitter, and this jitter caused flickering in some dimmer settings. Therefore I switched the method to polling (lines 11 to 16).

    All we have to do is to change the Triac off-time in both cycles, so the “dim” variable defines the transferred power to the load. As a starting point, I set the dimmer to the middle. That means for a duration of 5mS, the Triac is kept OFF. So let’s confirm our theory in practice by examining the load waveform.

    [6]: Testing

    Be careful: never connect your oscilloscope probe directly to the mains. The probe’s ground connection can build a closed loop with the mains terminal and blow up everything in the path, including your circuit, probe or oscilloscope or even yourself!

    There are several solutions to overcome this, such as using an isolator or using a differential probe … etc. I used an ordinary transformer (220V to 12V) and verified the output just by using this. Please check the figure-7 for the connections. I have to note that the load must be connected, otherwise you won’t see the true waveform.

    Figure-7, Probing the load and required connections

    The figure-8 shows the output waveform (50%). You can expand the code and add two buttons to increase and decrease the output power. You can develop the code and modify it with your own Arduino board and your specific needs.

    Figure-8, The output waveform in 50% of the power (dim = 5000)
    [7]: References
    Main source (You can download the Gerber and NC-Drill also):
  2. An FM transmitter is one of the most popular devices between electronic hobbyist, professionals and even non-technical people. In this article, we gonna learn to how to build an easy, stable and digitally controllable FM transmitter.

    For this design, I have selected the VMR6512 module which truly is like a full RF block on a chip!. It eliminates all essential circuitry for a basic FM transmitter such as inductors and trimmers. According to the VMR6512 datasheet: “VMR6512 is a highly integrated FM audio signal transmitter module. It integrates advanced digital signal processor (DSP), frequency synthesizer、RF power amplifier and matching network. So it can realize FM audio modulation without any external components. VMR6512 can also achieve broadcast quality sound by using digital pre-emphasis, digital filtering, automatic gain control, and digital frequency control technologies.“

    The operation frequency range is between 88.0MHz to 108.0MHz. the figure-1 shows the schematic diagram of the transmitter.

    Figure-1, The schematic diagram of the FM transmitter

    The LED D1 shows a proper power supply connection to the circuit(3.3V). The capacitors C1 and C2 reduce the supply noise (0805 packages). Three tactile switches (push button) have been used in the design. The SW1 resets the module, SW3 increases the frequency (+0.1MHz) and SW2 is used to decrease the frequency (-0.1MHz).

    The figure-2 shows a view of the top layer and figure-3 shows a view of the bottom layer of the PCB board. The figure-4 shows a 3D view of the assembled board.

    Figure-2, A view of the PCB’s top layer

    Figure-3, A view of the PCB’s bottom layer

    Figure-4, A 3D view of the assembled board

    I used an SMA connector for the P2 (Antenna connection). Therefore you can either use it to connect an antenna or use it to connect the output to an RF amplifier. Before increasing the power of your transmitter, check the regulation and broadcasting rules of your country of residence.

    You can download the Gerber and NC-Drill files from the reference.

    Gerber and NC-Drill files:
  3. An obstacle detection unit is an essential part of a variety of projects, such as robotics and security applications. The infrared sensors are widely used for these types of applications. The main drawback of some circuit designs is that the detection units are sensitive to the outside lights and react unstable or noisy.

    In this project, we selected a proper IR receiving component and designed the circuit in a way to act as stable as possible. Also, you can adjust the sensitivity of the sensor to detect the obstacles located near or far from the sensor.

    You can examine the schematic diagram in the figure-1. The famous 555 chip is used to produce a 38KHz square wave. Frequency of the wave can be adjusted by turning the R5 potentiometer. The receiver side uses a TSOP1738 (HS0038) IR receiver module. It typically reacts to the 38KHz IR pulse and activates its output.


    Schematic diagram of the IR obstacle detector

    According to the TSOP1738 datasheet: “The TSOP17XX– series are miniaturized receivers for infrared remote control systems. PIN diode and preamplifier are assembled on lead frame, the epoxy package is designed as IR filter. The demodulated output signal can directly be decoded by a microprocessor. TSOP17XX is the standard IR remote control receiver series, supporting all major transmission codes.”

    So these features, especially its embedded IR filter, make it suitable for our application. The figure-2 shows the designed PCB for the circuit. The PCB board mostly designed by SMD components which only take a small 3.2cm*1.8cm board size.


    PCB board design of the IR obstacle detection circuit

    As you can see on the PCB silkscreen, you must install an isolation barrier between the IR diode and the receiver. The two components are installed next to each other, so you have to make sure that the receiver only reacts to the “front-reflected” IR light.

    If you could not find something to put between the sensors, just cover the 5mm IR diode with a black heat-shrink and allow the light to exit just from the front.

    The figure-3 demonstrate a 3D view of the assembled board. You can inspect the installed components.

    A 3D view of the PCB board

    The LED D3 shows the correct power connection and the LED D1 lights up when an obstacle is located in the sensor detection range.

    The R1 potentiometer determines the transmission power which of course affects the detection range. The potentiometer R5 adjust the frequency. If you have an oscilloscope, you should be able to see a signal like the figure-4 at the U1, pin-3 (output). Adjust the R5 to read 38KHz. Actually, the R5 allows you to install a wide range of similar IR receivers that might operate with different frequencies.

    The 38KHz signal at the 555’s pin-3

    A 3-pins male pin-header connects the board to an external circuit. You must connect the +5V supply to the + terminal and the ground to the – terminal. The “S” output acts as an active low trigger. It means when the sensor detects an object, the “S” output will be connected to the ground (as the LED D3 lights up). The SMD package of the SMD components is 0805.

    You can download the PDF schematic, Gerber and NC-Drill files from the reference.

  4. Almost in any circuit design, building at least one regulation stage is necessary. Two power supply design options are available, which are linear and switching. The linear regulators are easy to build but inefficient, especially when there is a high difference between the input voltage and the desired output voltage. Also, by increasing the regulator output current, the efficiency also decreases. Both of these problems are easily visible in terms of heat dissipation.

    The switching regulators are very efficient but improper design and filtering could inject some amount of noise to the regulator’s output.

    There are many switching design options, but the TI company introduced a good chip which I will discuss it in this article. According to the datasheet: “The TPS54331 device is a 28-V, 3-A nonsynchronous buck converter that integrates a low RDS(on) high-side MOSFET. To increase efficiency at light loads, a pulse skipping Eco-mode feature is automatically activated. Furthermore, the 1-μA shutdown supply-current allows the device to be used in battery-powered applications. Current mode control with internal slope compensation simplifies the external compensation calculations and reduces component count while allowing the use of ceramic output capacitors.”

    The output voltage of the regulator even could be as low as 0.8V. Also, it introduces a high switching frequency (570KHz), which is good. The figure-1 shows the efficiency chart in relation to the output current and input voltage.

    Efficiency chart, the output voltage has fixed at 3.3V​

    The chart clearly shows that the highest efficiency (near 95%) satisfies when the input voltage is around 5V (the output has fixed at 3.3V) and the output current somewhere between 100mA and 1A. in most digital circuits, the input voltage is 12V, therefore the efficiency parameter would be something around 88% (1A current).

    The datasheet of the TPS54331 provided a table which defines the output voltage by modifying two resistor values, but in this article, I made the output variable. So you can adjust the output by turning a multiturn potentiometer. The figure-2 shows the schematic diagram. By turning the VR1 potentiometer, the output voltage would change.


    Schematic diagram of the switching voltage converter
    The schematic has drawn by the Altium designer, but you are not bounded to use this software. Just look at the schematic and re-design it in your own favorite CAD software.

    Be careful to select suitable voltages for the input and output capacitors. In the schematic, I defined the input to be 12V, and therefore the output would not exceed 12V. try to select high-quality XR5 capacitors for the output (C2, C3, and C4). Try to keep the component pins short, preferably use the SMD component and place them as much as close to the chip. Use two layers PCB and allocate one layer completely for the ground.

    If you desire that your design complies with the EMC rules, please make sure that you connect the ground of the regulator circuit and your main circuit at only one point. The switching currents of the switching power supply should not share a common ground with the rest of the circuit.

    If you use a single PCB for all parts of the circuit, keep the power unit far from the sensitive blocks such as analog circuits.

    You can download the Altium Schematic file from the reference.

  5. FM transmitters/receivers are one of the top favorite circuits of every electronic designer. An FM transmitter is one of the first circuits that an electronic enthusiast decides to build.

    For this purpose, instead of using discrete components and building one of the traditional transmitter circuits, let’s use the Si4712/13 chip. According to the Si4712/13 datasheet: “The Si4712/13 is the industry's first 100% CMOS FM radio transmitter with an integrated receiver to measure received signal strength. The device leverages Silicon Labs’ highly successful and proven Si4700/01 FM receiver and offers unmatched integration and performance allowing FM transmit to be added to any portable device by using a single chip. The Si4713 supports the European Radio Data System (RDS) and the US Radio Broadcast Data System (RBDS) standards including all the symbol encoding, block synchronization, and error correction functions.”


    The chip supply can be selected in a range between 2.7V to 5.5V. Therefore if you plan to connect it to a 3.3V microcontroller, you can supply the chip and design your circuit with the 3.3V supply, otherwise power it with a 5V supply to be applicable for the 5V logic microcontrollers. The connection interface of the chip with the output is the I2C. Therefore a proper supply voltage selection can prevent future problems with the logic voltage match, for example, a 3.3V microcontroller and the 5V I2C bus.

    I use the Altium designer to design schematics and PCBs. I did not have the footprint or schematic symbol of the Si4712/13 chip, therefore, as usual, I used the Samacsys search engine to quickly find and use the component.


    Anyway, I selected the 3.3V logic and prepared a basic schematic diagram. You can download and modify it based on your needs. If you have selected a 5V microcontroller, some small modifications should be made in the circuit, mainly to the I2C connection. I'll try to cover the logic level conversion in a different article.


    A Si4712/13 Arduino library is also available which you can easily play with it and transmit the data. You can also measure the received signal strength.

    “The Si4713 supports the European Radio Data System (RDS) and the US Radio Broadcast Data System (RBDS) standards including all the symbol encoding, block synchronization, and error correction functions. Using this feature, the Si4713 enables data such as artist name and song title to be transmitted to an RDS/RBDS receiver.”

    We can make many cool projects out of this, isn’t it!