Frequency Counter and Voltage Conversion

I would like to count a frequency coming off a Mesa THC A-D Card and convert that frequency back to the voltage that is being presented to that card. I've found a sample code/library that seems to work ok but I'm struggling to convert back to the original voltage. The THC A-D card has 10v = 926.5 kHz and 0v = 119.7 kHz and I can make the voltage match at 10v by taking the frequency by .0000107933 but that falls apart as the voltage drops. Is there a better way to count/convert the frequency?

With the math I have, at 10v it is correct but at as I go lower it starts getting further off. 3v at the power supply is reading as 2v for instance.

I'm multiplying by 128 because the THC A-D card is dividing the frequency by 128 on the output. Multiplying by 10 because of the gatetime.

Code:

#include <FreqCounter.h>

void setup() {
  Serial.begin(57600);                    // connect to the serial port
  Serial.println("Frequency Counter");
}

long int frq;
void loop() {

 FreqCounter::f_comp= 8;             // Set compensation to 8
 FreqCounter::start(100);            // Start counting with gatetime of 100ms
 while (FreqCounter::f_ready == 0)         // wait until counter ready
 
 frq=FreqCounter::f_freq;            // read result
 Serial.println(frq*10*128);                // print result
 Serial.println(frq*10*128*10.0f/926500,2);
 delay(20);
}

Assuming the relationship is linear, you need to use

voltage_out = m x frequency_in + b.

You have provided sufficient information to calculate m and b. I could do it myself but YOU should do the calculation.

Because frequency_in is never zero, the calculation takes a little work but solving for two variables is not that hard.

Good Luck!

If 0v = 119.7 kHz and 10v = 926.5 kHz, then your 10V span = 806.8 kHz. So (kHz in - 119.7) / 806.8 * 10 should = volts.

volts = 10 * (kHz - 119.7) / 806.8;

THAT is another and perhaps better way of saying the same thing.