View Single Post
Old 01-28-2020, 04:38 PM   #9
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 371
Re: Mechanical speedometer drive solution

Now we need to write some code for the Arduino to convert the range of frequencies to the range of motor speed.
The Arduino uses a scale of 0-255 to drive a motor. I could use 0-50Hz as my drive signal.
255/50 = 5.1, so my code will have a line that looks something like this:
analogWrite(motor, freq*5.1);
where analogWrite is the command, motor has been designated as the output pin in another line, freq is the frequency calculated in another line, and freq times the multiplier gives me the variable output between 0 and 255 from the variable input between 0 and 50Hz.
There are limitations here that will need to be addressed. The range 0-50Hz is good to about 90MPH, if I go faster than that, the signal will be out of range of the code. I can add a line that treats anything above 50Hz as 50Hz. The motor drive signal range 0-255 is a pwm with 255 being dc, 255 is the fastest the motor will spin. I’ll set the maximum RPM on the speedometer face to be driven by the 255 setting. The motor has a minimum speed that it will start at, and a minimum speed that it will run at. The minimum speed that it will run at may be lower than the starting speed. The Chicago Electric motor with planetary gear starts at what would be 8MPH. If it can run slower, I’ll have to goose it to get it moving, and then immediately back it down to under 8MPH. The pwm range 0 to 255 won’t start at 0, it will start at what it takes to keep the motor running at it’s slowest speed.
I’ve played around with a few examples of Arduino code that I found on-line. I have reconfigured the Arduino to accept a variable frequency from a fuction generator. I discovered that the Arduino does not recognize a 4volt frequency, it must be 5volts.
The motor will run with the Arduino signal 28, but it will reliably start to run with signal 35.
The code is adjusted to add 35 to frequency x 5.66. The upper end is limited to 255, so any input above 254(60Hz.) is converted to 255. The low end. The code named “freqCount” works well. But because 35 is added to the equation, the top speed is achieved with 39Hz. I’ll have to re-code so the motor starts with 35 at 1Hz, and runs through to 60Hz for 255. 39Hz x 5.66 = 220.74, and 220.74 + 35 = 255. 220/60Hz = 3.66, so I’ll change the multiplier in the code to 3.66.
The code seems easy enough to modify, and still needs improvement. I’ll check this setup with the RPM sensor when it becomes available.
The vehicle has 12volt signals, the Arduino runs on 5volt signals. Use a 7805 or similar to change 12v 2000ppm to 5v for Ardunio input. I’ll have to look at datasheets to verify this component reacts at the appropriate speed.
My transmission is from an ‘88GMC. The DRAC is integrated in the gauge cluster so I need to find a DRAC from ’92 to ’95 Truck, or ’90 to ’95 Van. I went to a couple wrecking yards last week, all the electronics were gone…
I may be able to use the Arduino for a DRAC. That would make it useful on a wider range of applications. The signal will require conditioning to transition between vehicle and Arduino. The VSS, reluctor signal looks like a .5v ripple on 12v. The 12v can be blocked with a capacitor, and the .5v ripple will need to be boosted to 5v so the Arduino can see it. That should be simple enough to achieve. The 128,000ppm, 4,000ppm, and 2,000ppm signals will need to be boosted from 5v to 12v.
The circuit in my truck takes the signal from the VSS/Reluctor sensor, runs it through the Ratio Adapter and produces a 128,000ppmile signal, I read about a Schmitt trigger used to convert the signal to a 12v square wave, from my o-scope results, it appears to happens with the divide by 32 circuit to produce the 4,000ppmile signal, finally a divide by 2 circuit produces the 2,000ppmile signal.
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