Process Components (PIC)

A Peripheral Interface Controller (PIC) is a microcontroller which is basically a mini computer on a chip. The subject of PIC’s is so vast, their applications so varied that all we can really do at this level is give you the most basic introduction.

To do that I am going to run you through the procedure for designing an alarm system. We will get the PIC to monitor the position of a fridge door. If the door is opened and left open for a set amount of time an alarm will sound. The alarm will not switch off until the fridge door is closed again.

Programming

Microcontrollers are enormously flexible devices because all of the functions they carry out have to be programmed into them. There are many types of programming language but we are going to look at just one known as assembly language.

Before you even begin to think about physically programming a PIC you need to run through the steps the program needs to take in order to carry out the function you desire. The best way of achieving this is through the use of a flow chart. I have designed a flow chart to carry out the function as described above. See if you can follow the logic!!

Basic Flow Chart

The 3 basic components for a flow chart are the ellipse which signifies a beginning or end, the diamond which is a decision or branching box and the rectangle which describes a process or output.

The next step is to transfer your design steps to code and that is where the real fun begins. Before we do that however please take some time to study the next slide which shows the basic layout of the PIC16F627 the chip you will be using.

PIC Layout

The next slide shows all of the connections required and briefly explains the circuit operation.

pic3

Assembly Language

Assembly language is a computer programming language used with micro-controllers. There are around 30 or so commands you can use, here we will use 6. I have included a walk-through of the most basic code required to carry out this function. Please note the comments, comments are an excellent idea when you are writing code because they explain what you are trying to achieve step by step.

They also help you to remember what the code does if you are returning to a project after some time away. Make sure any comments you write come after a semi-colon otherwise your programs will not compile.

Programmer

Now the completed code for the main program has to be inserted into a configuration file which sets the special conditions required for the chip you are going to use. At this level this is the point where to go any further we would be introducing unnecessary complexity. You will be given the necessary configuration file to complete this function. Your task is to ensure that the code you write carries out the function required. Here is an example of the complete file.

 

 

Leave a Reply