From 1fce10c1ee6fb406801a926f74c3ff51877862ad Mon Sep 17 00:00:00 2001
From: thkummi <36160753+thkummi@users.noreply.github.com>
Date: Thu, 19 Aug 2021 03:23:49 +0200
Subject: [PATCH] Add files via upload
---
Constenna.cbp | 45 +++++++++++++++++++
Makefile | 8 ++++
hb9cv.c | 78 +++++++++++++++++++++++++++++++++
hb9cv.h | 7 +++
main.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 255 insertions(+)
create mode 100644 Constenna.cbp
create mode 100644 Makefile
create mode 100644 hb9cv.c
create mode 100644 hb9cv.h
create mode 100644 main.c
diff --git a/Constenna.cbp b/Constenna.cbp
new file mode 100644
index 0000000..855cdf6
--- /dev/null
+++ b/Constenna.cbp
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..efeb6e4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,8 @@
+prog: main.o hb9cv.o
+ gcc -o prog main.o hb9cv.o
+
+main.o: main.c
+ gcc -c main.c
+
+hb9cv.o: hb9cv.c
+ gcc -c hb9cv.c
diff --git a/hb9cv.c b/hb9cv.c
new file mode 100644
index 0000000..80ddf98
--- /dev/null
+++ b/hb9cv.c
@@ -0,0 +1,78 @@
+/*
+Reference: https://de.wikipedia.org/wiki/HB9CV-Antenne
+The HB9CV antenna is related with the "ZL-Special"
+
+HB9CV Antanna Calculator
+Copyright (C) 2021 Thomas Kummer
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*/
+
+#include
+#include "hb9cv.h"
+
+void printunits (int *unit_index){
+ switch(*unit_index){
+ case 1: printf("mm\n"); break;
+ case 2: printf("inch\n"); break;
+ }
+}
+
+void hb9cv_calc (float *f, float *unit_factor, float *lambda, float *l1, float *l2, float *l3, float *l4, float *l5, float *bdiam, float *raddiam){
+ *lambda = ( 30000000 / *f) / 100;
+ *l1 = (( 0.92 * *lambda * 5) / 10) * *unit_factor;
+ *l2 = (( *lambda * 5) / 10) * *unit_factor;
+ *l3 = (( *lambda * 1.25) / 10) * *unit_factor;
+ *l4 = (( *lambda * 1.25) / 20) * *unit_factor;
+ *l5 = (( *lambda * 1.35) / 20) * *unit_factor;
+ *bdiam = ( *lambda * 0.0072) * *unit_factor;
+ *raddiam = ( *lambda * 0.0036) * *unit_factor;
+}
+
+void hb9cv_print (float *f, float *unit_factor, float *lambda, float *l1, float *l2, float *l3, float *l4, float *l5, float *bdiam, float *raddiam, int *unit_index){
+ printf(" Calculated for %f mHz\n", *f);
+ printf("\n");
+ printf(" Lambda is %f mm\n", *lambda);
+ printf(" L1 Driven Element is %f ", *l1); printunits(&*unit_index);
+ printf(" L2 Reflector is %f ", *l2); printunits(&*unit_index);
+ printf(" L3 element spaceing is %f ", *l3); printunits(&*unit_index);
+ printf(" L4 Matching on dr. element is %f ", *l4); printunits(&*unit_index);
+ printf(" L5 Matching on reflector is %f ", *l5); printunits(&*unit_index);
+ printf(" Boom Diam. is %f ", *bdiam); printunits(&*unit_index);
+ printf(" Radiator Diam. is %f ", *raddiam); printunits(&*unit_index);
+ printf("\n");
+ printf(" connect feed on this side \n");
+ printf(" --------------------------L1 \n");
+ printf(" L4|--\\| \n");
+ printf(" || \n");
+ printf(" L3| \n");
+ printf(" || \n");
+ printf(" | \\--|L5 \n");
+ printf(" ----------------------------L2 \n");
+ printf("\n");
+ printf("\n");
+ printf(" ===============================================\n");
+ printf(" || \\ |\n");
+ printf(" || C1 ___\\______\n");
+ printf(" || \\____/ ___|__\n");
+ printf(" || | /' | '\\ \n");
+ printf(" ||---)------\\.__|__./\n");
+ printf(" || | | 50 |\n");
+ printf(" || | | Ohm |\n");
+ printf("\n");
+ printf(" C1 10m-Band 50pF 6m-Band 30pF 2m band 12pF \n");
+ printf("\n");
+ printf("\n");
+}
+
+
+
+
diff --git a/hb9cv.h b/hb9cv.h
new file mode 100644
index 0000000..b977979
--- /dev/null
+++ b/hb9cv.h
@@ -0,0 +1,7 @@
+#ifndef HB9CV_H_
+#define HB9CV_H_
+
+void hb9cv_calc();
+void hb9cv_print();
+
+#endif // HB9CV_H_INCLUDED
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..53220e0
--- /dev/null
+++ b/main.c
@@ -0,0 +1,117 @@
+/*
+ctenna - a multi antenna calulator for console, written in C
+Copyright (C) 2021 Thomas Kummer
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*/
+
+#include
+#include "hb9cv.h"
+
+//#include
+
+void clear_scr(void){
+ printf("\033[H"); //brings cursor home
+ printf("\x1b[2J"); //clears screen
+}
+
+void printunit (int *unit_index){ // prints the selected unit
+ switch(*unit_index){
+ case 1: printf("mm"); break;
+ case 2: printf("inch"); break;
+ }
+}
+
+
+
+void set_freq(float *f){ // change the MHz
+ float input;
+ printf("Please input an f in MHz value: e.G. 432.2 \n");
+ scanf("%f", &input);
+ *f = input;
+ printf("\n");
+}
+
+void set_units_system(float *unit_factor ,int *unit_index ){ // change betweenn units
+ int input;
+ printf("Please choose (1)Metric or (2)Imperial units \n");
+ scanf("%i", &input);
+ *unit_index = input;
+ printf("\n");
+ switch(*unit_index){
+ case 1: *unit_factor = 1; break; // for metric
+ case 2: *unit_factor = 0.039; break; // for inch
+ default: *unit_factor = 1; *unit_index = 1; printf("Invalid input! Guessing! \n"); printf("\n"); break; // a fool, ... we go metric
+ }
+}
+
+void main_menu(float *f, int *unit_index){
+ printf("\n");
+ printf("===========================================================\n");
+ printf("-- MAIN MENU --\n");
+ printf("===========================================================\n");
+ printf("-- (1) Set Frequncy in MHz %f \n", *f);
+ printf("\n");
+ printf("-- (2) Choose units system ( set to: "); printunit(&*unit_index); printf(" )\n");
+ printf("\n");
+ printf("--= Omnidirectional Antennas =--\n");
+ printf("\n");
+ printf("-- (3) J-pole antenna\n");
+ printf("\n");
+ printf("-- (4) Groundplane\n");
+ printf("\n");
+ printf("--= Directional Antennas =--\n");
+ printf("\n");
+ printf("-- (5) HB9CV antenna\n");
+ printf("\n");
+ printf("-----------------------------------------------------------\n");
+ printf("-- (0) Quit --\n");
+ printf("-----------------------------------------------------------\n");
+ }
+
+int menu_select(){
+ int input;
+ printf("Enter your choice: ");
+ scanf("%i",&input);
+ return input;
+}
+
+int main(){
+
+ float f = 435,unit_factor = 1, lambda, l1, l2, l3, l4, l5, bdiam, raddiam; //startup with a 70cm QRG and metric system
+ int main_menu_sel = -1, unit_index = 1;
+
+ while (main_menu_sel != 0){ // main menu loop runs until "0" for quit
+
+ main_menu(&f, &unit_index);
+ main_menu_sel = menu_select();
+
+
+ switch(main_menu_sel){
+
+ case 1: clear_scr();set_freq(&f);
+ break;
+ case 2: clear_scr();set_units_system(&unit_factor ,&unit_index );
+ break;
+ //case 3: printf("Not yet"); break;
+ //case 4: printf("Not yet"); break;
+ case 5: hb9cv_calc(&f ,&unit_factor, &lambda, &l1, &l2, &l3, &l4, &l5, &bdiam, &raddiam);
+ hb9cv_print(&f ,&unit_factor, &lambda, &l1, &l2, &l3, &l4, &l5, &bdiam, &raddiam, &unit_index);
+ break;
+ // default: maybe easteregg in future
+ }
+ }
+ clear_scr();
+ printf("\n");
+ printf(" 73! \n");
+ printf("\n");
+ return 0;
+}