Here's all the code, not sure what you're getting at, but thanks for the analysis and help!
////////////////Simple Em4 pump controller for Arduino /////////////////////
//Steve Gough ------ Little River Research & Design
/////////// ------ tested and working very nicely 10-23-2010 -------------
////////// Modified 4-22-2011 to read Omega mag meter on pin 6
#include <LiquidCrystal.h>; // initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
/////////////////////////////// variables declaration //////////////////////
int pwmPin = 5; // = analog pin for input from PWM unit after passing through divider/low pass filter
int magMeterPin = 6; // input pin for mag meter open collector pulses
unsigned long startTime = 0;
float pwmVolts = 0;
float flowRate = 0; //flowrate in ml/s basd on average voltage
int flowRateInt = 0; // hold flowRate converted to integer for LCD priting without decimals
float rawVolts10Bits = 0; //diagnostic, raw reading on pin 5 before dividing by 1023
float rawVolts = 0; //voltage calc
float rawVoltsScaledVfd = 0; // volts into pin 5 * 5/1023; this is actuall Vfd, or voltage from filter/divider cirtuit into pin 5
//calibration variables - Q = aVal *Vfd^2 + bVal * Vfd + cVal
float aVal = -3.84; //add appropriate values
float bVal = 118.4;
float cVal = -472.8;
float durationHigh = 0; //meter reading variables
int durationLow = 0;
float durationAve = 0;
float duration = 0;
float durationSum = 0;
float freQuency = 0;
float magFlowrate = 0; //flowrate in ml/s
long hugeDurationLow = 0; //diagnostic variable
int magMeterPinState;
int lastState;
int pulseCount;
//=======================================================================================
void setup()
{
Serial.begin(9600); // Initialize a serial connection for reporting values to the host
lcd.begin(16, 2); // ----setup LCD screen and display welcome message
lcd.clear(); //clears lcd screen and goes to beginning of first line
lcd.print("Turning on");
lcd.setCursor(0, 1); // go to beginning of second line
lcd.print("pump controller");
delay (2000);
pinMode(magMeterPin, INPUT);
digitalWrite(magMeterPin, HIGH); //turn on pullup resistors for magmeter pin (which goes low for pulse)
}
void loop() ////////////////////////////----end setup ---- start loop ///////////////
{
if (millis() - startTime >1000) // if statement run at 1Hz, updates flow reading and LCD
{
updateFlowVfd(); // runs PWM voltage and flow calcs, updates flowRate variable
readMagmeter();
updateLcd(); //updates LCD readings and calcs flow and time totals
startTime = millis ();
// add amp reading here /// CurrentACS712 \ Learning \ Wiring
}
} //////////////////////// close loop ////////////////////////////////////////////////////////
void updateFlowVfd() /////////////////////// reads Vfd, calculates flow in ml/s, /////////
{ /////////////////////// calcs Vfd and Q in ml/s; also //////////////
////////////////////// totalizes Q and time //////////////////////
rawVolts10Bits = analogRead(pwmPin); //10bit voltage reading from Vfd on pin 5
rawVoltsScaledVfd = (5 * rawVolts10Bits) /1023; //Scaled to actual voltage from Vfd; actual voltage
// is (4.02)/1023 * reading; 4.02 is full scale voltage
//(but 5.0 works; 9-23 testing, go figure)
// from Vfd circuit, from 7-30 testing; this may vary
pwmVolts = (-2.873 * rawVoltsScaledVfd) +13.27; //Converted to actual PWM voltage output (max ~13.6 volts)
//remember this value will depend on voltage
//divider circuit precision and may need to be
//calibrated for each circuit; see Excel sheets for
//analysis and relationships
flowRate = ((aVal*(pow(pwmVolts,2))) + (pwmVolts*bVal) + cVal) ;
} //////////////////////////// end function updateFlowVfd ////////////////
void updateLcd () //////////////////////// function updateLcd() /////////////////////////////
{
lcd.clear ();
if (flowRate <= 0) // Prints zero to LCD so nonsensical numbers
flowRate = 0.00; // do not appear ; could cause BUG
flowRateInt = (int) flowRate; //converts to integer so decimals aren't printed to LCD
lcd.print(flowRateInt); //print flow and voltage on top line
lcd.print(" mls ");
lcd.print(pwmVolts);
lcd.print("V");
lcd.setCursor(0, 1);
lcd.print ("freq ");
lcd.print(freQuency);
//diagnostics
Serial.print ("freq");
Serial.println (freQuency);
Serial.print ("magflow");
Serial.println (magFlowrate);
Serial.print ("durationLow ");
Serial.println (hugeDurationLow);
} ///////////////////////////////////////// end updateLcd function /////////////////////////
void readMagmeter ()
{
//let's try reading just one pulse 
durationLow = pulseIn(magMeterPin, HIGH); //returns period in MICROseconds between low and high pulses, i.e. half of square wave
//float durationLow = durationLow;
hugeDurationLow = (durationLow*1000);
freQuency = 10000.000/(durationLow 2.000);
magFlowrate = 1000(350.00/freQuency) ;
Serial.println (hugeDurationLow);
} //end magMeter