Paul Smith wrote: >My interest with PIC is mainly for the control of amateur radio related >equipment such as repeaters and beacon controllers. ...beacon CONTROLLER! In the following, the PIC is the whole beacon. Just add a crystal, power (I use three 1.5V alkalines) and connect an antenna to OSC OUT. Also note this adjusts the prescaler of the watchdog as discussed earlier. - Mark Sullivan (aka KB0VVQ@niobrara.com) - ; ; PIC16C54 based CW beacon ; Mark K Sullivan 01Apr96 ; PIC16C54 Version ; ; ; 01Apr96 - MKS ; ; ; ; Connect PIC oscillator to 28 or 29.??? MHz crystal in the 10 meter band. ; Program fuses to enable WDT and select HS oscillator mode. ; Alter timing in DELAY routine for a substantially different crystal. ; ; This program identifies a CW beacon by switching the PIC's ; own oscillator on and off. Carrier-on delays are generated ; with a timing loop. Carrier-off periods are timed by the WDT ; with the CPU in sleep state. The PIC oscillator output should ; be fed to the antenna either directly or via an amplifier stage. ; If an external amplifier is added, pin PB0 or PB1 can be used to ; enable it. PB0 high or PB1 low should turn on the amplifier. ; ; The Morse keying rate must be a power-of-two multiple ; of the 18 mS nominal WDT period. I have chosen 72mS ; for the smallest element. This yields about 17 WPM keying. ; The relative duration of Morse code elements is as follows: ; ; dit = 1, dah = 3 ; inter-element delay = 1 ; inter-character delay = 4 (ARRL says 3 but that's not 2^n) ; ; Remember that WDT timing does not depend on the crystal. Changing ; the crystal without adjusting program timing will alter the ; relative timing of carrier-on and carrier-off elements, not ; simply scale the timing. ; ; PROCESSOR PIC16C54 RADIX DEC ; #define W 0 cblock 0 ;special function registers indf rtcc pc status fsr porta portb portc ;16C55, 57 only endc ; cblock 8 ;this program's variables Point ;index into message table Timer1 ;counters for time dealy routine Timer2 Timer3 Timer4 ;used to time the 1 minute delay endc ; org 0 ; ; ; Here is the table of symbols to send. Don't exceed 255 entries ; in the table, including the end marker. ; #define space 1 ;key inter-character space #define silence 2 ;key 1 sec of silence #define dit 4 ;key Morse . #define dah 5 ;key Morse - #define carrier 6 ;key 1 sec of carrier #define minute 7 ;key 1 minute of carrier ; table addwf pc ; ; This example ID table sends 5 seconds of carrier, ; a one second silence, ; the call sign KB0VVQ, ; another one second silence, ; and then repeats. ; retlw carrier ;five seconds of carrier retlw carrier retlw carrier retlw carrier retlw carrier retlw silence ;one second silence retlw dah ;K retlw dit retlw dah retlw space retlw dah ;B retlw dit retlw dit retlw dit retlw space retlw dah ;0 retlw dah retlw dah retlw dah retlw dah retlw space retlw dit ;V retlw dit retlw dit retlw dah retlw space retlw dit ;V retlw dit retlw dit retlw dah retlw space retlw dah ;Q retlw dah retlw dit retlw dah retlw silence ;one second silence ; retlw 0 ;end of table, start over ; ; ; Vector to RESET at power-up or when WDT expires ; RESET movlw 00h movwf porta ;turn off outputs movwf portb tris porta ;all pins are outputs tris portb btfss status,4 ;test TO bit, skip if cold start goto NEXT ;this reset was a WDT timeout ; LOOP clrf Point ;start at top of table symbol bsf portb,0 ;turn on final amp bcf portb,1 movf Point,W call table ;look up table entry addwf pc goto LOOP ;0 entry is table end goto dospc ;inter-character space goto dosil ;1 sec of silence goto NEXT ;code 3 - unimplemented goto dodit goto dodah goto dosec ;1 sec of carrier goto domin ;1 minute of carrier NEXT incf Point goto symbol ; dodit movlw 72 goto didah ; dodah movlw 3*72 didah call DELAY movf Point,W call table ;look up table entry andlw 04h ;test silence bit btfss _z ;skip if next element is not silent goto NEXT ;don't key inter-element space movlw 0ah option ;set WDT timeout to 72 mS bcf portb,0 ;turn off final bsf portb,1 sleep ; dospc movlw 0ch option ;set WDT timeout to 4*72 mS bcf portb,0 ;turn off final bsf portb,1 sleep ; dosil movlw 0eh option ;set WDT timeout to 1152 mS bcf portb,0 ;turn off final bsf portb,1 sleep ; dosec movlw 250 ;simply delay for 1 second call DELAY movlw 250 call DELAY movlw 250 call DELAY movlw 250 call DELAY goto NEXT ; domin movlw 60*4 ;a full minute of carrier movwf Timer4 min1 movlw 250 call DELAY decfsz Timer4 goto min1 goto NEXT ; ; ; Call DELAY with W the duration of desired delay in milliseconds. ; Calibrated approximately for 29.??? MHz crystal. ; DELAY movwf Timer1 d0 movlw 7 ;change this constant for different crystals movwf Timer2 d1 clrwdt decfsz Timer3 goto d1 decfsz Timer2 goto d1 decfsz Timer1 goto d0 retlw 0 ; org 1ffh ;PIC16C54 reset vector ; goto RESET ; end