Unit 2 Computer Control PIC stands for PROGRAMMABLE INTERFACE CONTROLLER A PIC chip takes in input signals and then controls output transducers Name: Form:
2
ASIC or Application Specific Integrated Circuits Examples of ASICs are 741 OPERATIONAL AMPLIFIER like you saw in the electronics section or a 555 TIMER. Each of these examples has one specific application. An Op Amp amplifies; a 555 Timer produces time control. However they look exactly the same. The advantages of ASICs are that they are cheap around 35p depending on which ASIC you buy. They have one particular application and there are circuits available to download that use them. They are not versatile as they only have one function and they can not be upgraded or reprogrammed. They need to be soldered into a PCB and connected to other components to make them work. The 555 timer can sink and source up to 300mA which is very useful for directly controlling a relay. But both the 555 and the 741only have one output pin. The 741 has two input pins and these are used to compare voltages together. Both the 555 and the 741 come in 8 pin DIL (DUAL in LINE) packages. The 555 timer only has one input pin, but it can be used in two ways. 741 555 The PIC chip or Programmable Interface Controller comes in a variety of sizes. PICAXE is a brand of such controller we use in school. They are referred to as microcontrollers. Some advantages of the micro-controller are: increased reliability because of smaller part count, reduced stock levels as less parts are needed, simplified product assembly, greater flexibility and adaptability since the features are written into micro controller program not hardwired in to the electronic hardware and rapid product development as the changes can be written in the software not the electronic hardware. However, to programme them you will need expensive out lay for computer equipment. They have multiple input and output pins, it can be updated, but can sink or source only up to 20mA. Compared to ASICs they are very expensive. PICAXE 08 1.50 3
Which is better an ASIC or a PIC chip? ASIC PIC Advantages Disadvantages Advantages Disadvantages Your answer: 4
Where are microcontrollers used? An example of a micro-controller in use is your microwave. The microcontroller will monitor a range of inputs from the door switch, keypad and provide outputs to the light, LCD display unit, turntable motor and magnetron. One single micro-controller can replace a number of discrete (separate) parts in a circuit to simplify the operation of a product. How are Microcontrollers used? Applications that make use of micro-controllers include: Alarm systems Household appliances Medical equipment Vehicle sub-systems some cars have up to 30 micro-controllers controlling fuel mix to central locking. Electronic instrumentation Are microcontrollers available in school? In industrial applications the micro-controllers will be programmed using a language called C. However for our applications in a school setting that level of programming will not be necessary. The micro-controller system we will be using in school is called the PIC AXE system, and the PIC AXE system makes use of a far simpler BASIC programming language called BASIC. The beauty of using the PIC AXE system of programming means that you can download the software at home from: www.picaxe.co.uk Year 8 Programmable PIC PCB The PCB here is one which year 8 has used to programme and make all sorts of different products with. It can be programmed to perform a number of different functions. Count up down food timer Bike light Metronome KIT (knightrider) 5
Are there different types of PIC AXE Chips? PICAXE MICROCONTROLLERS PICAXE Type IC Size Memory (lines) I/O Pins Outputs Inputs ADC Data Memory Polled Interrupt COST PICAXE-08 8 40-110 5 1-4 1-4 1L 128-prog No 1.15 PICAXE-08M 8 80-220 5 1-4 1-4 3 256-prog Yes 1.50 PICAXE-14M 14 80-220 13 5 6 2 256-prog Yes 1.70 PICAXE-18M 18 80-220 13 8 5 3 256-prog Yes 2.00 PICAXE-18X 18 600-1800 14 9 5 3 256+i2c Yes 3.00 PICAXE-20M 20 80-220 18 8 8 4 256-prog Yes PICAXE-20X2 20 1000-3200 18 1-17 1-17 0-9 256+i2c Yes PICAXE-28X1 28 1000-3200 23 9-17 0-12 0-4 128+i2c Yes PICAXE-28X2 28 1000-3200 x4 23 0-20 0-20 0-9 256+i2c Yes 4.50 PICAXE-40X1 40 1000-3200 32 9-17 8-20 3-7 128+i2c Yes PICAXE-40X2 40 1000-3200 x4 32 0-26 0-26 0-11 256+i2c Yes PICAXE Type Suffix M IC size Memory (lines) I/O Outputs Inputs ADC Data Memory Polled Interrupt refers to the order code of the chip M means music refers to the number of legs refers to the maximum number lines of programming code you can use. refers to the number of INPUTs or OUTPUTs you can connect to the chip refers to the dedicated Output connections refers to the dedicated Input connections refers to the number of ANALOGUE to DIGITAL CONVERTERS there are on the chip. L means low resolution. refers to the READ in information that can be stored refers to whether or not you can parallel process instructions However the PIC chip on its own cannot operate a system. The PIC chip will need to be interfaced (connected) to the outside world by designing a circuit and then a Printed Circuit Board (PCB). 6
What does a PICAXE chip look like? The N Identifies pin 1 The input and output components can then be connected to the PIC chip via the copper tracks on the PCB and the program running on the PIC chip will operate the system in a predetermined sequence. What are the rules when using a PICAXE chip? + 3-5 Volts 1 8 0 Volts Serial In 2 7 Pin 0 OUTPUT and Serial Out Pin 4 In/Out 3 6 Pin 1 Input & Analogue In Pin 3 Input only 4 5 Pin 2 In/Out PIC AXE Rules 1 The maximum voltage used with a PICAXE CHIP is 5 Volts 2 PIN 0 is OUTPUT and Serial OUT 3 PIN 1 is INPUT/OUTPUT or Analogue IN 4 PIN 2 is INPUT or OUTPUT 5 PIN 3 is INPUT ONLY 6 PIN 4 is INPUT or OUTPUT 7
7 LEG 2 is 8 LEG 1 is 9 Leg 8 is 10 The analogue input is on PIN 8
How can I tell a PIC chip what I want it to do? PROGRAMMING Writing a programme is about sequencing what you want the system to do. What do you think sequencing means? At the start of a control system it is useful to write a control statement. If.. then.. For example: If it the room gets dark then switch on a light. From this statement a sequence of instructions can be written. 1. If it is dark then switch on light 2. Switch off the light 3. Go to instruction 1 However what is wrong with this sequence? (think logically) Write an improved set of instructions here 9
Is there another way to write a computer programme? You can write a programme to control a device by using a more visual method called FLOWCHARTING. Flowcharts use symbols. Start or Stop a flow chart N Y Word bank Label the boxes by using these descriptions: Define a SUB(routine) dotted lines GOSUB(routine) straight lines Decision (Yes and No) Action, Pause or Delay (rectangular) 10
A typical flow chart used to flash LEDs after a button has been pressed Computer Control Start N Is the switch pressed? Y Switch on LED 1 for 1s NOTE how many things are happening inside this one action box? Switch off LED 1 for 1s Switch on LED 2 for 1s Switch off LED 2 for 1s Switch on LED 3 for 1s Switch off LED 3 for 1s Switch on LED 4 for 1s Switch off LED 4 for 1s Switch on LED 5 for 1s Switch off LED 5 for 1s Switch on motor 1 for 1s Switch off motor 1 for 1s Switch on buzzer 1 for 1s What is the limitation of this flowchart? (hint how many times will the LEDS flash? Switch off buzzer 11
SAQ 1. Draw the flowchart symbol for a decision, include directional arrows. [3] 2. Name three advantages of using MICROCONTROLLERS [3] 3. What does PIC stand for? [3] 4. Name three uses for microcontrollers [3] 5. How can you identify pin number 1 on any chip? [1] 6. Draw an action box as used in a flow chart, include directional arrows. [2] A* = 13, A = 11, B = 9, C = 8, D = 6, E = 4, F = 3, G = 2 12
Task 1 Designing a PCB Using what you know about electronics design a circuit to light up 4 LEDS from PIC Chip when you press a push button. Draw your circuit here: Now you will earn how to convert your circuit into a PCB using Quickroute 4.0 Start Programmes Subjects Technology Quickroute 13
QUICKROUTE is a piece of software that will convert a SCHEMATIC diagram into a PCB layout. It is COMPUTER AIDED DESIGNING (CAD) using electronics. Step 1 Draw your schematic diagram Right mouse click on the symbols menu Next select the 8 pin DIL Step 2 Click where you want to drop the component and enter the details as shown opposite. NOTE In the OPTIONS SYMBOL menu you can toggle on/off DISPLAY IDENTS to show or not show the labels Step 3 Next select symbols and the menu for passive res/cap/ind and look for the symbol No. 74 RES STD 0.25W (resistor standard 0.25 Watts) 14
Place the resistors where they are in your circuit diagram and give them the correct values. Step 4 Rotate and place resistors for the input potential divider circuit. Step 5 Add the GENERIC LED from the SEMI DIODE, TRANSISTOR menu. 15
Step 6 Add a voltage source from the SIMULATOR SPICE menu symbol NUMBER 16. Step 7 Connect up your circuit. Left click the line icon. Left click where you want it to start. Left click where you want it to connect. Right mouse click to end the line. To delete Left click the select tool to select a line and press delete. Step 8 Check your circuit looks similar to this one 16
Step 9 In this image the DISPLAY IDENTS are toggled ON. The schematic is now finished save it to a folder called TECHNOLOGY and call it PICDR1.BUT you can only use 7 letters with no spaces. Print off your SCHEMATIC DIAGRAM and stick it into your sketch book. The next stages are: NET COMPILE and then SCHEMATIC CAPTURE Read on only when you have saved your file 17
Changing the schematic into a PCB layout. Step 1 Click the net compile icon. Step 2 look for faults where joints have not been made and fix them e.g. this line is not joined delete the line and do it again. Step 3 click SCHEMATIC CAPTURE and the SCHEMATIC drawing will be converted into a rats nest PCB format. The symbols have been changed into their component layouts ready for soldering. CLICK YES to drawing will be lost. Save this file as PCBPIC1 The RATS NEST is an untidy rubber banded drawing too big to make and needs proper routing. 18
Step 4 Open up QUICKROUTE again, so you have 2 copies open and open up the PICDR.SCH. Now you have one copy of your SCHEMATIC and one copy of your PCB Step 5 Rearrange your components to make the board as small as possible. Rotate the components so they look like your schematic drawing. SAVE YOUR FILE as PCBPIC1 Step 5 Double click the components and using your schematic diagram label the components correctly. Start at R1 and work through. Step 6 Rearrange to make the PCB as small as possible and change the LED symbol for one found in the symbols menu. The rubber bands remain behind. 19
Step 7 Add copper tracks from the NET LINE menu No. 5 0.03 (0.03 inches) Step 7 From the VIEW menu click CURRENT LAYER and only the orange layer will be shown. No add ROUND PAD no. 72 to MOST of the pads use No. 88 for the LEDs Step 8 Using the T tool label the PCB Note LEDS moved so they will fit next to each other Step 9 Delete the symbols and flip so it can be used as the underneath acetate. 20
Step 10 Add the stereo socket for programming. Downloading the Program The serial download circuit is identical for all PIC AXE chips. The circuit consists of 3 wires from the PIC AXE chip to the serial port of the computer. One wire sends data to the serial input of the PIC AXE, one wire transmits data from the serial output of the PIC AXE to the computer, and the third wire is the common ground line between PIC AXE and computer. 3 2 1 Download stereo socket Above View 22K Serial Out Serial In 0V 10K PICAXE How can I get a 5 volt supply from a 6Volt battery? 4 x 1.5 Volts = 6 0.7 Volt drop now 5.3 Volts to PIC chip circuit 100µF 21
Step 10 should look like this. The stereo socket has been added A thin outline added Copper sections filled in to assist in the speed of etching the board Your name on the PCB Must be added 22
Writing Programmes Programming your chip Checklist Is the battery connected? Have you got a programming jumper? Is the lead connected into the serial port? Have you checked the quality of your soldered joints? Are you using a PICAXE 08? Is the download circuit correct on your PCB? Is the software set up for the PICAXE 08? Serial output of PC 6V battery 23
Program 1: Control statement: If the button is pressed light up the LEDS. If is is pressed again turn them off. PIC AXE 08 MODE. If this is wrong click view options and select 08. 24
Programme 2 Control Statement: If button is pressed all lights flash on and off quickly. When pressed again lights go off 25
Programme 3 Exercise Timer control statement: If the button is pressed light up 3 leds. Turn one off every 5 seconds until a minute is up then flash one 5 times. Notice this one has a count feature Adding 1 to a variable b0 and then testing its value 26
Programme 4 Egg Timer: If the button is on and extinguish LEDS in sequence for 3 and half minutes 27
Programme 5 Programmed Nightlight: If the button is pressed then switch on all LEDS and switch them off one at a time after every 5 minutes. BUT THERE IS A FAULT IN THIS PROGRAMME. FIND IT AND FIX IT Think about how to test it without waiting for 5 minutes at a time. 28
For more information about the PICAXE READ the booklet from the website www.picaxe.co.uk 29
Advanced programming Turning your PCB into a hot cold thermometer using a PICAXE 08 M chip 1. Remove the LED on PIN1 2. Connect a thermistor to PIN 1 (ADC) 3. Use the debug 0 and readadc1, b0 command 4. Read off the values of temperature on the screen 5. Use these values along with the VAR command to make a 3 LED thermometer Control statement: Turn on 2 LEDS at room temperature; 3 LEDS if it is hotter than room temperature and only 1 if it is colder than room temperature. 30