; ; $Header: E:/HAM/EVM/RCS/g3ruh.asm 1.7 1997/10/23 13:41:54 dbraun Exp $ ; ; $Log: g3ruh.asm $ ; Revision 1.7 1997/10/23 13:41:54 dbraun ; Added blinking of orange LED for received serial port data ; ; Revision 1.6 1997/10/21 07:26:10 dbraun ; Yellow LED now shows status of SCI TXD line ; ; Revision 1.5 1996/12/10 19:49:30 dbraun ; Added compile-time option for muting carrier when not xmitting. ; ; Revision 1.4 1996/11/20 13:37:34 dbraun ; Adjusted input and output levels for IC821. ; RxGain changed from 16.5 to 9.0 dB ; Tx level changed from .58 to .30 (gives 1.0 V p-p output) ; ; Revision 1.3 1996/07/18 19:26:54 dbraun ; Adjusted RxGain to 16.5 dB, for use with R5000. ; ; Revision 1.2 1996/07/17 13:27:45 dbraun ; Added line to switch on audio I/O relay for 9600 BPS port. ; ; Revision 1.1 1996/07/17 13:20:14 dbraun ; Initial revision ; ; page 132,79 opt rc opt mu title 'G3RUH demodulator' ;*************************************************************** ;* G3RUH.ASM -- 9600 bit/s G3RUH modem * ;* * ;* 9600 bit/s two level PAM demodulation with fixed rate * ;* sampling and adaptive equalizer. * ;* * ;* PAM demodulation is based on some ideas presented in book * ;* Lee, E., A., Messerschmitt, D., G.: * ;* "Digital Communication", * ;* Kluwer, 1988 * ;* * ;* Symbol synchronization is base on the article * ;* Mueller, K., H., Mller, M.: * ;* "Timing Recovery in Digital Synchronous Data * ;* Receivers", * ;* IEEE Trans. on Comm., Vol. COM-23, No. 5, May 1976 * ;* * ;* This module uses registers as follows: * ;* r0 - general purpose (temporary use) * ;* r1 - general purpose (temporary use) * ;* r2 - sample buffer pointer * ;* r4 - output filter pointer * ;* r6 - general purpose (temporary use) * ;* * ;* Copyright (C) 1993-1996 by Alef Null. All rights reserved. * ;* Author(s): Jarkko Vuori, OH2LNS * ;* Modification(s): * ;* 01.01.1996 Added support for both left and right * ;* channels * ;* 22.03.1996 Modified for the new SPY program * ;*************************************************************** ; User controllable parameters kiss set 1 ; give KISS data (1)/debug data (0) for SPY iDuplex set 1 ; full-duplex (1)/half-duplex (0) at start-up OLevel set 0.30 ; output signal level (in rms volts) RxGain set 9.0 ; Codec input gain in dB, set to match radio. RightAudioChannel set 0 ; left codec channel (0)/right codec channel (1) RightPTTChannel set 0 ; use left channel's PTT (0)/right channel (1) TxContCarrier set 0 ; continuous audio output (1) or muted when not xmitting (0) nolist include 'leonid' list ; Program parameters buflen equ 256 ; codec sample buffer lenght fs equ 48000.0 ; sampling frequency fd equ 9600.0 ; decision rate I equ 2 ; interpolation factor D equ 5 ; decimation factor 48k*(I/D)=19.2k ; AGC refLev equ 0.6 ; reference level for AGC agcN equ 15 ; agc analyse block lenght agcGain equ 100.0 ; agc integrator gain ; symbol synchro rwfc0 equ 0.99 ; random walk filter ciefficient (carrier off) rwfc1 equ 0.3 ; random walk filter ciefficient (carrier on) ; DCD DCDFil equ 0.02 ; decision error IIR LPF coefficient DCDN equ @cvi(0.3*fd+.5) ; delay (in s) after DCD off ; G3RUH specific poly equ $10800 ; G3RUH,K9NG scrambler polynomial (x^17 + x^12 + 1) ; flags xmit equ 0 ; xmit on/off car equ 1 ; carrier on/off ; macro for the PTT output handling ; O0 when left channel is used ; O4 when right channel is used pttled macro mode if RightPTTChannel b\mode #4,x:$ffe4 else b\mode #0,x:$ffe4 endif endm ; macro for DCD output handling ; O2 for both channels carled macro mode b\mode #13,x:$ffe4 ; N1OWU: was bit 2, I made bit 13 to match bpsk1200 endm YellowLED macro mode ;CAT line (a yellow LED connected) b\mode #3,X:$FFE4 endm OrangeLED macro mode ; (an orange LED connected) b\mode #14,X:$FFE4 endm ; first order high-pass IIR filter ; input in a, output in a ; frq is -3dB point (fc/fs) hpass macro acc,frq,store c1 set -1.0/@cos(6.28319*frq)*(1.0-@sin(6.28319*frq)) move acc,x0 move #>(1.0-c1)/2.0,y0 mpyr x0,y0,acc x:c1,y0 macr -x0,y0,acc move acc,x:1,x1 tlo x0,a move a,y:agcN,x1 move a,y:@pow(2,-5)*agcGain/(fs/agcN),x1 ; rectangular integration move b,x0 move y:(poly<<1)|1,x0 eor x0,b unscram lsr b move b1,x:poly,x0 jcc <_gb2 eor x0,a _gb2 move a1,x:DCDN,x0 jgt _car2 move x0,y:1,x0 ; no carrier after DCDN symbols sub x0,b #rwfc0,x0 move b,y: YellowLED clr .else YellowLED set .endi ; Do the same for the Rx data line and the orange LED. btst #0,x:$ffe5 ; Port C data register .if OrangeLED clr .else OrangeLED set .endi ; all this again, sigh! jmp iftaps,x0 sub x0,a #>icoeffs,x0 cmp x0,a #>ifbnks*iftaps,x0 jhs <_adv1 move (r2)+ add x0,a (r2)+n2 ; jumped over the first taps set _adv1 add x0,a a,x:iftaps,x0 add x0,a #>icoeffs+ifbnks*iftaps,x0 cmp x0,a #>ifbnks*iftaps,x0 jlo <_ret1 move (r2)- sub x0,a (r2)-n2 ; jumped over the first taps set _ret1 add x0,a a,x: