Over the past few days I have been playing with field currents during starting, trying to get a stable RPM measurement early on. But I can not. Am not sure if it is a case that the alternator needs to spin some min amount of time in addition to having field voltage, or what. But in any case I have not been able to get a stable RPM measurement until some time after the engine has started.
So, I am going to leave the 'started by RPMs' code in place but disable it via config options (setting STARTED_RPM_THRESH and STARTING_FIELD_PWM both = 0). Determining started via the measured Amps works so well I have no need to look at another way. But will leave the RPM code in place and perhaps someone else's system will be able to get it to work - and find it useful.
While working on this I added a check in the RAMP code to monitor at what field PWM value the alternator starts to produce current. That value is noted and used during stopping to get a good stable RPM measurement to allow for nice ramping down of the RPMs in a cool-down period. And by measuring this value each time the engine starts it is self correcting. I have noticed a little variance each time the motor started during my trials.
Also - when capturing the PWM value of 1st amps, I tuck away the measured RPMs. Because the alternator is in RAMP mode the throttle motor has been driven to Full Speed and the RPMs captured at that point represent what the engine is actually able to do. This again is self optimizing and can differ from the spec sheet max due perhaps to some slack in the throttle linkage, or. . .. . . But if the engine is not able to reach full RPMs, then it most certainly can not support delivering full Watts. So this demonstrated max RPMs is used to adjust max target watts, using the RPM / WATTs look-up table. By doing this we reduce the risk of trying to pull too many watts out of the motor in the case it is not able to reach the spec sheet RPMs.
The code is cleaning up nicely, I want to do some more testing and perhaps small changes, but I expect to be posting a new version by the end of the month.