SWR METER DIGITAAL MAKEN
Posted: Fri Dec 15, 2017 1:38 am
				
				Ik heb een Arduino op Daiwa cn-101L aangepast om tot 50 mhz digitaal te kunnen uitlezen.
2 meter moet nog,i.v.m. een andere Correctie factor komt dit een ander keer,
En het schema.

			2 meter moet nog,i.v.m. een andere Correctie factor komt dit een ander keer,
En het schema.
Code: Select all
/*
  Lees analoge waarde op Pin 0 en Pin 1 en zet deze om naar Voltage en daarna naar Watt.
  Let op maximale ingangspanning is 5Volt!!!!!!!
  En zet dit om met correctie-factor c naar Power.
 */
#include<LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);      //aansluitingen display
float fwd_voltage = 0.0;
float fwd_power = 0.0;
float ref_voltage = 0.0;
float ref_power = 0.0;
float c=0.0;                 //correctie factor c bij 100 watt c= 2.4 en bij 1 watt c=10.0 fwd power
float d=0.0;                 //correctie factor d bij 100 watt c= 2.4 en bij 1 watt c=10.0 ref power
int value=0;
float SWR=0.0 ;
//==================================================================================================================
void setup()
{
   Serial.begin(9600);     //  opens serial port, sets data rate to 9600 bps
   lcd.begin(16, 2);       //// set up the LCD's number of columns and rows: 
   lcd.print("PE1IWT SWR 1.5  ");
   delay(3000);
   
}
void loop()
{
//   Van fwd_voltage naar fwd_power ===============================================================================
   
   int fwd_analog_value = analogRead(A0);                    //ingangsspanning  A0 meten !!!!MAX 5Volt!!!!
  fwd_voltage = (fwd_analog_value * 5.0) / 1024.0;           // voltage meting  0.00 tot 5.00 Volt
  fwd_power = (((fwd_analog_value * 5.0) / 1024.0)/c)*100;   // Corr.factor c=bij 100watt =2.4 en bij 1 watt=10.0
  
//  Van ref_voltage naar ref_power =================================================================================
   int ref_analog_value = analogRead(A1);                    //ingangsspanning  A1 meten !!!!MAX 5Volt!!!!
  ref_voltage = (ref_analog_value * 5.0) / 1024.0;           // voltage meting  0.00 tot 5.00 Volt
  ref_power = (((ref_analog_value * 5.0) / 1024.0)/d)*100;   // Corr.factor d=bij 100watt =2.4 en bij 1 watt=10.0
// ====================================================================================================================
  
 
// Aanpassen corectiefactor c i.v.m. niet liniair gedrag van de diode spanning uit de meetbrug.
if (fwd_voltage > 0.05)              //correctie bij 1 watt OK
   {
     c=10.0;
   } 
if (fwd_voltage > 0.13)              //correctie bij 2 watt OK
   {
     c=7.0;
   } 
if (fwd_voltage > 0.16)              //correctie bij 3 watt OK
   {
     c=5.5;
   } 
if (fwd_voltage > 0.21)              //correctie bij 4 watt OK
   {
     c=5.5;
   } 
if (fwd_voltage > 0.25)              //correctie bij 5 watt ok
   {
     c=5.35;
   } 
if (fwd_voltage > 0.32)              //correctie bij 6 watt ok
   {
     c=5.35;
   } 
if (fwd_voltage > 0.36)              //correctie bij 7 watt ok
   {
     c=5.35;
   } 
if (fwd_voltage > 0.42)              //correctie bij 8 watt ok
   {
     c=5.39;
   } 
if (fwd_voltage > 0.47)              //correctie bij 9 watt ok
   {
     c=5.35;
   } 
if (fwd_voltage > 0.55)              //correctie bij 10 watt ok
   {
     c=5.3;
   } 
if (fwd_voltage > 0.6)              //correctie bij 15 watt
   {
     c=4.5;
   } 
if (fwd_voltage > 0.77)              //correctie bij 20 watt
   {
     c=4.0;
   } 
if (fwd_voltage > 1.03)              //correctie bij 30 watt
   {
     c=3.7;
   } 
if (fwd_voltage > 1.29)              //correctie bij 40 watt
   {
     c=3.3;
   } 
if (fwd_voltage > 1.57)              //correctie bij 50 watt
   {
     c=3.0;
   } 
if (fwd_voltage > 1.72)              //correctie bij 60 watt
   {
     c=2.85;
   } 
if (fwd_voltage > 1.89)              //correctie bij 70 watt
   {
     c=2.75;
   } 
if (fwd_voltage > 2.03)              //correctie bij 80 watt
   {
     c=2.6;
   } 
if (fwd_voltage > 2.21)              //correctie bij 90 watt
   {
     c=2.5;
   } 
if (fwd_voltage > 2.3)              //correctie bij 100 watt
   {
     c=2.4;
   } 
if (fwd_voltage < 0.09) 
   {
     fwd_voltage=0.0;
   }
//================================================================================================
// Aanpassen corectiefactor c i.v.m. niet liniair gedrag van de diode spanning uit de meetbrug.
if (ref_voltage > 0.05)              //correctie bij 1 watt OK
   {
     d=10.0;
   } 
if (ref_voltage > 0.13)              //correctie bij 2 watt OK
   {
     d=7.0;
   } 
if (ref_voltage > 0.16)              //correctie bij 3 watt OK
   {
     d=5.5;
   } 
if (ref_voltage > 0.21)              //correctie bij 4 watt OK
   {
     d=5.5;
   } 
if (ref_voltage > 0.25)              //correctie bij 5 watt ok
   {
     d=5.35;
   } 
if (ref_voltage > 0.32)              //correctie bij 6 watt ok
   {
     d=5.35;
   } 
if (ref_voltage > 0.36)              //correctie bij 7 watt ok
   {
     d=5.35;
   } 
if (ref_voltage > 0.42)              //correctie bij 8 watt ok
   {
     d=5.39;
   } 
if (ref_voltage > 0.47)              //correctie bij 9 watt ok
   {
     d=5.35;
   } 
if (ref_voltage > 0.55)              //correctie bij 10 watt ok
   {
     d=5.3;
   }
   // ============================== swr berekenen =============================================================
   
   {
    SWR=(sqrt(fwd_power)+sqrt(ref_power))/(sqrt(fwd_power)-sqrt(ref_power))     ;   // 100w fwd 20 w ref = 2.62
                                                                                    // 25 w fwd 5 w ref  = 2.62     
   }                                                                                //  5 w fwd 1 w ref  = 2.62
    
if (fwd_voltage < 0.1)     // niet de negatieve getallen te laten zien.
   {
     SWR=0.0;
   }
    if (SWR > 4.0)        //SWR boven de 4 is niet nodig.
   {
     SWR=4.5;
   }
  
//====================================================================================================================
    
   lcd.setCursor(0, 1);
   lcd.print("Antenne SWR= ");
   lcd.print(SWR);                      //SWR op display
   
   lcd.setCursor(0, 0);
   lcd.print("POWER FWD=  ");
   lcd.print(fwd_power);                      //POWER FWD op display
    delay(300);
    
    //lcd.print(fwd_power);            // fwd power naar display     
    //lcd.print(fwd_voltage);          // ingangs spanning op display ,eerst spanning meten en tabel maken
    //lcd.print(ref_voltage);          // ingangs spanning op display 
    //lcd.print(ref_power);            // ref power naar display
    //lcd.print(SWR);                      //SWR op display
    //lcd.print(c);                        //corectie factor
    
}