A 16x84 is a single-chip microcontroller: a complete computer on a single IC. Complete means the a 16x84 chip contains a processor, program memory, scratch memory and connections for the interfacing to other ICs. Compared to for intance a PC a 16x84 contains only a tiny amount of each of these resources, and the processor is much slower that the one inside a PC. On the other side a 16x84 is much smaller and consumes much less power than a PC.
It is not uncommon for a PC to contain one or more PIC chips (or close relatives), for instance inside the mouse.
|program memory||1 Mb ROM, 5 Gb HD||1 K Instructions in EEPROM, 64 BYTES Data EEPROM|
|scratch memory||32 Mb RAM||36 (16c84) or 68 (16f84) byte RAM|
|processor||32 Bits, 200 MHz, 200 MIPS, 100 MFlops||8 Bits, 10MHz, 2.5 MIPS, 1KFlops|
|peripherals||monitor, keyboard, mouse, paralel port, serial ports, network, joystick, MIDI, loudspeakers, microphone||13 I/O pins|
|power consumption||5A@ 5V, 3A @ 12V (50W)||100uA @ 5V (0.5mW)|
|size||40 x 20 x 10 cm||158 x 10 x 5 mm|
|weight||10 kg||1 g|
Keep in mind that the qualifiers K and M are often have a slightly different meaning when used in with computers (informatics). The other qualifiers useually have their normal menaing.
|M||mega = 1.000.000 = 10^6||2^20 = 1024 * 1024 = 1048576|
|K||kilo = 1.000 = 10^3||2^10 = 1024|
|m||milli = 10^-3|
|u||micro = 10^-6|
|n||nano = 10^-9|
|p||pico = 10^-12|
A 16x84 is an 18 pins IC. 13 of these pins (A0 .. A4, B0 .. B7) are free to be used by the program in the 16x84 in any way. These pins are digital, so they can (when programmed as outputs) be made high or low, or (as inputs) detect a high or low voltage applied to them. The program can decide whether a pin is an input or an output, and this can be changed during the execution of the program.
The other 5 pins are the ground (Gnd), power (Vcc = +5 Volt), a reset input, (MCLR, must be high for the chip to work) and two connections for a crystal (OSC1 and OSC2).
The pins A4 and B0 can be used as normal input or output pin, but these pins also have a special function: A4 as input for the on-chip counter and B0 as interrupt input. When these special functions are not used A4 and B0 can be used like any other pin, but beware that A4 is an open drain output: it can not source current. The port B pins can be programmed to have internal weak pull-ups (relatively high resistors to the Vcc).
The pins B6 and B7 are used by the loading of the program into the 16x84. This won't work when these pins are loaded too heavily, in that case in-circuit programming is not possible. A load which is connected via a 10k resistor will never be a problem.
A 16x84 by itself will not do anything usefull: you must first write a program which tells the chip exactly what it should do. Then you must translate (compile) this program into a list of codes which the chip can understand and load these codes into the chip. Once this has been done the program will remain in the chip untill you load a new program, even when the power is switched off.
The code 16x84 stands for two different IC's, the older and sometimes cheaper 16c84, and the newer 16f84. Unless a 16f84 is specified explicitly (it has more scractch RAM) both can be used.
A 16x84 will function only when a crystal is connected to it, with two small capacitors alongside. Most often a 4 MHz crystal and two 22pF capacitors will be used. A 16x84-10 (the last number indicates the maximum crystal frequency) can also work with a 10MHz crystal, which will make it 2.5 times as fast as with a 4MHz crystal.
To put it all together 4 types of 16x84 exist: the 16c84-4, 16c84-10, 16f84-4 end the 16f84-10. The f and -10 versions are a little more expensive, but when you must buy one and have a choice take the 16f84-10.
This is the basic schematics which you will need for each assignment. You see the 16x84 chip itslef, the crystal with the two capacitors, a resistors which keeps the MCLR pin high, and a decoupling capacitor on the power and ground lines. Place this capacitor as near to the 16x84 power and ground pins as possible.
On the foto's you can see the components and the circuit build on a solderless breadboard. To prevent damage to its pins the 16x84 chip is always in an IC socket with round (stiff) pins.
The schematics show that the 16x84 needs a 5 Volt power. For experiments where you always leave the program loader connected and the current use is less than 100 mA the power supply in the loader can be used. In that case the 5 Volt is derived from the wall-wart which powers the loader.
For a circuit which will be used separate from the loader or use more than 100 mA a small power supply can be created from a 7805. With a small heatsink and a limited diffreence between input and output voltage a 7805 can deliver 1 A. When you want to use battery power you can take a 4.5 V or 6 V battery (3 or 4 penlights) or 4 NiCad cells.
When you must power the 16x84 from a battery which delivers too high a volatage (for instance 12 V for a stepper motor) you simply put a 7805 inbetween. Take great care that the higher voltage is never delivered to the 16x84, because that is a reliable way to kill the chip.
We write the programs for the 16x84 in a programming language called JAL. On the PC we use a text editor, for instance notepad (windows) or edit (DOS) to write the source file. The extension of the source file must be ".jal". When you have completed the source you must compile it by giving the DOS command
Replace <file> with the name of your source file, without the .jal extension.
When the compiler detects an error it whill inform you. The error message will show the line and character where the compiler detected the error. In such a case you must edit the program again to correct the error and compile again, untill the compiler finds no more errors.
When the program has been compiled successfully it must be loaded into the 16x84. This is done via a loader which is connected to the serial port of the PC. The loader is connected to the 16x84 with a test clip. Note that the black indication on the test clip corresponds to pin 1 of the 16x84. The testclip has only 16 pins, so pin 9 and 10 of the 16x84 remain outside the test clip.
The DOS command to load a compiled program into the 16x84 is
like with the compilation <file> must be replaced with the file name, without the ".jal" extension.
wisp go <file>
When the loader is connected to a different port than COM1 the port must be specified on the command line, like
wisp port com2 go <file>
When the loading does not succeed (some other message appears instead of the OK which indicates successfull loading) you can try the following:
Now you can see whether your circuit and program do what you expect. The connection to the loader (the testclip) can remain in place.
Programming is difficult, so do not expect your program to work the first time round. When it does not seem to work you must debug it. Observe carefully what the circuit does do, look at your program and try to determine why it behaves that way.
The assignments are structured in such a way that you start with a simple circuit and a program which you can just copy. In a number of steps the circuit and program are expanded towards the final goal.
Each step is indicated by a "work in progress" icon: Do not try to skip steps, this will likely result in a program which has changed so much that you will have a lot of trouble getting it to work.
Save the programs you write in your own directory on the PC and on a floppy which you keep yourself. Some assignments require you to re-use parts of programs written during previous assignments. A file name next to the "work in progress" icon suggests a file name which you can use to save your work.