View Single Post
Old 02-18-2021, 04:56 PM   #46
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

One year ago I started this project! I’m really happy with the results. I figured out how to drive a motor to spin the speedometer through the full range using brute force in open-loop mode. The motor was unable to start below about 10mph. I found I could run the motor at full output and pause after each hole in the optical disk, reduce the pause and the motor spins faster. Use this pause code until 10mph, and then switch the code to freewheeling. This helped me understand how to deal with the torque curve of the motor and speedometer.

Now I’m using PID code to run in closed-loop mode. The speedometer starts under 1mph and runs through to max.

I have been playing with the PID code. It takes some fiddling to get adjusted. Start out with Ki=0, Kd=0, and ITIME=0. Through trial and error: Set Kp so 45Hz input yields 80mph, Kp=1.35 for this example. Set BIAS so 5Hz yields 9mph, Then recheck what frequency drives 80mph and readjust Kp, Kp=1.1 BIAS=450. Set Ki, try different values starting with 0.05, readjust Kp. Kp=1, BIAS =450, Ki=0.005. Using the Ziegler-Nichols method to determine Kd, first figure Pu. Pu=(2Kp)/Ki, so (2*1)/0.005=400. Kd=(KpPu)/8, so (1*400)/8=50. Set ITIME, I use 50. Recheck the 5Hz at 9mph, and 45Hz at 80mph. Readjust accordingly and refigure Kd. Repeat this until you are satisfied with the results.
I was updating the {error_prior = error} every second, and then moved it to update every iteration about 12mS. I’m not sure if there is much difference in performance. That is the only line of PID code in the main loop, the rest of the PID code is in the beginning before the setup as it just defines the parameters.

Today I wired in the LM1085 LDO, it works. The LM1085 low dropout voltage regulator takes the 14v input and puts out 12v for the motor, and the Arduino. I’m ready to connect to my truck and see how it performs.
Attached Images
 
__________________
'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