;666666666666666666666666666666666666666666666666666666666666666666666666 ;6 6 ;6 VARIABLE DELAY T/R SWITCH 6 ;6 6 ;666666666666666666666666666666666666666666666666666666666666666666666666 'Define the Input & Output lines Output 0 'OPTO #1 Output 1 'OPTO #2 *OR* PIEZO/SPEAKER Input 2 'MUX SWITCHES *OR* VOLTAGE INPUT Input 3 'IR INPUT Input 4 'SWITCH *OR* ONE-WIRE TEMP SENSOR 'Define come constants used in generating Morse Code Symbol Ntrdit=225 'time between element flashes = 225 millisec. Symbol Charlen=500 'time between character groups = 500 millisec. Symbol Time1=3000 'time between chirping and sending call sign = 3 sec. or 3000 msec. Symbol Time2=5000 'time between becon transmissions = 30 sec. or 30000 msec. Symbol OPTO1=0 Symbol VoltDiv=1 Symbol Rtmrpin=2 'Define some variables to hold variable data Symbol I=b1 'Loop variable for call sign letter position Symbol J=b2 'Loop variable for element position in Morse character Symbol K=b3 'Variable holding successive Morse bit data from character Symbol V=b13 'Variable holding LAST battery reading Symbol Mchar=b4 'Variable holding the current Morse character for transmission Symbol Numdit=b5 'Variable holding the # of elements data of the Morse character Symbol Ditdat=b6 'Variable holding the element data of the Morse character Symbol Mask=b7 'Variable holding changing mask data to obtain ' successive bits in the Morse character Symbol Send=w4 'Word length variable holding 'rather' large numbers ' for the time constants Ditlen*3, 500, 1000 Symbol Ditlen=b10 'time length of basic DIT ' 240ms = 5 WPM ' 120ms = 10 WPM ' 92ms = 13 WPM ' 60ms = 20 WPM Symbol OPT=b11 'MUX switch settings Symbol AD=b12 'A/D input value INIT: If Pin4=1 then INIT 'wait for Key down Low OPTO1 'turn ON OPTO1 TR: Gosub MUX 'go read the MUX switches Lookup OPT,(240,120,92,80,60),Ditlen 'get proper element time ' tone units ( 10 msec/unit ) ' 240ms = 5 WPM ' 120ms = 10 WPM ' 90ms = 13 WPM ' 80ms = 15 WPM ' 60ms = 20 WPM Send=Ditlen*5 'Calculate T/R timeout time as 5*dit time CATCH:If Pin4=0 then TR 'key is down so reset timeout length Pause 1 'pause 1 millisec Send=Send-1 'chalk up a millisec of interval If Send>0 then CATCH ;more time remaining in interval? High Opto1 'turn off the relay Goto INIT 'look for next char ;MUX SWITCH INPUT ; This subroutine reads an analog voltage on logical pin 2. ; The 4 MUX DIP switches are used to create an analog voltage ; based on which switch is closed. Each switch controls a weighted ; resistor to create 4 unique voltage readings for the 4 switches. ; The max reading is 255 (8 bits) so dividing the reading by 52 ; will produce a whole number between 0 and 4 based on which switch ; is closed... MUX: ReadADC 2,AD 'read the MUXed switch voltage (8 bits) OPT = AD/52 'normalize it to 5 readings Return 'we are done!