Home » SWR (VU meters werken de berekeningen nog niet)

SWR (VU meters werken de berekeningen nog niet)

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>SWR meter/Lionel</title>
		<style>
		html,
		body {
			width: 100%;
			height: 100%;
			margin: 0;
		}
		canvas {
			background: #CCC;
			display: block;
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			width: 100%;
			height: 100%;
		}
	</style>
  </head>
<body>
  <section>
    <div>
       <canvas id="canvas" width="1920" height="1080">
         This text is displayed if your browser 
         does not support HTML5 Canvas.
        </canvas> 
    </div>
		<content>
		<p>		
			<span id="Kanaal1"></span>
			<span id="Kanaal2"></span>
			<span id="Kanaal3"></span>			
			</br>	
		</p>
	</content>
<script type="text/javascript">

setInterval(function ( ) {
	  var xhttp = new XMLHttpRequest();
	  xhttp.onreadystatechange = function() {
		if (this.readyState == 4 && this.status == 200) {
		  document.getElementById("Kanaal1").innerHTML = this.responseText;
		}
	  };
	  xhttp.open("GET", "/Kanaal1", true);
	  xhttp.send();
	}, 500 ) ;

setInterval(function ( ) {
	  var xhttp = new XMLHttpRequest();
	  xhttp.onreadystatechange = function() {
		if (this.readyState == 4 && this.status == 200) {
		  document.getElementById("Kanaal3").innerHTML = this.responseText;
		}
	  };
	  xhttp.open("GET", "/Kanaal2", true);
	  xhttp.send();
	}, 500 ) ;

setInterval(function ( ) {
	  var xhttp = new XMLHttpRequest();
	  xhttp.onreadystatechange = function() {
		if (this.readyState == 4 && this.status == 200) {
		  document.getElementById("Kanaal3").innerHTML = this.responseText;
		}
	  };
	  xhttp.open("GET", "/Kanaal3", true);
	  xhttp.send();
	}, 500 ) ;


var canvas;  
var ctx;
var dx = 2;
var dy = 4;
var WIDTH = 1920; 
var HEIGHT = 1080; 
var x = WIDTH;
var y = HEIGHT;
var Threshold = 4.00;

var Kanaal1Spanning = [00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50];
var Kanaal2Spanning = [00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50];
var Kanaal3Spanning = [00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50];





 
function clear() {
  ctx.clearRect(0, 0, WIDTH, HEIGHT);
}

function init() {
  canvas = document.getElementById("canvas");
  ctx = canvas.getContext("2d");
  return setInterval(draw, 10);
}


function draw() {
  clear();
  ctx.fillStyle = "#000000"; //background color

 

  
  
  
  for (i = 0; i <= 50; i++) {
	 Kanaal1Spanning[i] = parseFloat((document.getElementById("Kanaal1").innerHTML).slice(i*6, i*6+6))
	};
  for (i = 0; i <= 50; i++) {
	 Kanaal2Spanning[i] = parseFloat((document.getElementById("Kanaal2").innerHTML).slice(i*6, i*6+6))
	};

  for (i = 0; i <= 50; i++) {
	 Kanaal3Spanning[i] = parseFloat((document.getElementById("Kanaal3").innerHTML).slice(i*6, i*6+6))
	};
  
  DisplayKanaal1Spanning();
  DisplayKanaal2Spanning();
  DisplayKanaal3Spanning();
 
    
  
	
	
 
 ctx.fillText("TEXT HERE", 0, 0);

}




function DisplayKanaal1Spanning(){
	xpos = 50;
	ypos = 200;
	Temp2=32;
	ctx.fillStyle = "#007744"; //donkergroen kader
    	ctx.fillRect(xpos+100,ypos-120, 500, 100);
 	ctx.fillStyle = "#FFFFFF"; //wit in donkergroen kader
    	ctx.fillRect(xpos+110,ypos-110, 480, 80);
 	ctx.font = "30px Verdana"
	ctx.fillStyle = "#007744"; // donkergroen}
	ctx.fillText('FDW Power', xpos+ 270, ypos-60); // maximale vermogen
	
	ctx.fillStyle = "#007744"; //donkergroen kader
    	ctx.fillRect(xpos+100,ypos, 500, 800);
	ctx.fillStyle = "#000000"; // Zwart linkerlijn
	ctx.fillRect(xpos+460,ypos+200, 5, 500);
	ctx.fillStyle = "#00FF00"; // Groen
	ctx.fillRect(xpos+465,ypos+202, 45, 500);
	ctx.fillStyle = "#000000"; // Zwart rechterlijn
	ctx.fillRect(xpos+505,ypos+200, 5, 500);
	ctx.fillRect(xpos+460,ypos+200, 50, 10);  //Zwart bovenlijn
        ctx.fillRect(xpos+460,ypos+700, 50, 10); //Zwart onderlijn

	waarde = 30;
	ctx.font = '30px Verdana';
		var aa = Number.parseFloat(Kanaal1Spanning[50]).toFixed(0);
		ctx.fillStyle = "#555555"; // Grijs
		ctx.fillRect(xpos+465,ypos+202, 40, aa);
		for (i = ypos+200; i <= ypos+726; i += 50) {
		ctx.fillStyle = "#000000"; // zwart
 		ctx.fillRect(xpos+465,i, 45, 5);  //Zwart bovenlijn
		 waarde = waarde-5;
		 }

		ctx.fillStyle = "#FFFFFF"; // wit
		ctx.fillText(aa, xpos+300, ypos+550);
		ctx.fillText('150W', xpos+450, ypos+180);
		var ab = Number.parseFloat(Kanaal1Spanning[1]).toFixed(1);
		ctx.fillText(ab, xpos+300, ypos+500);
		var ac = Number.parseFloat(Kanaal1Spanning[2]).toFixed(1);
		ctx.fillText(ab, xpos+300, ypos+600);
		ctx.fillText('0W', xpos+460, ypos+750);
		ctx.stroke();


		
		
}	
function DisplayKanaal2Spanning(){
		xpos = 600;
		ypos = 200;
		Temp2 = 50
	ctx.fillStyle = "#007744"; //donkergroen kader
    	ctx.fillRect(xpos+100,ypos-120, 500, 100);
 	ctx.fillStyle = "#FFFFFF"; //wit in donkergroen kader
    	ctx.fillRect(xpos+110,ypos-110, 480, 80);
 	ctx.font = "30px Verdana"
	ctx.fillStyle = "#007744"; // donkergroen}
	ctx.fillText('REF Power', xpos+ 280, ypos-60); // maximale vermogen
	ctx.fillStyle = "#007744"; //donkergroen kader
    	ctx.fillRect(xpos+100,ypos, 500, 800);
	ctx.fillStyle = "#000000"; // Zwart linkerlijn
	ctx.fillRect(xpos+460,ypos+200, 5, 500);
	ctx.fillStyle = "#00FF00"; // Groen
	ctx.fillRect(xpos+465,ypos+202, 45, 500);
	ctx.fillStyle = "#000000"; // Zwart rechterlijn
	ctx.fillRect(xpos+505,ypos+200, 5, 500);
	ctx.fillRect(xpos+460,ypos+200, 50, 10);  //Zwart bovenlijn
        ctx.fillRect(xpos+460,ypos+700, 50, 10); //Zwart onderlijn

	waarde = 30;
	
		ctx.font = '30px Verdana';
		var aa = Number.parseFloat(Kanaal2Spanning[50]).toFixed(0);
		ctx.fillStyle = "#555555"; // Grijs
		ctx.fillRect(xpos+465,ypos+202, 40, aa);
		for (i = ypos+200; i <= ypos+726; i += 50) {
		ctx.fillStyle = "#000000"; // zwart
 		ctx.fillRect(xpos+465,i, 45, 5);  //Zwart bovenlijn
		 waarde = waarde-5;
		 }

		ctx.fillStyle = "#FFFFFF"; // wit
		ctx.fillText(aa, xpos+300, ypos+550);
		ctx.fillText('75W', xpos+455, ypos+180);
		var ab = Number.parseFloat(Kanaal2Spanning[1]).toFixed(1);
		ctx.fillText(ab, xpos+300, ypos+500);
		var ac = Number.parseFloat(Kanaal2Spanning[2]).toFixed(1);
		ctx.fillText(ac, xpos+300, ypos+600);

		ctx.fillText('0W', xpos+460, ypos+750);
		ctx.stroke();


		
}	
function DisplayKanaal3Spanning(){
		xpos = 1150;
		ypos = 200;
		Temp2 = 32;
		
			 
  	ctx.fillStyle = "#007744"; //donkergroen kader
    	ctx.fillRect(xpos+100,ypos-120, 500, 100);
 	ctx.fillStyle = "#FFFFFF"; //wit in donkergroen kader
    	ctx.fillRect(xpos+110,ypos-110, 480, 80);
 	ctx.font = "30px Verdana"
	ctx.fillStyle = "#007744"; // donkergroen}
	ctx.fillText('VSWR', xpos+ 300, ypos-60); // maximale vermogen
	
	ctx.fillStyle = "#007744"; //donkergroen kader
    	ctx.fillRect(xpos+100,ypos, 500, 800);


	ctx.fillStyle = "#000000"; // Zwart linkerlijn
	ctx.fillRect(xpos+460,ypos+200, 5, 500);
	ctx.fillStyle = "#00FF00"; // Groen
	ctx.fillRect(xpos+465,ypos+202, 45, 500);
	ctx.fillStyle = "#000000"; // Zwart rechterlijn
	ctx.fillRect(xpos+505,ypos+200, 5, 500);
	ctx.fillRect(xpos+460,ypos+200, 50, 10);  //Zwart bovenlijn
        ctx.fillRect(xpos+460,ypos+700, 50, 10); //Zwart onderlijn

	waarde = 30;
	ctx.font = '30px Verdana';
		var aa = Number.parseFloat(Kanaal3Spanning[50]).toFixed(0);
		ctx.fillStyle = "#555555"; // Grijs
		ctx.fillRect(xpos+465,ypos+202, 40, aa);
		for (i = ypos+200; i <= ypos+726; i += 50) {
		ctx.fillStyle = "#000000"; // zwart
 		ctx.fillRect(xpos+465,i, 45, 5);  //Zwart bovenlijn
		 waarde = waarde-5;
		 }

		ctx.fillStyle = "#FFFFFF"; // wit
		ctx.fillText(aa, xpos+300, ypos+550);
		ctx.fillText(' 3', xpos+455, ypos+180);
		var ab = Number.parseFloat(Kanaal3Spanning[1]).toFixed(1);
		ctx.fillText(ab, xpos+300, ypos+500);
		ctx.fillText(' 1', xpos+460, ypos+750);
		ctx.stroke();


	
}	


init();

</script>

  </section>
</body>
</html>

SWR.INO bestand voor de D1 mini pro

/*  R van der Werf 14-11-2019 2025 werkt met juiste libraries waarvan backup gemaarkt is 15-6-2025
 *  SWR meter voor  deze versie werkt alleen de berekeningen voor db ed moeten nog gedaan worden
 *   
                      WCMCU-4051              WEMOS D1 MINI PRO
    0-5 V            ____________                ____________
Kanaal1---------Y2  |            | VCC-------5V |            |
Kanaal2---------Y3  |            | VEE-------GND|            |
Kanaal3---------Y4  |            | GND-------GND|            |
                    |            | S0--------D5 |            |
GND ------------GND |            | S1--------D6 |            | 
                    |            | S2--------D7 |            |
                    |            | E---------D8 |            |
                    |            | Z--10K--|-A1 |            |
                    |____________|         |    |____________|
                                          10K
                                           |    
                                          GND
 op de ingangen Y2,Y3 en Y4 spanning deler beveiligd met zenerdiode 5,1V  van 12V naar 5 Volt
 op de Z uitgang panningsdeler 10k/10k  omdat de A1 van WEMOS D1 MINI PRO maximaal 3,3V mag hebben
*/


#include <ESP8266WiFi.h>
#include <ESPAsyncWebServer.h>
#include <Wire.h>
#ifndef APSSID
#define APSSID "SWR"
#define APPSK  ""
#endif

// Put your SSID & Password
const char *ssid = APSSID; // The name of the Wi-Fi network that will be created
const char *password = APPSK;   // The password required to connect to it, leave blank for an open


float Huidige_Kanaal1_Spanning = 0;
float Huidige_Kanaal2_Spanning = 0;
float Huidige_Kanaal3_Spanning = 20;
float Kanaal1_Data[51] = {0}; // Data Kanaal1
float Kanaal2_Data[51] = {0}; // Data Kanaal2
float Kanaal3_Data[51] = {0}; // Data Kanaal3
String Kanaal1DataString;
String Kanaal2DataString;
String Kanaal3DataString;
int LeesKanaal1;  // Gemeten spanning Kanaal1
int LeesKanaal2;  // Gemeten spanning Kanaal2
int LeesKanaal3;  // Gemeten spanning Kanaal3
float ValueKanaal1;  // Gemeten spanning Kanaal1
float ValueKanaal2;  // Gemeten spanning Kanaal2
float ValueKanaal3;  // Gemeten spanning Kanaal3

AsyncWebServer server(80); // Start webserver

String Send_Kanaal1() { // Creates the string which is read/send
  String a = Kanaal1DataString;
  return String(a);
}
String Send_Kanaal2() { // Creates the string which is read/send
  String b = Kanaal2DataString;
  return String(b);
}
String Send_Kanaal3() { // Creates the string which is read/send
  String c = Kanaal3DataString;
  return String(c);
}



void setup() {
  pinMode(D0, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(D2, OUTPUT);
  pinMode(D3, OUTPUT);
  pinMode(D4, OUTPUT);
  pinMode(D5, OUTPUT);
  pinMode(D6, OUTPUT);
  pinMode(D7, OUTPUT);
  pinMode(D8, OUTPUT);
  Wire.begin();
  Serial.begin(115200);
  delay(100);
 
  if (!SPIFFS.begin()) {
    return;
  }
 
  WiFi.mode(WIFI_AP_STA);  //need both to serve the webpage and take commands via tcp
  IPAddress ip(1, 2, 3, 4);
  IPAddress gateway(1, 2, 3, 1);
  IPAddress subnet(255, 255, 255, 0);
  WiFi.softAPConfig(ip, gateway, subnet);
  WiFi.softAP(ssid, password);             // Start the access point
  Serial.println("Connecting to ");
  Serial.println(ssid);
  Serial.println(WiFi.localIP());
  
  server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(SPIFFS, "/index.html");
  });
  server.on("/Kanaal1", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", Send_Kanaal1().c_str());
  });

  server.on("/Kanaal2", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", Send_Kanaal2().c_str());
  });

  server.on("/Kanaal3", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send_P(200, "text/plain", Send_Kanaal3().c_str());
  });
  server.begin();
  digitalWrite(D8, LOW); //Enable
}

void loop() {
  LeessHuidigeWaarde();
  MaakVerzendString();
  delay(10);
}
void LeessHuidigeWaarde() {
  digitalWrite(D5, HIGH);//Blauw
  digitalWrite(D6, HIGH);//Groen
  digitalWrite(D7, LOW);//Rood
  delay(30);
  LeesKanaal1 = analogRead(A0);
  ValueKanaal1 = map(LeesKanaal1, 0, 700, 0, 500);
  digitalWrite(D5, LOW);//Blauw
  digitalWrite(D6, HIGH);//Groen
  digitalWrite(D7, LOW);//Rood
  delay(30);
  LeesKanaal2 = analogRead(A0);
  ValueKanaal2 = map(LeesKanaal2, 0, 700, 0, 500);
  digitalWrite(D5, LOW);//Blauw
  digitalWrite(D6, LOW);//Groen
  digitalWrite(D7, HIGH);//Rood
  delay(10);
  LeesKanaal3 = analogRead(A0);
  ValueKanaal3 = map(LeesKanaal3, 0, 700, 0, 500);
  Kanaal1DataString = String("");
  Kanaal1_Data[50] = ValueKanaal1;
  Kanaal2_Data[50] = ValueKanaal2;
  Kanaal3_Data[50] = ValueKanaal3;
  
  Kanaal1_Data[0] = ValueKanaal1;
  Kanaal2_Data[0] = ValueKanaal2;
  Kanaal3_Data[0] = ValueKanaal3;
}

void MaakVerzendString() {
  Kanaal1DataString = String("");
  for (int i = 0; i <= 50; i++) {
    if (Kanaal1_Data[i] >= 10.00 || Kanaal1_Data[i] < 0.00) {
      Kanaal1DataString = Kanaal1DataString + String(Kanaal1_Data[i]) + String(" ");
    }
    else
    {
      Kanaal1DataString = Kanaal1DataString + String(Kanaal1_Data[i]) + String("  ");
    }
  }

  // string 7 posities groot maken vaste format
  Kanaal2DataString = String("");
  for (int i = 0; i <= 50; i++) {
    if (Kanaal2_Data[i] >= 10.00 || Kanaal2_Data[i] < 0.00) {
      Kanaal2DataString = Kanaal2DataString + String(Kanaal2_Data[i]) + String(" ");
    }
    else
    {
      Kanaal2DataString = Kanaal2DataString + String(Kanaal2_Data[i]) + String("  ");
    }
  }
  // string 6 posities groot maken vaste format
  Kanaal3DataString = String("");
  for (int i = 0; i <= 50; i++) {
    if (Kanaal3_Data[i] >= 10.00 || Kanaal3_Data[i] < 0.00) {
      Kanaal3DataString = Kanaal3DataString + String(Kanaal3_Data[i]) + String(" ");
    }
    else
    {
      Kanaal3DataString = Kanaal3DataString + String(Kanaal3_Data[i]) + String("  ");
    }
  }
}