' ********************************************************************** ' DOPPLER TUNING BOX ' Written by OZ1BXM Lars Petersen, Holstebro, Denmark ' Homepage: www.oz1bxm.dk ' E-mail: oz1bxm@pobox.com ' This software runs on a Basic Stamp 2 (see www.parallax.com) ' ********************************************************************** ' ' DOPPLER CORRECTION OF TRANSCEIVERS WITH NO RS232 INTERFACE ' ' The BS2 receives RS232 frequency data sent by WispDDE and converts it into DTMF tones, ' which are used for doppler correction of the downlink frequency on the Kenwood TM-455E. ' ' The radio type as set in WispDDE is IC-475 (Settings -> Radio -> Model). This makes WispDDE ' transmit frequency information in the CI-V format. ' ' The RS232 protocol is CI-V by Icom, see www.plicht.de/ekki/civ/ ' The serial link between the PC and the BS2 runs at 2400 baud; faster speeds have been tried, ' but 4800 and 9600 baud produced errors. ' ' The following is checked in software before sending DTMF tones: ' Is the command-byte equal to $05 (write to rig command)? If yes, continue. If no, get new frame. ' Has the frequency changed since last time? If yes, continue. If no, get new frame. ' Now the software adjusts the radio's frequency by pressing the PF-key ' and sending 5 DTMF-digits ' ' The length of the "Write data to rig" command frame in CI-V is 11 bytes (11 octets) ' Example frame sent by WispDDE: ' FE FE 14 E0 05 15 83 29 35 04 FD ' The preamble (FE FE) is detected, but not saved. The trailer (FD) is not saved. ' 14 is the address of radio (destination); ' E0 is the address of the computer (origination); ' 05 is the command-byte: "Write data to rig" ' Frequency data: 1 Hz is sent first (lower nibble of 15, i.e. 5), ' then 10 Hz (upper nibble of 15, i.e. 1), then 100 Hz (lower nibble of 83), and so on. ' Frequency sent in the example frame = 0435.298.315 ' ' The software stores 6 bytes in civArray: ' 0 1 2 3 4 5 ' cmd 10Hz1Hz 1K100 100K10K 10M1M 1G100M ' ' Neither the address of the radio nor the address of the PC is checked. The software does not ' respond to any commands, so "Bidirectional interface" in WispDDE should be disabled. ' The TM-455 radio must receive the 5 DTMF-digits in this order: 1M, 100K, 10K, 1K, 100 ' Example: If frequency 0435.298.321 is received via RS232 then 52983 is sent to the radio ' via DTMF. Remaining digits (1, 10, 10M, 100M, 1G) in civArray are not used. ' ' {$STAMP BS2} ' {$PBASIC 2.5} ' GreenLED PIN 8 ' Green LED is connected to P8 (pin 13) RedLED PIN 9 ' Red LED is connected to P9 (pin 14) Spkr PIN 14 ' Speaker connected to P14 (physical pin 19) PF PIN 15 ' FET-switch connected to P15 (physical pin 20) IsOn CON 0 ' LEDs are active low IsOff CON 1 Enabled CON 1 ' testfreq_pin and debug_pin enabled when high testfreq_pin VAR IN6 ' P6 (pin 11) enables/disables generation ' of test-frequencies debug_pin VAR IN7 ' P7 (pin 12) enables/disables the debug LEDs index VAR Nib bcd VAR Byte bcdhi VAR bcd.HIGHNIB ' bcd high nibble freq VAR Byte current_freq VAR Word new_freq VAR Word civArray VAR Byte(6) ' 6-byte array Init: LOW PF ' Set PF low (deactivated) OUTPUT GreenLED ' Pin is output GreenLED = IsOff ' Turn LED off GOSUB FlashGreenLED ' Flash the green LED once OUTPUT RedLED ' Pin is output RedLED = IsOff ' Turn LED off GOSUB FlashRedLED ' Flash the red LED once freq = 0 ' Initialize current_freq = 0 ' Initialize Main: IF (testfreq_pin = Enabled) THEN ' Load civArray with a locally generated test data ' civArray(1) and civArray(5) are not loaded as ' these bytes are not used ' 6 digits are loaded: 37.210.n where n = 0..7 freq = (freq + 1) & %00000111 ' increment freq, new value is $0n where n is 0..7 civArray(0) = $05 ' command-byte "write-to-rig" civArray(2) = freq ' 1K 100 civArray(3) = $21 ' 100K 10K civArray(4) = $37 ' 10M 1M PAUSE 1400 ' 1.4 s delay ELSE SERIN 16, 16780,[WAIT($FE,$FE), SKIP 2, STR civArray\6\$FD] ' get 6-byte string from RS232 ' 16 = use SIN port (pin 2) to receive data ' 16780 = 2400 baud 8-N-1 inverted ' Wait for FE FE; skip the next 2 bytes, and ' store the next 6 bytes. ' If $FD is received: store string and continue ENDIF IF (civArray(0) <> $05) THEN ' If the command-byte is different from 05: GOSUB Err_LED ' flash the error LED (if enabled) and jump to Main GOTO Main ENDIF new_freq.HIGHBYTE = civArray(2) ' Save the new frequency (100, 1K, 10K, and 100K new_freq.LOWBYTE = civArray(3) ' values are saved) in new_freq and compare it with IF (current_freq = new_freq) THEN Main ' the current frequency, return to Main if no change GOSUB PressPF ' "Press" the PF key bcd = civArray(4) ' Select byte 4 and send the 1 MHz digit bcd = bcd << 4 ' Shift left 4 bits to fetch the low nibble GOSUB SendDTMF ' Send bcd's high nibble to radio via DTMF ' Now send the remaining 4 digits: FOR index = 3 TO 2 ' Do this twice (index = 3, 2) bcd = civArray(index) GOSUB SendDTMF ' Send bcd's high nibble to radio bcd = bcd << 4 ' Shift bcd left 4 bits to fetch the low nibble GOSUB SendDTMF ' Send bcd's high nibble to radio NEXT current_freq = new_freq ' Store the new frequency GOSUB Ok_LED ' Flash the OK LED (if debug_pin is enabled) GOTO Main ' Start again from top SendDTMF: DTMFOUT Spkr, 50, 50, [bcdhi] ' Send bcd's high nibble, 50 ms on, 50 ms off RETURN PressPF: ' Kenwood TM-455 needs a "key press" before it HIGH PF ' accepts frequency input (that is DTMF tones). PAUSE 90 ' The PF key does not have a fixed function; it must LOW PF ' be programmed by setting Menu no. 70 to activate PAUSE 10 ' function 84 (ENTER). RETURN ' Function 84: "Used with the DTMF mic keypad for ' direct entry of the operating frequency or ' memory channel". See Kenwood TM-455 Instruction ' Manual p. 14 and 35-36. Err_LED: IF (debug_pin = Enabled) THEN FlashRedLED RETURN Ok_LED: IF (debug_pin = Enabled) THEN FlashGreenLED RETURN FlashRedLED: RedLED = IsOn PAUSE 150 RedLED = IsOff PAUSE 100 RETURN FlashGreenLED: GreenLED = IsOn PAUSE 150 GreenLED = IsOff PAUSE 100 RETURN