Learn-Arduino-via-simulations

Analog Signals

It is usually quoted that life is a combination of highs and lows. So according to this saying, let’s name this behaviour of life as binary (0/1) or digital (LOW/HIGH). But is it really the case that our life swings between these 2 states only? If yes, then any day in our life would be either the best day or the worst day. But we also encounter some neutral days, not so good and not so bad day also. Then how do we characterise these states of life? So, the analog behaviour comes to the rescue. It accepts all valid values between a specified range.

Let’s relate the same thing to real-world application in electronic devices. A ceiling fan without a regulator has digital/binary nature: if 0, it is OFF and if 1, it is running at its maximum rpm (revolutions per minute). An LED bulb connected to the mains also has digital nature: if a voltage is applied across it, it glows with maximum brightness; if no voltage applied, it stops glowing at all. While observing the Diwali lights, they glow with full brightness and then slowly dim out to reach complete darkness. They exhibit analog behaviour. Another example of analog nature is the accelerator in a vehicle; we can vary the speed of the vehicle between a certain minimum and maximum speed (depending upon the gear in which you are driving). So analog and digital both are important in real life.

Now a digital voltage can be obtained very easily by just inserting a switch between the battery (energy source) and our equipment. When we require 0/LOW, we open the switch, and when we require 1/HIGH, we close the switch. image

But is obtaining the analog voltage also that easy? Let’s see! Consider the same switching process of digital voltage but with very fast switching, say 100 times ON-OFF in 1 second (don’t amaze it can be achieved easily 😊) and connect a bulb (the one with tungsten wire as it would be easier to visualize) to this voltage. What our eyes will see is that the bulb is continuously glowing even though we are opening the switch (i.e. no voltage to the bulb) for some amount of time. Observe another thing, its brightness is comparatively lesser than with the usual bulb in our homes. So what? We have obtained a state between the minimum (0/LOW) and maximum (1/HIGH). Now in this 100 times ON-OFF process if the ON time is equal to the OFF time and we average out the voltage over this 1 sec, we get the resultant voltage to be half of the maximum voltage. Therefore we can obtain any analog voltage value by varying the ON time and OFF time. This concept is widely known as PWM (Pulse Width Modulation). Look at the figure below to understand better.

We can also find the digital input & output pins (0-13) on the microcontroller (say Arduino UNO) that either read digital values from a sensor or give digital values to an actuator.

image

We can also find analog input pins (A0-A5) on the same Arduino UNO but what about the analog output pins? Can we locate them on the board? Yes, we can but where? Can we locate some digital pins with a ‘~‘ in front? These are the PWM pins. Now we can just vary the ON-time to OFF-time ratio to obtain any analog voltage of requirement.

Now take an Arduino UNO, a resistor and an LED and glow the LED with varying brightness by giving different analog voltages via the PWM pins. Now don’t just stay at 2 discrete states, enjoy in the continuous band!