Silicon ChipThe PICAXE, Pt.4: Motor Controller - May 2003 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: We use too many batteries
  4. Feature: HID Car Headlights - How They Work by Peter Smith
  5. Project: WidgyBox - A Guitar Distortion Effects Unit by Peter Smith
  6. Project: A 10MHz Direct Digital Synthesis Generator by David L Jones
  7. Project: The Big Blaster Subwoofer by Julian Edgar
  8. Feature: The Brightest White LEDs On Earth by Julian Edgar
  9. Product Showcase
  10. Weblink
  11. Vintage Radio: The HMV C43B console radio by Rodney Champness
  12. Project: Printer Port Hardware Simulator by Jim Rowe
  13. Project: The PICAXE, Pt.4: Motor Controller by Stan Swan
  14. Back Issues
  15. Notes & Errata
  16. Market Centre
  17. Advertising Index
  18. Book Store
  19. Outer Back Cover

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

You can view 28 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 "WidgyBox - A Guitar Distortion Effects Unit":
  • Widgybox PCB pattern (PDF download) [01105031] (Free)
  • Panel artwork for the Widgybox (PDF download) (Free)
Items relevant to "A 10MHz Direct Digital Synthesis Generator":
  • PIC16F628A-I/P programmed for the 10MHz DDS Generator [DDSFRQ20.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC16F628 firmware for the 10MHz DDS Generator [DDSFRQ20.HEX] (Software, Free)
  • 10MHz DDS PCB pattern (PDF download) [04105031] (Free)
  • Panel artwork for the 10MHz DDS Generator (PDF download) (Free)
Items relevant to "Printer Port Hardware Simulator":
  • LPT Simulator PCB pattern (PDF download) [07105031] (Free)
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 4 A Shop Spinning along Door Minder . . with PICAXE . with attitude! Hopefully you’ve been following our previous “PICAXE-08” articles and by now have tested, tweaked, tortured and tamed diverse circuits. A lthough these initial “PICNIK box” ideas were based around a solderless protoboard, there’s naturally nothing sacred about that! In fact, reader email feedback shows boundless “down under” prototyping initiative at work, such as just a 16pin DIP IC socket wired as a minimal test bed. A “seamail” even detailed an old salt’s “08” control of a diesel generator (using the READADC feature to monitor output voltage) rustled up while cruising off Tasmania. Did he get a controller dropped by seagull? Perhaps the appeal of PICAXE circuits relates to just such an approach, since many of the “usual” electronic components can be organised under software rather than silicon and cop- per hardware. The “08” is certainly shaping up as the little controller that could … Supply voltage As remarked in April (and now confirmed by Revolution Education), some users have found a 6V supply too high. Unreliable programming, or even “bootstrap” wiping, may occur at this voltage, particularly (it seems) with late 1990’s RS-232/USB transition PCs. (However, all my programming, using a full 6V and an AMD 475MHz notebook, has had no problems.) Naturally 4 AA cells will have more energy on tap to keep your circuit running longer, but it appears that 5V should now be the maximum supply. You don’t have to use a “toy” motor: with suitable buffering, this PICAXE project can control motors in a “real” device such as this cordless drill. . . Here we are modifying a cheap calculator to act as a poor man’s counter. 84  Silicon Chip by Stan Swan Several techniques to achieve this may be used: use a dummy shorting cell and so run off a 3 cell (4.5V) supply; drop 0.7V multiples with a series-connected silicon diode or two; or even use Nicad/NiMH cells (4 x 1.2V = 4.8V). Outputs Outputs so far have just driven LEDs or made sounds but could even be used to pull in sensitive relays. When more power hungry loads are driven, the limited PICAXE output current (~20mA) needs buffering if the IC is not to be overwhelmed. For modest loads, drawing just a few 100mA, a simple “electronic relay” bipolar transistor will handle this job nicely. Should you have more ambitious applications in mind, drawing considerable current, then respect all those boring issues relating to separate power supplies, heat dissipation and possibly substantial “back-EMF” and stalling currents. For such uses, the L293D H-bridge motor driver IC is suggested, since it’s capable of forward-reverse-stop twin motor control (to 600mA per channel) and comes with inbuilt spike protecting diodes – all for under about $10. Revolution Education sell the L293D pre mounted on the AXE023 motor driver board, that even includes a PICAXE-08 socket. To ease you into motor control however, this month’s main circuit uses a very efficient DC “solar motor”, typically drawing just 30mA at 3V. Small hobby motors often draw hundreds of milliamps – these so called solar www.siliconchip.com.au motors are normally intended for sun powered photovoltaic projects. Just 30mA – this motor could almost be driven directly from a PICAXE output . . . but let’s not push our luck! Almost any handy small signal NPN transistor can be used to achieve buffering, although the base resistor value may need changing if types other than a BC547 (capable of handling more current) are used. The usual DC motor “hash” is taken care of by a 100nF capacitor directly across the motor terminals and a reverse-connected silicon diode tames any motor “back-EMF”. A small paper flag glued suitably to the shaft indicates rotation and is safe enough should your fingers come too close while spinning. The program The program is again quite self explanatory and simply organises an endless but entertaining “speedup/ slowdown” procedure. Try doing this with a 555! The initial “kickstart” helps overcome motor mechanical friction, although a drop of CRC lubricant (“oilware”?) on the bushings may be just as helpful. Reference to previous month’s LDR/ NTC ADC sensor circuits could stimulate you to modify and enhance this program so motor speeds could now be light or temperature-controlled. Aha – how about a small cooling fan that sped up when the air temperature rose? Of course, more powerful small motors can be used but you’ll need to switch to a beefier transistor such as the TIP41C or BD437 along with a modified base resistor for that. One tempting application, still under exploration, is to PICAXE control an efficient Jaycar “Camping Shower” submersible pump. These run on 12V DC (but draw under 1A) and could pump irrigation or solar heated water only under suitable situations, such as at night or when certain temperatures were reached. Check http://manuka. orconhosting.net.nz/solarh2o.htm for my initial ideas . . . You could also modify the code suitably (use HIGH or LOW of course rather than PWM!) if you wish this transistor to control a sensitive relay such as the DSE P-8005. Simply remove the motor and connect leads to the relay’s energising coil instead, leaving the diode in place. www.siliconchip.com.au Once again, it’s very similar to previous months – we make changes to the output circuit and the code inside the PICAXE itself. Note the supply is no longer 6V – see the comments about the 5V rail in the text. The usual protoboard component layout, with the “PICnik Box” mockup below. As usual, for clarity, we have made a few minor component position changes between this photo and the protoboard layout above. Oh, you noticed the LED, did you? That’s yet another variation . . . one which we have covered overleaf. Note the new use for dead batteries as shorting cells! May 2003  85 As we said previously, even though protoboard is convenient for lashing together experimental circuits, you don’t have to use it. The photos at right show a hybrid approach, with most parts soldered to stripboard, but with IC socket strips (DSE P-4300) used for quick “plug in” component changes. Such a setup offers cheaper and more compact circuits and flexibility when away from a soldering iron. Photos: Andrew <copurnicus<at>paradise.net.nz> PICAXE-08 COMMANDS USED THIS MONTH: symbol SYMBOL The only new (pseudo) command here is “symbol”, which all, symbol doesn’t crib on the PICAXE memory, so you can makes programs much more lucid, since “plain English” now blithely redefine those messy b0, b1s with no program words can be used instead for algebraic variables. Best of overhead – not even on the set-up lines text entry either. BASIC PROGRAM LISTING (This can also be downloaded from http://picaxe.orconhosting.net.nz/motorpwm.bas) ‘ Demo PWM motor demo- PICAXE-08 May 2003 SilChip Ver 1.0 11th Mar.03 ‘ Best assembled & tested with solderless “PICNIK” box as detailed SilChip Feb.03 ‘ Refer http://picaxe.orcon.net.nz for background info & potential of PICAXE-08! ‘ Extra parts=DSE P-8980 “Solar Motor”, 4.7k resistor, NPN BC547 transistor ‘ General Si diode & 100-220nF polyester cap (both to stop motor hash & “back emf”) ‘ Dummy cell for 4.5V use. Optional counter =cheap calculator(!) +LDR & heatshrink ‘ New commands here = symbol ‘ Ref.PICAXE prog.editor.pdf help files,& BASIC Stamp 1 manuals etc for insights ‘ via Stan. SWAN (MU<at>W, New Zealand) => s.t.swan<at>massey.ac.nz <= ‘————————————————————————————————— ‘ Byte variables b0= slowing down, b1 = speeding up, b2= slow spin demo ‘————————————————————————————————— ‘ Lines beginning ‘ are program documentation & could be ignored if need be. ‘ Program available for web download => http://picaxe.orconhosting.net.nz/motorpwm.bas ‘————————————————————————————————— symbol slowdown = b0 ‘redefine variables b0, b1, b2 symbol speedup = b1 ‘ using PICAXE “symbol” command symbol slowspin = b2 ‘ to make easier recall/understanding kickstart: pwm 2,255,8 wait 2 ‘ brief routine to overcome initial motor friction ‘ 8 industrial strength pwm cycles to pin 2 ‘ short wait before main routine begins pwmspin: pulsout 4,3000 for speedup = 70 to 255 step 1 pwm 2,speedup,4 next speedup ‘ main pwm demo routine ‘ pulse LED pin 4 for 3mSec to indicate start ‘ values < 70 found unable to easily spin motor ‘ 4 cycles at pin 2 of increasing pwm duty ‘ continue to full speed (255 = 100%) for slowdown = 255 to 70 step –1 pwm 2,slowdown,4 next slowdown ‘ slow motor down at same rate ‘ 4 cycles at pin 2 of decreasing pwm duty ‘ continue until at slowest reliable speed for slowspin= 1 to 80 pwm 2,70,10 next slowspin ‘ longer slow speed spin demo- repeat 80 times ‘ 10 cycles 70/255 % of 5V at pin 2 ‘ continue loop goto pwmspin ‘ repeat entire motor spin demo routine 86  Silicon Chip Some more references and parts suppliers . . . 1. http://picaxe.orconhosting.net.nz Authors enthusiastic web site – updated with many pictures and DIY details. 2. http://picaxe.orconhosting.net.nz/ motorpwm.bas program listing to copy and paste to PICAXE editor. 3. “ The Robot Builders Bonanza” McComb. TAB Books 2000 (DSE B1599) has outstanding motor inter facing details (particularly Steppers & Servos Ch.19-20). 4. Dick Smith Electronics “Solar Motor” (Cat P-8980; approx $3) (3V <at> ~30mA). The P-8005 relay, under 42mA at 5V, can switch up to 2A at 150V. Other mentioned items (capacitor, diode, transistors, heatshrink, etc) via DSE also. 5. Pocket calculator – most bargain and stationery stores. $2-$4 range. 6. Jaycar Electronics “Camping Shower” (Cat YS-2800; approx. $27). 7. Oatley Electronics (www.oatleyelectronics.com) and Microzed (www.microzed.com.au) now stock PICAXE-08 ICs and many accessories. NEXT MONTH: More motor madness So – your triple fives are now in the bin? Since, with flair, “08”s look certain to win. But – you hanker for more – Motor circuits galore? Next up we’ll “step” and “serve” spin! www.siliconchip.com.au A Poor Man’s Counter To stimulate your lateral thinking, here is a simple enhancement for our earlier circuits that offers optically coupled LCD counting. Forget $$ LCD displays and interfacing: we’re going to use a cheap pocket calculator. Pocket calculators sell for only a few dollars, yet offer tempting counting prospects by just exploiting the old schoolboy “1/+/=/=/=” key stroke routine. The carbon-impregnated pad which normally bridges out calculator key contacts offers about 10kΩ resistance. This is (aha!) a value close to a LDR’s bright light resistance. (LDR dark resistance is many megohms – it can be regarded as virtually open circuit). After disassembly, two neat holes are drilled in the PC board near the “=” key and two thin wires are soldered across the “=” key grid contacts. Solder an LDR to these two wires, then black-heatshrink the LDR inside a suitable tube, so that stray light will be cut and triggering will be just from an LED when in the tube’s other end. A suitable PICAXE-generated flash from this LED is now as good as a key press to the modified calculator, although debouncing circuitry (and LDR dark “settling”) tends to limit response rate to about once a second. Most auto-power-off calculators will shut down after some 10 minutes of inactivity too, so perhaps choose an “always on” type (ie, cheap-n-nasty!) if your counting application has only light traffic. SC OATLEY’S “PIC-AXEALL” BREADBOARD KIT In yet another variation on the protoboard theme, Oatley Electronics have released a breadboard kit especially designed for PICAXE (and PIC) experimenters and developers. More importantly, the kit is very cheap, especially when you consider what it includes (significantly cheaper than going the “protoboard” route and much simpler than going down the stripboard path). The kit (Cat K193) includes: • a specially designed PC board with a 28-pin DIL IC socket, capable of handling all PICAXE and most PIC chips • the PC serial interface (10kΩ and 22kΩ resistor) along with the programming slide switch • a piezo speaker • a 5.5V DC mains plugpack and 3.3V or 3.9V zener diode power supply (there is also provision for www.siliconchip.com.au an optional 7805 regulator if more power is required for higher current outputs). • three different coloured status LEDs (with 2.2kΩ resistors). • a pushbutton switch No chip is supplied with the kit, giving complete flexibility as to which particular chip is used. If the type of PICAXE chip ordered with the kit requires a crystal or resonator, it will be supplied with the chip. The top side of the PC board is screen-printed with both component positions and the tracks, or connection paths, underneath the board. Four mounting holes are also provided The board has power supply (+ & -) rails along both edges (similar to the protoboard arrangement) while each of the pins on the IC socket is brought out to a pad, which can be connected through to other pads, supply rails, etc. Two electrolytic and several 22nF capacitors are spread around the board to ensure a clean DC supply. While intended as a breadboard, there is nothing to stop the board being used for a permanent PIC/PICAXE project. If it is too big (at 80 x 60mm – shown above life size) it can be trimmed to an appropriate size. At $12.50, we believe this kit is very good value for money, particularly as it includes the plugpack supply. It is available from Oatley Electronics, PO Box 89, Oatley NSW 2223 (Phone 02 9584 3563, Fax 02 9584 3561) or via www. oatleyelectronics.com May 2003  87