;************************************************************************************************** ;* IAMBIC keyer * ;* version 1.0.0 06 Nov 2009 * ;* Using device type PIC12F509 * ;* * ;* This iambic keyer uses a PIC12F509 microcontroller to generate the dot/dash timing and key * ;* the transmitter. Most modern rigs are keyed by grounding the key line. The maximum current * ;* on the keying line is usually no more than a few mA. If your transmitter has high voltage * ;* or high current on the keying line, you will need to use a relay to key the rig. * ;* * ;* * ;* Vdd (pin 1) Gnd. Battery negative, and transmitter common ground. * ;* * ;* Vss (pin 8) +5vDC. Battery positive, three AAA cells will last for months... * ;* * ;* GPIO_b0 (pin 7) DOT paddle 100k resistor to Vss, 5k1 resistor to Vdd via paddle dot * ;* switch, and 10nF capacitor to Vdd. * ;* * ;* GPIO_b1 (pin 6) DAH paddle 100k resistor to Vss, 5k1 resistor to Vdd via paddle dah * ;* switch, and 10nF capacitor to Vdd. * ;* * ;* GPIO_b2 (pin 5) Tx key Sw 5k1 to base of TX switching transistor. Transistors emitter * ;* to Vdd (common TX GND), collector TX KEY. Don't forget the * ;* protection diode across the transistors collector emitter, * ;* a 1N4007, anode to collector cathode to emitter / Vdd / gnd. * ;* * ;* GPIO_b3 (pin 4) ** UNUSED ** * ;* * ;* GPIO_b4 (pin 3) ** UNUSED ** * ;* * ;* GPIO_b5 (pin 2) OSC input RC 470pF capacitor to Vdd, and 5k1 resistor in seriese with * ;* 22k variable resistor(POT) to Vss * ;* * ;* * ;************************************************************************************************** list p=12F509, f=inhx8m ; Microcontroller & base include "P12F509.inc" ; Register memory mapping file ; _CONFIG options available ; Code protect _CP_ON _CP_OFF ; Oscillator _LP_OSC _XT_OSC _IntRC_OSC _ExtRC_OSC ; Watch Dog Timer _WDT_ON _WDT_OFF ; MasterCLR _MCLRE_ON _MCLRE_OFF __CONFIG _CP_OFF & _WDT_OFF & _MCLRE_OFF & _ExtRC_OSC ;************************************************************************************************** ;* System variables * ;************************************************************************************************** COUNT1 equ H'000C' ; Count for delay loops COUNT2 equ H'000D' ; -- "" -- FLAG equ H'000E' ; User flag register ;************************************************************************************************** ;* System constants * ;************************************************************************************************** W equ H'0000' ; Destination W - Working register f equ H'0001' ; Destination f - File DIT_SW equ H'0000' ; DOT switch (ON PADDLE KEY) DAH_SW equ H'0001' ; DASH switch (ON PADDLE KEY) KEY equ H'0002' ; KEYING output DIT_FLG equ H'0000' ; DOT flag bit ;************************************************************************************************** ;* reset vector * ;************************************************************************************************** RESET org H'0000' ; Reset vector address goto INITIALISE ; Start of program execution ;************************************************************************************************** ;* system initialisation * ;************************************************************************************************** INITIALISE bcf STATUS,PA0 ; goto bank0 movlw b'11000101' option ; /GPWU off, /GPPU off, TOCS fOSC/4, TOSE TE, PSA TMR0, ; Ratio 64:1 (b'11000101') ; OPTION REGISTER setup... ; b7 - /GPWU wake up on change (GP1,GP2,GP3) ; 0=enabled, 1=disabled ; b6 - /GPPU weak pull up resistors (GP1,GP2,GP3) ; 0=enabled, 1=disabled ; b5 - TOCS TMR0 timer scourse ; 0=fOCS/4 pin 1=TOCKI ; b4 - TOSE TMRO edge select ; 0=leading edge 1= trailing edge ; b3 - PSA ; 0=TMR0 1=WDT ; b2-b0 - Preescaler ratio clrwdt ; clear watchdog timer clrf TMR0 ; clear TMR0 clrf GPIO ; GPIO configuration... movlw b'111011' ; b0 - GP0/ICSPDAT in (DOT switch on paddle key). tris GPIO ; b1 - GP1/ICSPCLK in (DASH switch on paddle key). ; b2 - GP2/T0CKI out (Tx keying output). ; b3 - GP3/MCLR in (Unused port). ; b4 - GP4/OSC2 out (Unused port). ; b5 - GP5/OSC1/CLKIN in (RC clock). bcf GPIO,KEY ; Make sure Tx is not keyed on power up. movlw 0 ; Clear DOT and DASH flags. movwf FLAG ; -- "" -- goto START ; Goto Main program loop. ;************************************************************************************************** ;* Primary delay loop * ;************************************************************************************************** DAH movlw 0x1E ; DOT/DASH delay loop... goto CONT DIT movlw 0x0A CONT movwf COUNT1 LP2 movlw 0x6E movwf COUNT2 LP1 decfsz COUNT2,1 goto LP1 decfsz COUNT1,1 goto LP2 retlw 0 ; End of delay. ;************************************************************************************************** ;* Main program loop * ;************************************************************************************************** START PPSL btfss GPIO,DIT_SW ; Is the DIT paddle pressed? goto DOT btfss GPIO,DAH_SW ; Is the DAH paddle pressed? goto DASH goto PPSL ; Loop untill next paddle press... DOT btfss GPIO,DAH_SW ; Are both paddles pressed? goto IAMBIC ; If Yes then goto IAMBIC sub... DOT2 bsf GPIO,KEY ; Else Key transmitter. call DIT ; Delay one DOT length. bcf GPIO,KEY ; De Key transmitter. call DIT ; Delay one DOT length. bsf FLAG,DIT_FLG ; Set last element sent flag DOT (for IAMBIC action). goto PPSL ; Return to Primary Paddle Sensing Loop. DASH btfss GPIO,DIT_SW ; Are both paddles pressed? goto IAMBIC ; If Yes then goto IAMBIC sub... DASH2 bsf GPIO,KEY ; Else Key transmitter. call DAH ; Delay one DASH length. bcf GPIO,KEY ; De Key transmitter. call DIT ; Delay one DOT length. bcf FLAG,DIT_FLG ; Set last element sent flag DAH (for IAMBIC action). goto PPSL ; Return to Primary Paddle Sensing Loop. IAMBIC btfss FLAG,DIT_FLG ; Check last charicter sent... goto DASH2 ; Last charicter sent was a DOT, now send DAH. goto DOT2 ; Last charicter sent was a DOT, now send DAH. END