Silicon ChipThe PICAXE: Pt.2: A Shop Door Minder - March 2003 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: LED lighting for cars - it's about time / Victoria to stop DIY mains wiring?
  4. Feature: GM's Hy-Wire Fuel-Cell Car by Silicon Chip
  5. Feature: A Look At Emergency Beacons by Peter Holtham
  6. Project: LED Lighting For Your Car by Peter Smith
  7. Project: Peltier-Effect Tinnie Cooler by Ross Tester
  8. Product Showcase
  9. Weblink
  10. Project: The PortaPAL Public Address System; Pt.2 by John Clarke and Leo Simpson
  11. Project: The Little Dynamite Subwoofer by Julian Edgar
  12. Review: Canon's Image Stabilised Binoculars by Leo Simpson
  13. Project: The PICAXE: Pt.2: A Shop Door Minder by Stan Swan
  14. Vintage Radio: Antennas & earthing systems for crystal sets by Rodney Champness
  15. Notes & Errata
  16. Market Centre
  17. Advertising Index
  18. Book Store
  19. Outer Back Cover

This is only a preview of the March 2003 issue of Silicon Chip.

You can view 27 of the 96 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "LED Lighting For Your Car":
  • LED Lighting for Cars PCB patterns (PDF download) [05103031-7] (Free)
Items relevant to "The PortaPAL Public Address System; Pt.2":
  • PortaPAL PCB patterns (PDF download) (01103031-4) (Free)
  • Panel artwork for the PortaPAL (PDF download) (Free)
Articles in this series:
  • The PortaPAL Public Address System (February 2003)
  • The PortaPAL Public Address System (February 2003)
  • 12V SLA Battery Float Charger (March 2003)
  • The PortaPAL Public Address System; Pt.2 (March 2003)
  • The PortaPAL Public Address System; Pt.2 (March 2003)
  • 12V SLA Battery Float Charger (March 2003)
  • Fitting A Wireless Microphone To The PortaPAL (August 2003)
  • Fitting A Wireless Microphone To The PortaPAL (August 2003)
Articles in this series:
  • PICAXE: The New Millennium 555? (February 2003)
  • PICAXE: The New Millennium 555? (February 2003)
  • The PICAXE: Pt.2: A Shop Door Minder (March 2003)
  • The PICAXE: Pt.2: A Shop Door Minder (March 2003)
  • The PICAXE, Pt.3: Heartbeat Simulator (April 2003)
  • The PICAXE, Pt.3: Heartbeat Simulator (April 2003)
  • The PICAXE, Pt.4: Motor Controller (May 2003)
  • The PICAXE, Pt.4: Motor Controller (May 2003)
  • The PICAXE, Pt.5: A Chookhouse Door Controller (June 2003)
  • The PICAXE, Pt.5: A Chookhouse Door Controller (June 2003)
  • The PICAXE, Pt.6: Data Communications (July 2003)
  • The PICAXE, Pt.6: Data Communications (July 2003)
  • The PICAXE, Pt.7: Get That Clever Code Purring (August 2003)
  • The PICAXE, Pt.7: Get That Clever Code Purring (August 2003)
  • The PICAXE, Pt.8: A Datalogger & Sending It To Sleep (September 2003)
  • The PICAXE, Pt.8: A Datalogger & Sending It To Sleep (September 2003)
  • The PICAXE, Pt.8: The 18X Series (November 2003)
  • The PICAXE, Pt.8: The 18X Series (November 2003)
  • The PICAXE, Pt.9: Keyboards 101 (December 2003)
  • The PICAXE, Pt.9: Keyboards 101 (December 2003)

Purchase a printed copy of this issue for $10.00.

MORE FUN WITH THE PICAXE – PART 2 A Shop Shop A Shop Door Minder . . . Door Minder . . . Door Minder . . . with attitude! with with attitude! attitude! by Stan Swan L ast month (Feb 2003) we introduced the innovative PICAXE08 IC and a simple application, a flashing LED, all built into a solderless “PICNIK box”. If you didn’t see last month’s issue, it will pay you to get a copy and read it because some of the concepts might be a little different to what you’re used to, such as BASIC Stamps, etc. By now, readers should have familiarised themselves with basic operations and the commands high, low, pause and goto. PICAXE instructions are much the same as used in classic BASIC programming. There are a lot of BASIC texts around (no pun intended!), such as Greg Perry’s “QBASIC by Example” (QUE 1993) or from the Parallax BASIC Stamp Programming Manuals. There’s also a huge amount of information available on the ’net. Given that you don’t need to be a programming guru to use PICAXE instructions, initial applications here will be educational rather than exotic. PICAXEs have only enough RAM for about 40 program lines, so there’s some incentive to code efficiently! Our simple application here uses about half the memory available, so room remains for your own tweaking. buzzer sound long enough to be noticed; sometimes the buzzer “locks on” when it is actuated to behave more like an alarm. This month’s circuit acts as a “shop door minder with attitude”, since it not only sounds a buzzer when the light beam is broken but also provides a simple “traffic” indication by flashing a LED at an increasingly faster rate with each event. Now that could be handy – if you don’t happen to own a shop and wish to count customers, this project could, at a glance, tell you the number of times your cat door is opened! Don’t own a cat? You’ll think of something to count! The flash rate increases are not linear but counts per minute can be noted and related to visitor numbers via a simple lookup table. A further LED could even be added (pin 0?) to indicate a count of 10 had been reached, at which point the main counter could drop back to a slow rate again. By this means, up to perhaps 30 events can be quite reliably “read off ”. If a PC remains attached, the exact count (to 255 events) can be just read off using debug. Mmm – 255 cats visited last night ? What IS in your pantry! The circuit Aside from the core parts mentioned last month, just a few extra resistors are Shop Door Minder A shop door minder usually consists of a light source which creates a beam, a light sensor which detects that beam and a buzzer circuit which sounds when the beam is broken. Sometimes there is a delay circuit to make the www.siliconchip.com.au If you don’t happen to own a shop, you can always find something else to count – just remember to take into account four legs and a tail . . . March 2003  79 A “debug” screen shot. This reveals just how useful such PC feedback is – you can note all the variables ticking away nicely! used, one of which is a light dependent resistor, or LDR. Your setup values may vary depending on your application but 100Ω in the voltage divider, plus similar as a LED dropping resistor, should do. For initial trials a small bright light (perhaps a white LED) is also needed. More practical setups could see the light path extended with lenses, shrouds or even a mirror. Only small currents pass along the wires so leads to the LDR and light can be conveniently placed. Things really depend on the stray background light seen by the LDR, although this can be allowed for to some extent by altering readadc threshold values. For a longer light path the lens from a pocket torch may help to concentrate the beam, while the LDR could even be recessed into the torch If this looks somewhat similar to last month’s project, it just might be! The basic differences are the LED and LDR which provide an “analog” input to the PICAXE. The PICAXE programming does the rest. base to give shading from stray light. The program’s readadc threshold value, initially 160, may need lowering to suit of course. To prevent false triggering from shadows, reflections or visitor legs (or tails!), a small delay, perhaps “pause 500”, may be needed in the readadc loop. Obviously this delay may cause the unit to become unresponsive if events occur too rapidly. Having a light on to hold the alarm off may be wasteful of battery power of course. Perhaps you could modify the program so that darkness holds the sensor off and room light alone is enough to trigger things – much as would occur when a medicine cupboard door was opened. The point of these PICAXE circuits is to stimulate your interest, to see what can be done very cheaply and to help you come up with your own variations. Of course, we will help you along the way with more applications to keep those creative juices flowing! Incidentally, if you come up with a scathingly brilliant PICAXE application that you would like to share with the world (and perhaps feature on these pages), please feel free to email me – s.t.swan<at>massey.ac.nz Where to get the PICAXE-08 Currently there is no Australian distributor. Order direct from the UK agents (Revolution Education) on line shop www.techsupplies.co.uk – they are very prompt. There are a few differences between the photo above and the Protoboard layout at right. Follow the layout and you shouldn’t go wrong! 80  Silicon Chip www.siliconchip.com.au PICAXE-08 COMMANDS USED THIS MONTH readadc PICAXEs have a valuable Analog to Digital Conversion (ADC) feature, which in theory converts “real world” analog voltages into 256 steps of digital equivalents. There’s an unavoidable deadspot on the upper range however and the resulting 160 divisions are treated in blocks of 10, so only 16 discrete values are available! Although obviously unsuitable for MP3 encoding or the like, this is quite enough for many simple applications. In fact our circuit here uses ADC at just a yes/no level in response to an LDR’s (light dependent resistor) resistance changes with illumination, so not even all these 16 divisions matter. Pin 1 ADC input needs a voltage rather than a resistance, so the old voltage divider trick is rustled up, involving two series resistors connected between +ve and ground with their midpoint delivering a variable voltage as the LDR value changes. The readadc command finally assigns this ADC value to a program variable at pin 1. Alter the readadc threshold value or resistor (here 160Ω and 100Ω) to fine tune with your LDR and light path. Incidentally, LDRs typically have a resistance of 1 MΩ + in the dark and around 1 kΩ in bright light, with a quite rapid response as illumination alters. sound With the suggested piezo speaker, sounds can be directly produced from output pins using the sound command. Most piezos are optimised for high frequencies (typically 4kHz) so fidelity may be poor for other tones. It’s worth experimenting with your setup, since a more distinctive “fruity” alert may be produced with two sounds together. debug If the serial programming cable remains connected during PICAXE runs, program data values can be usefully monitored on the PC screen. Up to 16 “byte” variables (b0 - b15) can have tabs kept on them. pulseout This provides timed duration output pulses (to microseconds) at specified pins, and effectively packages up HIGH, PAUSE and LOW in one efficient command . for - next (step) Creates a repeating loop that executes program lines between the FOR and NEXT statements as it increments. The optional STEP value defaults to 1 unless specified. maths operations Variables to a maximum value of 255 (at which point they roll over) can be added, subtracted, multiplied or divided, with left to right solving but with only integer solutions. Hex and binary are also handled but brackets are disallowed and fractional portions of results are discarded (although clever techniques can off set this). BASIC PROGRAM LISTING (This can also be downloaded from http://picaxe.orconhosting.net.nz/adcprog.bas) ‘ Demo program for March 2003 SilChip PICAXE-08 article Ver1.0 20th Jan 2003 ‘ Best assembled & tested with solderless “PICNIK” box as detailed SilChip Feb03 ‘ Refer http://picaxe.orcon.net.nz for background info & potential of PICAXE-08 ‘ Extra parts = LDR, White LED, Red LED, 2 x 100 Ohm, 1 x 330 Ohm, piezo speaker ‘ LDR & illuminating light can be moved apart- maybe use lenses & light guides? ‘ New commands here = sound, readadc, debug, pulsout, for-next & simple maths. ‘ Ref.PICAXE prog.editor .pdf help files,& BASIC Stamp manuals etc for insights ‘ via Stan SWAN (MU<at>W, New Zealand) => s.t.swan<at>massey.ac.nz <= ‘—————————————————————————————————— ‘ Byte variables b0 = LDR “resistance value” b1 = event counter ‘ b2 = pulse delay in msec b3 = sound loop ‘ Strictly only the LHS code below is needed. Remarks (‘) can be ignored ‘—————————————————————————————————— sound 4,(100,10,80,10) ‘initial dual sounds to inform that powered up ldrdemo: readadc 1,b0 debug b0 if b0 <160 then beeper b2 = 250/b1 if b2 =0 then ldrdemo pulsout 2,1000 pause b2:pause b2:pause b2 goto ldrdemo ‘ LDR resistance monitoring routine ‘ read LDR low resolution value via voltage divider ‘ show variable LDR value(s) to attached PC screen ‘ warbling alert tones when LDR shaded ‘ produce delay value.NB max variable value is 255 ‘ prevents LED flash when not yet triggered ‘ pulse LED pin 2 for 1000x10 microsec = 10millisec ‘ more events give decreasing delay between pulses ‘ continually loop unless LDR shaded beeper: for b3= 1 to 3 sound 4,(100,20,80,20) next b3 b1=b1+1 goto ldrdemo ‘ piezo speaker 2 tone sound routine ‘ loop to sound tones 3 times ‘ repeating dual tones each 20 msec ‘ sound loop increment ‘ event counter increment ‘ return to monitoring routine www.siliconchip.com.au Some more references . . . 1. “QBASIC by Example” Greg M Perry (Que Books 1993) 2. Parallax Inc, the BASIC Stamp originators, have free resource downloads (.PDF files) via their web site (www.parallax.com) BASIC Stamp Users Programming Manual Version 2. (351 pages, 3.2MB download) BASIC Stamp 1 Application Notes Ver 1.9 (126 pages, 1MB download). 3. “The Art of Electronics” Horowitz and Hill (Cambridge University Press 1989). Chapter 9 offers good ADC insights. NEXT MONTH: The Picaxe by now you should know, Gives sounds & makes LEDs glow, But it also does more, Next ’tis a PWM chore, And all for very small dough! SC March 2003  81