![]()
To get a feel for the ideas and evolution of this project, if you haven't already done so, please see this page, detailing the mark one wireless bike alarm.
This is a big page - please give it time to load. All photos are thumbnails - click on them for a larger view.
Since the construction of the first PMR based wireless alarm last year, I had constantly sought ways to improve it. The main issue was reducing the size of the unit, but other areas with scope for improvement included ease of activation, luggage loop connections and ease of removal for bike cleaning and service. I'd identified several issues with the previous design:
The size was tolerable, but quite bulky, and decidedly vulnerable bolted to the down tube.
The first key switch failed, and the second became faulty.
Remembering the key was a pain in the bum - note that the bike lock key is non-removable until the lock is operated.
The luggage loop terminals were fiddly and liable to catch shoelaces while pedalling.
Removing the unit for service was a nightmare
I was also unhappy with the rough nature of the construction - I had proved the concept worked, but now was the time for more elegance in the solution.
For a few months I scoured all available channels looking for alternative PMR sets to base the new alarm upon. I originally thought the Entel Eurowave would be the natural choice - but obtaining information despite a rather unhelpful attitude from Entel indicated that their product was so basic that it had no 'call' feature - as this was central to the design, and not really having thought about the practicalities of circuitry yet, I ditched the idea. I knew that any design I would come up with would have to be quite different to the last one - all the small radios were fitted with soft-off power controls rather than the old fashioned rotary volume knob on the Binatone. This meant that whenever the alarm was activated, the control electronics would have to first simulate pressing the power button to turn the radio on. This was a concern, because I recognised that adding another analogue timer would make the circuitry bulkier, and possibly outweigh the advantage of using a smaller radio. Discussing the idea with friends, and following a suggestion on a newsgroup, I had the idea planted in my head of using a PIC microcontroller to control the radio.
PIC's have been around for a long time - I'd learned about them at college. A PIC, or programmable interface controller, is a small, self-contained microprocessor, complete with memory and all the components of a functioning embedded control system in one tiny package. They have a number of general purpose pins which can be assigned as either inputs or outputs, and a simplified, minimal instruction set which can be manipulated to undertake a huge variety of control tasks. PIC's are programmed using a number of methods, and to learn more, I picked up a couple of books. Programming the PIC itself is usually undertaken by writing the code as a text file on a PC, assembling or translating it into a hex file, and then using a software package to transfer the assembled code to the chip using a programmer. Commercial programmers can be purchased for about £150, but one of the books I purchased helpfully contained a circuit board upon which a useful PIC programmer could be constructed - together with a CD full of handy information and software. The two books I bought were McGraw Hills' 'Programming And Customizing PICmicro Microcontrollers' by Myke Predko (that's the one with the freebies), ISBN 0-07-136172-3 and the smaller, but slightly more useful book published by Newnes 'PIC - Your Personal Introductory Course 2nd Edition' by John Morton, ISBN 0-7506-5038-9. Reading these books, I learned that although at first daunting, PIC's were easy to use and were ideally suited to the task at hand.
As it was again the season of radio rallies, I pottered along to Drayton for the annual MARS rally, where I'd bought the Binatone sets 12 months previously. Originally intending to buy parts to build the PIC programmer with, I came back with some bargain PMR sets, but more on that later. I got the parts I needed, as well as a few PIC16F84's - an 18 pin example of the PIC. When I got home construction of the programmer commenced.
I played around for a while, my first programs mainly involving counting and turning LED's on and off. Unlike earlier PIC's, the 16F84 was a re-writable device - many of the earlier microcontrollers were writable once only. This meant that once programmed, the only thing to do if there was a bug was to throw the chip away and crack open another. The fact that the 16F84 was reprogrammable gave me a little more freedom. I was soon reasonably confident programming for the PIC, and assembled circuits solderlessly on breadboard.
The bargain PMR sets I acquired were Telcom TE200's. I got 4 customer returns for a minimal sum - I think £8 for the four. I had originally intended to base the new design on a pair of ICOM 446S radios - about £80 each, but on seeing the Telcoms, I couldn't resist them. They were tiny, and appeared to have a whole raft of features. What was particularly interesting was the fold-down antenna they were fitted with - it looked removable and suitable for re-mounting on another enclosure. I knew that I wasn't going to get four good radios - I only needed one. Rooting carefully through the selection, I bought one evidently water damaged, one whose antenna had been broken off the main housing, one unspecified casualty and one with a melted battery contact. Trying them with batteries (these were 6v devices - another plus) I found 2 worked straight away, the water damaged one was dead, and the burn out needed new contacts... not bad for a day's haggling.
No time was wasted as I stripped one down.
I started thinking in depth about
circuits. I knew I could program the PIC to turn the module on, and to press the
call button for a time period. An issue I also faced was that the Telcom had no
range check feature - I used this on the Binatone to alert me if the alarm went
dead or I went out of contactable range of the bike. As I intended to continue
using the MR500 as a receiver, I wanted to solve the problem. Experiments with a
working Telcom
indicated
that all the Binatone was doing was broadcasting a very short burst of RF on the
selected channel at close intervals. Replicating this behaviour on the Telcom by
pressing PTT quickly was adequate to make the Binatone think another was in
range. The Telcom's have an annoying 'feature' in that they add a short beep to
the audio on release of the PTT key... until I had better means of
experimentation (shorter duration PTT pulses from the Telcom) I was disappointed
to discover that the beep was audible on the Binatone... quite a problem.
Normally the radio sits in silence, only making a noise on the reception of
stray bursts of RF or when the alarm went off - the idea of the unit sat there
beeping was unacceptable.
Before I could experiment, I needed to come up with a suitable way to interface the PIC to the radio module. The relay I had used on the original alarm was good, but too bulky, and quite noisy. The idea of turning the alarm on to be met with a cascade of clicking put me off the idea. Poking around the circuit with a multimeter I found that the buttons (on the Telcom, they are all 2 contacts) merely shorted a line floating at about 3.8V to ground. This was confirmed by a circuit diagram of a Telcom 150 I found on the net... see here (PDF document, Adobe Acrobat required). Now my circuitry was going to be running at 6 volts, and it was tempting to just connect a PIC output straight onto the 3.8volt line - after all, both the radio and the PIC would share a common ground. Keeping the line high and then dropping it (i.e. outputting 0,lowering it to ~0 volts) would be equivalent to pressing the button. I was, however, worried that the radio would not stand such a positive voltage, and after no little consideration came up with the concept detailed in the diagram shown.
The idea was to add a small signal diode in line between the PIC output and the radio. The diode would conduct from the radio into the PIC output, thus blocking the voltage rise from the PIC when the output was high, and conducting to ground when the output was low. The solution appealed because there would be no delay in action (as caused by a relay), it would be silent and totally reliable.
I tested this theory carefully by soldering a wire from the pushbutton input, through a diode, and touched the ground terminal. The radio saw the button as being pressed. I touched the wire to the +6v supply, and measured the voltage on the pushbutton contact - still 3.8 volts. I tried it on the power on, call and PTT buttons, and they all worked. My main concern was that the voltage rise on the radio pushbutton line would not be great enough to prevent the radio from seeing the action of the PIC, and to my surprise, found that 3 diodes in series could be added giving a voltage drop of just over 2 volts. It seemed I'd found a solution.
The next step was to consider the first steps in the programming of the PIC. In simplified terms what it needed to achieve is detailed in the flowchart illustrated. I discovered through experimentation that the radio, when energised, needed a second or so to settle and boot when power was applied before hitting the power button, otherwise it would be ignored. I also found that the device exhibited peculiar 'key rollover' properties', in that when one button was pressed, small pauses had to be allowed for otherwise no response would be elicited.
It would be far too lengthy to
enter into the minutia of microcontroller programming here, for anyone
interested in the subject I recommend a number of sites, the links to which can
be found at the bottom of this page. I intend to approach the discussion of the
program in general terms, and anyone wishing to know more about the program can
mail me here.

The general intention was to start the radio, and then enter a loop of pressing PTT and pausing, to maintain contact with the receiver. The alarm conditions (vibration, luggage loop) would be continuously monitored and any activity detected would lead to the suspension of the loop and the alarm procedure being executed. Along with the signal outputs to the radio, I'd decided to use a single, 2 chip LED for indication purposes and assign a couple of inputs, one for the vibration switch and one for the luggage loop.
Inside the PIC, the 13 general purpose pins it provides are divided into one group of 5 (port A, labelled RA0 to RA4) and one group of 8 (port B, labelled RB0 to RB7). Any pin in any port can be assigned as either an input or an output, and these can be read from or written to at any time. Pin RB0 and pins RB4 to RB7 have an extra function, in that they can be programmed to cause interrupts when used as inputs.
The best way to achieve my goal of monitoring the alarm conditions was to use interrupts... interrupts are a facility on the 16F84 that can be used to halt current program execution, and start executing another portion of code. Providing the interrupt has been handled correctly, when complete, the PIC will recommence exactly where it left off - in other words, execution has been interrupted for a more important task. On the 16F84, the two interrupts which were useful to me were INTF and RBIF - INTF occurs when a specific change occurs on pin RB0, and RBIF occurs when any one of the pins RB4-RB7 undergoes a change of state. I decided to attach the vibration switch to RB0 and the luggage loop to RB4. This took care of the inputs, and I decided to be tidy and assign all the port A pins to output functions; RA0 and RA1 were to operate the indicator LED and RA2 to RA5 were to operate the radio.
Writing the software for the PIC was no trivial task; I wrote it gradually over a couple of weeks. The main difficulty with writing PIC programs is that once written, one cannot necessarily tell what is happening when the program doesn't function - it's impossible to tell what's going on inside the chip. Thus fault-finding is a laborious and infuriating task. While programming, I tested the chip and software, as well as modifications to the circuitry, on solderless breadboard as I went along. Sometimes I found myself looking for programming faults that were actually circuit design issues...
I learned much about the Telcom in the process. Many of the pauses in the final program are required to allow the radio time to settle. One bug I found after final construction was that if the alarm was triggered during a range check pulse, because of the rollover issue, the radio would not send the call tone. It behaved like it did, but with no RF broadcast, even though the display said that was what it was doing. Inserting a pause at the start of the alarm interrupt before the call key was simulated solved that one.
It was while experimenting in this manner that I found out how the range check system on the Binatone's actually worked. As I have mentioned, any signal on the selected waveband was enough to keep the MR500 happy. What I couldn't work out experimenting by hand, was how come the radio didn't make a sound when it received an RF pulse from another Binatone. The answer became blindingly obvious while fiddling with the PIC program - as I shortened the range check pulse from the Telcom, the MR500 stopped making a noise. However, using another Telcom, I could still plainly hear a roger beep. When set in range check, the MR500 just suppresses the speaker for the first 400mS or so of reception. Broadcasting a very short pulse falls within this, so the radio doesn't make a noise. I was surprised a just how basic Binatone's solution was. But I was very happy to overcome the beep problem!
The source code for the finished program can be viewed by clicking here; this is the current version of the software completely annotated. Some modifications were made following construction, but I feel it's best to supply just one set of code. The reasons for the modifications will become clearer as you read on.
After what seemed like an age, I had a working circuit programmed and assembled on breadboard on the bench. Testing had eliminated all the issues I found, and I was happy to commence construction. I had overcome a number of issues - the unit was to be switched on and off using a magnet. The magnet would operate reed switches inside the case of the alarm, epoxied to the cover. To arm the device, a normally open reed was used - this fires the gate of a SCR which latches the circuitry into operation, the current consumed keeping the SCR switched on; and to turn off, a normally closed reed was inserted into the negative line to break the current, thus de-latching the SCR and turning the alarm off.
The 2 colour LED was programmed to display yellow when arming (both chips on at once), red when sending a range check pulse and green in an alarm condition. At this point I was using the radio without any form of antenna - I found the radio, strangely, performed well enough without one for testing purposes.
It was at the point of the first construction I experienced the greatest problems. I actually built two alarms, abandoning the first due to difficulties. The first was built around the TE200 I had be experimenting with all along - I was over-confident in the program and glued the PIC to the rear side of the radio module, dead bug style, with other components mounted from the chip's pins, using the screening can as a ground and various leads and copper wires as bus bars. I had trouble mounting the unit in the selected enclosure, mounting the unit too far to the one end, and had to open the mounting holes; The LED, mounted underneath the module, obstructed it. Whilst the alarm worked, it was a disaster.
Leaving aside the dimensional cock-ups, once I had the alarm built, I started to shake out electronic bugs. Occasionally, the transmitter would lose contact with the receiver, as if not range check pulse had been broadcast. Sometimes the alarm would turn on, but the module did not. As the days went by, the alarm would die after 10 or 20 minutes, the module being dead but the PIC still running. Sometimes the alarm would not go off if the bike was disturbed, or just switch off altogether. To say I was losing heart would be a major understatement. I just didn't understand why it all worked so well on the bench in breadboard but on fixing everything permanently it turned turkey...
My instinct told me to suspect the PIC program, however, due to the downright foolish way in which I had constructed it, I couldn't reprogram the PIC. I scoured the program's source code to try to find what was causing the issues, to no avail. I burned another PIC, and tried synthesising the same results with another module, but to no avail. It all worked perfectly. As time went on, I began to suspect the diode interface method - quite irrationally on reflection. I got hold of some opto-isolators to try and remove the link between radio and PIC.
Opto-isolators are small chips containing a LED and a variety of photosensitive switch. I chose a device called a photomos relay (RS stock no. 171-8623, data sheet available here, Acrobat reader required) which behaves exactly like a relay, except it will only switch DC, has no moving parts, and comes in a tiny, six pin package. This device was capable of switching low voltages at extremely low currents, with no volt drop. I got hold of a few and tried them in the alarm. There was possibly a minor improvement, but it remained troublesome. I came to the conclusion that the only way to sort the design out was to rebuild it - I had begun to suspect the radio module. It was, after all, a customer return, and may have had some kind of fault all along.
I obtained replacement parts, took others from the previous unit, and then thought about construction once more. I needed a method of making the PIC removable for reprogramming, and generally making the electronics tidier and easier to modify. After some consideration, I got a piece of strip board, and instead of using it by pushing component leads through it and soldering on the reverse side, used it copper side up. This made mounting of the assembled board on the screening can possible by covering the underside with sticky plastic and gluing it down. I used a chip socket for the PIC. To be on the safe side, I used the photomos relays for all three pushbuttons.
To my surprise, and not to mention suspicion, the second build worked fine. I did notice that there are at least two issues of the Telcom 200 module in circulation - the one I first used was a 'B' series (identified on the PCB); the second a 'C' series - there were component differences and the firmware in the radio was different - the 'C' series said 'Call' on the display when it was calling, whereas the 'B' version did not. One problem the change gave me was that the call tones between the units differed in duration. The B had a duration of 9 seconds and the C only 4... I ended up modifying the program to press call twice for each activation, as 4 seconds were barely enough to hear the alarm being activated. One side effect of using interrupts for the detection was that the luggage loop no longer needed to be shorted out when not in use. Since the interrupt the loop is connected to is activated by a change of state, it was a simple matter to make the alarm activate only on the PIC seeing a change from connected to disconnected - if the alarm is armed without the loop present, it will never experience the change of state required to activate the luggage alarm and consequently just trigger on the vibration alarm. Should the luggage loop be broken, the alarm keeps sounding until it's reconnected.
The final circuit is shown below.
(Clicking on the diagram will open a larger, more legible version in a separate window)
I notice that I still have issues with surplus 10K resistors...
And that's about the size of it. In total, I spent about 3 months working on the alarm - not solid work, but hours here and there. Performance has been solid since the second build, and freinds and acquaintances find the concept and size remarkable. The range is good, and the position is far less intrusive.
Mission accomplished!
In conclusion, I'd like to thank Clive Roberts for continually listening to me expounding ludicrous theories and talking utter rubbish, and lending radio advice and support. An honourable mention must also go out to Delboy, his PMR radio forum was the source of many answers as were his PMR pages. Delboy is a sex machine...
Links of some use:
All the information you ever wanted about license-free radio.
If you want a PMR answer, these guys will know.
![]() |
|
![]() |
|
A growing site with plenty of information.
|
The manufacturers of the 16F84 PIC.
|
All the PIC info and help you could ever need.
|
PH Andersons' wonderful embedded control pages
This guy's writings about interrupts makes it all easy.