Observations from Scotland.

One for the Techies.    Allan Copland GM1SXX     10th March 2009.

A Cheap and cheerful Beacon Keyer.

Flash programmable PIC microcontrollers make a cheap and easy means of creating a beacon keyer for amateur radio use that offers a lot of operational flexibility.  Since these are cheap, easy and quick to program, it's possible to make a keyer that can be reprogrammed in mere tens of seconds rather the minutes or hours that were required with EPROM based controllers.  With the correct cable (for ICSP), you can even re-program the beasts in-situ.

What's more, you can buy a Flash PIC programmer very cheaply on EBay and PIC development boards from a number of sources. Since most people don't like programming in machine code, you can use a compiler instead, a fully featured compiler operated in DEMO mode, so you don't even need to buy that :-)  My compiler of choice is the MIKROELEKTRONIKA PIC BASIC compiler which you can download and try for free, from http://www.mikroe.com/zip/mikrobasic/mikrobasic_7002_setup.zip  The compiler is a large zip file, so expect it to take a while to download.  Once downloaded, you just click on the file and go for the default settings.

The compiler is quite expensive if like me you buy a copy, but for a one-off small application like this, you can download and use it for free, so long as the compiled code is below a certain size.... I believe 3 K Bytes.  The example code can therefore be compiled using the (free) demo version of the compiler.  This was one of those rare products I REALLY liked from day one, so I bought a pukka license for it.

You can use the demo version of the compiler  to compile the following code with your own message replacing the one(s) I chose. Be aware that the clock crystal frequency may need to be altered to suit whatever XTAL or ceramic resonator *YOU* choose to use in the target board.

I wrote this software for the 16F877A device but it should be able to be recompiled for any common PIC Flash device with PORTB and a USART.  That gives you a lot of options.  The 16F877A is total overkill for this application, but since I have lots of them, that's what I used :-)

I use little PIC boards from VOTI in the Nederlands. VOTI are both cheap and fast... so I like them a lot!  They are called 'Dwarf Boards' for reasons beyond my ken, but they are cheap and do a job of work. You can buy them from here....    http://www.voti.nl/dwarf/index.html

The 40 pin PIC board http://www.voti.nl/dwarf/doc/DB001.pdf  is perfect for use with the 16F877A

The only other thing you need is the PIC Programmer. I bought mine from a nice chap called Kenny Wong, in Kowloon (no kidding... LA2QAA!) for a very small sum of money.  A search of EBay for 'PIC PROGRAMMER' should turn up something suitable, at a suitably low cost.  You want a 40 pin pic programmer for the F (flash) series devices.  EBay  The 40 pin programmers will also program the smaller FLASH PIC's so they are a good invertment.

Once you have downloaded the compiler, you should download and unzip the source code from here.... using whatever unzip software  is your favourite.

demo.ZIP

Unzip the code and paste it ito the examples folder of the compiler.  If you do a default install of the compiler, copy the files to the ...

C:\Program Files\Mikroelektronika\mikroBasic\Examples   folder.

The ZIP contains two files.  The program file and the project file.

You can now launch the compiler and browse to the code and open it.  It will look something like this. 

Here is a screenshot of the compiled program. 

 

You have to do two things now....

1) tweak the clock settings from 010.0000000Mhz to whatever YOU intend to use. 

and

2) Place YOUR message  in place of the one I have, in the last part of the program code.

To compile the software, you browse to the unzipped code from the PROJECT/ OPEN PROJECT option.

At that point, you should set the CLOCK frequency for whatever rock or resonator you want to use.... PROJECT / EDIT PROJECT etc... and set the clock rate.  OK it and go to FILE / SAVE ALL.

The next step is to replace MY messages with YOUR messages. 

 

If your message is for example 'DE LA2QAA PERSONAL BEACON'  you need to put in ...

  _D _ E  __  _L _A  _2  _Q _A _A __ _P _E _R _S _O _N _A _L __  _B _E _A _C _O _N __

Two dashes... __ places an 'inter-word gap' between the letters while each individual letter has a single dash in front and a space behind it. 

Once compiled, you need to find the HEX file in the appropriate place (usually C:\Program Files\Mikroelektronika\mikroBasic\Examples ) and use that to program the PIC with the help of your PIC programmer.  After that, you load the PIC into the VOTI board, and you are good to go.

The software runs in an endless loop and  once started, by applying 5 volts to the PCB, it will run continuously until the power is removed..

When you compile the program, if you have done everything right, the 'messages' window should look something like the example above.

If not. it will flag up any errors complete with line numbers, and you have to de-bug the line(s) and recompile until the compiler runs successfully, as above.

For those who do not have access to a cheap programmer or are not technical types, I'm willing to program a 16F877A PIC for you, provided you first contact me by email and  send me a 16F877A PIC with adequate return postage & packing  plus the message you wish to send (printed in plain text).  I'm QTHR.  See QRZ.com.

The keyer can be programmed to send a single repeating sequence or a combination of messages.

 As an example, you might wish to send

DE GM3XYZ + PERSONAL BEACON + KEY DOWN 20 SECONDS

followed by

GM3XYZ IO85AB  + KEY DOWN 5 SECONDS (sent three times)

then loop back and send the whole lot again.

This is easy to do.    It's quite flexible.  Whatever you need, ask. I can make a hex file, ready to program into an 16F877A PIC. 

I usually buy my microcontrollers from EBay.... just do whatever is cheapest for you.

I'm also looking at the possibility of a CW message plus a manchester coded one following it.

The message beings sent is also echoed out of the serial USART at 1200 bauds, 8 bit no parity, so it's possible to connect a serial data terminal or PC to monitor what is being sent as a 1200 bauds ASCII message string.

How the program works.

Apart from setting the clock frequency for your particular XTAL. the last part of the program only needs to be altered to YOUR needs.

The program works by defining di,dit and dah as state changes of the correct timing on the output of PORTB of the PIC.

The letters, numbers and punctuation etc of the Morse alphabet, are then defined in as procedures terms of  di, dit's or dahs.  Oh and di's and dit's are identical.... so I cheat too!

Finally, there is the main program loop. It is executed endlessly in a While/Wend loop that can never end.

The message or messages is/are placed within this loop.

You may ask why I didn't just use A instead of _A or B instead or _B. Well, thats easy, I can't.  The letters A-Z are verboten!,  hence the use of the underscore prefix.

I'm certain this program could be rewritten much more elegantly, but I wrote it for code clarity instead, trading program style for readability.

Re loops...

It's also possible to have loops within the main program loop, to control the sending of messages.  For this, there I defined the ctr (counter) variable.

In the example below, we send the first string three times, followed by the second string being sent once. 

The lines...

USART_write (13) USART_write (10)'carriage return +line feed to home serial
USART_Write_Text ("DE GM1SXX ")

simply echo the message to be sent via the serial USART.  If you don't need or want this feature, you can delete the lines beginning with USART

The next line

_D _E __ _G _M _1 _S _X _X __

sends "DE GM1SXX" in Morse code, to PORTB. 

It's pretty straightforward to use.

 

The supplied example code is as follows...

' *******************endless MORSE MESSAGE DATA LOOP****************************
While 1<>2

'repeat this loop THREE times
for ctr=1 to 3
USART_write (13) USART_write (10)'carriage return +line feed to home serial
USART_Write_Text ("DE GM1SXX ")
_D _E __ _G _M _1 _S _X _X __
USART_write(13) USART_write (10) ' cr/lf
USART_Write_Text ("IO75UV ") ' echo string to serial port
_I _O _7 _5 _U _V __
USART_write(13) USART_write (10) ' cr/lf
USART_Write_Text ("PERSONAL BEACON ") ' echo string to serial port
_P _E _R _S _O _N _A _L __ _B _E _A _C _O _N __
USART_write(13) USART_write (10) ' cr/lf
USART_Write_Text ("Key Down Period.") ' echo string to serial port
KEY_DOWN
next ctr

'and repeat this loop once (or however many times you wish!... by altering the value of ctr)

for ctr=1 to 1
USART_write (13) USART_write (10)'carriage return +line feed to home serial
USART_Write_Text ("QSL VIA GM1SXX AT AMSAT POINT ORG ")
_Q _S _L __ _V _I _A __ _G _M _1 _S _X _X __ _A _T __ _A _M _S _A _T _POINT _O _R _G __

KEY_DOWN
USART_write (13) USART_write (10)'carriage return +line feed to home serial
USART_Write_Text ("DE GM1SXX ")
_D _E __ _G _M _1 _S _X _X __
USART_write(13) USART_write (10) ' cr/lf
USART_Write_Text ("PERSONAL BEACON ") ' echo string to serial port
_P _E _R _S _O _N _A _L __ _B _E _A _C _O _N __
USART_write(13) USART_write (10) ' cr/lf
USART_Write_Text ("Key Down Period.") ' echo string to serial port
KEY_DOWN
next ctr

' and loop back to the start and repeat the sequence forever
Wend ' wend forever because 1 cannot equal two... unless you are a woman!
'$$$$$$$$$$$$$$$$$$$$$$$$ Main Program Loop end $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

 

This repeats the FIRST loop THREE times, then sends the SECOND  loop ONCE.

If you like things simple... The simplest implementation of a repeating message loop might be...

' *******************endless MORSE MESSAGE DATA LOOP****************************
While 1<>2
D _E __ _G _M _1 _S _X _X __
KEY_DOWN

' and loop back to the start and repeat the sequence forever
Wend ' wend forever because 1 cannot equal two... unless you are a woman!
'$$$$$$$$$$$$$$$$$$$$$$$$ Main Program Loop end $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

This one would just send 'DE GM1SXX' followed by a KEY DOWN tone repeatedly.

Finally. Like all good programs, the program MUST end with an end statement....

end.

Without this, it wont compile correctly.

Inverted and NON Inverted data outputs.

I deliberately sent the message data to ALL the pins of PORTB.  The pins can be paralleled together (as nibbles) for greater current drive capability should you need more than a single port line can supply... but  note that PORTB RB0-3 is configured as NORMAL while RB4-RB7 are configured as INVERTED. You can parallel pins RB0-RB3 and RB4-RB7 separately. Whatever you do, DONT just parallel ALL the pins together . They are driven as two data 'nibbles' but with opposing 'sense'..so they won't like it!   You CAN however link together RB0-RB3 and RB4-RB7 as SEPARATE  NORMAL and INVERTED data outputs.

The pin-out of the 16F877A device is shown below

If you build the beacon 'ded-bug' style, the clock xtal goes across pins 13 &14 and you should connect a 30pf ceramic cap from both pins to ground.  If you use a ceramic resonator, omit the capacitors.  PortB uses pins 33 through 40. 

The photo below shows my PIC programmer and a VOTI Dwarf board running the beacon software.  They are sitting on top of a 'standard' plastic place mat.  I think these are about 4 inches square.

The dwarf board is sitting on a pack of AA cells and is connected by the black wire running to the jack on the battery 'pack'.  A single ty-wrap is holding the assembly together.  I used a blue LED and series resistor to 'monitor' the CW as flashes of light during testing.

To the left of the Dwarf board is my programmer. I note that these and similar models are still available on EBay at low cost.  The programmer fits a standard PC serial port and comes with suitable software (WINPIC800).

It's entirely feasible to build a keyer ded-bug style with nothing more than a scrap of PCB. a crystal, a few capacitors and a resistor.  Ugly is fine for these chips.  They are not very demanding either of construction, or of supply voltage.  Anything around 5 volts is fine.

On the 16F877A, pins 11 & 32 go to +5V DC. Pins 12 & 31 go to ground.  Pin 1 (MCLR) can be tied directly to the +5V line or alternatively fed to the junction of a 4k7 resistor and 10uF capacitor strung between +Ve and ground. The resistor goes from +5 to pin 1 and the capacitor from pin 1 to ground. This gives a reset signal at start-up.  The clock pins are 13&14 and across these go to your xtal or resonator. If you use an xtal, two 30PF caps should additionally go from pins 13 & 14 to ground. For a resonator, these capacitors should be omitted.  The PORTB lines B0-B7 are pins 33 to 40 respectively.  Since the software sends the CW message to as both NORMAL and INVERTED logic, PINS RB0-RB3 can be paralleled (for normal), and Pins RB4-RB7 may be paralleled to give inverted logic

If you only need a single TTL line, then just chose any appropriate pin in the RB0-RB3 (normal) or RB4-RB7 range (inverted).

Finally, if you like the idea but are not a technical type and need something similar for a beacon, please contact me and describe what you'd like. I may be able to help.  I'm QTHR (QRZ etc)

 Al.

GM1SXX