/* bolometer1: Calculate the input power from the measured voltage, by solving the quadratic equation. Input: The measured voltage [mV] Output: The calculated power [mW, dBm] Version 2013-06-07 * ---------------------------------------------------------------------------- * "THE BEERWARE LICENSE" (Revision 44): * Dr. Rolf Freitag (rolf dot freitag at email dot de) wrote this file. * As long as you retain this notice you can do whatever * the GPL (GNU Public License version 3) allows with this stuff. * If you think this stuff is worth it, you can send me money via * paypal, and get a contribution receipt if you wish, or if we met some day * you can buy me a beer in return. * ---------------------------------------------------------------------------- */ #include #include #include // solution of the quadratic equation long double calc_x1 (long double a, long double b, long double c) { long double x1 = 0; x1 = ((-b) + (sqrtl (powl (b, 2) - (4 * a * c)))) / (2 * a); return x1; } int main (int argc, char *argv[]) { long double x = 0, y = 0, z = 0; char **endptr = &(argv[1]) + 10; if (argc < 2) return (-1); y = strtold (argv[1], endptr); // mV, input x = calc_x1 (-9.762e-6, 7.232e-2, -y); // with a and b from the calibration //z=10*logl(x)/logl(10.0); // dBm z = 10 * log10l (x); // dBm printf ("At %.2Lf Millivolt the Power is %.1Lf mW = %.1Lf dBm.\n", y, x, z); return (0); }