There is a vast number of different microcontroller models out there. Here I will concentrate on the rather cool AVR ATMEGA8 and ATMEGA16 chips, priced at 3.50 and 8.00 euro. A smaller alternative is the ATtiny45. But this list is far from exhaustive. I will go into some of their capabilities later.
Let's get you used to a few concepts.
A microcontroller is a little IC chip as you know it, with a lot of pins (e.g. 28 or 40, or even just 8). Inside sits something like a miniature version of your PC. The cool thing is that you can program it in C and/or in assembler, to take input or send output through its pins.
- You type your program on your PC and compile it for the microcontroller.
- You wire the chip to a plug to make the programming pins available.
- Into it you plug your In-System Programmer (ISP) which looks like a boring cable.
- The ISP's other end goes into, by choice, the serial or the parallel port of your PC. Note from the present: these days I use homemade USBasp connectors to upload programs to the AVR, which, you guessed it, connects to the USB port instead.
- Now you run software to write the compiled program through the PC port, through the ISP into the microcontroller.
Once programmed, the chip is autonomous and the program will start running whenever the chip is connected to a power supply. The microcontrollers discussed here also have EEPROM memory, meaning they can keep data even if the power is off.
What can you do with it? You can switch LEDs on and off, you can read input from a `keyboard', you can control devices in real-time, make serial communication, have an operating system on it (I am told), lots of things.
|This is the oldschool interpretation of an ISP cable and a programmer board. The board hosts an ATMEGA8 which is driven by a 4 MHz oscillator. The transistors on the right are driving an old train station clock (not shown).|
I recommend any GNU/linux as a basis for programming.
I am introducing you to programming an Atmel ATMEGA microcontroller (ATMEGA8, ATMEGA16, ...).
A homemade In-System Programmer (ISP) is described. I use the PC's *parallel* port to do the *serial* type of AVR programming.
I use GNU's toolchain (for the `avr' target) to compile the chip's programs from C source code.
I use the avrdude program to load code up to the chip.