CodeCleanup.txt line numbers are by now approximate For code maintenance: Flag "gate = 1;" does not necessarily change/define the BTM gate line *ALL* such instances were replaced with GATE_ON, which also sets the flag. ... same for standby, ppt, btm_pow, rf_in_on. Reviewed the sensor conversion functions to avoid errors on open sensors during testing. temperatures default to -3degC ignore SWR warnings when Prefl < 30dBm (1 watt) To quickly verify the bits going through 74HC04 inverters: line 884 //*************** for debugging only *************************** case '0': GATE_OFF PTT_OFF STANDBY_OFF BTM_POWER_OFF RF_IN_OFF break; //*************** for debugging only *************************** case '1': GATE_ON PTT_ON STANDBY_ON BTM_POWER_ON RF_IN_ON break; //*************** for debugging only ***************************/ These can be instantly removed from the code with the comment lines /********* SOME OF THESE ARE QUESTIONABLE NOTE INVERTERS ************/ // LINE 102 #define GATE_ON BitWrPortI(PEDR, &PEDRShadow, 0,3); gate=1;// PE3 #define GATE_OFF BitWrPortI(PEDR, &PEDRShadow, 1,3); gate=0;// INVERTER #define PTT_ON BitWrPortI(PEDR, &PEDRShadow, 1,5); ptt=1;// PE5 #define PTT_OFF BitWrPortI(PEDR, &PEDRShadow, 0,5); ptt=0;// INVERTER #define STANDBY_ON BitWrPortI(PEDR, &PEDRShadow, 0,4); standby=1;// PE4 #define STANDBY_OFF BitWrPortI(PEDR, &PEDRShadow, 1,4); standby=0;// INVERTER #define BTM_POWER_ON BitWrPortI(PDDR, &PDDRShadow, 1, 4); btm_pow=1;// PD4 #define BTM_POWER_OFF BitWrPortI(PDDR, &PDDRShadow, 0, 4); btm_pow=0; #define RF_IN_ON BitWrPortI(PDDR, &PDDRShadow, 1, 2); rf_in_on=1;// PD2 #define RF_IN_OFF BitWrPortI(PDDR, &PDDRShadow, 0, 2); rf_in_on=0;// RELAY DRIVER // MAY NEED CONNECTION FROM RMC pin 27 TO TP11 RELAY1 **** <<<<<<<<<< /********************************************************************************/ line 228: RF_IN_OFF // BitWrPortI(PDDR, &PDDCRShadow, 0, 2); // (RF_RELAY_ON) init to off) set PD2 low BitWrPortI(PDDR, &PDDCRShadow, 0, 3); // SPARE OUT init to off) set PD3 low BTM_POWER_OFF // BitWrPortI(PDDR, &PDDCRShadow, 0, 4); // (TX_ON init to off) set PD4 low line 236 GATE_OFF STANDBY_OFF PTT_OFF /* BitWrPortI(PEDR, &PEDRShadow, 1, 3); // (GATE init to off) set PE3 HIGH (Inverter) BitWrPortI(PEDR, &PEDRShadow, 0, 4); // (STDBY init to off) set PE4 low (Inverter) BitWrPortI(PEDR, &PEDRShadow, 1, 5); // (PTT init to off) set PE5 HIGH (Inverter) */ line 551 /* gate=0; ptt=0; standby=0; btm_pow=0; rf_in_on=0; */ GATE_OFF PTT_OFF STANDBY_OFF BTM_POWER_OFF RF_IN_OFF line 586 switch (channelADC) { case 3: i_28 = calib_i_28(vadc[3]); break; case 4: btm_temp = calib_btm_temp(vadc[4]); break; case 5: mci_temp = calib_mci_temp(vadc[5]); break; //FIXED?? line 148<<<< case 6: hts_temp = calib_hts_temp(vadc[6]); break; //FIXED?? line 1019<<< case 7: v_28 = calib_v_28(vadc[7]); break; } line 158 float calib_v_28(float valf) {return(valf*21.0);}; // check divider calib. line 596 btm_hot = BitRdPortI(PEDR, 7); // E7 // D7 - bit need to be connected in hardware // NEEDS PULL-UP RESISTOR TO MAKE IT ACTIVE-LOW (OPTOISOLATOR) tx_disable = !BitRdPortI(PDDR, 7); tx_disable =0; //FIX FIX FIX FIX<<<< line 438 /* NOTE: "else if" means that only one condition at a time is serviced Highest priority (check_data=3;) must come first simple "if" would provide multiple error messages but only the last would be serviced */ void verify_data(void) // SINGLE LINE MESSAGES { //check_data=0; if ((v_28 < cfg.v_28_brownout) && (tomco_mode > MODE_PWR_OFF)) { check_data=1; if (holdwrite[0]==0) {sprintf(message,"Alert 1: 28 V bus %.1fV\r\n",v_28); write_ip(cfg.ip_err,message); holdwrite[0]=1; ActionMesssage(); } } // GainDAC(7); // perhaps it would be appropriate to reduce the power to aleviate the droop. // But I should point out that if the REGULATED +28v is low (out of regulation) is is more likely COLLAPSED. else if (i_28 > cfg.i_28_idle && tomco_mode == MODE_NOPPT) // not transmitting // else if (i_28 > cfg.i_28_idle && tomco_mode!=2) // MODE_STANDBY RADAR_3.c { check_data=1; if (holdwrite[1]==0) { sprintf(message,"Alert 2: idle current = %5.1fA ",i_28); write_ip(cfg.ip_err,message); holdwrite[1]=1; ActionMesssage(); } } // had to boost the cfg.i_28_idle to 3.5 amps else if (i_28>cfg.i_28_full && tomco_mode == 4) // transmitting // else if (i_28>cfg.i_28_full && tomco_mode==2) // MODE_STANDBY RADAR_3.c { check_data=2; // reduce gain if (holdwrite[2]==0) { sprintf(message,"Alert 3: amplifier current i_28 = %5.1fA ",i_28); write_ip(cfg.ip_err,message); holdwrite[2]=1; ActionMesssage(); } } // GainDAC(7); // perhaps it would be appropriate to reduce the power to reduce current. else if (i_28>cfg.i_28_standy && tomco_mode == MODE_STANDBY) // else if (i_28>cfg.i_28_standy && tomco_mode == 1) // RADAR_3.c MODE_PWR_OFF { check_data=1; if (holdwrite[3]==0) { sprintf(message,"Alert 4: i_28_standy = %5.1fA ",i_28); write_ip(cfg.ip_err,message); holdwrite[3]=1; ActionMesssage(); } } else if (btm_hot || btm_temp>cfg.btm_temp_max || hts_temp>cfg.hts_temp_max || mci_temp>cfg.mci_temp_max) { check_data=2; // reduce gain if (holdwrite[4]==0) { sprintf(message,"Alert 5: temperatures: btm %4.0f mci %4.0f htsink %4.0f btm_hot=%d ",btm_temp, mci_temp, hts_temp,btm_hot); write_ip(cfg.ip_err,message); holdwrite[4]=1; ActionMesssage(); } } else if (rf_in>cfg.rf_in_max) /* this condition should never happen with the Schottky */ { check_data=2; // reduce gain if (holdwrite[5]==0) { sprintf(message,"Alert 6: RF_IN %5.0fdBm too large ",rf_in); write_ip(cfg.ip_err,message); holdwrite[5]=1; ActionMesssage(); } } else if (swr_dB < cfg.swr_max_dB) // ********************************************************************** { if(rf_refl > 30) // ignore trivial cases <<<<<<<<<<<<<<<<<<< { check_data=1; if (holdwrite[6]==0) { sprintf(message,"Alert 7: SWR %5.1f Pfwd: %5.1f Prefl: %5.1f ",swr_dB, rf_forw, rf_refl ); write_ip(cfg.ip_err,message); holdwrite[6]=1; ActionMesssage(); } } } else /* no fault */ { check_data=0; return; } } /* end procedure check_data */ // 2012 01 31 line 773 check excess drive before turning on amplifier: /* normal loop, in standby, check if signal comes *****************************/ case 1: waitfor(tomco_mode==MODE_NONE); if (rabbit_mode != 1) break; // changed by Error if (rf_in>cfg.rf_in_thres && !tx_disable) /* leave standby and flip to rabbit_mode 2 */ { sprintf(message,"Signal detected: %5.1fdBm. \r\n",rf_in); write_ip(cfg.ip_err,message); if (rf_in < cfg.rf_in_max) {write_ip(cfg.ip_err,"Signal OK, enabling amplifier\r\n");} else { write_ip(cfg.ip_err,"Excess drive Signal,\r\n"); tomco_mode=MODE_STANDBY; rabbit_mode=1; break; } tomco_mode=MODE_IDLEXMIT; rabbit_mode=2; } /* keep looping and wait for signal to go up */ break;