Download Print this page

Advertisement

Quick Links

PICAXE-08 ALARM PROJECT
1
A
S
LARM
YSTEMS
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.
Almost all modern buildings are fitted with some type of alarm. For
instance a fire detection system may have a number of smoke sensors
to detect the smoke from a fire.
However many alarm systems are also safety systems - for instance an
alarm system on an oil rig may monitor the temperature and pressure
of the crude oil as it is being extracted and automatically shut
the system down if a fault is detected. This ensures the safety of
both the workers and the environment around the oil rig.
All systems are made up of input and output devices. Often
these devices are connected to a microcontroller that interprets
the information from the sensors and switches the outputs on
and off at the correct time.
In the case of a fire alarm system the inputs may be smoke
sensors and the keypad on the front of the control panel. The
output devices are the display on the control panel as well as
the external siren and strobe light. The microcontroller is the
'brain' of the system.
Microcontrollers are powerful electronic components that have a
memory and can be programmed to switch things on and off in a
special sequence. The microcontroller in the fire alarm, for
instance, has been programmed to switcyh the siren on and off
when the smoke sensor has detected fire.
1

Advertisement

loading
Need help?

Need help?

Do you have a question about the PICAXE-08 and is the answer not in the manual?

Questions and answers

Summary of Contents for Revolution PICAXE-08

  • Page 1 PICAXE-08 ALARM PROJECT LARM YSTEMS 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).
  • Page 2 PICAXE-08 ALARM PROJECT LOCK IAGRAMS The electronic system that makes up the alarm system be drawn as a ‘block diagram’ . The smoke sensor and keypad provide information to the microcontroller, and so these are known as ‘inputs’ . The microcontroller then ‘decides’ how to behave and may then operate the outputs e.g.
  • Page 3 Design Specification Points 1) The design will use a PICAXE-08 microcontroller as it’s brain. 2) The design will include an LED indicator, a piezo sounder to generate noises and an alarm output that could be a siren or motor..
  • Page 4 PICAXE-08 ALARM PROJECT LECTRONIC OMPONENTS The main electronic components you may need for your alarm are shown here. The next few pages describe each of these components in more detail, and also provide some programming ideas that may be useful when you are later programming your alarm.
  • Page 5 PICAXE-08 ALARM PROJECT 2 - E ECTION LECTRONIC OMPONENTS ICROCONTROLLERS What is a microcontroller? A microcontroller is often described as a ‘computer-on-a-chip’ . It is an integrated circuit that contains memory, processing units, and input/ output circuitry in a single unit.
  • Page 6 PICAXE project board! Output 0 With the PICAXE-08 system leg 7 has two functions - when a program is being run the leg is known as output 0 and can control outputs like LEDs and motors.
  • Page 7 PICAXE-08 ALARM PROJECT ATTERIES What is a battery? A battery is a self-contained source of electronic energy. It is a portable power supply. Batteries contain chemicals that store energy. When connected into a circuit this chemical energy is converted to electrical energy that can then power the circuit.
  • Page 8 PICAXE-08 ALARM PROJECT Safety! Never 'short circuit' any battery. Alkaline and rechargeable batteries can provide a very large current, and can get so hot that they will actually melt the battery box if you short circuit them! Always make sure you connect the battery around the correct way (red positive (V+) and black negative (0V or ground)).
  • Page 9: Light Emitting Diode (Led)

    PICAXE-08 ALARM PROJECT (LED) IGHT MITTING IODE What is an LED? A Light Emitting Diode (LED) is an electronic component that gives out light when current passes through it. An LED is a special type of diode. A diode is a component that only allows current to flow in one direction.
  • Page 10 PICAXE-08 ALARM PROJECT Testing the LED connection. After connecting the LED it can be tested by a simple program like this: start high 0 wait 1 This program would switch the LED (connected to output pin 0) on and off every second. If the LED does...
  • Page 11 PICAXE-08 ALARM PROJECT UZZERS AND IEZO RANSDUCERS What is a piezo transducer? A piezo transducer is a low-cost 'mini-speaker' that can used to make sounds. The sound that the piezo makes can be changed by altering the electronic signals provided by the microcontroller.
  • Page 12 PICAXE-08 ALARM PROJECT Testing the piezo connection. start After connecting the piezo it can be tested by a simple program like this: sound 2,(65,100) sound 2,(78,100) sound 2,(88,100) This program would make the piezo (connected to output pin 2) make 4 different sounds (value 65, 78, 88 sound 2,(119,100) and 119).
  • Page 13 PICAXE-08 ALARM PROJECT RANSISTOR What is a transistor? A transistor is a component that controls current flow in a circuit. A transistor acts as an ‘electronic switch’ so that a small current can control a large current. This allows low-current devices, like a microcontroller, to control large current devices (like motors).
  • Page 14: Output Devices

    PICAXE-08 ALARM PROJECT Testing the transistor using a buzzer A buzzer could be connected as an output device as in this cicruit. After connecting the buzzer it can be tested by a simple start program like this: high 4 wait 1...
  • Page 15 PICAXE-08 ALARM PROJECT IGITAL ENSORS WITCHES What are switches? A digital sensor is a simple ‘switch’ type sensor that can only be ‘on’ or ‘off’ . If a graph is drawn of the on-off signals as the switch is pushed it will look like this: Switches are electronic components that detect movement.
  • Page 16 PICAXE-08 ALARM PROJECT Using switches A switch is used with a resistor as shown in the diagram. The value of the resistor is not that important, but a 10k resistor is often used. When the switch is 'open' the 10k resistor...
  • Page 17 PICAXE-08 ALARM PROJECT (LDR) IGHT EPENDENT ESISTOR What is an LDR? A Light Dependent Resistor (LDR) is special type of resistor that reacts to changes in light level. The resistance of the LDR changes as different amounts of light fall on the top 'window' of the device.
  • Page 18 PICAXE-08 ALARM PROJECT Using LDRs. A LDR can be used in two ways. The simplest way to use an LDR is as a simple on-off ("digital") switch - when the light level is above a certain value (called the 'threshold value') the LDR will provide an on signal, when the light level is below a certain value the LDR will provide an off signal.
  • Page 19 PICAXE-08 ALARM PROJECT Testing the LDR (digital) After connecting the LDR it can be tested as a start digital switch by a simple program like this: pin1=1 low 0 high 0 This program will switch output 0 on and off according to the light level.
  • Page 20 Start the Programming Editor software. Select View>Options to select the Options screen (this may automatically appear). Click on the ‘Mode’ tab and select PICAXE-08 Click on the ‘Serial Port’ tab and select the serial port that the PICAXE cable is connected to.
  • Page 21 PICAXE-08 ALARM PROJECT Flowchart Screen The Flowchart Editor allows flowcharts to be drawn and simulated on-screen. The flowchart can then be automatically converted into a BASIC program for downloading into the microcontroller. Select Zoom Zoom In/Out Pan Line Out If Delay Sub Other...
  • Page 22 PICAXE-08 ALARM PROJECT Line Tool Use this tool to draw lines between shapes. Corners can be added by clicking once. When the line is near to a shape it will ‘snap’ to the connection point. Label Tool Use this tool to add descriptive labels or titles to the flowchart.
  • Page 23 PICAXE-08 ALARM PROJECT On Screen Simulation To simulate the flowchart, click ‘Simulate’ from the Flowchart menu. The program will then start to run on-screen. As the program runs each cell is highlighted red as it is carried out. The ‘Inputs/Outputs’...
  • Page 24: Using Symbols

    PICAXE-08 ALARM PROJECT Downloading Flowcharts Flowcharts are not directly downloaded to the microcontroller. First the flowchart is converted into a BASIC program, which is then downloaded. To convert a program select ‘Convert’ from the Flowchart menu. The BASIC program for downloading will then be created.
  • Page 25 PICAXE-08 ALARM PROJECT ECTION - BASIC ROGRAMMING Programming in BASIC is more powerful than using flowcharts. This is because BASIC contains more commands, eg. for...next loops, which cannot be used with the graphical flowchart methods. However you have to be more accurate in your ‘typing’ as no spelling...
  • Page 26: Detailed Instructions

    Start the Programming Editor software. Select View>Options to select the Options screen (this may automatically appear). Click on the ‘Mode’ tab and select PICAXE-08 Click on the ‘Serial Port’ tab and select the serial port that the PICAXE cable is connected to.
  • Page 27 Check that the battery is connected to the PICAXE Make sure the Programming Editor software is in the correct mode (look for ‘PICAXE-08’ in the statusbar at the bottom left of the screen). Click PICAXE>Run (or the toolbar icon) (or press the shortcut key F5) To save a program/flowchart: Click File - Save As...
  • Page 28: Circuit Diagram

    ECTION LARM The Alarm project uses a PICAXE-08 microcontroller with an LED and piezo sounder as user feedback devices, and a user selectable ‘output’ device (e.g. siren or strobe light). The project can also react to digital and/or analogue sensors (e.g. an LDR light sensor).
  • Page 29 PICAXE-08 ALARM PROJECT UILDING THE LARM What you will need: R1 and R2 10k resistor (brown black orange gold) 22k resistor (red red orange gold) 330R resistor (orange orange brown gold) 1k resistor (brown black red gold) 1k/10k resistor (brown black red/orange gold)
  • Page 30 PICAXE-08 ALARM PROJECT Soldering the PCB. The printed circuit board (PCB) is specially manufactured with a ‘solder resist’ layer to make it simpler to solder. This is the green ‘lacquer’ layer that covers the tracks so that the solder does not stick to these tracks. However for successful assembly the PCB must be carefully assembled and soldered.
  • Page 31 PICAXE-08 ALARM PROJECT These instructions presume you are soldering all the components directly on the board. The instructions are identical if you are using longer wires to join some components (e.g. the LED), although you must be even more careful you get the wires around the correct way on the LED.
  • Page 32: Step 2 - Check The Components

    1) Check that the black battery clip wire is in the hole marked ‘0V’ and the red battery clip wire is in the hole marked ‘V+’ 2) Check that the PICAXE-08 chip is in the socket correctly, with the dent (showing pin1) closest to the stereo socket.
  • Page 33 Connect the cable to the back of the computer and to the PICAXE socket on the PCB. Make sure the cable is pushed fully into the socket on the PCB. start Make sure the software is in the PICAXE-08 mode and the correct serial port is selected (see section 4 of this booklet for more information).
  • Page 34 PICAXE-08 ALARM PROJECT Step 6 – Test the piezo start Type in and download the following program: sound 2,(65,100) sound 2,(78,100) sound 2,(88,100) The piezo should make 4 different noises. If it does not make sure the wires are correctly soldered, that...
  • Page 35 PICAXE-08 ALARM PROJECT Step 8 – Test the LDR start Connect an LDR to the analogue input. Type in and download the following program. readadc 1,b1 b1> 100 b1> 50 low 0 high 0 high 4 low 4 low 4 low 0 Note: it may be necessary to alter the threshold values if the room is dark e.g.
  • Page 36 PICAXE-08 ALARM PROJECT 6 - P ECTION ROGRAM DEAS Now that you have assembled and tested your alarm, it is time to develop your own program. This program can make the alarm react in different ways to the digital and analogue sensors.
  • Page 37 PICAXE-08 ALARM PROJECT Program 1...
  • Page 38 This project development was funded by the UK Offshore Oil and Gas Industry. www.oilandgas.org.uk/education/ (c) Revolution Education Ltd 2002 www.rev-ed.co.uk All rights reserved. May be photocopied for non-commercial educational use in classrooms in schools and colleges only. PICAXE is a trademark of Revolution Education Ltd...

This manual is also suitable for:

Axe102