Friday, 13 March 2015

Pulse Width Modulation

Pulse Width Modulation or (PWM) is technique used by engineers all over.It is a complex process which is studied under analog signal manipulation. To demystify PWM consider an LED hooked up to a battery and a switch.

Imagine you could toggle the switch ON and OFF at speeds where you can no longer make out whether the LED is blinking.

 Is that it ?

Common sense dictates that it would appear as if the LED was glowing continuously. At least that's what I thought.

Practically to toggle a switch at such high frequency you can employ one of the following methods.
1. Use a relay to blink the LED
2. Utilize a microprocessor kit such as an Arduino.

What you will actually observe when you do this is while the LED will have stopped blinking it's brightness will also seem to have reduced. Say it is ON for 20ms and OFF for 20ms. That means it is ON and OFF for 50% of a duty cycle respectively. The LED will seem to have dimmed by 50%.

 This is one of the textbook applications of Pulse Width Modulation.

Here I would like to include that duty cycle is the ratio of ON time of a device to the total time period (i.e ON time plus OFF time).

Another application of PWM is DC Motor speed control. Say the rotation speed is maximum for voltage V and minimum when it is 0. When a cycle with 50% of voltage V and 50% voltage 0 is given to the motor, voila ! the motor runs at half speed.

The general idea is that the motor is a slow inertial device and is unable to respond to high clock speeds and as a result is never truly at full speed or minimum speed hence runs at half speed.

So what is Pulse Width Modulation technique ?

Putting it into words it is a technique used for producing analog like properties by using digital systems.

If you want to know how to implement this using an Arduino click on the link given below,

Arduino PWM

Follow the steps and keep reducing the parameter in the delay( ); function until the LED appears to stop blinking. Do this in a dark room to observe PWM in action.

Until next time,

Abhijeet





   

Tuesday, 10 March 2015

Programming Alternatives

The need for programming in electronics arises when we start dealing with microprocessors and microcontrollers. Any device which you want to automate and do amazing stuff at your bidding needs a microprocessor and hence, programming.

 'C' is the most trusted language when it comes to embedded programming and frankly the way to go if you want to get involved in embedded technology. But, it does require time and effort to really understand the clockwork behind it. This becomes a problem if you want to make something cool urgently and immediately.

After the introduction of microcomputers such as Arduino, Raspberry pi and Mango pi among others thousands of people with wonderful ideas have flocked to the embedded world. But, many of them including me hit a bump when it comes to coding. Some of them are artists,hobbyists, and beginners who may or may not want to get into the crux of programming. While several alternatives to C,C++,Java etc exist, here I will talk specifically about the Arduino IDE and the Processing Language.

The Arduino board has a custom built compiler known as the Arduino IDE (Integrated Development Environment) which is based on the Processing Language made by Casey Reas and Ben Fry. The Processing Language was originally made for helping artists make computer based art with minimum involvement of programming logic.
Later it was modified to suit the needs of the Arduino. This language gets rid of several cryptic and abstract concepts which are inevitable when it comes to orthodox programming.

For example in C programming to display a simple statement like "I don't wanna learn programming" you have to write something like this,

# include<stdio.h>

main(void)
{
printf("I don't wanna learn programming");
} 

Note: To run this program on windows you need to use #include<conio.h> and a getch(); command along with the above program or you might never see the output. 

While in the Processing language to make a circle you have,

ellipse(50,50,80,80);

which makes a circle with centre at 50,50 and length and breadth 80,80.

Although it is not as simple as I am making it out to be the advantages really come out when you start working with the Arduino and compare it with orthodox techniques associated with microprocessors.

Cheers,

Abhijeet