Hello, new to Arduino and new to this forum. I have a problem that I have been mostly able to solve -- at least in my own mind -- through research and experimentation till now. I have some electronic background in the dim past, but am very handy with DC and computers(plus mechanical, etc. etc.).
So the problem is, I have a large industrial generator that came with my home, mid-80's vintage. The damper on the mechanical governor is NLA and the closest replacements I have found are not satisfactory.
So, in a nutshell, I need to control the speed of the generator under varying conditions and loads and I need to control it fairly precisely. Variations in speed translate into variations in both voltage and AC Hz in my main home circuit panel. Speed oscillations are triggered by changes in load, for example the 1.5HP well pump turning on, or one of the 3/4HP booster pumps, furnace, refrigeration compressor, etc. etc.
I have settled on an Arduino controlling a stepper connected to the carburetor shaft on the generator, stepper position to change based on sensing of engine speed over/under setpoint.
OK to skip this paragraph, broad info... but I have been playing with an arLCD unit(Uno R3), stepper motors/drivers, looked into the PID library and read Brett Beauregard's excellent writeup, I wrote code to implement a touch interface on the arLCD, to test the control of control motors with a step and direction controller, and more. I know the generator control circuits pretty well, and have essentially full wiring diagrams though many components are proprietary black boxes. There is enough info to navigate the various system interlocks and make use of the important ones.
At this point the challenge is to safely and accurately monitor engine speed, mains output frequency, or some proxy.
Output frequency needs to be 60Hz ±1.
Frequency spec dictates engine speed 3600 ±60 RPM or 60 ±1 revs/second.
Tachometer pulse from the conventional ignition would be 2 pulse/rev(4 cyl. engine) or 120 pulse/sec
Finally, there is a gear tooth sensor on the flywheel that seems to be seeing about 49 teeth around the circumference. This based on two separate readings of ~61.5Hz on the mains output and ~3.03KHz on the gear tooth sensor with a DMM. BTW this sensor has two wires, one is ground and I see 300mVAC across the two. Seems I will need an op-amp to boost this enough to be read as high/low. Note that this sensor connects into one of those black box interlock systems I mentioned earlier, so whatever I do ought to be pretty high impedance, like my DMM.
I have been a little chicken about connecting my scope to this system; one of these days I need to get a battery powered scope.
Let me just note here that I have seen this thread and I am not feeling the need to time every tooth: Fly Wheel Sensor - Best Approach?
I am thinking that using the gear tooth sensor would be ideal, since that presents a proxy for RPM inside the control box where I want to mount my speed control. Mains/Tach signals are either dangerous or low resolution.
I seem to recall having read that there is an option to use one of the timers as a counter. I can't find that so I am looking for help here(and if I am going about this all wrong please feel free to set me straight).
What I thought I understood was that I can just let a hardware counter count until I am ready to check it, then take that value, reset counter to 0, check elapsed time and arrive at an RPM reading. An 8 bit counter should be plenty, that's enough to count for over 5 revolutions.
If this is feasible then I wouldn't need to worry much about timing. I could just let the hardware count teeth for about 1/2 revolution(~25 teeth, 1/120sec), make an adjustment if needed, rinse, repeat.
If it is not feasible to use a hardware timer in this way please suggest alternatives.
Yes I know I could count digital inputs by polling for state, my concern there is that then the Arduino might be too busy to properly run the LCD and check for user input. I may just replace the arLCD with an Uno once I am done with development but during development I think a UI would be handy.