Skip to content

Instantly share code, notes, and snippets.

@LightningStalker
Created August 25, 2017 22:36
Show Gist options
  • Select an option

  • Save LightningStalker/6cfb52a7be52d28e50d1d0a70d5312d9 to your computer and use it in GitHub Desktop.

Select an option

Save LightningStalker/6cfb52a7be52d28e50d1d0a70d5312d9 to your computer and use it in GitHub Desktop.
LC Tank resonance frequency calculator
/* Compile with gcc -Wall -o tankfreq tankfreq.c -lm */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char **argv)
{
if (argc == 3)
{
printf ("%f\n", 1 / (3.14159265359 * 2 * sqrt (atof(argv[1]) /
1000000 * atof(argv[2]) / 1000000)));
return (0);
}
else
{
puts ("tankfreq is an LC tank resonance frequency calculator.");
puts ("output is frequency in Hz\n");
puts ("Usage: tankfreq microfarads microhenries");
puts ("Example: tankfreq 3.3 .86207");
puts ("Output should be: 94360.861167");
return (1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment