Controlling the intensity

We have controlled a lot of light now. It's time that we control our fans and other air circulation systems. Whenever we talk about fans or any other air circulation devices, then essentially we are talking about motors. As we have learned earlier, motors are simple devices, which can be controlled every easily using a motor driver. But as you know, back then we were controlling DC motors. DC motors are extremely simple devices. But when we talk about our household appliances, then most of these devices will be working on AC or alternating current. I am assuming that you must be aware of what that is and how it is different from DC.

Now that you know that the motors used in our households are working on AC, you must also think about the fact that their control mechanism will be much different to DC motors. You are right, if you thought so. However, the good thing about electronics is, nothing is really difficult or complicated. The basics are pretty much the same. So, let's see how we can control the speed of the motors in AC supply.

As we have seen earlier, we can simply have a PWM signal given to the DC motor and the motor will run at the speed of the average voltage as a result of the PWM signal. Now, you must be thinking that this can be applied to AC as well. The thing is, yes it can be done if you want to control a light or similar devices, which do not have any major change in the characteristics in case the wave form is distorted. However, when we are talking about any other component, then we come across a big problem. The AC wave form looks like this:

This basically means that the potential is changing periodically. In most of the households, this is 50 times per second. Now, imagine if we have a PWM-controlled device that is switching the circuit that only lets the power supply to pass at certain intervals. Then, the different parts of the sinusoidal waves would be passed on to the final output.

As you can see in the preceding PWM, fortunately the PWM signal has matched with the phase of the AC power; however, due to this, only the positive end of the phase is being transferred to the final output and not the negative end. This will cause a severe problem to our load and there is a very good chance that the appliance that is connected will not work.

We have another example in which the PWM is random and it lets random parts of the wave pass by. In this, we can clearly see that randomly any part of the wave is being transferred and the positive and negative end voltage is not in sync, which again will be a huge problem. Hence, instead of using PWM, we use something really interesting.

The method that is most commonly used is called phase fired control. Sometimes it is also called phase angle control or phase cutting. What it essentially does is, it cuts the wave at certain parts of the phase letting the rest of the wave cross by. Confused? Let me show you here: 

Now, as you can see the phase behind the second half of the AC wave is getting chopped and is not getting passed in the final output. This makes the final output to be only 50% of the overall input. What this technique does is, it maintains the AC nature of the power supply while still being able to reduce the overall resulting voltage. Likewise, as you can see in the next diagram, the wave is getting chopped after 75% of the wave has already passed. This results in the output being relatively lower:

Now you must be asking, how did we actually go ahead and do this? It is done by a relatively complex circuit that detects the phase angle of the wave and then opens or controls a triac, which is a high power bi-directional semiconductor. This leads the power supply to pass or to be stopped at certain phases. We will leave the exact working of this circuit for the next time as it is fairly complex and will not be relevant to this book.

Now coming to the basic point, we know what phase cutting is, we also know that triac is the basic device that lets us do that. But how do we go ahead and do it using Raspberry Pi is the question.

So firstly, we will need an AC-dimmer module. This module already has all the components of phase detection and chopping. So all we need to do is simply control it using simple PWM.

Though I might not have to demonstrate how to connect the circuit or what the code should be, for the sake of understanding, let's connect a light bulb to our Arduino using this module and then control the bulb. Now, the first thing to remember is that the load should be a bulb and not anything else such as an LED light. So go ahead and connect the circuit as shown in the following figure:

Once this is done, go ahead and upload the following code:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.OUT)
I = 0
pwm= GPIO.PWM(18,50)

for I < 100:

I = I+1
pwm.start(I)
time.sleep(0.1)


GPIO.cleanup()}

As expected, the attached light will start to glow very faintly first and will increase the intensity gradually until it reaches 100%. That is how simple it is to control such a complex process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.22.136