#!/usr/bin/python """ Morse Code Generator. Geoff Robinson, G4AKW, Version 1.0, 4th December 2011. Requirements: Python 2.7, Linux OS, alsaaudio. Usage # python mainmorse.pyThe basic element of Morse code is the dot and all other elements can be defined in terms of multiples of the dot length. The word PARIS is used because this is the length of a typical word in English plain text, it has a total length of 50 dot lengths. If the word PARIS is sent ten times in a minute using normal Morse code timing then the code speed is 10 WPM. There are 500 dot lengths in a minute for 10 wpm or 1000 dot lengths per min for 20 wpm. The dot length is therefore 60mS for 20 wpm. The python dictionary 'code' and the function convert() converts characters to their dot space equivalents i.e either on or off keying. """ import serial import time, thread import random import sys import sched import wave, struct, math from alsaaudio import * import signal def convert(msg): """ Take msg and convert it to the correct True or False dot interval values.""" global start, morselist code = {'a':'. ...','b':'... . . .','c':'... . ... .','d':'... . .','e':'.', 'f':'. . ... .','g':'... ... .','h':'. . . .','i':'. .','j':'. ... ... ...', 'k':'... . ...','l':'. ... . .','m':'... ...','n':'... .','o':'... ... ...', 'p':'. ... ... .','q':'... ... . ...','r':'. ... .','s':'. . .','t':'...', 'u':'. . ...','v':'. . . ...','w':'. ... ...','x':'... . . ...', 'y':'... . ... ...','z':'... ... . .','1':'. ... ... ... ...','2':'. . ... ... ...', '3':'. . . ... ...','4':'. . . . ...','5':'. . . . .','6':'... . . . .', '7':'... ... . . .','8':'... ... ... . .','9':'... ... ... ... .', '0':'... ... ... ... ...',' ':' '} """ next we go character by character through the message and add in the correct spacing""" for ch in msg: morse = '' if ch == ' ': morse = morse + ' ' # 4 spaces plus 3 below = 7 for space else: morse = morse + code[ch] morse = morse + ' ' # 3 spaces between chars for ch1 in morse: if ch1 == '.': ch1 = True else: ch1 = False morselist.append(ch1) # morselist is the input buffer start = 1 def catcher(signum, _): """This is the handler function for the SIGALRM interupt which is generated every dot interval """ global c,z,morselist,start if c != 0: # if c!=0 a dah is sounding so skip this function for 3 dot intervals c = c - 1 return else: if (start == 1) and (z < len (morselist)): # check input buffer end not reached if morselist[z] and morselist[z+1]: # detect a dah z = z + 3 c = 3 out_dah.write(s_dah) elif morselist[z]: # detect a dit z += 1 out_dit.write(s_dit) else: # detect a space z += 1 else: return return def mysound(freq, dur) : """ Function sounds a freq (Hz) sinusoid with dur (mS) length """ global s_dit, s_dah, out_dit, out_dah, period_dit, period_dah rate = 44100 # frame rate period_dit = int(dur * 44) # number of frames (44 frames per mS)(slightly less) period_dah = int(dur * 44 * 3) sig_dit = [ math.sin( 2.0*math.pi*freq*x/rate ) for x in range(period_dit) ] sig_dah = [ math.sin( 2.0*math.pi*freq*x/rate ) for x in range(period_dah) ] # The scale factor for 32bit resolution scale = ( 2**32 - 1 )/2.0 # Scale the signal list sig_32dit = [ int(scale*x) for x in sig_dit ] sig_32dah = [ int(scale*x) for x in sig_dah ] # sound card device initialization out_dit = PCM(type=PCM_PLAYBACK, mode=PCM_NONBLOCK, card='default') out_dah = PCM(type=PCM_PLAYBACK, mode=PCM_NONBLOCK, card='default') # parameters channels = 1 out_dit.setchannels(channels) out_dah.setrate(rate) out_dah.setchannels(channels) out_dit.setrate(rate) # Signed 32 bit samples for each channel (Little Endian byte order) out_dit.setformat(PCM_FORMAT_S32_LE) out_dah.setformat(PCM_FORMAT_S32_LE) out_dit.setperiodsize(period_dit) out_dah.setperiodsize(period_dah) s_dit=struct.pack('<'+channels*period_dit*'l',*sig_32dit) s_dah=struct.pack('<'+channels*period_dah*'l',*sig_32dah) # l is long integer size=4 pack requires (88100 times ?) arguments # use out_dit.write(s_dit) for dit sound # use out_dah.write(s_dah) for dah sound def main(): global morselist,y,w,z,c,start if (len(sys.argv) > 1): speed = sys.argv[1] print "The speed is set to", speed, "wpm" else: speed = 20 print "The default speed is", speed, "wpm" y = int (speed) x = (1200/y) # x is dot interval in mS w = x/1000.0 # w is dot interval in sec z = 0 c = 0 start = 0 mysound (800, x) # Sound frequency set to 800Hz morselist = [] signal.signal(signal.SIGALRM, catcher) # Set the handler for signal.SIGALRM to the function catcher. signal.setitimer(signal.ITIMER_REAL, w, w) #This timer sends a SIGALRM signal every dot interval. a = "_" print 'On a newline type cr to end input: ' while a != '': try: a = raw_input() except EOFError: # needed as SIGALRM interupts keyboard input continue a = a.lower() convert(a) main()
This very simple 2 Fet power amplifier easily achieves 250W output with an FT817 5W drive. The key design details as follows: 3:1 broadband input transformer matches the 5.5 ohm gate load resistor (4 x 22 ohms in parallel) to the 50 ohms required by the FT817 . The 4:1 output broadband transformer presents 3 ohms (16:1 impedance ratio) to the balanced HEXFET pair each mounted on a 3mm copper heat spreader which is insulated from the 2 1w/degC heatsinks. These are blown cool by a fan underneath. The power supply required is 28v at 30 amps. The amp is around 50% efficient with a standing 750mAmp temperature compensated bias. An IC 703, with 10watts output will drive the output to around 400 watts. The output filter shown is a 5 pole topband filter with T130-2 torroids and 400v silver mica caps. Peak output voltage on 160 metres with 5 watts drive is 160v or 320v p-p in 50 ohms equating to 250watts. This is slightly higher than the reading on the 3kw MFJ power meter. The inline F...
Comments