background image

13

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

13

Supported by:

T

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

Where are transistors used?

Transistors are used in radios and electronic toys and many

other devices such as this electronic stapler.

Using transistors.

A transistor has three legs. These are labelled base,

collector and emitter. The base connection is the leg

that is used to activate the ‘electronic switch’. When a

small current is passed through the base connection, it

allows a much larger current to flow down between the

collector and emitter. This larger current can be used to

switch on devices such as motors, lamps and buzzers.

A common transistor is the BC548B type. This has a

plastic can 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 electric coils inside

the motor generate electrical signals as the motor

rotates. These signals (the electronic noise) can

disrupt the operation of the microcontroller. Some

motors, like solar motors, produce very little noise

whilst others can create a lot of noise.

To prevent electrical noise affecting the micro-

controller circuit a 220nF capacitor should always

be soldered across the motor terminals before it is used.

In addition, a diode (e.g. 1N4001 diode) should be connected

alongside the motor. This prevents damage to the transistor as

the motor slows down after the transistor switches off (for a

short period of time (as it slows down and stops) the motor is

acting as a ‘dynamo’ and generating electric current!). When

connecting a diode make sure the ‘band’ is connected the

correct way around. It is also a good idea to connect a 100uF

electrolytic capacitor across the battery supply to help

‘suppress’ the the electrical noise.

0V

Pin

1k

Output

device

BC548B

V+

1N4001

emitter (E)
base (B)
collector (C)

B

C

E

m

+V

0V

m

+V

0V

small

current

into base

large

current

across

collector/

emitter

Содержание AXE102

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Отзывы: