View Single Post
Old 05-13-2022, 03:06 PM   #53
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 373
Re: Mechanical speedometer drive solution

I have been experimenting with frequency counting. I tried a hardware solution with a frequency to voltage convertor I.C. the LM2907. I tried a software solution using the Arduinos internal registers.
A fair amount of mathematical acrobatics is required with the LM2907. The control frequency is fed into the LM2907(35Hz to 2844Hz). The LM2907 outputs a voltage(0.02v to 2.16v). That voltage is scaled in the software to a value the Arduino can use(3.6/1023.0). That value is counted and divided by the count to get a smooth average. That average is run through a polynomial equation to get a close match to the control frequency.
The LM2907 solution requires about 20 counts to transition from one frequency to the next when read each iteration of the code. Adding the readings 200 times and then dividing by 200 gets a smooth result, but perhaps discarding the first 20 reads after a change in input is detected would be more accurate and counting would not be required. Even at that, the code iterates 200 times in 54mS.
The Arduinos internal registers can be used for counting frequency with the expense of disabling the millis function. This is not a problem as timing requirements can be based off the register timer. The register timer uses interrupts. Since I was using interrupts for the optical disk, I set up one register counter for the control frequency. The two different interrupt routines did not appear to interfere with each other.
The use of a register counter appears to be more accurate. That may be due to the direct nature, and the lack of mathematical acrobatics. The accuracy seems to degrade below a 200mS sample time, so the hardware solution would appear to be faster.
So far I have been experimenting with the use of a signal generator for both the control frequency, and the optical disk frequency. The next step is to implement both counter types connected to the speedometer. I have also acquired an FET to drive the motor instead of the BJT that I had originally used. I’m building two circuit boards, one for each system. I’ll have to calibrate the code for each and see which one performs the best.
All this because I’m going from using the 2,000 pulse per mile signal to using the 128,000 pulse per mile signal. After I get the frequency counting situated, I will work on getting a smoother needle response.
__________________
'47 Panel to '88 K2500 Frame Swap
Mechanical Speedometer Drive Solution
1947.2 1 ton Chevy Panel
1955.2 Chevy 6700 Bus/RV
1990 Chevy K1500
Second Series is offline   Reply With Quote