Wednesday, November 24, 2010

Getting Started with Microcontrollers

There are several common questions people ask when they begin learning about microcontrollers and I have found that a lot of the answers online to be from very experienced professionals who over think and over complicate the question. So before I become like them I thought i would answer these questions from the point of view of a person who just figured most of this out. So to begin let's list the most common questions I have seen from beginners.
  • What is a microcontroller?
  • What can a microcontroller do?
  • Which microcontroller should I get?
  • Where do I get a microcontroller?
  • How do I program a microcontroller?
  • How do I connect _______ to a microcontroller?
  • How do I take over the world with a microcontroller?
Now the last one I am still working on so I will have to get back to you on that one. But as for the rest I believe I have enough knowledge to answer. So in the next couple blogs i will answer these questions. Now, logically I will begin with the first:
  • What is a microcontroller?
A microcontroller in the most fudamental definition is a computer on a chip, it contains a processor, storage, and programmable GPIO. General Purpose Input/Output are I/O pins that can be set as input or output. Of course this is not all, depending on the microcontroller it may have an ADC, a DAC, UART, I2C, SPI, PWM, a watchdog, and various timers. I am assuming you don't know what all that means so I will explain. 

First, an Analog-to-Digital Converter (ADC) is a nice little gizmo that converts an analog signal into an digital signal. What this means is that you can convert a voltage from a sensor like a potentiometer into a numerical value that your program can then operate upon. A Digital-to-Analog Converter (DAC) does the opposite, it converts a digital signal into an analog one. One application of a digital-to-analog converter is in audio, sound is stored as numbers in memory and is then converted to an analog signal using the DAC. 

The Universal Asynchronous Receiver/Transmitter (UART) is one of the ways you can communicate with your microcontroller. It is through this that you can talk to serial LCDs, USB, and RS232(desktop serial). Inter-Integrated Circuit (I2C) or 2-wire interface is intended for communication between ICs on a single board. I2C has addressing so that 112 nodes can communicate on the same bus, you would use I2C to add EEPROM (more storage) or a DAC to your project. Serial Peripheral Interface Bus (SPI) is a synchronous serial communication connection that is full duplex (two-way communication simultaneously). For example you can use SPI to connect a SD card to your microcontroller. 

Pulse-Width Modulation (PWM) is a way of controlling things such as motors so that you can control speed. But instead of actually changing the amount of power supplied PWM just turns on and off really fast to give that illusion. You would use PWM for motor speed control and LED dimming. The watchdog timer is used by the system to reset the system if the main program freezes. It resets the system if it is not regularly updated by the processor. The other timers are used for things like real time applications. When something must happen by a certain time you would use a timer to ensure it happened on time. 

So all this means is that a microcontroller is a system on a chip that has various ways of communicating to the world. By connecting sensors and mechanical devices to your microcontroller you can begin building interesting systems that can react to the environment, communicate with others, and gather data!

No comments:

Post a Comment