Getting Started with PICs.
Ideas, tips and how to getting started with microcontrollers projects. (6/4/2007)
Microcontrollers are, basically, a computer in a single chip. It contains memory, processor, I/O ports (I/O = Input/Output) and other periphericals. Can you believe a single chip does contain RAM, ROM, CPU, I/O Ports, timers and other gadgets? It only needs a keyboard and display to be a working computer...
...I almost forgot; It also needs Software.
Microcontrollers are expensive ccompared with CMOS or TTLs chips, but using it on any electronic project allows to save parts and money. Here is an example of the same project using Microcontroller and without microcontrollers:
A simple 8-pin chip replaces diodes, ICs, resistors, capacitors and transistors. Why? Because the 12F629 chip is a MICROCONTROLLER and replaces all those parts with the SOFTWARE. The software, also known as "code", "program" or "instructions". The software looks like this:
No idea what is this about? Don't worry. You will be able to find the HEX files that contains the software for the microcontroller. After some time, you will be able to undestand and make your own programs. Meanwhile, let's learn what we need to start to build some projects with Microcontrollers.
I do use MICROCHIP microcontrollers, also known as Microchip PIC or just PIC. There are some reason why I only use PICs:
1. Inexpensive - Some PICs cost less than $2.00 USD.
2. Documentation available - All technical specifications and datasheets are available at the Microchip website.
3. Lots of projects available - The web shows thousands of projects using Microchip Microcontrollers. Plenty of projects.
4. Low cost development - With less than $10.00 USD, I can make my own programmer and start making projects!
What I need to building projects with PICs?
First, you need a COMPUTER. Old computers with DOS 6.X, Windows 9X works ok. It doesn't need to be an expensive or super-fast computer. Even old 486-66 works fine to make microcontroller projects.
You need to be sure the computer have Serial and/or Parallel port to connect the PIC Programmer.
Second, you need a PROGRAMMER. A programmer is the hardware needed to put the software inside the PIC. Programming the PIC is also known as "burning" the PIC.
This is a simple and easy-to-build PIC programmer JDM compatible. It works using the power from the RS-232 Serial port, so before building it, you need to be sure the voltage at the serial port is at least 11 Volts. 9.5 Volts at the serial port may be enough to program some PICs. The serial cable should not be longer than 3 feet. Shorter = better.
You can build this PIC programmer with less than $10.00 USD. You can buy a a commercial one if you have the resources and time for it.
Third, You need the SOFTWARE to use with the computer and transfer the code to the PIC.
I do recommend IC-PROG, it is easy to use, free to download and it is available in many languages.
You can download IC-PROG HERE
Also, you can download the help files in ENGLISH HERE
Download the help file in SPANISH AQUI
Download the help file in ITALIAN
For other files and supporting information, visit IC-Prog website.
Last, You need the CODE for the PIC. A microcontroller is useless without the code. The instructions on the code or HEX FILE indicates to the PIC what to do or how to do to perfom the task.
Once you have all the requirements, is time to start working with microcontrollers.
I built my own programmer using a small solderless breadboard and I used a 16F84A to begin with my projects. Once the PIC programmer is ready, is time to test it.
Open IC-Prog and press F3. The hardware settings allows to setup the hardware. Choose the JDM Programmer if you built the above schematic or the one that you purchased. Many hardware that uses RS-232 are JDM compatible.
Set the I/O Delay to the max (40) and do not invert any signal. Set the COM port used and use the DIRECT I/O Interfase.
If you want to test the programmer directly using a voltimeter, you can click the menu SETTINGS - HARDWARE CHECK and enable each signal for the Pic Programmer to verify it. You may need to read the technical data for the 16F84A to determine each signal.
Once the hardware is connected and configured, right click on the link and choose "Save target as" to download the HEX file.
The HEX file is a program to blink a led connected at the port B0 using a PIC 16F84A (16F84 works also). Once you download the HEX file, Burn the PIC with it using Ic-Prog.
Open IC-Prog and Choose the PIC 16F84A.
Next, click the menu FILE - OPEN FILE and choose the saved HEX file (flashled.hex).
If you get a warning message saying "This file does not contain a device ID value!", just ignore it.
Another important detail when using and programming microcontrollers is the configuration word or also known as FUSES.
Fuses indicates the configuration for the PIC regarding the timers, watchdog, code protection and oscillator.
For the led flasher, we need to change the OSCILLATOR to RC and the fuses configuration are: WDT OFF, PWRT ON, CP OFF.
Is very important to verify this configuration as it makes the PIC work properly.
Click the button "Program All" to burn the PIC. It will transfer the HEX file to the EEPROM on the microcontroller. If you get the message "Devide successfully verified!" that means IC-Prog was able to communicate correctly with the PIC.
If you get an error about "Address 0000h", that means communication with the PIC was not successfully and it may be a hardware failure. Verify:
If you were able to program the PIC, is time to build the circuit.
The 10k resistor connected to pin 4 is the RESET control, allows the PIC to run. The 10k resistor at the pin 16 defines the frequency of the PIC. The fuse configuration was assigned as RC but one 10k resistor is enough to start the oscillator at the PIC.
When you apply voltage to this circuit, the LED will flash approximately one time per second (1 hz)
If it doesn't work, check the wires, voltage and components. Most of the times, when a PIC project doesn't work is because the fuse configuration is not correct. Sometimes, if using a AC adapter, the power is not good enough or needs more capacitors to make stable the voltage.
Just because a PIC project was tested doesn't mean it will work the first time. Verify the connections and components TWICE to be sure it match the schematics.
|ADC without ADC.>|