background image

27

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

27

Supported by:

Programming Editor Software Reminders:

Toolbar short-cuts:

To download/run a BASIC program:

1.

Check the download cable is connected to the PICAXE and the computer’s serial

port

2.

Check that the battery is connected to the PICAXE

3.

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

4.

Click 

PICAXE>Run

 (or the toolbar icon) (or press the shortcut key F5)

To save 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 flowchart)

3.

Select a filename from the list by clicking on it

4.

Click <OK>

To start a new BASIC program:

1.

Click 

File - New

To start a new flowchart:

1.

Click 

File - New Flowchart 

(or the toolbar icon)

To on-screen simulate a flowchart:

1.

Click 

Flowchart - Simulate... 

(or the toolbar icon)

2.

Click on the flowchart to stop the simulation

To convert a flowchart to BASIC:

1.

Click 

Flowchart - Convert to BASIC... 

(or press the shortcut key F5)

To print a program/flowchart:

1.

Click 

File - Print... 

(or the toolbar icon)

2.

If you want each program line printed in A BASIC program to have a number, make

sure the ‘Print Line Numbers’ box is checked

3.

Click <OK>

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: