* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Yr9_PIC_Chip
Transistor–transistor logic wikipedia , lookup
Valve RF amplifier wikipedia , lookup
Resistive opto-isolator wikipedia , lookup
Regenerative circuit wikipedia , lookup
Music technology (electronic and digital) wikipedia , lookup
Electronic paper wikipedia , lookup
Index of electronics articles wikipedia , lookup
RLC circuit wikipedia , lookup
Electronic engineering wikipedia , lookup
Crossbar switch wikipedia , lookup
Flexible electronics wikipedia , lookup
Rectiverter wikipedia , lookup
Integrated circuit wikipedia , lookup
Printed circuit board wikipedia , lookup
Opto-isolator wikipedia , lookup
Surface-mount technology wikipedia , lookup
Charlieplexing wikipedia , lookup
Y Pant School The PIC Chip Name/Door Plate Year 9 Project 1 Introduction This is a major DESIGN and MAKE Project, but do not let that worry you! During years seven and eight you designed and made things using all sorts of materials and processes. This project will draw on all of the skills and knowledge learned during those projects and introduces you to control to help you produce a useable product. The Project Situation Control is used in electronic circuits to capture a person’s attention and to follow a sequence of operations. You have been asked to produce a name plate for a room of your choice which will incorporate an electronic control circuit with LED’s that you will programme to control the LED’s on your circuit. Brief Design & make a name/door plate for a room of your choice, which will incorporate a PIC Control Circuit. Brief 2 Design and make an electronic dice. The dice must show numbers 1-6 randomly by switching LEDs on and off. Design & Specification Points 1) The design will use a picaxe08 microcontroller as its controller. 2) The design will include LEDs in a dice pattern. 2 Organising your Project We are going to use a combination of methods to make an attractive name plate. To do this we will first ANALYSE the problem in class. An important factor is your design work. Before we do anything else it is necessary to outline two of the ESSENTIALS in this project: 1. It must use a PIC Control Circuit. 2. It must house the circuit securely. We are going to use a combination of materials to satisfy the requirements. Everyone has used metal, wood, plastics, and electronics in projects. This project is going to extend the skills that you have in a number of these areas. The following pages describe electronic components and their uses. You will be shown how to use them to produce a circuit that will help to illuminate your name plate. You will learn to produce the TECHNOLOGY currently used to control electronic circuits, which influence what we ALL buy. To help us produce the most attractive advertisement everyone will have the opportunity to use the STIKA. This is a computer generated manufacturing tool that copies your designs on to self-adhesive vinyl. It will help you to produce a ‘real life’ advertising display. The use of Electronics, Plastics, Timber, Stika-12 and Unimatic CAM will help you to produce a high quality advertisement. This project puts you in touch with the future, in how many other things do you achieve the same thing, think about it? 3 Designing with Electronics/Control Using Electronics to solve design problems is not as difficult as you might think. Most of you will remember the circuit you had to design for your animated display; this circuit has a few more components but is not that much more difficult to understand. It uses control. 4 Electronic Dice What is a microcontroller? A microcontroller is often described as a ‘computer on a chip’. It can be used as an ‘electronic brain’ to control a product, toy or machine. The microcontroller is an integrated circuit (‘chip’) that contains memory (to store the program), a processor (to process and carry out the program) and input/output pins (to connect switches, sensors and output devices like motors). Microcontrollers are purchased ‘blank’ and then programmed with a specific control program. This program is written on a computer and then ‘downloaded’ into the microcontroller chip. Once programmed the microcontroller is built into a product to make the product more intelligent and easier to use. Example use of a microcontroller 5 The picture above shows an electronic dice that can be made to generate a random number. It can be used like a normal dice in games. The dice works by switching Light Emitting Diodes (LEDs) on and off in the pattern of dots found on a traditional dice. The microcontroller is the ‘brain’ of the dice. Microcontrollers are powerful electronic components that have a memory and can be programmed to switch things on and off in any sequence. The microcontroller in the dice can switch the LEDs on and off to show numbers between one and six. As the ‘diagonal’ pairs on LEDs in the dice always light at the same time, they can be switched on and off by the same microcontroller output. Therefore 4 outputs (3 pairs and central ‘dot’) are required. Block Diagrams The electronic system for an electronic dice can be drawn as a ‘bock diagram’. Input Push Switch 6 Process Microcontroller Output LEDs The push switch is an electronic device that can detect movement and is known as an ‘input’. The microcontroller then ‘decides’ how to behave and may then switch the output LEDs on in different patterns. What is the PICAXE System? The microcontrollers used in devices such as electronic games can be difficult to program, as they generally use a complicated programming language called ‘assembler code’, which can be quite difficult to learn. The PICAXE system makes the microcontrollers much easier to program. The control sequence can be drawn (and simulated) on the computer as a flowchart, or written in a simpler programming language called BASIC. This makes it much easier to use the microcontroller as the complicated ‘assembler code’ does not need to be learnt. A simple BASIC program and flowchart are shown here. In this case both programs do the same thing – flash a light (connected to output 0) on and off every second. Main: high 0 wait 1 low 0 wait 1 goto main start high wait 1 low 0 7 wait 1 Personalising your Electronic Dice There are several ways to personalise your electronic dice name plate. Here are some things to think about: Your LEDs and switch will need to be fixed to the circuit using wires. As the name plate will house the circuit. What colour LEDs are you going to use? The most common LEDs are red, but many other sizes and colours are available (e.g. blue) How will you activate the dice? We are going to use a push switch but you could have a light sensor (LDR) that can detect changes in light level when you put your hand over it. Electronic Components The main electronic components you may need for you electronic dice are shown here. 8 PICAXE-08 microcontroller Light Emitting Diode (LED) Push Switch 3 x AA Battery Box Picaxe Download socket Electronic Components Microcontrollers Resistor What is a microcontroller? A microcontroller is often described as a ‘computer on a chip’. It can be used as an ‘electronic brain’ to control a product, toy or machine. The microcontroller is an integrated circuit (‘chip’) that contains memory (to store the program), a processor (to process and carry out the program) and input/output pins (to connect switches, sensors and output devices like motors). Microcontrollers are purchased ‘blank’ and then programmed with a specific control program. This program is written on a computer and then ‘downloaded’ into the microcontroller chip. Once programmed the microcontroller is built into a product to make the product more intelligent and easier to use. Where are microcontrollers used? Applications that use microcontrollers include household appliances, alarm systems, medical equipment, vehicle subsystems, and electronic instrumentation. Some modern cars contain over thirty microcontrollers – used in a range of subsystems from engine management to remote locking! As an example, a microwave oven may use a single microcontroller to process information from the keypad, display user information on the seven segment display, and control the output devices (turntable motor, light, bell, and magnetron) 9 How are microcontrollers used? Microcontrollers are used as the ‘brain’ in electronic circuits. These electronic circuits are often drawn visually as a ‘block diagram’. Input Process Output The program for the microcontroller is developed (and tested) on the Door Switch Microcontroller computer and then downloaded into the microcontroller. Once the Bell program is in the microcontroller it starts to ‘run’ and carries out the instructions. How is the program transferred to the microcontroller? The PICAXE-08 microcontroller is programmes by connecting a cable from the serial port at the back of the computer to a socket on the printed circuit board (PCB) beside the microcontroller. This socket (which looks like a head phone socket as found on an MP3 Player) connects to two legs of the microcontroller and to 0V from the battery. This allows the computer and the microcontroller to ‘talk’ to allow a new program to be downloaded into the microcontrollers memory. The socket and interfacing circuit is included on every PCB designed to be used with the PICAXE-08 microcontroller. This enables the PICAXE microcontroller to be re-programmed without removing the chip from the 10 PCB – simply connect the cable whenever you want to download a new program! BATTERIES What is a battery? A battery is a self-contained source of electronic energy. It is a portable power supply. Batteries that contain chemicals that store energy. When connected into a circuit this chemical energy is converted to electrical energy that can then power the circuit. Which battery size should I use? Microcontrollers generally require 3 to 6V batteries to work, and so it is better to use a battery pack made up of two, three or four AAA or AA size cells. Never use a 9V PP3 battery as the 9V supply will damage the microcontroller. Which battery type should I use? Different batteries are made of different chemicals. Zinc-carbon are the cheapest, and are quite suitable for many microcontroller circuits. 11 Alkaline batteries are more expensive, but will last much longer when driving devices like motors that require larger currents. Lithium batteries are much more expensive but have a long life, and so are commonly used in computer circuits to provide a clock back up. Rechargeable can be recharged when they ‘run-down’. They are generally made up of nickel and cadmium (Ni-cad) or nickel metal hydroxide (NiMH) chemicals. SAFETY! The microcontroller chip will be damaged if the battery is connected incorrectly. Using Battery Snaps Battery packs are often connected to electronic printed circuit boards by battery snaps or wires. Always ensure you get the red and black wires the correct way around. It is also useful to thread the wires through holes on the board before soldering it in place – this provides a much stronger joint that is less likely to snap off. Never accidentally connect a 9V PP3 battery to the battery snap – this will damage the microcontroller, which only works between 3 and 6V. 12 Resistors Resistors are very important in electronics because we often have to limit the amount of current flowing in a circuit or parts of it. The most common resistors consist of a thin film of carbon over a ceramic tube, each end of which has a wire connecting leg. The resistance simply depends on the type of carbon used. Carbon Film is in the middle of the Resistor. Resistors are colour coded with four bands that can be read to give their values in ohms. The higher the number in Ohms, the greater the resistance. To read a resistor’s value, look at its first colour band (opposite end to the metallic band) and find this colour on the chart. Now look across the chart to Column 1 and note the number. Do this for the other two colour bands, going across the chart to Column 2 and then to Column 3. 13 If, for example, the resistor’s first colour band is yellow, we note ‘4’ in Column 1 on the chart. If the second band is violet, we go across to Column 2 and note ‘7’. If the third is red, we see two noughts in Column 3, giving a figure of 4,700. This is the value in ohms of the resistor. The Resistor Gold + or – 5% Silver = or – 5% Colour Black Brown Red Orange Yellow Green Blue Violet Grey White Band 1 0 1 2 3 4 5 6 7 8 9 Band 2 0 1 2 3 4 5 6 7 8 9 Band 3 Nothing 0 00 000 0000 00000 000000 Work out the resistance values of these resistors Colour 14 Band 1 Band 2 Band 3 Total Blue Grey Brown Red Red Red Brown Black Red The LED Most of the circuits use a light emitting diode (LED) rather than a bulb. LED’s give out less light, but they use less current and cost less. LED’s also come in three colours: red, green and amber. Unlike a bulb, an LED does not have a filament. It is too hard to explain here how it works, but it is easy to use if you follow two simple rules: Examples of different LED’s. Symbol for and LED LED Rule 1 15 An LED must be used with a resistor in the circuit loop. This restricts current flow and prevents the LED taking more current than is good for it. If an LED takes too much current it will break. LED’s are small in size, they are 39mm. LED Rule 2 An LED must be connected in a circuit with its (-) leg facing towards the (-) terminal of the battery. If you look at they bottom of an LED, there is a small flat edge on the plastic, and the (-) leg is nearest to this. An LED is a diode. This lets current pass only when it is connected in a circuit the right way around. If it is connected backwards, nothing happens and no light. Diagram Shows LED Symbol, Flat side of LED, Shorter and Longer legs. Connecting the LED to a microcontroller. Because the LED only requires a small amount of current to operate, it can be directly connected between the microcontroller output pin and 0V (with the series protection resistor). Two LEDs can be driven from the same pin if you use the resistor for each LED. 16 After connecting the LED it can be tested by a simple program like this: main: high 0 wait 1 low 0 wait 1 goto main This program would switch the LED on and off every second. If your LED does not work check: 1. 2. 3. 4. the LED is connected the correct way around. the correct resistor is used. the correct output pin number is being used in the program. all the solder joints are good. This program flashes the LED connected to output pin 0 on and off 15 times using a BASIC programming technique called a for…next loop (this technique cannot be used with flowcharts). The number of times the code has been repeated is stored in the memory of the PICAXE chip using a ‘variable’ called b1 (the PICAXE contains 14 variables labelled b0 to b13). A variable is a ‘number storage position’ inside the microcontroller than the microcontroller can use to store numbers as the program is carried out. main: for b1 = 1 to 15 high 0 pause 500 low 0 pause 500 next b1 end 17 ‘ start a for…next loop ‘ switch pin 0 high ‘ wait for 0.5 second ‘ switch pin 0 low ‘ wait for 0.5 second ‘ end of for…next loop ‘ end program Switching more than one LED at once Sometimes it is useful to switch more than one LED on or off at the same time. This saves time when lots of high and low commands would have to be used together. Pin 4 2 1 0 Value 16 4 2 1 The command that does this is called let pins = After the equals sign a number is used. Each output pin is given a value, and the number used in the program is the sum of these values. Digital Sensors (Switches) What are switches? A digital sensor is a simple ‘switch’ type sensor that can only be ‘on’ or ‘off’. Switches are electronic components that detect movement. There are a large number of different types of switches e.g. 18 Push switches that detect a momentary ‘push’ Micro-switches with long levers that detect small movements Tilt-switches that detect jolting Reed-switches that detect a magnet being moved What are switches used for? Push switches are commonly used on device like keypads. Micro-switches are used in burglar alarms to detect if the cover is removed from the alarm box. Reed switches are used to detect doors and windows being opened and tilt switches are often used to detect movement in devices such as toys, hair-dryers and tool-box alarms. Switch Symbols The symbol for a slide switch and a push switch are shown here. 19 Printed Circuit Boards Modern electronic circuits use only a few wires to connect the main parts together. The components are held together on a printed circuit board called a PCB. Printed circuit board is a thin fibreglass board about 1.5mm thick. On one side of the board is a layer of copper, only about 0.25mm thick. To use the board we must first draw our circuit onto the copper using a special etch resist pen. Take great care at this stage because once the board is placed into the etch tank mistakes cannot be altered. PCB Layout 20 A PCB Board with Components. Etching When you are happy with your circuit, you are ready to place it into the acid (Ferric Chloride). This will eat or etch away all the copper not protected by the special etch resist pen. Take care with this, as it is poisonous and corrosive, don’t get it on your clothes or hands!!! Once all the unwanted copper has been removed you can use the tongs to remove your circuit from the acid and then was it under the cold-water tap. The etch resist pen must now be removed to leave only the copper tracks ready for us to start drilling. Use wire wool to remove the etch pen. An Etching Tank 21 Note the protective gloves that must be worn when using this machine. You can see the PCB in the acid, which is removing the copper, which is not needed. After a circuit board has been placed into an Etching Tank the circuit tracks are left in pen. Once rubbed with wire wool copper is exposed. Drilling You will now need to drill holes in the circuit board for attaching the components. The pins or legs of the components must pass through the board, so they can be soldered to the copper side. To make these small holes you will need a very small drill bit, which is easily broken if not handled with care. Take your time and don’t forget to wear safety glasses!! 22 e-Printed PCB Holes being drilled into a PCB board. The drill bit is very small!!! So, be careful. Soldering Take care when using soldering irons, avoid burning the leads and always replace them in the soldering iron stand when you are not actually using them. Do not leave them lying on a workbench. The component pins and the board should be cleaned with a piece of fine wire wool before soldering. The soldering iron bit is heated and then ‘tinned’ by putting a small amount of multicore solder on it. The solder is hollow and has flux inside. Flux helps to keep the joint clean while it is being heated. It is very important that the work is heated properly, in order to get a good joint, which makes good electrical contact. Hold the tip of the iron on the copper next to the component. Place the solder onto the copper next to the iron. When the work is hot enough the solder will melt and flow. Remove the solder and run the tip of the iron around the pin of the component to make sure it is properly joined to the copper. 23 Example of Soldering Iron Stand, Soldering Iron and Power Source. The power source is used to control current and heat. Always ensure the solder joint is neat and not crossing the tracks. Always solder electronic components correctly to a PCB, if you do not the circuit will not function and the components could break. 24 Remember to follow Health & Safety Rules!!! 25 26