Professional Documents
Culture Documents
**************************************************************
* POWER & SWR meter on 2x16 char LCD display *
* By ON7EQ Aug 2011 *
**************************************************************
The circuit:
* pin 13 = LCD backlight control (1= backlight ON). Use an emittor follower
(like BC639) to control LCD backlight (this draws about 120mA)
* pin A0 : SWR probe FWD voltage input (SWR bridge type 'MONIMATCH')
* pin A1 : SWR probe REFL voltage input
! Set the diode forward voltage in variable 'Diode'. For 1SS99 or other
Schottky diodes, it is around 130mV @ 0,1mA
* pin Digital 2 : 'bip' Sound Switch : when grounded -> SWR 'bip' tone mode
* pin Digital 3 : PEP mode Switch : when grounded -> PEP mode
When switch in center position : normal power/swr mode, instant power & dBm
readout
When using a center toggle switch, Pin 5 must be connected to +5v
If a 3-way toggle switch is present, it will be automatically detected and
the variable 'PushButton' set accordingly.
* pin Digital 5 : Mode push button : when grounded (pulse), next mode is
selected
! the mode is stored in EEPROM & memorized for next boot
BAND SELECT :
-------------
It can be necessary to apply different parameters / calibration factors per
band.
* pin Digital 6 : BAND push button : when grounded (pulse), next band is
selected
! the band is stored in EEPROM & memorized for next boot
*/
// variables
char* myStrings[]={" HF ", " 6m ", " 4m "," 2m ", " 70cm"," 23cm","
13cm"};
/////////////////////////////////////////////////////////////////////////////
///////////////
// modes
byte PEP = (1); // 0 if PEP measured
byte Tone = (1); // 0 if tone SWR tune (bip)
float VoltFWD = 0;
float VoltFWDmax = 0;
float VoltPEP = 0;
float VoltREF = 0;
int VoltFWDmini = 0;
// *************************************************************
// ******************** S E T U P ************************
// *************************************************************
void setup() {
//setup pins
pinMode(LCDbacklight, OUTPUT); //Backlight LCD display
pinMode(PEPswitch, INPUT); // if grounded --> 'PEP' mode
pinMode(ToneSwitch, INPUT); // if grounded --> 'Bip' mode
pinMode(ModeSwitch, INPUT); // if grounded --> cycle through modes
pinMode(BANDSwitch, INPUT); // if grounded --> cycle through bands
// lcd.setCursor(0, 1);
// lcd.print("by ON7EQ 08/2011");
// delay (2000);
lcd.setCursor(2, 0);
lcd.print("QRV on");
lcd.print( myStrings[BAND]);
clearline1();
lcd.setCursor(2, 1);
lcd.print("Pmax = ");
else {
if (PWRmax < 1) {
else {
PowDis = PWRmax ;
//format PowDis
// set timers
DisplayTime = millis ();
BacklightTime = millis ();
} // end of setup
// *************************************************************
// *********************** L O O P ************************
// *************************************************************
void loop() {
beeponce = 0;
MODE = MODE + 1;
if (MODE >= 3) MODE = 0;
}
}
beepband = 0;
BAND = BAND + 1;
//show band
lcd.setCursor(11, 1);
lcd.print( myStrings[BAND]);
else {
if (PWRmax < 1) {
else {
PowDis = PWRmax ;
//format PowDis
// read sensors
// PEP detect
// decay
else if ((millis() - PeakTime) > 400) { // 400 = PEP Peak hold time
VoltFWDmax = VoltFWDmax / (decay + 0.3);
PeakTime = millis ();
decay = decay + 1; //decay
}
// =========================================================
// ************ Refresh LCD display Routine ****************
// =========================================================
void refreshdisplay () {
DisplayCycle = DisplayCycle ++ ;
// LCD Backlight
if (VoltFWD>0) {
digitalWrite(LCDbacklight,1) ; // turn backlight on
BacklightTime = millis (); //set timer
}
else if (((millis() - BacklightTime) > 8000)) { // 8 seconds backlight
digitalWrite(LCDbacklight, 0) ; // turn backlight off
}
// Overrange detect
else {
else {
//format PowDis
tone(TonePin,2500);
delay (200) ;
noTone(TonePin);
//process REF
// POWER Display
lcd.setCursor(0, 0);
lcd.print("Pwr ");
lcd.setCursor(0, 0);
lcd.print("VoltFWD= ");
lcd.print(VoltFWD, DEC);
delay(500);
*/ //////////////////////////////////////////////////////
else {
PowDis = PWR * 10;
else {
PowDis = PWR * 10;
if (PowDis/10 < 100) {
lcd.print(" ");
}
if (PowDis/10 < 10) {
lcd.print(" ");
}
lcd.print((PowDis/10), DEC);lcd.print(".");
lcd.print((PowDis)%10, DEC);
lcd.print("w (PEP)");
}
}
// SWR Display
lcd.setCursor(11, 1);
lcd.print( myStrings[BAND]);
lcd.setCursor(0, 1);
lcd.print("SWR ");
else if ( (VoltFWD > (Diode+1)) & (VoltFWD < (VoltFWDmini)) & (VoltREF <=
(Diode+1))){ // at low power no SWR display or < 1.5
lcd.print("<1.5 ");
}
else {
Vratio = VoltREF / VoltFWD;
// Check ROUTINE
else {
SWRDis = SWR * 10;
lcd.print((SWRDis/10), DEC);lcd.print(".");
lcd.print((SWRDis)%10, DEC);
lcd.print(" ");
}
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Batt Volt=");
if (SupplyVoltage < 100) {
lcd.print(" ");
}
if (SupplyVoltage < 10) {
lcd.print(" ");
}
lcd.print((SupplyVoltage/10), DEC);
lcd.print(".");
lcd.print((SupplyVoltage)%10, DEC);
lcd.print("v");
if (SupplyVoltage <= VoltSupplyMini) {
lcd.setCursor(2, 1);
lcd.print("LOW BATTERY !");
}
delay (1500);
}