PIC's

[HOME]     [KEY STAGE 3]     [KEY STAGE 4]    [AS - A LEVEL]    [GLOSSARY]

 

HOME
Back
Flowcharts
Sample Projects
   

Programmable Interface Controllers


Since the first integrated circuit or silicon chip was developed in the late 1950's The trend has been towards ever increasing complexity and an ever decreasing size of circuit.

Perhaps the most obvious example of this is the computer. If we ignore the various peripheral devices, the basic structure of a computer is similar to the one shown below.

The two main elements of a microcomputer are the CPU or Central Processing Unit and its Memory. The interconnections are known as buses because they contain a large number of parallel  connecting wires. The three sets of buses connecting these two blocks are:
The data bus 
The address bus
The control bus

The data bus carries data being processed in both directions. The single direction address bus carries memory addresses. 

The control bus is used to make sure everything works in the correct sequence by sending and receiving timing signals. 

The input/output unit allows the computer to communicate with peripheral devices.

Early computers were huge devices sometimes occupying several rooms, over the years the size of microcomputers has reduced as their power has increased.

PIC's or Programmable Interface Controllers are essentially microcomputers on a 'chip'. A typical PIC such as the 16F84 contains all the elements shown above.

The 16F84 PIC, combines a microprocessor, ROM, RAM and an Input/Output Unit in a single chip.

They can be obtained in 8, 18 and 28 pin configurations which provide a variety of output and digital and analogue inputs.

The chips use reprogrammable 'flash memory' which can written and rewritten to with ease.

Building a working controller involves simply connecting the chip to power, interfacing input and output components and adding a capacitor, resonator and a reset switch.

The most commonly used PIC is the 16F84 shown. This is an 18 pin device which has 8 outputs and 5 inputs. 

Connecting Power to the 16F84 PIC

The pin out diagram for the 16F84 is shown on the right. The 16F84 requires a 6V DC supply. This can be provided by 4 x AA cells.

A 4MHz ceramic resonator must also be connected as shown below. The 16F84 provides an internal clock pulse. The resonator is used to regulate the speed of the clock pulse (4MHz).

Pin 4 (reset) must be connected via a 4k7 resistor to +V.

 A reset facility can also be added by adding a push to make between pin 4 and 0V.

Interfacing Input and Output Devices

Providing care is taken over matching voltage and current levels, digital sensors or transducers can be directly connected to the input and output ports.

The most common digital sensors are switches. 

                                                   

Micro-Switches, Reed Switches, Tilt Switches and Push Switches can all be directly connected to any input pin as shown right. The 10k resistor prevents a short circuit and the 1k resistor protects the input pin. In these cases the digital input will move from logic 0 to logic 1 when the switch is pressed.

Although the 16F84 does not have analogue input pins an analogue sensor can be used if the sensor is connected via a potential divider and transistor as shown.

                    

A phototransistor can be used to switch the input directly 

In both these cases the input will move from logic 1 to logic 0 when the switching level is reached.

An LED can be driven directly from any output
As can a Seven Segment display.

 

Taking the required outputs high in the correct sequence will display the numbers 0 - 9

A Piezo sounder can be connected directly to produce a range of sounds. 

The sounds are produced by pulsing the required output with a variety of frequencies generated by the programmed instructions.

Higher current devices which cannot be driven directly will require a simple transistor switching circuit. A device which is frequently used is the BCX 38B darlington driver.

In some situations it will be impossible to match voltage and current levels of the PIC and the input and output devices you want to use. In this instance you will need to use two separate power sources and drive the output transducer from a transistor.

Although the PIC and the output device have different supply voltages the 0V rail must be common to both.

This is essential for the correct operation of the circuit.

Stepper motors are motors which do not spin freely but turn in steps of 7.5 0, so that 48 steps will cause the motor to turn through 3600 or one complete revolution. The two types of stepper motor available are known as unipolar and bipolar types. The unipolar is the type explained below.

A suitable motor can be obtained from - Rapid Electronics - code 37-0500

Unipolar stepper motors have four coils which must be switched on and off in the correct sequence to make the motor turn. The table below shows the correct sequence.

 Step  Coil 1  Coil 2  Coil 3  Coil 4
1 1 0 1 0
2 1 0 0 1
3 0 1 0 1
4 0 1 1 0
5 1 0 1 0

The ULN 2003A darlington driver IC is used to drive the stepper motor as show below.

This project board uses PCB mounted push switches as inputs and LED's as outputs. Both IC's should be mounted in sockets. The PCB mounted switches could be wired to other sensors and there is the facility for 2 pin pcb connectors to be connected in parallel to the output LED's to connect other output devices. A 7805 regulator and Darlington driver array is used to allow most output devices to be driven safely. Double Click the PCB to open the PCB Wizard file.

 

Most modern microcontrollers use what is called 'flash' programming using EEPROM (electrically erasable programmable read only memory). This means that the device should be capable of being re-programmed over 10,000 times. 

This is important because you will rarely get the microcontroller program correct first time and you will inevitably want to change it. If you do make a mistake, the PIC can simply be re-programmed with new code. The program will stay in the PIC's memory until it is re-programmed.

Microcontrollers use instructions provided in binary (a sequence of 0's and 1's) often called machine code. This 'code' means very little to anyone but a skilled programmer.

In industry microcontrollers are programmed using a 'compiler' or 'assembler'. This is a programming language which is slightly easier to understand but unless you take A-Level computing you will be unlikely to be able to use or understand it.

For most applications in school, the complexity of these languages makes their use impossible (or at least unrealistic) for most applications.

In KS4 you may be taught a programming language called BASIC, which the majority of students cope with quite well. At KS3 however, even learning BASIC is unrealistic in the time we have. 

For most students a much simpler and easier to understand programming technique is to use a programme editor such as the one provided with Crocodile Technology. Most programme editors use a flowchart approach to design programs. The editing software then converts the flowchart into BASIC or Assembly language before the microcontroller is programmed.


PIC based Microcontroller systems are provided by a number of suppliers. They are all capable of

PIC Logicator for instance requires a programmer into which you insert the microcontroller for programming. 

The PICAXE system uses special microcontrollers with a small programme called  a bootstrap programme permanently written into its memory which allows you to programme the microcontroller while it is installed in your project.

The Chip factory system is a low cost PIC programming unit that works without a PC. It uses its own basic programming language, and is portable.

PIC Logicator and Chip factory both support a range of 28 and 18 pin microcontrollers. The PICAXE system provides support for their own 8, 18 and 28 pin chips.

All this makes it very difficult to to explain accurately how every microcontroller could be used.

A number of newer Microcontrollers have recently been released. They are much cheaper than the older devices, enabling additional features at a lower cost. For instance the 18 pin 16F627 is much cheaper than the old 16F84A, has two analogue inputs, and two extra input pins as it also has an internal resonator.

The types most commonly used are: 
  8 PIN - 12F629 (2 input, 4 output)
18 PIN - 16F627 (4 input, 2 analogue, 8 output, 1 sound)
18 PIN - 16F84A (4 input, 8 output, 1 sound)
18 PIN - 16F818 (2 input, 2 analogue, 8 output, 1 sound)
28 PIN - 16F872 (8 input, 4 analogue, 8 output, 1 sound)
 

 

 

 

 

[HOME]     [KEY STAGE 3]     [KEY STAGE 4]    [AS - A LEVEL]    [GLOSSARY]

Best viewed at a resolution of 800x600 and at least 256 Colours

Deyes High School, Deyes Lane, Maghull, Liverpool L31 6DE
Headteacher: Peter Reed
Chair of Governors: Dr David Allen

Phone 0151-526-3814 or 7110
Fax 0151-526-3713

www.deyes-high-school.co.uk 

e-mail: admin@deyes-high-school.co.uk

You are Visitor No.
Hit Counter
Since December 10th 2003

 

For problems or questions regarding this website contact 
[Design and Technology Dept]

Last updated: August 10, 2003 .