/**************************************************************** /* Program Name: DX70SGC.c /* Version: 1.0 /* Date: 27 August 2002 /* /* This source was written by Zack Clobes, W0ZC for use /* with Alinco DX-70 Transceivers using SGC tuners. It is /* free for all non-commerical use. You may contact me /* at zack@clobes.net. /* /* Periodic updates and/or modifications will be made /* available at www.rckara.org/. /* /* While I trust this code with my own equipment, I make /* no warranty that it will function correctly in any given /* environment and will not be held resposible for data or /* property loss due to the failure of this code or /* related hardware. /***************************************************************/ #include <16f84.h> #fuses XT,NOWDT #use delay(clock=4000000) #define SGC_TUNED PIN_A2 #define DX70_START PIN_B5 #define DX70_PTT PIN_B4 #define PIEZO PIN_B3 void chirp(void); void beep_k(void); void beep_bad_tune(void); void main(void) { int iCnt; int iTuneStatus; //0=not tuning, 1=tuning, 2=good match, 3=bad match int iSolidOn; int iChirp; int i; delay_ms(1000); //wait for everything to power up beep_k(); iTuneStatus = 0; //we're not tuning while(1) { //wait in infinate loop for the tune_start to go high if (input(DX70_START)) { //we have a start tune output_high(DX70_PTT); //key the transmitter delay_ms(1000); //always tune at least 1 second chirp(); //initialize the counter variables iCnt = 0; iChirp = 0; iTuneStatus = 1; //we're starting to tune //start watching the tuned light //can't go longer than 200 because the DX-70 times out before the tuner while((iTuneStatus == 1) && (iCnt < 200)) { //loop until we're done tuning delay_ms(100); if (iChirp > 20) { chirp(); //chirp every 2 seconds iChirp = 0; } iCnt++; iChirp++; iSolidOn = 0; //default the flag off if (input(SGC_TUNED) == 0) { //the tuned light came on (went low) iSolidOn = 1; //we had a trigger, now watch it for (i=0;i<10;i++) { //loop thru for 100ms to make sure we have a valid tune line (not line noise) if (input(SGC_TUNED) == 1) iSolidOn = 0; //set the flag that we're not solid delay_ms(10); } iCnt++; //we just spent 100ms in the loop above //if the line stayed high for the past 100ms, then the tuner is done if (iSolidOn) { output_low(DX70_PTT); //shut the xmitter down - we're done with it //now wait to see if the light stays on, or if it's blinking iTuneStatus = 2; //assume a good tune for (i=0;i<8;i++) { delay_ms(100); if (input(SGC_TUNED) != 0) { //it's blinking iTuneStatus = 3; //bad tune i=8; //break out of the loop } } } } } output_low(DX70_PTT); //make sure the xmitter is off if (iTuneStatus == 2) { beep_k(); //good tune } else { beep_bad_tune(); //bad tune } iTuneStatus = 0; //reset back to not tuning } } } void chirp(void) { //make a small chirp - as during the tuning process output_high(PIEZO); delay_ms(75); output_low(PIEZO); } void beep_k(void) { //send a K in morse to indicate finished tuning output_high(PIEZO); delay_ms(325); output_low(PIEZO); delay_ms(100); output_high(PIEZO); delay_ms(130); output_low(PIEZO); delay_ms(100); output_high(PIEZO); delay_ms(400); output_low(PIEZO); } void beep_bad_tune(void) { //send three longs to indicate a bad match output_high(PIEZO); delay_ms(750); output_low(PIEZO); delay_ms(500); output_high(PIEZO); delay_ms(750); output_low(PIEZO); delay_ms(500); output_high(PIEZO); delay_ms(750); output_low(PIEZO); }