Beacon Keyer
A simple beacon keyer with Atmel AVR mega16
The Atmel mega16 (in dip40 package in this circuit) is a 20 year old IC and might be difficult to find,
but perhaps you might have one and your programming setup still works?
The keyr-r004.hex file is object code; the firmware has already been assembled and built,
all keyr firmware being identical. The flash of the mega16 just needs to be programmed with this file:
The beacon message is then set with 9600 8N1 serial terminal program.
This keyer sends cw (from 1 to 99wpm with keyout, keying and FSK tones)
Messages (that can be up to 50 characters long) and keying speeds are stored in EEPROM.
Although the keyr-r004 firmware is in fact a complex (program, microcode and supporting hardware) state machine,
its functioning is easily understood. Perhaps too often exceptionally complicated systems are advocated as
replacements for systems that worked simply before? In extreme cases, the old technology is made unavailable
so as to force the acceptance of the new. Perhaps CW keys will be next?
Getting started with a DIP (if still available)
When using a MOS IC, be sure never to apply a voltage to any pin exceeding the voltage at the IC's
+ve supply pin, or a voltage below that at the IC's 0v supply pin. This also means that when the IC's
supply voltage is OFF, apply no voltage to any pin. The 1/2 LM358 (optional) in the circuit below is
powered from the IC's supply to ensure this condition is met when measuring an external voltage.
Notice that the LM358 output can swing to 0v. The fullscale input voltage at pin pA0 (40) is 2.55v.
The keyer's message can be set to include the voltage at this pin- 2.55v fullscale is included in the
keyer's message as '25.5'.
The circuit. (Although a few keying outputs are shown, only one is used at a time!).
Most RS232 accept 0v as negative voltage input; make sure that the 10k returns to +5v and it is the
4k7 that returns to +12v! Set the 9600bps 8N1 for Fdx with incoming (from keyer) CR translate set
to CR/LF. Additional outputs from the program are available on pins pC6,pC7 (28,29) but in cw modes
only. Ensure the supply voltage is free of transients and voltage spikes, and preferably, install
the keyer in a shielded box. If the fuses low byte is not programmed the circuit might work without
a crystal but the serial terminal speed would be 1200bps because everything would function at 1/8th
of design speed. And in that case (really not recommended), a keying speed of (for example) 88WPM
would have to be set to achieve 11WPM keying speed.
Test setup
Note extra switch on pB4 (5) used for firmware testing and coffee tin fed at 0.008Ghz. Check 5v
supply before connecting it to the mega16- double check the pins connected to supply and 0v. Only solder
to MOS pins with supply voltage turned off and after touching soldering iron bit to 0v ground plane.
Inspect all MOS pins for shorts before initial powering up the circuit. Connections are shown above for
MISO,MOSI and SCLK; if using these pins DO NOT change device high fuses- it is possible to achieve 'lockout'
if care is not taken.
'deadbug' construction
Tin the flat part of the IC pins that you intend to solder to. Then install the IC. Place a small piece
of plastic (extending to just beyond the pins) between the IC and the ground plane- this prevents blob
shorts that are impossible to remove. Anchor the IC to the ground plane with the 0v connections and
capacitors on the supply pins. Keep the connections to the crystal and it's capacitors short and direct.
The crystal case can be held to the board with an uninsulated loopover wire, but hold the leads of the
crystal at the crystal case between pliers before bending the wires. Use multicore wire (from old ribbon
cable) for the connections to pins. Tin the multicore before attaching to flat part of IC pin; these
connections are made by holding the the tinned pin against the end of the tinned wire and heating with
soldering iron. After doing all this, it really is too late to question the position of pin 1 of the IC...
It is however sometimes easier to attach the wires to the pins before installing the IC.
Select Mode
pB4 pB3 pB2 pB1 pB0
1 1 0 0 1 CW program/set message
1 0 0 0 1 CW beacon/send message
Select program mode. Attach terminal and power up the keyer. If the 232 link is ok, the keyer should then show
aeb3 on the terminal. Then type in the beacon message. Press return. If you see double characters, set Fdx ON.
If the keyer response overwrites the text you typed in, set CR translate (in) to CR/LF. When the message is
correct, type !SAVE and press return. If you have a DIP switch, select beacon mode PB3=0 (switch 4 ON), then
press reset. If you don't have a DIP switch, power the circuit down and set Pin (4) to 0v level, then power up
the circuit again. In beacon mode, the keyer no longer responds to the terminal, but instead shows characters
as they are being sent. The A/D value is then shown (if either the | or ~ were included in the message) and A/D
offset and gain adjustments can then be made.
Pressing just return (without a message text) shows the current message.
Type !LOAD to check message was saved.
To set keying speed for example to 15wpm, type !WPM=15
If you have no reset button installed, type !RESET instead (set pB3 to 0 level first).
Keying
Pin (19) goes active for keying. For a CW beacon, this either pulls the beacon's frequency low by 800Hz or switches on
the carrier:
Circuit from 40 year old SPRAT for (slow) ook. To avoid the oscillator frequency being pulled on keying and the chirp
that it causes, ensure that there is a buffer or isolation stage between the oscillator and the keyed stage. A problem
with ook is possibility of keyclicks being transmitted as sidebands. (The circuit as shown above is used with a class 'C'
final so that with no drive the output stage is off).
As pin (19) goes active, a 1470Hz square wave is produced on pin (18). The 1470Hz can be used with a SSB transmitter
for keying much like CW. If the 1470Hz tone is for keying, a BPF with a Q of 3 can be used to tidy up the square wave:
It really has to be a clean sine wave to look like CW.
Also during keying, pin (21) generates square waves at 1811/1008Hz so you can hear
what the CW fsk beacon would sound like.
Message
Special characters for beacon message:
| reads the voltage on pA0 (40), full scale 2.55v is '25.5' within message, or
~ reads power on pA1 (39), full scale 2.55v is '25.5' or '255' within message, see pA4
{ set pC7 (29) to 1 level,
} set pC7 (29) to 0 level,
^7 shows pA7 (33) level as H or V,
^6 shows pA6 (34) level as 2 or 1,
^5 shows pA5 (35) level as H or L,
^4 shows pA4 (36) level as H or L, pA4 also sets ~ power fullscale to either 255 or 25.5
_ (CW only) 5 second key down delay, this also sets pC6 (28) to 1 level for duration.
\ (CW only) shows SWR from Vf on pA2 (38) and Vr on pA3 (37); >2.5 sets pC3 (25)
For example, a hot switched PIN diode could change antenna polarisation with pC7. Or the PIN diode
could be switched from pC4 (26) that toggles for each message, and read back in with ^7 and shown
as H or V:
The resistors on the output side (as with pC4 in the above sketch) should be low values, perhaps 4k7 and 2k2
to ensure the transistor doesn't switch on during keyer startup.
To measure power (pA1) and voltages (Vf,Vr) voltages with CW on/off keying one _keydown is needed in the message
before the ~ or \ characters. (If there is no _keydown character in the message then a peak hold circuit would
be needed). This not being required for FSK since carrier is constantly on and the power and swr can be read
anywhere within the message.
Notes
The MOS pins, as outputs, can only supply a few mA of current. So use a series resistor from any
output to limit current; in this way a small audio transformer can be driven from pin (18) (include a series
capacitor)- and when resonant at 1470Hz, produces a very clean sine wave. A MOS output if damaged, probably
prevents the keyer from useful operation, and the MOS IC can then only be used for a different project. So
always use a series resistor at outputs. Pins pB0...pB4 are configured as inputs from device reset and can be
safely shorted to 0v for '0' level mode selection. Leaving MOS input pins unconnected is not a good idea
because if they float to the 2.5v level, current increases at the input pin buffer (both P and N transistors
switch at same time). So generally, provide a pullup resistor on unconnected MOS inputs. However, pins
pB0...pB4 have pullups internal to the MOS device enabled from device reset. The keyer program only reads
these pins after (at) device reset.
Each dot is one element length keydown followed by a one element length keyup.
Each dash is three element length keydown followed by a one element length keyup.
The last keyup of a character is followed by two more keyups; so there are three elements of keyup
between each character. If the next character to be sent is a space, four more keyups follow. So
the total keyup time between words is 1+2+4 or 7 element lengths. A space character following a previous
space character produces a 7 element keyup. The keyer adds a space onto the end of the message if the
message does end with a space. So a space at the end of a message is not needed.
You might notice (probably with slow CW) that the green/red dots and dashes are one element time before
the actual keying at KEYOUT. Also but only for CW, the length of _Keydown varies a little by element
length (or !WPM setting); the _keydown being a (preset) variable number of unkeyed E. Element length in
mS is always 1200/Wpm. So for 12Wpm, elements are always 100mS long.
Program
This program is written in Atmel assembly language. Excepting Atmel appnote multiply and divide routines
(used for !WPM, !ELEM and Swr), this is all original software.
If you have the serial connection working as described above and are for any reason unimpressed with
the keyer, and are perhaps more interested in maths than CW, you might try the calculator instead?
Cordic BCD Calculator 16Mhz:19200 (or 8Mhz:9600)
(Best not to have any pins shorted to 0v though). There is a four number stack that gets pushed up on
'enter', but after typing in a number or function, press space. ? lists the CORDIC functions. dbg times
execution with 16Mhz xtal. Calculations are done with BCD numbers. This too is written in assembly language
but I no longer have the source code; it having been saved in a NSFT disk system. (The .hex file is a ROM
dump. This object code, with changes to interrupt vector table, UDR and Timer addresses probably being required,
should be work as is on a more recent device. The unpacked BCD numbers with exponent and flag bytes each take
16 bytes).
Both .hex download
The mega series of processor make provision for a bootstrap loader. With such a loader, it is possible
to program the processor's flash via the serial connection detailed above. The problem however, is how
to program the bootstrap loader to begin with.
Avoid !SAVEing the same keyer message more than 100000 times and remember to reprogram the flash in 2122.
Declaration
The machine created by this firmware complies with the requirements.
The robot sends CW without useing a key.
CW revisited
CW is based on a telegraphic code that in turn in based on a code long ago pioneered by Mr. Morse.
But with a few tricks, this old code can be brought up to date. CW is decoded by ear and such decoding
might provide a 'processing gain' unachievable with purely digital communication schemes? [A list of
beacon frequencies helps too].
If a 16Mhz crystal is used instead of recommended 8Mhz, everything happens twice as fast. The
terminal speed becomes 19200, the 1470Hz keying tone becomes an unusable 2940Hz, 6WPM becomes
12WPM and the 5 second _keydown delay shortens to 2.5 seconds. But there might be a reason to
alter the clock speed:
A keyer set for a 8 WPM with a clock of 8Mhz will generate CW at 14 WPM if clocked at 14Mhz instead
of 8MHz (the serial link then becomes unusable at 16800bps). However, if that 14MHz was derived from
the 10m beacon reference (output frequency 28Mhz/2), the on/off (important!) keying of the 10m becomes
synchronised to the beacon frequency. So if the beacon was sending (exactly) 12wpm and was received at audio
of 1000Hz on a receiver, each dot element would be exactly 100 cycles of audio. And if there were drift
in the system to say 1010Hz, the dot element would take 101 cycles of audio. Now 12wpm CW with element
length 100mS could be seen as a 10bps digital signal. The bandwidth required to receive such a signal
depends on channel quality (signal to noise), but is somewhere between 1.2x and 1.5x the bitrate. So
perhaps for this example the signal is good enough for a 1.3x bandwidth, the receiver could lock into the
received 1000Hz signal and could synthesize a 13Hz receive filter. The received code is still copied by ear.
The exact WPM generated by this keyer depends not only on the !WPM it is set to, but also on the exact clock
frequency. But the receiver could determine it - exactly. (Such a beacon might include the 'EEEEEE' sequence
in the keying message, but no _keydown).
Extra features
HELL (with keyout and either 1470Hz pulses or FSK 1712Hz/1225Hz)
HELL most easily displayed by apk, is decoded by visual interpretation and offers a similar processing
gain over purely digital systems. The HELL speed of 2.5cps (perhaps 25WPM) has not much advantage over CW,
but HELL sends many pixels per character; a form of forward error correction.
pB4 pB3 pB2 pB1 pB0
1 1 0 0 0 HELL program/set message
1 0 0 0 0 HELL beacon/send message
The HELL message can be viewed with the HELL apk using tone from the piezo. Most of the HELL
characters are shown with !TEST command from terminal.
The messages for the CW beacon and HELL beacon are stored within device EEPROM in different
places; the messages are different for each mode. To measure power for the on/off keyed HELL
the ~ character should follow two consecutive _keydown characters.
In HELL mode, the tones at pin (21) are 1712/1225Hz.
Filters are usually cascaded to improve response but can be cascaded for use at two different
frequencies. Here for the 490Hz shift HELL:
Use plastic capacitors for C1. The frequency can be adjusted with R2. The filter, besides passing
the audio frequency, also has to respond fast enough at the keying rate.
Although the 1470Hz pulses are recommended for HELL (lower duty cycle) for SSB transmit, check the apk first
before deciding if FSK should be used instead. (The 1470Hz pulses are as with CW, synchronous to the device clock.
But for HELL, in order for accurate timing, the clock must be exactly 8Mhz). The actual audio frequency that the
1470Hz is received at, is of course determined by the SSB receiver frequency setting and is not important for
the apk test. For a purpose built HELL beacon, use the keyout output (19) from the keyer; FSK being much easier
than fast on/off keying. For HELL, the shortest keying is at 8.16mS or at a rate of 61.25Hz. This (can) generates
sidebands spaced at 61.25Hz around the carrier. But this 8.16mS keying rate does not occur that often, since
sections of HELL characters are usually comprised of connected elements.
If you want to change between HELL and CW modes while in beacon mode, pB0 needs to change state before a device
reset. pC4 could be used to keep count for this:
(The processor executes 8 million instructions per second and although very unlikely, it could get one wrong
sometime, or some bit in a register might be changed by external influence. So a reset every now and again is
not a bad thing. If this possibility however remote is of concern, the message can end with the { character
and a transistor hooked from pC7 back to uP reset line).
Extra feature: Fast Beacon
Tropo, that is atmospheric rather than ionospheric propagation, is far more likely over the ocean:
And also more likely at shorter wavelengths?
This linecode (in daily use worldwide) works at any fixed phase shift and has no DC component:
Extra features: A beacon needs to be receivable by all monitoring stations without adjustment being required for different
receivers used. So direct FSK (ie asynchronous; only data no clocks) is used here. This (PLX varicode) prints on noise and
for that reason a selcall is included; squelch not being fast enough. One and a half received messages probably being
required for the characters to arrive in the sequence expected by the selcall. A counter showing selcall detects is shown
when the reset button on the receiving keyer is pressed. The receiver shows all received characters and on selcall will
activate pC0, pC6 and beep from pD7 as shown in the sketch above. One false selcall is to be expected once during a period
of 280 years. Although the detection of (for example) 20 cycles of 1Khz tone could be done far simply and more effectively,
this scheme proposed above does have an advantage. And that is that more than one transmitter (geographically spaced)
could operate on the same frequency. The selcall being programmed to respond to the first 4 characters of either
transmitter's 5 character identification message; the first 4 characters common to both messages. Or more useful, set
the selcall for '/BCN' character sequence.
Further complexity is possible with a dual band / dual beacon signalling system using pA data bits...
Since program mode is 11011 and receive mode is 01011, a switch on pB4 (together with a device reset) could be used
in a half duplex system for further experiments; it being unnecessary to !SAVE the message in order for it to be sent.
Notice that the message initially sent in program mode following a reset, is the last message that was !SAVEd. Also that
when switching to receive mode, if no new selcall characters are typed, the selcall characters remain unchanged. These
are minor inconveniences (?) compared to the complexity of having two keyers, two radios and a split screen terminal for
the full duplex alternative. [This VHF direct FSK is only useful only for strong signal working since the keyr uses a simple
demodulator working with 0s and 1s only. A more sophisticated demodulator might use over sampling, confidence levels and a
property of the linecode to build likely bit history].
Beacons
Beacons are at the lowest frequencies of 6m since F layer MUF (frequency) slowly increases and beacons provide advance
notification of such propagation should it occur. [Except from Africa]. Some VHF propagation types being directional,
require high beacon density. Beacons for 6m (and above) are usually 800Hz downshift CW FSK while 10m beacons are on/off
keyed CW. Notice that lists of beacon frequencies and cluster reports show the beacon's carrier frequency (the downshift
FSK CW is heard in LSB mode as a 800Hz tone).
[The beacons shown in the map above are the work of individuals, and all these efforts combine to form a global beacon system
for the DXhound].
Test (minibeacon) transmitter
Beacons should be well designed transmitters with specification exceeding that of commercial equipment
as regard to in-band noise, stability and spurious emission. And signal quality. The keying (better electronic
than by distressed fowl), in particular. When a beacon is received as a very strong signal (S9+40), it is usually
the receiver's passband limitations that show as inband spurious responses.
While this transmit circuit probably doesn't meet all those requirements, it is straightforward:
(Having built a few beacons, a different approach attempted for this one). The inductors are on T50-6.
But don't use a varicap for the FSK since temperature compensation is difficult (it depends on applied
voltage; the shift will change). An open collector transistor switching in some capacitance might be used
instead. The mosfet is used as a low noise buffer for the 50Mhz signal from the 74HCU04 (and g2 of the
mosfet is shown connected to g1). The 74HCU04 could have its own 5v (or low noise 5.6v) regulator from
the +8v because any noise on HCU supply appears on output of oscillator. This HCU IC is unbuffered logic
intended for linear circuit operation. The capacitors at pin 2,3 reduce the drive to the crystal to ensure
it is not overdriven to reduce temperature effects. The '3866 is biased so as to reduce the harmonic content
of the transmitted signal. Best use a few turns in bead for the RFC shown at base of '3866. The 2N3906 keeps
the voltage across the 10ohm resistor constant at 0.4v by varying the '3866 base current. Since the current
through the 10ohm is mostly '3866 collector current, this collector current is kept near 40mA. So with a DC
input of 280mW, 150mW of RF output is achieved. The difference of (280-150 or) 130mW is dissapated as heat.
Even with a heatsink of 20degrees/watt, the temperature rises only by 2 degrees. If a transistor with a much
higher Ft is used as a replacement, negative feedback around the new part could be used to reduce gain. Crystals
marked 16.666...17.0Mhz or 50...51Mhz or 83.3...85Mhz will work with this circuit for output between 50 and 51Mhz.
[The 34Mhz notch didn't do much since the 34Mhz at output wasn't from the '3866].
By setting pA4 to 'H' level and connecting a diode voltage probe to the 150mW output to feed voltage via
LM358 into pA1, the beacon message could include '150 MILLIWATTS' or '0.150 WATTS'. A peak voltage of 3.87v
providing an RMS voltage of 2.74v for this example. A voltage of 1.96 volts being required at pA1 since
(((1.96/2.56)*256)^2)/256=150; a -1 missing in those brackets somewhere. SWR (if required) with line coupler
for Vf at pA2 and Vr at pA3. SWR to a maximum of 25:1, is calculated as (Vf+Vr)/(Vf-Vr). That just leaves
pC3 and pA0...
It is of interest to note that if the keyer is clocked with 16.697267Mhz for keyup and 16.697000Mhz for keydown,
the element time for 6WPM becomes 95.82407 mS for keyup and 95.82556 for keydown. Or a keying difference between
keyup and keydown of 12.5229 WPM and 12.5227 WPM, and it is unlikely that this small error would be noticed. It
is however more likely the keyer would notice that the 9600bps link (actually 19200bps, but don't tell the keyer
that) had changed to 10018bps. But this problem can be fixed:
$00b7 e323 ldi r18,51 ; 8e06/(16*9600) is 52 (computers start counting from 0)
Try 53 for 16.7Mhz and 19200. (Don't set the baud rate much lower, that will prevent the program from working).
For this example, 'e323' changes to 'e325' (33h being 51 decimal, 35h being 53 decimal).
What makes this more (?) confusing is that the digits are transposed for these particular hex and dec values!
(A hex file editor is used to modify the program. And a new .hex file generated for flash programming).
The transmit circuit detailed above was built about 20 years ago, so getting the same components might be
difficult, but the '3866 circuit is useful a building block for your high specification beacon perhaps?
If you let the smoke out, it stops working:
Class 'X' maybe.
Alternative keyer; far simpler
An Android program using inbuilt GPS timer and MP3 could be used for 10 location 5 second wordwide SSB time
slot beacon network. The MP3 could be processed audio, the transmitter VOX. This includes another 'processing gain'
for the receiver since the transmit timing schedule is known in advance.