Silicon ChipPicaxe Infrared Remote Control - November 2004 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Fixed line phones no longer a necessity
  4. Feature: Look Mum: No Wires by Ross Tester
  5. Feature: The New Era In Car Electrical Systems by Julian Edgar
  6. Project: USB-Controlled Power Switch by Jim Rowe
  7. Project: A Charger For Deep-Cycle 12V Batteries, Pt.1 by John Clarke
  8. Project: The Driveway Sentry by Jim Rowe
  9. Project: SMS Controller, Pt.2 by Peter Smith
  10. Project: Picaxe Infrared Remote Control by Clive Seager
  11. Feature: Emergency Power When All Else Fails by Stan Swan
  12. Vintage Radio: Those troublesome capacitors, Pt.2 by Rodney Champness
  13. Back Issues
  14. Book Store
  15. Advertising Index
  16. Outer Back Cover

This is only a preview of the November 2004 issue of Silicon Chip.

You can view 23 of the 112 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 "USB-Controlled Power Switch":
  • USB-controlled Power Switch PCB pattern (PDF download) [10111041] (Free)
  • USB-Controlled Power Switch label artwork (PDF download) (Panel Artwork, Free)
Items relevant to "A Charger For Deep-Cycle 12V Batteries, Pt.1":
  • PIC16F628A-I/P programmed for the Deep-cycle 12V Battery Charger [battchrg.hex] (Programmed Microcontroller, AUD $10.00)
  • PIC16F628A firmware and source code for the Deep-cycle 12V Battery Charger [battchrg.hex] (Software, Free)
  • Deep-Cycle 12V Battery Charger PCB patterns (PDF download) [14111041/2/3] (Free)
  • Deep-cycle 12V Battery Charger front panel artwork (PDF download) (Free)
Articles in this series:
  • A Charger For Deep-Cycle 12V Batteries, Pt.1 (November 2004)
  • A Charger For Deep-Cycle 12V Batteries, Pt.1 (November 2004)
  • A Charger For Deep-Cycle 12V Batteries, Pt.2 (December 2004)
  • A Charger For Deep-Cycle 12V Batteries, Pt.2 (December 2004)
Items relevant to "The Driveway Sentry":
  • Driveway Sentry PCB pattern (PDF download) [DRIVSENT] (Free)
  • Driveway Sentry front panel artwork (PDF download) (Free)
Items relevant to "SMS Controller, Pt.2":
  • ATmega8515 programmed for the SMS Controller (Programmed Microcontroller, AUD $15.00)
  • ATmega8515 firmware and source code for the SMS Controller (Software, Free)
  • SMS Controller PCB pattern (PDF download) [12110041] (Free)
Articles in this series:
  • SMS Controller, Pt.1 (October 2004)
  • SMS Controller, Pt.1 (October 2004)
  • SMS Controller, Pt.2 (November 2004)
  • SMS Controller, Pt.2 (November 2004)
Items relevant to "Picaxe Infrared Remote Control":
  • PICAXE-08M BASIC source code for the PICAXE Infrared Remote Control (Software, Free)
Articles in this series:
  • Those troublesome capacitors, Pt.1 (October 2004)
  • Those troublesome capacitors, Pt.1 (October 2004)
  • Those troublesome capacitors, Pt.2 (November 2004)
  • Those troublesome capacitors, Pt.2 (November 2004)

Purchase a printed copy of this issue for $10.00.

Here’s how to add infrared remote control to all your PICAXE-08M projects! PICAXE infrared remote control By Clive Seager I N THE SEPTEMBER 2004 issue, we showed you how to assemble “Rudolph the Red-Nosed Reindeer”. Rudolph is a simple Christmas decoration with flashing LEDs that can play a variety of tunes, including mobile phone ring tones. As promised, this month we assemble the infrared remote transmitter and add the receiver components to Rudolph’s PC board. Before we describe how to assemble the various pieces, let’s first take a look at the basics of infrared transmission on the new PICAXE-08M. Infrared remote control The PICAXE-08M includes two commands for sending and receiving data over an infrared link. The infraout command sends data on pin 7, whereas the infrain2 command receives data on pin 3. Data is transferred using a simple modulation technique based on the well-documented Sony Infrared Remote Control System (SIRCS) protocol. The SIRCS protocol uses a 38kHz modulated infrared signal consisting of a start bit (2.4ms) followed by 12 data bits (7 data bits and 5 device ID bits). Logic level “1” is transmitted as a 1.2 ms pulse, logic ‘0’ as a 0.6ms pulse. Each bit is separated by a 0.6ms gap (see Fig.1). When used within Sony production devices, the 5 device ID bits represent the type of equipment (1 = TV, 2 = video, 26 = DVD, etc). The 7 data bits represent different commands (1 = channel 2, 2 = channel 3, 16 = channel up, 20 = mute, etc). Within this PICAXE project the Sony-allocated commands are not relevant, but a full list is provided in the PICAXE manual for those interested in controlling their own Sony hardware! Fig.1: basics of the SIRCS protocol, showing the composition of each serial transmission. A logic “1” is represented by a 1.2ms burst of the 38kHz carrier, whereas a logic “0” is represented by a shorter 0.6ms burst. Each bit is separated by a gap of 0.6ms. 90  Silicon Chip Sending data To transmit infrared data, the PICAXE command is: infraout device,data For example, to send the Sony command “TV - mute”, the command would be infraout 1,20. Note that device should always be 1 when used in PICAXE projects and data can only be between 0 and 127, as the SIRCS protocol only specifies 7-bit capability. The full program for the transmitter is shown in Fig.6. As infrared signals are easily corrupted, the data is actually sent 10 times to increase reliability. This matches commercial remote controls that tend to transmit the data at 45ms intervals whilst the button is held down. Note that the program uses codes “1”, “2” and “3” for the three switches, but you can edit these to any number between 0 and 127. This would be useful when you want to control multiple units in the same room, using different data commands for each unit. Building the transmitter As hinted at in September, the various tunes played by Rudolph can be triggered remotely using an infrared transmitter. This simple project uses a PICAXE-08M micro, three pushbutton switches and an infrared LED to make a complete hand-held remote, the circuit for which appears in Fig.2. A second visible LED is included for user feedback. siliconchip.com.au Parts List 1 infrared PC board 3 miniature pushbutton switches (S1 - S3) 1 battery clip 1 3 x AA battery holder 1 8-pin IC socket Semiconductors 1 PICAXE-08M (IC1) 1 Vishay TSOP4838 infrared receiver IC 1 5mm yellow LED (LED) 1 5mm infrared LED (IRLED) Capacitors 1 4.7µF 16V PC electrolytic Fig.2: circuit diagram for the simple infrared transmitter. As no serial link socket is provided, the PICAXE chip must first be plugged into the “Rudolph” PC board (described in September 2004) for programming. Resistors (0.25W 5%) 3 10kΩ 2 330Ω Also required (not in the kit) Rudolph kit (part no. AXE107S) PICAXE Programming Editor software (v4.1.0 or later) PICAXE download cable (part no. AXE026) 3 x AA alkaline cells Obtaining kits & software The design copyright for this project is owned by Revolution Education Ltd. Complete kits (Part No. AXE108S) and/or the Vishay infrared receiver (Part No. LED020) for this project are available from authorised PICAXE distributors – see www.microzed.com.au or phone Microzed on (02) 6772 2777. The PICAXE Programming Editor software can be downloaded free of charge from www.picaxe. co.uk or ordered on CD (part no. BAS805). Fig.3: the overlay diagram for the infrared remote transmitter. Install the wire link (under IC1) first, then all the other parts, making sure that the IC socket is around the right way. Assembly is very straightforward and should only take a few minutes. Begin by installing a wire link in the position indicated by a dotted line on the overlay diagram (Fig.3). An off-cut resistor leg is ideal for the job. Note that as an IC socket will be mounted over the link, it must be lying flat on the PC board before soldering. Install all of the resistors, switches and IC socket next, making sure that you have the notched (pin 1) end of the socket around the right way. Install the two LEDs next, noting that the infrared LED (IRLED1) leads must be bent at 90 degrees so that it points away from the PC board (see siliconchip.com.au Fig.4: transmission range can be increased by adding an external transistor circuit to drive the infrared LED. photo). Make sure that you have the flat (cathode) sides of the LEDs oriented correctly. The infrared LED may be supplied in either a “black” or “water clear” epoxy package. Finally, solder the battery leads to the positions indicated after threading through the adjacent hole. Note that the board runs from a 4.5V (3 x AA) battery pack – do not connect a 9V PP3 battery! To reduce overall size, a serial link socket is not provided on the transmitter PC board. Therefore, the PICAXE08M chip must be programmed on the main Rudolph PC board and then transferred to the transmitter board. After assembly and programming, November 2004  91 pin and the LED, as shown in Fig.4. Fig.5: any PICAXE-08M can receive infrared remote control signals with the addition of just a few components, as shown here. you can check transmitter operation by looking at the infrared LED “end-on” through a webcam or digital camera (such as a mobile phone camera). Although the LED is not visible to the naked eye, these camera are sensitive to infrared light and so the infrared LED will display a faint glow on the camera screen whilst operating. Extending transmitter range A 330Ω resistor is used in series with the infrared LED to limit current flow from the PICAXE port pin to an acceptable level. This gives a transmission range of about 4-5 metres, which should be enough for most users. However, infrared LEDs can typically be driven with a much higher current, thus extending the potential transmission range. If you need the maximum possible range, then a transistor driver circuit can be added between the PICAXE infrared output Fig.6: Transmitter Program Listing ' Wait until switch press main: if pin1 = 1 then tx_1 if pin2 = 1 then tx_2 if pin3 = 1 then tx_3 goto main Legs Versus Pins tx_1: let b1 = 1 goto tx_ir 'Code 1 tx_2: let b1 = 2 goto tx_ir 'Code 2 tx_3: let b1 = 3 goto tx_ir 'Code 3 In PICAXE BASIC, “pin” refers to a logical input or output port number, not a physical pin. Conversley, physical pins are referred to in the PICAXE documentation as “legs”. Confused? We’re not surprised. When describing a PICAXE circuit, SILICON CHIP will continue to refer to physical pins as “pins”, just as we do for all our projects. We’ll leave the legs for the organic world! (Editor.) ' Transmit code 10 times for increased reliability tx_ir: high 4 'visual LED on for user feedback for b2 = 1 to 10 'send infrared code 10 times infraout 1,b1 pause 45 next b2 low 4 'LED off goto main 92  Silicon Chip Receiving data The infrared receiver portion of the “Rudolph” circuit from last month is reproduced in Fig.5. Any PICAXE08M project can receive infrared remote control signals with the additional of these four components. A Vishay TSOP4838 infrared receiver IC demodulates the 38kHz carrier wave to give a logic output. It also contains filters to suppress noise signals from devices such as fluorescent lights. The block diagram of the receiver is shown in Fig.8. To receive infrared data, the PICAXE command is simply: infrain2 This command waits for a valid input signal and then stores the data in a variable named “infra”. This variable can then be used to play different tunes, as shown in the full receiver program in Fig.7. As the PICAXE-08M uses the standard SIRCS protocol, the receiver will also work with commercial “universal” style infrared remote transmitters. These are widely sold as “one-for-all” replacements for use with home audio and video equipment. All you need to do is program them with one of the Sony-compatible equipment codes from the supplied list of manufacturers codes. Rudolph upgrade Only two parts remain to be added to the Rudolph PC board. The receiver IC is soldered into the “IR” position, with the leads bent over so that it lies flat on the board. A 4.7µF capacitor is also added to filter the supply, noting that the positive lead goes in as indicated by the “+” marking on the overlay diagram. The 330Ω and 4.7kΩ resistors should already be installed on the board, as they were part of the original assembly. Finally, reprogram Rudolph with the BASIC code listed in Fig.7, which adds the necessary infrared remote control functions. That done, you should be able to choose between three tunes using the buttons on your remote control board! Summary With a minimum of external components and the new infraout and infrain2 commands, you can add remote control capability to all of your siliconchip.com.au Fig.7: Receiver Program Listing ' ***** main loop ***** main: infrain2 'debug infra 'wait until infrared signal 'optional display on screen for testing Silicon Chip Binders REAL VALUE AT $12.95 PLUS P & ' ***** play tune ***** 'play tune depending on light level if infra = 3 then play_xmas if infra = 2 then play_rudolf if infra = 1 then play_jingle goto main play_jingle: P 'internal tune Jingle Bells play 1,3 goto main play_silent: play 2,3 goto main 'internal tune Silent Night play_rudolf: 'internal tune Rudolf The Red Nosed 'Reindeer play 3,3 goto main play_xmas: These binders will protect your copies of S ILICON CHIP. They feature heavy-board covers & are made from a dis­ tinctive 2-tone green vinyl. They hold up to 14 issues & will look great on your bookshelf. H 80mm internal width 'external ring tone tune 'We Wish You a Merry Xmas tune 3, 4,($22,$27,$67,$69,$67,$66,$24,$24,$24,$29,$69,$6B,$69,$67, $26,$22,$22,$2B,$6B,$40,$6B,$69,$27,$24,$22,$24,$29,$26,$E7,$22, $27,$67,$69,$67,$66,$24,$24,$24,$29,$69,$6B,$69,$67,$26,$22,$22, $2B,$6B,$40,$6B,$69,$27,$24,$22,$24,$29,$26,$A7,$22,$27,$27,$27, $E6,$26,$27,$26,$24,$E2,$29,$2B,$69,$69,$67,$67,$02,$22,$22,$24, $29,$26,$E7) goto main H SILICON CHIP logo printed in gold-coloured lettering on spine & cover H Buy five and get them postage free! Price: $A12.95 plus $A7 p&p per order. Available only in Aust. Silicon Chip Publications PO Box 139 Collaroy Beach 2097 Or fax (02) 9979 6503; or ring (02) 9979 5644 & quote your credit card number. Use this handy form Enclosed is my cheque/money order for $________ or please debit my  Bankcard  Visa    Mastercard Card No: _________________________________ Fig.8: this diagram reveals the basic functional blocks within the TSOP4838 infrared receiver. As well as the actual PIN (photo) diode, it includes amplifier, discrimination and demodulation circuits to reconstruct the original digital data, which appears on the “OUT” pin. Card Expiry Date ____/____ Signature ________________________ Name ____________________________ Address__________________________ PICAXE-08M projects. “Rudolph the Red-Nosed Reindeer” demonstrates siliconchip.com.au how it all works, and might even be a party favourite come Christmas! SC __________________ P/code_______ November 2004  93