Thursday, February 10, 2011

Why the Arduino won and Why its here to stay

For a beginner, if you are still considering to use Arduino vesus other microcontrollers, Phillip Torrone, Creative Director of Adafruit on Make: Online wrote an interesting article on "Why the Arduino won and Why its here to stay" that might just be able to help tip you over.

The author also commented that it only takes 10 minutes, assuming your Internet download is fast, to get Arduino up and running and that itself show the simplicity of Arduino.

From reading the article, it remind me of some of the things I told my readers when choosing between different types of Arduino. I usually advise beginner that "Unlike the PC CPU where faster and more Ghz is better, in microcontroller, less is good, uses less power and more power efficient, you can even run it off batteries".

To keep the Arduino cost low with a lower entry barrier, everything else is modular or called a breakout board or "shields" in Arduino term like LCD module, network or TCP/IP module, realtime clock module, GPS module and many other modules. Again, less is good and keep it simple concept.

I find most challenging part for beginners is actually understanding the datasheets, Sparkfun wrote a good article on how to Read a Datasheet, well, we can read english but understand engineer's terminology is another challenge for beginners as most datasheets are written by engineers for engineers.

Finding the correct components is the next most asked questions, like "How do I control a 12V or 220V from an Arduino ?" What parts do I need to accomplished this task ? I will address this in my next blog entry.

One of the recent events I think "Arduino won" is the worldwide shortage of the Atmega328 DIP version of the chip from Atmel. DIP (stands for Dual In-line Package) is a through-hole packaging of the chip that can be plugged into a breadboard or IC (Integrated Circuit, technical name for chips) sockets and can easily be removed and replaced if you burned your chip. The original version of Arduino have all the components in through-hole and the latest version, Arduino UNO moved most of the components into surface mounted except for the main Atmega328 chip. With the recent shortage, to fulfill the hugh demand, Arduino made a surface mounted version of Arduino UNO. The DIP version of the chip is important because hobbyist like myself, like to make parmanent version of Arduino for different type of projects.

All these food related names like DIP, chips, bytes and nibble just makes me hungry.

















Sunday, February 6, 2011

Arduino Pins - Analog style output - Pulse Width Modulation (PWM)

The last part of the Arduino Pins - Analog Output using Pulse Width Modulation.

We have mentioned about digital input, digital output and analog input. How do we do analog output ?

There are no analog output pins on the Arduino and how can I control the intensity or brightness of the LED or variable speed of the DC motor or fan. Yes, you can do analog output style,  it is called Pulse Width Modulation (PWM) and Arduino have a function called analogWrite() to accomplished this with digital pins. This is done by turning on and off the digital pins very quickly at a rate of 500 times per seconds ( frequency of 500Hz).

If you look at the Arduino UNO board, there are ~ beside the following pins - 3, 5, 6, 9, 10 and 11.  These are the PWM pins you can use. To use the analogWrite(), the syntax are :-

analogWrite( pin, dutyCycle );


The pins are 3,5,6,9,10 and 11 and the dutyCycle is a value from 0 to 255.

PWM duty cycle

If you want the LED to be 100% brightness or the PC fan running at full speed, set the dutyCycle to 255. If you want 50%, set the dutyCycle to 128. If you look at the Aduino Fade example, it uses pin 9 instead of the pin 13 for Blink example.  This is because pin 13 is not a PWM pin.

Please note that the function analogWrite() have nothing to do with the Analog Pins!!!

CPU Cooler with PWM


An application of PWM is most commonly found in CPU air cooler with 4 wires to control the speed (RPM) of the fan based on the temperature sensor of the CPU. This is to reduce the noise level by controlling the speed (RPM) of the fan.

You can refer to this article on controlling DC motor / fan speed using PWM.