When I started my car the original intention was to design all my own instruments using PIC microcontrollers. Because of this, I decided to make my own electronic speedo using a PIC microcontroller showing the speed on three 7-segment LED displays. I also played with a liquid crystal display, but this wasn't ideal for a speedo.
In the end I decided that what I really want is to finish my car and drive it - and making my own instruments was likely to be a major time-waster. As a result, the only part of my car that uses a PIC is the immobiliser circuit. This uses a technology called "Dallas 1-wire", which can read the unique code in a small device called an iButton. This is a small stainless steel package that is the same size and shape as a large hearing-aid battery.
A PIC is a microcontroller, which is a microprocessor with built-in memory packaged into one device. Specifically it refers to a range of devices made by Microchip Technologies, of which the most popular is the PIC 16F628 (an updated version of the popular 16f84). This 18-pin DIL device uses flash memory that can be erased and re-written electrically many hundreds of times. The alternative devices can either not be erased at all, or require a special UV light source.
The amount of memory available on the 16F628 seems very small to anyone used to modern PCs, just 2048 bytes for the program and 224 bytes of EEPROM for long-term 'power-off' storage, but this is often more than sufficient for most control applications. For example, I used barely a third of the memory to create the original 7-segment LED speedometer circuit described in these pages.
The main benefit of using a microcontroller is that a complete control mechanism can be created with a singe chip and a very small handful of commonly available components. Like most modern ICs they are vulnerable to static electricity, but are very durable in all other respects.
Four major components are required to program a PIC:
In my case, I used:
Of these, the editor, compiler and loader program were downloaded free from the Internet.
The WISP628 programmer is available from the designer as a kit of parts (see his page for details). The other programming hardware was very simple, the design of which also came from the Internet. It is possible to make a simpler programmer than the JDM, but this one was in this list of those supported by IC Prog and cost me less than £10 in components, including the PIC chip. The only difficulty some people have found with this design is when the serial lead is too long - you can see that mine is VERY short! This board has since been extended with a 40-pin ZIF socket to allow the programming of 16F876 and 16F877 PICs.
You will notice two other "essentials" in the picture. The first is an anti-static wrist strap that is connected to earth at its other end - PICs can easily be destroyed by static. The other item is a cheap IC puller that can be used to take the PIC chip out of sockets without bending the pins - the chip may have to be moved many times while the its program is being developed, unless you use an in-circuit programmer (e.g. the Wisp628).
In addition I have a cheap and cheerful breadboard for prototyping circuits before finalising a design (see below), and a free, limited-functionality demo version of Eagle Layout Editor to draw the circuit diagram and lay out the board.
We're not talking great expense here!
When I originally planned to program my own PICs I thought that I would be using Microchip's assembler language and their MPASM assembler compiler. This did not fill me with great joy as it had been a long time since I programmed anything at that low level. Compilers in higher-level languages such as C or Basic cost a significant amount of money and would have blown any idea of 'cheap instrumentation'.
I was very pleased to stumble accidentally onto a link to a hitherto unknown language, JAL. When I followed the links I found a complete, free compiler that I could download. JAL (Just Another Language) is the pet project of Wouter van Ooijen.
The language is very easy to use by anyone who has experience of a high-level language such as C, Basic or Pascal, as long as the user remembers that JAL is aimed exactly at the requirements of the PIC processor: variables are either bits (on or off, 1 or 0) or 8-bit integers (0 - 255). Handling bigger numbers or floating points require special techniques or libraries.
The big bonus is the set of libraries that come with the compiler. These contain useful routines to help when using 7-segment displays, some common liquid crystal displays, stepper motors, serial links, and setting delays and intervals.
JAL is very modest in its machine requirements: It can be run on a 386 PC, but a 486 or better is recommended. Its memory and disk requirements are also modest (but the more you have, the quicker it will compile).