Silicon ChipTelephone Dialler For Burglar Alarms - April 2003 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Thunderstorms - nature's monster light show!
  4. Subscriptions
  5. Feature: IMAX: The Giant Movie Screen by Barrie Smith
  6. Feature: Silent Running: Building A Quiet PC by Peter Humphreys
  7. Project: Video-Audio Booster For Home Theatre Systems by Jim Rowe
  8. Project: A Highly-Flexible Keypad Alarm by John Clarke
  9. Project: Telephone Dialler For Burglar Alarms by Leon Williams
  10. Project: Three Do-It-Yourself PIC Programmer Kits by Jim Rowe
  11. Project: Electric Shutter Release For Cameras by Julian Edgar
  12. Weblink
  13. Product Showcase
  14. Feature: Soldering: A Closer Look by Maurie Findlay
  15. Project: The PICAXE, Pt.3: Heartbeat Simulator by Stan Swan
  16. Vintage Radio: The AWA R154 battery console by Rodney Champness
  17. Notes & Errata
  18. Market Centre
  19. Advertising Index
  20. Book Store
  21. Outer Back Cover

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

You can view 29 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 "Video-Audio Booster For Home Theatre Systems":
  • A/V Booster PCB pattern (PDF download) [02104031] (Free)
  • Panel artwork for the A/V Booster (PDF download) (Free)
Items relevant to "A Highly-Flexible Keypad Alarm":
  • PIC16F84(A)-04/P programmed for the Keypad Alarm [KEYPAD.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC16F84 firmware and source code for the Keypad Alarm [KEYPAD.HEX] (Software, Free)
  • Keypad Alarm PCB pattern (PDF download) [03104031] (Free)
Items relevant to "Telephone Dialler For Burglar Alarms":
  • PIC16F84(A)-04/P programmed for the Alarm Dialler [ALARM.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC16F84 firmware and source code for the Alarm Dialler [ALARM.HEX] (Software, Free)
  • Alarm Telephone Dialler PCB pattern (PDF download) [03204031] (Free)
  • Panel artwork for the Alarm Dialler (PDF download) (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.

BEEF UP YOUR HOME’S SECURITY A Telephone Dialler For Burglar Alarms By LEON WILLIAMS This project will dial a preprogrammed telephone number and send a warning tone via a modem when its input is triggered. Although primarily intended to connect to the output of an alarm system, it could be used for any purpose where you need to be notified immediately when an event has occurred. I T’S A SAD FACT of life today that a great many homes are fitted with burglar alarms. Many of these alarms, especially low-cost self installed ones, don’t have the facility to telephone the owner when an alarm occurs. If you were unfortunate enough to be away from home and have an unwanted visitor, you are dependent on someone making the effort to contact you, probably well past the time the incident occurred. With this Alarm Dialler project connected to your alarm system, you will be notified within seconds of an alarm occur­ ring, through a call to your tele­phone. And if you own a mo48  Silicon Chip bile tele­phone there’s the added bonus that you can be virtually anywhere in the country and still receive the call. Once you are notified, you can then contact the authorities or a neighbour or friend for assistance. As well as this obvious application, the project could also be used for other less critical uses; any time you want to be immediately informed that a particular event has happened. The Alarm Dialler is an easy-tobuild project using a PIC microcontroller and a handful of other inexpensive components, all housed in a small plastic box. The unit connects to a modem via a standard serial inter- face. It uses the modem to make and answer calls via your telephone line. There are four alarm connection points on the rear panel, two for the alarm input and two that can be used to reset an external device. When in idle mode, it flashes a front panel LED and continually scans the alarm input connections. If an alarm condition occurs, it sends commands to the modem to dial a preprogrammed telephone number. When you answer the call, you will hear a calling tone, and if the tele­phone has a calling identification display, you can also confirm that it is your alarm system calling. siliconchip.com.au The Alarm Dialler has many options, allowing it to be used in a broad range of applications. The various alarm input config­urations are selected with a multi-way DIP switch, while other settings such as stored telephone numbers are programmed using a PC and a simple menu system. Why use a modem? You may ask yourself, why do we need to use a modem? While it may seem an unnecessary complication, it does provide an easy solution to a number of design problems. First, it avoids us having to connect our device directly to the telephone line, as the modem provides the necessary safety isolation. Second, a modem provides all the functions we need to make and answer calls, which greatly simplifies the Alarm Dialler hardware cir­cuit. These functions include looping the line to establish and answer calls, dialling DTMF digits, ring detection, tone genera­tion and connection timers. The Alarm Dialler communicates with the modem via an RS232 interface. The speed is permanently set in the PIC at 2400bps and while this is slow by today’s standards, it’s fast enough for our needs and more importantly, eases the burden on the PIC software UART. The modem requirements are very modest and so it only needs to be a basic type. More than likely you have an old modem lying around somewhere that can be put to service. If you don’t, you can buy one second­hand or even a new one at a very reasonable price. Basically, all modems are ‘AT’ compatible. This means that they communicate with a PC using the AT command set. The PC sends commands to the modem preceded with the letters AT meaning ATten­tion. The modem also sends messages to the PC on this interface. The modem can be configured to talk to the PC using strings of letters (verbose) or single digits (terse). Single digit messages are generally used when a human is not viewing the responses and this is how the modem must be configured to work with the Alarm Dialler. Alarm input options The Alarm Dialler has a 2-wire connection point and can accept either a contact or switched voltage alarm system output (see Fig.1). The contact output could be from a standard relay, a switch or perhaps a reed relay, using either normally open (N/O) or normal­ly closed (N/C) contacts. When a contact input is Main Features •  PIC microcontroller based. •  Alarm input can monitor N/O or N/C contacts or an external voltage . •  Alarm reset output. •  No direct connection to the telephone line. Uses a standard modem to make and answer calls.   • Dial in and test if system operational.   • Programmed easily via a PC. •  Programmable retry attempts. •  Primary and Secondary telephone number store. •  Alarm input inhibit switch. •  Automatic alarm reset option. •  EEPROM stores settings in case of power outage. •  Uses low-power 12V AC or DC power supply.   • Cheap and easy to build. used, the main board is electrically con­nected to the outside world. For this reason, it is important that the The rear panel carries spring-loaded terminals for the Alarm Input and Alarm Reset signals, a DB9M connector for the modem and a DC socket for the power supply. siliconchip.com.au December 2005  49 Table 1: Alarm Input Options Normal Condition Alarm Condition S1/1 S1/2 S1/3 S1/4 S1/5 S1/6 Open contacts Closed contacts On Off On Off On Off Closed contacts Open contacts On Off On Off On On Voltage Off Voltage On Off On Off On Off Off Voltage On Voltage Off Off On Off On Off On external alarm contacts do not have any voltage applied to them and that the cable to the Alarm Dialler is not too long. A very long cable could possibly get noise induced into it, which could lead to false alarms. Alternatively, if using the external voltage option, the normal state can be either voltage “on” (up to 50V DC) or voltage “off”. The normal state means that this is the condition when the alarm is not active. With this type of input configuration, the Alarm Dialler circuit is electrically isolated from the alarm input by an optocoupler (OPTO1). Only a few mA of current is needed to operate the optocoupler and this is achiev­ed with around 4V on the alarm input terminals. If you want to use a much higher voltage than this, an external resistor should be placed in series with the input to limit the current through the optocoupler LED. Note that DIP switches typically have a maximum rating of 50V DC at 100mA. The alarm input options are set with DIP switches 1-6 and Table 1 shows the settings for each option. Alarm reset output The Alarm Dialler provides a set of output relay contacts that operate for one second and can be used to reset the alarm or some other external device. The PC board has provision to connect either the N/O or N/C contacts for this purpose. The relay will only operate after three incoming calls have been received within 90s after an alarm has been detected or, if Automatic mode is selected, after all outgoing calls have been made. Program menu items The program menu is produced by the Alarm Dialler and dis­played on the connected PC screen. Each menu item is described below. Automatic mode: The Alarm Dialler has the option to be in either Auto50  Silicon Chip matic mode or non-Automatic mode. When Automatic mode is set to Yes, a non-interactive mode is selected. This is simply where the preprogrammed number or numbers are dialled with a 45-second delay in between calls. After all the calls have been made, the relay operates for one second. The Alarm Dialler will not return to scan mode until the non-alarm state is found. This prevents it from continually calling if the alarm is not reset. When Automatic mode is set to No, the Alarm Dialler is in interactive mode and it is possible to reset the alarm without having to wait for all the calls to be dialled. During the 45-second wait period between outgoing calls, the Alarm Dialler monitors the modem for a ring message. If an incoming call is detected during this 45-second inter-call period it then waits a further 90 seconds for two more. It is necessary to receive a total of three calls within the 90-second period to reset the alarm. If only a single incom­ing call was allowed to do this, a random call from someone else could accidentally reset the alarm before you were contacted. If three calls are detected, it considers that you called in response to the alarm. It then resets the alarm, cancels all further calls and returns to scan mode. If an incoming call is not detected or less than three are counted during the 90-second period, the next outgoing call is attempted, unless all the retries have been completed. Primary number: This is a 19-digit store to hold the telephone number of the first number dialled after an alarm is detected. Secondary number: This is a 19-digit store to hold the telephone number of the second number dialled after all the Primary number retries have been completed. Use secondary: If this option is set to Yes, the Secondary number will be dialled after the Primary number is finished. If set to No, the Primary number is the only one dialled and the Secondary number is ignored. While this option is valid in Automatic mode, in general it will only be set to Yes in Non-Automatic mode. In this case, if a response to the Primary number calls is not received, the Secondary number will then be dialled. Retries: This is the number of retry attempts allowed for each telephone number. The range is 1-9. Full details of how to program the Alarm Dialler are cov­ered later in this article. Remote status checks The Alarm Dialler incorporates extra features that allow you to remotely check its status. If everything is normal and there are no alarms, the front panel LED will flash and incoming calls will be ignored. However, if there are three separate incoming calls within 90 seconds, the first two calls will be ignored but the third call will be an­swered. When the modem answers the call by going on-line, it sends an answer tone and then drops off-line after 20 seconds. By using this feature, you can tell if the unit is powered up and operating normally from anywhere that you can use a tele­phone. The only indication the Alarm Dialler has of an incoming call is a ring message from the modem. The modem sends the digit “2” each time a burst of ring is received. The Alarm Dialler counts the time in seconds between ring bursts to distinguish between those within the same call and those from separate calls. When an incoming call is being received from the telephone exchange, ring bursts are two seconds apart. However the time between the last ring burst from one call and the first ring burst from the next call will be much greater than this. The Alarm Dialler will register a new call if the gap is larger than six seconds. It would be unusual to receive three calls within 90 sec­onds in normal use and so the unit should rarely answer a random call. Even if someone does call three times in quick succession, all that will happen is that the unit will answer on the third call send the answer tone and then drop off line again. Obvious­ly, if you are unable to get the Alarm Dialler to answer at all, either the unit or the modem has siliconchip.com.au Fig.1: a PIC16F84 microcontroller (IC1) forms the heart of the circuit. It accepts the Alarm Input signal and drives an RS232 transceiver (IC2, MAX232) which interfaces to the modem. The modem, in turn, connects to the telephone line and carries out the dialling. failed, the power is off or the telephone line is faulty. Failed call state If an alarm has occurred and the Alarm Dialler has exhaust­ ed all its call retries and did not get an incoming three-call response, it goes into a failed-call state. In this mode, it will not return to normal scan mode until it has received three calls within 90 seconds. This is done for two reasons. First, it avoids continually sensing an alarm condition and re-dialling if the alarm has not been reset. Second, it allows you to check if an alarm has occurred, if you have not been previously contacted. siliconchip.com.au While in failed-call mode, the Alarm Dialler will answer every incoming call. So if you call the unit to check its status and it answers immediately, this indicates that an alarm has almost certainly occurred. To double check that this is the case, call again two more times, within the 90-second period. If the unit answers every call then an alarm has occurred. This three-call sequence will also reset the alarm and return the Alarm Dialler to scan mode. Note that this alarm checking and reset feature is only available in non-Automatic mode. Receiving an alarm call If the Alarm Dialler is programmed for Automatic mode, it will simply call the Primary and Secondary numbers, depending on the values set for ‘Use secondary’ and ‘Retries’. It is not possible to call the Alarm Dialler during this process and cancel the calls. For this reason, it’s probably a good idea to keep the ‘Retries’ number low and only use the Secondary number option if really necessary. Each time you answer the call, the modem call­ing tone will be heard for 20 seconds and then the call will be terminated. In non-Automatic mode, it is possible to reset the alarm without having to wait for all the calls to be dialled. During the 45-second wait period between outgoing calls, the Alarm Dialler monitors the modem for a ring message. Note, however, that because the modem is online for 20 seconds after the call is made, there is only effectively 25 seconds for you to call the Alarm Dialler before the next call is made. December 2005  51 Parts List 1 PC board, code 03204031, 115 x 99mm 1 plastic case, 140mm x 110mm x 35mm (Jaycar Cat. HB5970) 10 PC board stakes 1 8-way DIP switch (S1) 1 4MHz crystal (X1) 1 DC panel-mount socket 1 9-pin male ‘D’ connector with locking nuts 1 4-way speaker connector (Jaycar Cat. PT-3002 or equivalent) 1 12V SPDT relay (RLY1) 1 18-pin IC socket 2 10mm x 3mm screws and nuts 4 small self-tapping screws Light duty hook-up wire, tinned copper wire Semiconductors 1 PIC16F84-04P (IC1; programmed with ALARM.HEX) 1 MAX232 RS232 transceiver (IC2) 1 4N25 optocoupler (IC3) 1 BC337 NPN transistor (Q1) 6 1N4004 power diodes (D1-D6) 1 7805 positive 5V regulator (REG1) 1 5mm green LED (LED1) Capacitors 1 470µF 25V PC electrolytic 5 10µF 16V PC electrolytic 2 100nF (0.1µF) MKT polyester 2 22pF ceramic Resistors (0.5W, 1%) 4 10kΩ 1 330Ω 2 4.7kΩ 1 100Ω 2 470Ω When you receive an alarm call you will hear the modem calling tone and you must wait for the modem to time out and go off -line before calling back. Circuit description The full circuit for the Alarm Dialler is shown in Fig.1. As you can see, there’s not a lot to the hardware because, as mentioned before, the line interfacing functions are handled by the modem. The microcontroller used is a PIC16F84 (IC1) which does all the hard work. It has 1K of ROM (which is just about all used in this project), 52  Silicon Chip 68 bytes of user RAM and 64 bytes of non-volatile EEPROM. The EEPROM holds the configuration settings in case of power failure. Pin 14 is the power supply pin, while ground (0V) is con­nected to pin 5. The reset input (pin 4) is held permanently high via a 100Ω resistor and this simple reset system has proved to be effective. The internal oscillator appears at pins 15 and 16 and a 4MHz crystal is used to supply accurate timing for the internal counters. Pin 10 is connected to the Program switch (S1/8) with an external 10kΩ pull-up resistor, so that with the switch open, the pin is read as high or a one. When the switch is closed, the pin is read as low or a zero. Pin 11 is connected to the Inhibit switch (S1/7) and works in the same manner. Pin 7 is the transmit data pin and is normally high, puls­ing low when a zero data bit is sent. Pin 6 is the receive data pin and is used to both interrupt the PIC when a character is re­ceived and to receive the actual data bits. Normally, pin 6 is high with no data present and goes low when a character start bit is received. This negative edge inter­rupts the PIC and forces it to enter the interrupt routine. This routine samples the eight character bits and stores them in an internal PIC register. After the stop bit has been received, it exits the interrupt routine and the main code processes the character. Software UART More complex microcontrollers have a dedicated hardware UART to do this receiving but in this less-qualified PIC we must do this in software. The UART operates in half-duplex mode, meaning that it cannot send and receive data at the same time. Pin 18 controls the LED and when it is low the LED is on and when it is high the LED is off. A 330Ω resistor limits the LED current to around 10mA. Pin 8 is the relay output pin, which is normally low and goes high for one second to turn on transistor Q1. When the transistor is biased on, relay RLY1 operates, providing the reset signal to the alarm system. Pin 13 is the alarm input pin. The normal state can be high or low, depending on the input switch settings. Switch S1/6 tells the PIC whether the voltage on the alarm pin is the normal or the alarm state. If S1/6 is off, pin 12 is held high and the alarm state is when pin 13 is low. If S1/6 is on, pin 12 is held low and the alarm state is when pin 13 is high. IC2 is a MAX232 RS232 transceiver used to interface the 5V logic signals in and out of the PIC to the 9-pin interface. It only requires a 5V power supply and produces the required plus and minus RS232 voltages by an internal inverter using four external 10µF capacitors. IC2 has two receivers and two transmit­ters but only one receiver and transmitter are used in this circuit. On the RS232 side, pin 13 is the receive data input and connects to pin 2 of the ‘D’ connector, while pin 7 is the trans­mit data output connecting to pin 3 of the ‘D’ connector. On the logic side, pin 12 is the receive data pin and pin 10 the trans­mit data pin. A 4N25 optocoupler (IC3) is used to isolate the PIC from external voltages on the alarm input. When about 3mA of current flows in the internal LED, the transistor within IC3 is turned on. This takes pin 5 of IC3 low and consequently pin 13 of IC1 low. When DIP switches S1/1, 3 and 5 are off and S1/2 and 4 are on, the input is configured to accept an external voltage input. The current through the optocoupler LED is limited by a 470Ω resistor and protected from reverse polarity by diode D5. In this configuration, the input circuit is completely isolated from the main PC board components. The external positive voltage must be connected to the “+” alarm point, otherwise diode D5 will be re­versed-biased and the alarm will not be recognised. When DIP switches S1/2 & 4 are off and S1/1, 3 & 5 are on, the input is configured to accept a contact input. In this mode there is no external voltage to operate the optocoupler LED, so the internal +5V rail is supplied through the same 470Ω limit­ing resistor and diode D5. Power supply The power supply is a 3-terminal voltage regulator circuit providing 5V from a range of input voltages. A diode bridge comprising diodes D1-D4 allows both AC and DC supplies to be employed. If a DC supply is used, the positive lead will be di­rected to the regulator input, irrespective of the polarity of the power connector wiring. The main reason for using this circuit is to allow a wide range of power supply possibilities. The Alarm Dialler siliconchip.com.au Fig.2: install the parts on the PC board as shown here, taking care to ensure that all polarised parts go in the right way around. The Alarm Reset output has only two connections, so select either the N/O or N/C con­tact, depending on your application (ie, use one or the other but not both). draws minimal current – only about 50mA maximum when using a 12V DC supply. Construction Fig.2 shows the assembly details. Start construction by installing the parts on the PC board. There are three wire links to be installed, so do these first. Ensure they are straight and lay flat on the PC board. Follow these with the smaller components, such as the resistors, diodes and IC socket. Next, install the capacitors, ensuring that the electrolyt­ics are installed with correct polarity. The relay, DIP switch and PC stakes can be installed next. Follow this with the tran­sistor (Q1), crystal and ICs, leaving the PIC chip until later. The LED is installed with 15mm of lead length and then bent at right angles so that it can push out through the hole in the front panel when the PC board is secured in place. The 5V regulator (REG1) runs quite cool and won’t need a heatsink under normal circumstances. Once the PC board is loaded, you can prepare the case – see the pho- Resistor Colour Codes o o o o o o siliconchip.com.au No. 4 2 2 1 1 Value 10kΩ 4.7kΩ 470Ω 330Ω 100Ω 4-Band Code (1%) brown black orange brown yellow violet red brown yellow violet brown brown orange orange brown brown brown black brown brown 5-Band Code (1%) brown black black red brown yellow violet black brown brown yellow violet black black brown orange orange black black brown brown black black black brown December 2005  53 Fig.3: a serial crossover cable is required to connect the Alarm Dialler to a PC for programming. If you don’t have a crossover cable, just wire a couple of female DB9 connectors together as shown here. tographs as a guide. Start by drilling holes in the rear panel to mount the power socket, the alarm connector and ‘D’ connector – see Fig.6. The alarm connec­ tor used in the prototype is a 4-way speaker terminal strip and requires four holes for the connector tabs and two for the mount­ing holes. Finally, drill a hole in the centre of the front panel just large enough to allow the LED to slide through. Once the case has been prepared, install the power socket, the alarm connector with 3mm screws and nuts, and the ‘D’ connec­ tor with locking nuts. Mount the PC board in the case with four small self-tapping screws. Slide the rear panel into place and then wire the rear panel connectors to the PC board stakes with light duty hook-up wire. The alarm input is polarised, so make sure that the red terminal is wired to the “+” alarm PC stake. The alarm reset output has only two connections, so select either the N/O or N/C con­tacts, depending on your application. Note that because we are using a diode bridge at the supply input, you don’t have to worry about the polarity of the supply wiring. When all the wiring is completed push the LED back­and slide the front panel into place. Now slide the LED into the hole in the front panel so that it pokes through by a few millimetres. Initial testing Once construction is complete, connect the power supply and, using your multi­meter, measure the voltage at the power supply stakes on the PC board. The power supply can be anywhere between 12-20V DC or 9-16V AC without requiring a heatsink on the 5V regulator. If you are going to operate the unit in areas of high tem­perature, then either a heatsink should be added to the regula­ tor, or preferably, reduce the voltage of the power supply. Although the relay coil is rated for 12V operation, using a higher supply voltage shouldn’t be a concern, because the relay is energised for only one second at a time. Next, measure the voltage at the output of REG1. You should get a reading close to +5V and the same voltage should be at pin 14 of the PIC socket. Pins 2 & 6 of IC2 will be a volt either way of +9V and -9V, respectively, if this IC is working correctly. If not, remove the power source quickly and look for errors, especially with the power wiring and the installation of the polarised components. If everything looks OK, remove the power, wait a few sec­onds and insert the programmed PIC chip into the 18-pin socket. Apply power again and after a short period you should see the LED flash briefly and then repeat after a few seconds delay. Each time the LED flashes, it is sending AT to the modem and looking for an OK (0) response. This is done each time the Alarm Dialler powers up and is used to ensure that the modem is connected and the interface is operating at the correct speed before normal alarm monitoring commences. Alarm Dialler programming Turn off the power to the Alarm Dialler and connect a PC running a terminal emulation program such as HyperTerminal using a serial cross­ over cable. The PC needs to be set to 2400bps, 8 data bits, no parity and 1 stop bit with flow control off (Fig4a). Note that the Alarm Dialler’s RS232 interface is similar to the one on your PC and to get them to talk to each other, you need to cross the data lines over. This means that the transmit data pin of the Alarm Dialler goes to the receive data pin of the PC and vice versa. Fig.3 shows how to make a simple Fig.4a (left) shows how to set up the PC’s COM port to communicate with the Alarm Dialler when you start HyperTerminal, while Fig.4b (above) shows the menu that appears in the HyperTerminal window when the Alarm Dialler is in programming mode. 54  Silicon Chip siliconchip.com.au The PC board is secured to integral pillars in the base of the case using self-tapping screws. Note that the N/O relay output has been used here but you could use the N/C contact instead. crossover data cable, with a couple of 9-pin female ‘D’ connectors and three pieces of hook-up wire. Or you can buy one if you prefer. Once connected, place S1/8 into the on position and apply power to the Alarm Dialler. Now move S1/8 to the off position, the LED should turn on and the menu appear on the PC screen. The menu is easy to understand and navigate and the items will be self-explanatory. Simply select the desired option by pressing the character in brackets for that option and remember to use upper-case characters – see Fig.4b. Programming options are stored in the EEPROM as they are entered and there is no need to do a separate save action. If an out-of-range or illegal entry is made, an error message is dis­ played and the menu refreshed. siliconchip.com.au To exit the programming mode, place S1/8 into the on posi­tion again and then back to the off position. Once this is done successfully, a goodbye message will appear on the screen. Alarm inhibit To inhibit alarm detection at any time, move S1/7 to the on position. This could be used to avoid the Alarm Dialler imme­diately sensing an alarm condition if you are experimenting and changing the input connection or DIP switch settings. When the alarm input wiring and switch settings are in place, S1/7 can then be placed in the normal off position. Switch S1/7 can also be used to manually reset an alarm after it has been triggered. When an alarm occurs, a software flag is set within the PIC and stored in EEPROM. The reason for this is to remember that an alarm occurred if there is a power outage during an alarm calling sequence. When power is reapplied and an alarm call sequence has not been completed, it starts the sequence again. To manually reset the alarm flag, switch off power, place S1/7 into the on position, turn on the power again and move S1/7 back to the off position. The alarm flag is also reset each time you enter program mode to make changes to the configuration. Configuring the modem To ensure the modem you are using works properly with the Alarm Dialler, you must first configure it with the required settings. To do this, connect a PC running a terminal emulation program such as HyperTerminal to the modem, using a standard serial December 2005  55 your modem and see if it is an available option, or get another modem! The time to wait online after making or answering a call is determined by the value in the modem S7 register. You may find that some modems actually wait longer then the programmed 20 seconds and you may not be able to make three calls within 90 seconds. If you find the wait is too long, then you will need to experiment with the value programmed into the S7 register. Now for the test procedure. Start by programming the Alarm Dialler with Automatic mode set to Yes. That done, program the Primary and Secondary numbers to relevant telephone numbers, the ‘Use second­ary’ option to Yes and the ‘Retries’ to 2. Once programming is finished, leave the PC connected using the serial crossover cable. You will notice that after you exit programming mode the letters AT appear on the screen. This is the Alarm Dialler look­ ing for a modem. Type the number 0 followed by the Enter key. When the Alarm Dialler receives this it thinks it has found the modem, starts flashing the LED and goes into scan mode. At times during the remainder of the testing we will be simulating the sequence that the modem sends to the Alarm Dialler when it detects an incoming burst of ring. We do this by typing the number 2 on the PC keyboard, followed by the Enter key. An incoming call from the telephone line has a burst of ring every two seconds and so a 10-second call would be comprised of five bursts, each two seconds apart. Final testing Checking that it’s alive To fully check the Alarm Dialler functions, programmable settings and modem operation, you need to make real telephone calls. However, while call charges are relatively inexpensive, you prob­ably don’t want to make a lot of calls until you know everything is working OK. We get around this problem by checking most of the Alarm Dialler functions without making any real calls. The way we do this is to simulate the actions of the modem using the PC. First, to make life as easy as possible for testing purposes, set the alarm input up for N/O contacts as shown in Table 1. That way, you can later simulate an alarm condition just by shorting the two alarm input terminals. The first test is to simulate calling the Alarm Dialler from a remote location three times within 90 seconds to check if it is alive. Ensure the Alarm Dialler is in idle mode and that the LED is flashing normally. Simulate an incoming call for 10 seconds (ie, by repeatedly typing 2 and pressing Enter on the PC’s keyboard) and check that the LED stops flashing after the first ring burst. Now wait at least another six seconds and simulate another call. The LED should remain on and nothing else should happen. Finally, wait another six seconds and simulate a third incoming call. If the Alarm Dialler is working correctly, the letters ATA will appear on the screen and, after a Table 2: Modem Configuration Typical Command Required Options &K0 Disable RS232 data flow control lines. S0=0 No auto answer - Alarm Dialler determines when the modem will answer a call by sending it ATA. &D0 Ignore DTR lead on RS232 interface. E0 Wait 20 seconds after making or answering a call before releasing the line when a carrier is not detected. Use digits rather than character strings for modem responses. Do not echo characters received by the modem back to the Alarm Dialler. &W Write the settings to non-volatile memory. S7=20 V0 cable (ie, not a crossover type). Now type the letters AT followed by the Enter key. If the modem receives and decodes this properly, it will respond with the letters OK. Now type AT&F and then Enter to reset the modem to its factory de­fault settings. Once this is done type the sequence AT&K0S0=0&D0S7=20V0E0&W, exactly as shown and terminate by press­ing Enter. Notice that the 0 is a digit zero and not an upper-case letter. If the modem accepts the settings, it will respond with a zero, indicating that all is OK. If not, and this is very unlike­ly, your modem does not recognise these standard commands. In this case, consult your modem’s user man­ual and read the explana­tions in Table 2 to find and enter the commands that match your modem. Calling-tone option A modem option not shown in Table 2 but referred to throughout this article is the calling-tone option. Some modems will send a calling tone automatically every call, while some do not have this facility. Some others have the capability but require it to be enabled. If you need this feature and it doesn’t seem to operate, you will need to check Fig.5: the full-size front panel artwork. There’s just one hole to be drilled & that’s for the indicator LED. 56  Silicon Chip siliconchip.com.au Fig.6: this full-size artwork can be used as a drilling template for the rear panel. The cutout for the DB9 connector can be made by drilling a series of small holes around the inside perimeter and knocking out the centre piece. couple of seconds, the LED will start to flash again. The sequence ATA instructs the modem to go online and answer the call. Checking automatic mode The next test will check that Automatic mode operates cor­rectly. First, simulate an alarm condition on the input. The screen should now show the letters ATDT, followed by the digits for the Primary number that you have entered during programming. The sequence ATDT is the command sent to the modem to tone dial the following number. Wait 45 seconds and the same sequence should appear on the screen again. At this point the primary number has been dialled twice which is the number set in Retries. As we have set Use Secondary to Yes, the same delayed dialling sequence should occur again, however this time the Secondary number is used. Once all the calls have been made, the Alarm Dialler waits 45 seconds, operates the relay and the LED starts to flash normally. Checking non-automatic mode Once you are satisfied that Automatic mode is working cor­rectly, you can test Non-Automatic mode. Program the Alarm Dia­ ller with Automatic mode set to No, leaving everything else the same. Simulate an alarm as before and check that the letters ATDT followed by the digits for the Primary number are seen on the screen. Wait around 20 seconds and simulate an incoming call com­prised of two bursts of ring. When the Alarm Dialler is in alarm mode it will only answer an incoming call after it has received two ring bursts. After the second burst, the Alarm Dialler should respond by displaying ATA on the screen, instructing the modem to go online and answer the call. siliconchip.com.au Fig.7: this is the full-size etching pattern for the PC board. Wait 20 seconds and simulate a second incoming call in the same way. If the second call is detected the letters ATA should appear again indicating that the Alarm Dialler is answering the second call. Finally, wait another 20 seconds and simulate a third incom­ing call. The Alarm Dialler should send ATA as before, however this time the relay will operate and the LED will start flashing. This is because three calls within 90 seconds have been regis­ tered in response to an alarm call. If all these off-line checks perform correctly, you can be assured that the Alarm Dialler is working properly. If you want, you can test other features such as the failed call state, chang­ing the number of retries and using the Primary number only and so on. When you are satisfied that every­ thing is OK, you can con­ nect your modem to the Alarm Dialler and tele­ phone line and test the system for real. Don’t forget to reset DIP switch S1 to the alarm input option you require SC (see Table 1). Where To Get The PIC Software To obtain the Alarm Dialler software, download the file “ALARM.ZIP” from the SILICON CHIP website and unzip it. You can use “ALARM.HEX” to program your own PIC chip, while you can get a better understanding of how it all works by reading the “ALARM.ASM” file. December 2005  57