Add files via upload

This commit is contained in:
thkummi
2021-08-19 03:23:49 +02:00
committed by GitHub
parent de9a046b24
commit 1fce10c1ee
5 changed files with 255 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="ctenna" />
<Option execution_dir="../Constenna" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/Constenna" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/Constenna" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="Makefile" />
<Unit filename="hb9cv.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="hb9cv.h" />
<Unit filename="main.c">
<Option compilerVar="CC" />
</Unit>
<Extensions />
</Project>
</CodeBlocks_project_file>
+8
View File
@@ -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
+78
View File
@@ -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 <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#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");
}
+7
View File
@@ -0,0 +1,7 @@
#ifndef HB9CV_H_
#define HB9CV_H_
void hb9cv_calc();
void hb9cv_print();
#endif // HB9CV_H_INCLUDED
+117
View File
@@ -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 <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "hb9cv.h"
//#include <stdlib.h>
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;
}