background image

33

PICAXE-08 ALARM PROJECT

revolution

© copyright 2002 - AXE102 Alarm Student Project Notes Version 1.1

Revolution Education Ltd.   Email: [email protected]   Web: www.rev-ed.co.uk

33

Supported by:

Step 4 – Download a program to test LED 0.

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.

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).

Type in and download the following program:

program like this:

main:

high 0
wait 1
low 0
wait 1
goto main

The LED should flicker as the program downloads. After the download is complete the

LED should flash on and off every second. If the LED does not flash check that it is

around the correct way and that the 330R resistors are in the correct positions on the

PCB.

If the program does not download check that the 22k, 10k, socket and IC socket are all

soldered correctly. Use a multimeter to make sure you are getting 4.5V across the top legs

(1 and 8) of the microcontroller. Check that the cable is pushed firmly into the socket

and that the correct serial port is selected within the software.

Step 5 – Test the output

Connect an output device (e.g. buzzer) to the output wires

and then type in and download the following program:

main:

high 4
wait 1
low 4
wait 1
goto main

The buzzer should sound on and off every second. If it

does not check that the transistor and diode and buzzer

wires are all around the correct way.

start

high 0

low 0

wait 1

wait 1

start

high 4

wait 1

wait 1

low 4

Summary of Contents for AXE102

Page 1: ...ystem 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 p...

Page 2: ...in devices such as the alarm 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 th...

Page 3: ...ses and an alarm output that could be a siren or motor 3 The design will be also be able to react to analogue sensors such as light sensors Block Diagram The block diagram for your alarm may look like...

Page 4: ...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...

Page 5: ...iances 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 r...

Page 6: ...enever you want to download a new program The circuit diagrams of PICAXE circuits often do not include the components above to make it easier to understand the input output connections However the two...

Page 7: ...ery pack made up of 4 AA cells will last much longer than a 9V PP3 battery as it contains a larger total amount of chemical energy as it is physically larger Therefore items that require more power to...

Page 8: ...onic printed circuit boards by battery snaps Always ensure you get the red and black wires the correct way around It is also useful to thread the battery snap through holes on the board before solderi...

Page 9: ...e available in many different colours including red yellow green and blue Special ultrabright LEDs are used in safety warning devices such as the flashing lights used on bicycles Infra red LEDs produc...

Page 10: ...the program 4 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...

Page 11: ...erefore when a buzzer is connected to a battery it will always make the same sound A piezo does not contain this circuit and so therefore needs an external signal This signal can be supplied by the ou...

Page 12: ...und note that some sounders cannot produce very high tones and so number greater than 127 may not be heard When using multiple sounds you may also include them all on the same line e g sound 2 65 100...

Page 13: ...with a flat edge The flat edge enables the base collector and emitter legs to be correctly identified Using motors Motors can generate electrical noise as they turn This is because the magnets and ele...

Page 14: ...ond If the buzzer does not sound check that 1 the diode is connected the correct way around 2 the correct resistors are used 3 the transistor is connected the correct way around 4 the buzzer red wire...

Page 15: ...ber of different types of switches e g push switches that detect a momentary push micro switches with long levers that detect small movements tilt switches that detect jolting reed switches that detec...

Page 16: ...This program will switch an output on and off according to if the switch is pushed or not main make a label called main if input3 is on then flash jump if the input is on goto main else loop back aro...

Page 17: ...electronic circuits to measure changes in light level What are LDRs used for LDRs are used in automatic street lamps to switch them on at night and off during the day They are also used within many al...

Page 18: ...ropriate If desired the fixed resistor can be replaced by a variable resistor so that the threshold value can be tuned to different light values A more versatile way of using the LDR is to measure a n...

Page 19: ...connecting the LDR it can be tested as an analogue sensor by a program like this main readadc 1 b1 if b1 100 then do4 if b1 50 then do0 low 0 low 4 goto main do4 high 4 low 0 goto main do0 high 0 low...

Page 20: ...ed to normally labelled COM1 or COM2 2 Start the Programming Editor software 3 Select View Options to select the Options screen this may automatically appear 4 Click on the Mode tab and select PICAXE...

Page 21: ...y converted into a BASIC program for downloading into the microcontroller Flowchart Screen Select Tool Use this to select and move shapes When a single shape is selected it s BASIC code can be edited...

Page 22: ...just drop it in the general area and then use the select tool to move the shape to the correct position Once the shape is in position click on it so that it is highlighted The BASIC code for the shap...

Page 23: ...s the program runs each cell is highlighted red as it is carried out The Inputs Outputs and Variables windows also appear when a simulation is being carried out To adjust the input values click the on...

Page 24: ...nnected shape is found Therefore always use a stop shape or line to complete the flowchart before simulation or conversion Note that it is possible to quickly convert and then download a flowchart by...

Page 25: ...ches output 0 on and off every second When you download the program an LED connected to output 0 would flash on and off every second main high 0 pause 1000 low 0 wait 1 goto main This program uses the...

Page 26: ...y appear 3 Click on the Mode tab and select PICAXE 08 4 Click on the Serial Port tab and select the serial port that the PICAXE cable is connected to Click OK 5 Type in the following program main high...

Page 27: ...ave a program flowchart 1 Click File Save As or the toolbar icon 2 Type in a filename 3 Click OK To open a saved program flowchart 1 Click File Open or the toolbar icon 2 Select the file type BASIC or...

Page 28: ...or strobe light The project can also react to digital and or analogue sensors e g an LDR light sensor The electronic block diagram is shown below output pin0 is connected to the LED output pin2 is co...

Page 29: ...n the type of LDR used LED1 5mm red LED PZ piezo sounder TR1 BC548B Transistor D1 1N4001 diode C1 100uF electrolytic capacitor IC1 8 pin IC socket IC1 PICAXE 08 microcontroller CT1 PICAXE download 3 5...

Page 30: ...ldering iron in position and touch the solder against the joint Allow enough solder to melt to cover the joint 4 Take the solder away first then the soldering iron 5 Allow the solder to cool for about...

Page 31: ...t worry if the solder joins on the two metal contacts either side of the socket as they are supposed to be joined anyway 6 Push the IC socket into position Make sure the notch at one end points up tow...

Page 32: ...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 p...

Page 33: ...the LED should flash on and off every second If the LED does not flash check that it is around the correct way and that the 330R resistors are in the correct positions on the PCB If the program does...

Page 34: ...ll not work if hanging loose and that the wire link over the letters PX is on the board Step 7 Test the switch Connect a switch to the digital input Type in and download the following program main mak...

Page 35: ...oto main Note it may be necessary to alter the threshold values if the room is dark e g try 60 and 30 instead of 100 and 50 The LED and output should come on at different times as you raise and lower...

Page 36: ...oop which flashes the LED on and off and also checks the analogue sensor fitted with a LDR and digital input fitted with a switch When the push switch is pressed an alarm is sounded for two seconds If...

Page 37: ...read light value high 0 readadc 1 b1 if analogue value low then make sound if b1 40 then beep if switch pushed do alarm if pin3 1 then alarm do a delay pause 500 LED full off and check sensor again l...

Page 38: ...larm if switch off do tamper if pin3 0 then tamper goto main tamper beep until switch shut tamper high 0 sound 2 120 100 if pin3 1 then main goto tamper alarm output on forever alarm high 4 goto alarm...

Reviews: