The 1947 - Present Chevrolet & GMC Truck Message Board Network







Register or Log In To remove these advertisements.

Go Back   The 1947 - Present Chevrolet & GMC Truck Message Board Network > General Truck Forums > Engine & Drivetrain > LSx Swaps

Web 67-72chevytrucks.com


Reply
 
Thread Tools Display Modes
Old 03-26-2020, 05:59 PM   #1
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

I rearranged the code and now it is working well. The motor does not run without input. Starts slow with the optical disk delay, and then seemlessly transitions to the PID code at around 5MPH, and then maxes out at full input.
I attached the motor to a speedometer. I anticipated less load, unfortunately the slow speeds can’t overcome the resistance of the speedometer. It starts to spin at about 10MPH, but works above that.
I may be able to increase the power in the optical disk delay code, and also increase the range for that portion of the code, so it switches to PID after 10MPH instead of 5MPH. If that doesn’t work, I will put an optical disk on the motor from the cordless drill and tune the code for that.
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
Old 06-11-2020, 04:15 PM   #2
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

I’m still working on the code. The code overall is not too complex, and I’m trying to keep it as simple as possible. I am able to drive the speedometer across the entire range from Zero to 90MPH. I use the motor as a stepper below 25MPH. At 25MPH and above the motor should run with the PID control.
In an attempt to keep the code simple, I am using the MAP command to set the range of Input frequency vs. Microsecond delay(between holes in the optical disk) for the stepper motor code. The line looks like this: val2 = map(val2, 1, 14, 25, 1);// Input Range(Hz) - Output Range(uS)
Where val2 is the delay time, with an input from the 2000 pulse per mile signal of 1Hz, the delay is 25uS between 3 holes in the 64 hole optical disk. With an input of 14Hz, the delay is 1uS. The input range is scaled to the output range, and since the two ranges are not equal, or an even fraction, the output is granular. That is to say there are 14 steps from 1MPH to 25MPH. The limiting factor here is the MAP command as it does not handle floating point integers. If I want finer detail, I could code an array, or something, I’m not sure, but it would be more complex. As it is, the slow speed is working well, and I still need to dial it in.
The speed above 25MPH. I’m thinking about using the MAP command here also. The PWM is a range from 1 to 255. My simple code uses the equation (freqency x 5.1) to get the PWM signal. I found that with the speedometer connected to the motor, the maximum PWM of 255 drives the speedo at 90MPH. The 2000 pulse per mile signal will be 50Hz at 90MPH, so 255/50 = 5.1. Unfortunately when I plug a lower frequency into this equation, say 15Hz x 5.1 = 76.5 for the PWM signal. The motor won’t turn at that PWM signal, it will turn at 20MPH with 120 PWM. So the motor has more torque at higher speeds, DUH! I need a multiplier of about 9 with the input of 15Hz, so the MAP code would be something like this: val3 = map(val3, 15, 50, 9, 5);// Input Range(Hz) - Output Range(multiplier). So for the input frequency range of 15Hz to 50Hz, the variable(val3) would be 9 to 5. That variable could be used in the equation to determine what the PWM signal should be. There is another equation that determines what the optical disk frequency should be, and is used to adjust the PWM signal, that is the PID control. That needs to be fine tuned as well.


Well, the MAP command doesn’t work well here. I’ll focus on getting the PID code solid.
It turns out that I know nothing about PID programming. I did find some useful information about it, I could make a career of learning how to implement it. I struggled with the code that I do have for awhile, and found a simple solution based on a PID concept. PID samples the system parameters, put that data in a buffer for a set period of time, samples again and compares the stored data to the current data. I figured out how to write the code to achieve this, and based on the difference between the previous input signal and the current input signal, I change the multiplier by a set amount. That line of code is: change = (diff * .09). Then I determine if the input frequency has increased, or decreased, and add, or subtract “change” from the multiplier val3. Again, the output PWM is determined by multiplying the input frequency by val3. With this bit of code, I get a multiplier at val3 = 9 when the input frequency is 15Hz, and val3 = 5 @ 50Hz. Now I have the desired output of 25MPH with an input of 15Hz, and 90MPH with input of 50Hz. Unfortunately the multiplier is linear, so the intermediate readings are off. I need to put a curve on the multiplier. I know what the results should be, so I can create a graph. From the graph I’ll have to come up with an equation and put that in the code. I remember a math class that had me creating graphs from equations, so I know it’s possible to draw a curved line and determine an equation equal to the curved line. It’s been a decade or two… After I get this working, I’ll get on with figuring out PID programming. Ultimately I’ll need to have the feedback as I am seeing problems with my setup. I found that the motor can get bogged down if it is not lined up exactly with the speedometer. My linkage is not precision, and the bracket is flimsy, if I bump it the motor shifts slightly, and the code is thrown off. When it is aligned well, the speedometer spins freely. I’ll need to come up with a robust bracket to overcome that. Using PID would also adjust for mechanical variations.
__________________
'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
Old 06-11-2020, 05:26 PM   #3
kglowacky
Registered User
 
Join Date: Mar 2020
Location: The Woodlands,Tx
Posts: 562
Re: Mechanical speedometer drive solution

I went with having the tail shafted machined to install a old school mechanical worm gear. This is the second time I have done this on a 460E works great. It takes also installing a tail shaft gear next to the current one already there. kinda on the expensive side.
kglowacky is offline   Reply With Quote
Old 06-12-2020, 08:17 AM   #4
TrybalRage
Registered User
 
Join Date: Jun 2014
Location: Reading, PA
Posts: 203
Re: Mechanical speedometer drive solution

I think this is awesome. I mentioned a similar idea on the LS swapped squarebody facebook page. All the available solutions (Dakota, CableX) seem way, way too expensive for what they do... read a signal and spin an electric motor.

I proposed a Raspberry Pi setup, but same concept.
__________________
1985 C10 Silverado LWB LS Swapped! Other Stuff

2010 Suburban 2500 LT 4WD
TrybalRage is offline   Reply With Quote
Old 06-12-2020, 05:49 PM   #5
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

I considered modifying the transmission output to run a mechanical cable. The original discussion about this that I found on another forum was actually started by someone who does modify transmission tail housings. That thread was taken over by a discussion on making a motor drive for a speedometer. There was no final answer to the speedometer drive on that discussion, it went on for a couple years and just fizzled out. I have something that kind of works, and I’ll keep improving it until it is a finished product. It would be easier to just buy an off the shelf solution, $300 is not bad for a working original speedometer considering all the time I have put in so far.
There are some detailed write-ups online about converting from mechanical to electric, so easy enough to do it in reverse. I’m working with the drivetrain from an ’88 K2500, so NP241 transfer case. I can get a rear housing from an ’88 to ’89 for mechanical speedo for $200? Drive gear $80, and driven gear $12. An in-line speed sensor can be placed on the speedometer cable to generate the 2000 pulse per mile for $100. I still need a DRAC since my DRAC is integrated with the gauge cluster in the ’88 GMC, so another $40? If I did this, I might be inclined to eliminate the slip yoke on the NP241, so $500 for that kit.
Klowacky, I read about thar mod on-line in a very detailed description. That looks like a clean solution.
TrybalRage, Thanks for the encouragement. I’m interested in that project, I’ll try to find it. I looked into RaspberryPi vs. Arduino, and found the RasperryPi is an entire computer, operating system and all. Arduino is just a microproccessor. They are both the same size. As this project evolves, I will do away with the arduino, and just use the IC with the code on a custom made pcb.
__________________
'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
Old 06-21-2020, 05:52 PM   #6
TrybalRage
Registered User
 
Join Date: Jun 2014
Location: Reading, PA
Posts: 203
Re: Mechanical speedometer drive solution

Not exactly related to what you’re doing, but I was at the local pick n pull yesterday and on a whim grabbed a cluster from a 98 Silverado that looked similar in layout to what the thread by ls1nova, where he uses an s10 speedo retrofit to his gauges.

I disassembled it, just to get some ideas, and after looking things over I don’t think I’ll be able to use it due to the configuration of the board vs odometer, but really got me thinking more about solutions. I know you’re trying to drive a “cable” but how in the world does no one manufacture a little board to run one of these stepper motors like the stock layout? The whole doodad could be assembled for like $35. Especially since it seems like the 4K signal is pretty standard for gm.

I saw the video and other threads of folks using an arduino for that, but now one ever shows it working in a vehicle.
__________________
1985 C10 Silverado LWB LS Swapped! Other Stuff

2010 Suburban 2500 LT 4WD
TrybalRage is offline   Reply With Quote
Old 07-24-2020, 12:41 PM   #7
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

Progress has been slow during the shutdown. I did find an epic description about PID on Arduino. http://brettbeauregard.com/blog/2011...-introduction/
I’m not sure what to do with all this information, it’s a bit deep. I also found this site with a working example of a ballancing robot. https://www.robotshop.com/community/...tor-controller
I modified this code, removed the LCD part, and lined out the quadrature encoder parts. I’m not sure if it will work without the quadrature encoder, I know that’s for detecting direction, it can also be used for timing. I loaded my modified version of this code onto my test setup. It spins the speedometer, but not smooth. I need to understand what’s happening inorder to manipulate the code to do what I want. I also need to work on the equation for the torque line of the motor. Once I get a grasp on this PID code, I’ll incorporate it with my working code.
__________________
'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
Old 08-06-2020, 01:17 PM   #8
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

I’m working on the torque curve of the motor. From what I previously found PWM/Hz=Multiplier. If I graph out Multiplier vs. MPH where Multiplier is y, and MPH is x, I get a curve. (I could use PWM, or HZ for x as well). I vaguely remember drawing curves from equations when I went to school. Here I will determine an equation by looking at a curve. From what I have found so far is that there are different kinds of equations for different kinds of curves. I have to know about all these equations, pick one that is close, and SWAG the answer(Scientific Wild-Ass Guess). I found an equation in a book:
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
Old 08-06-2020, 01:19 PM   #9
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

y=b^2 looks like it might fit. Although my curve goes high to low, and it does not cross the y axis. Now I’m looking at examples of how to find the equation of a curve and I keep seeing setting x to zero, or setting y to zero. My curve has no x or y intercepts. I just learned that finding an equation from a curve is called regression. So I need to find a regression model that matches this curve. I’m looking at Graphing Exponential Function on a math website. Ah, this curve displays exponential decay, so the equation might be y=b^-2. I have drawn the curve on paper, and in excel. In excel, Select the PWM/Hz column, open the insert tab, select Charts, I used Clustered column. Open chart design tab, Add chart element button, Trendline, More Trendline Options to open the Format Trendline panel. In the Format Trendline panel select the Axis Options button(looks like a bar graph), and select Power, check the box for Display equation on chart. The data from my motor, and my speedometer gives me the equation: y=45.992(x^-0.531).

I set up another spreadsheet with Hz., PWM, and PWM/Hz. and see how close this equation is to PWM/Hz.. Not as close as I like. I can change the values of the two numbers in the equation to get closer to what I need. The last column is the result from the equation minus PWM/Hz. to see the difference. Not exact, but hopefully not too far off. So now I’ll try to implement this equation in my code. 41.98*(Hz^-0.575) where Hz is the 2000ppm signal. Read the 2000ppm signal, run it through this equation, multiply the 2000ppm frequency by the result of this equation to get the PWM signal to drive the motor. Notice this dataset has 17 points, the end result will be 90 points (0 to 90mph). I need a non-linear variable multiplier to handle the variations of the motor torque at different speeds. I hope this equation works.
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
Old 08-12-2020, 02:47 PM   #10
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

The arduino code for an exponent is: pow(base, exponent) so pow(Hz, -0.575). Three lines added to my code. It’s been awhile since I looked at my code. This curve will not be used under 25mph(14Hz). The results are way off due to the funky mechanical connection. The speedometer housing has a 5/8” threaded part. I have a ¾” hole punch that I used for the aluminum plate. I used a rubber gasket from a garden hose between the plate and speedometer. This left a gap between the threaded part and the hole in the mounting plate. If the motor is not perfectly centered, the shaft binds. I now have shimmed this gap with a strip of rubber adhesive, the motor spins freely and all my numbers are different. I took a new sample of numbers for PWM at every 5mph starting at 25mph. Calculated the multiplier by dividing this PWM by Hz. Made a new graph based on this updated data, and got a new equation of 10.45(Hz^-0.285). I put this in the code and it works. The needle is still off, but I’m getting closer to a working model. This spreadsheet shows the data for 25mph to 90mph. The Hz column represents the 2000ppm signal from the DRAC. PWM is the signal from the Arduino used to spin the motor. PWM is determined by the input frequency multiplied by a variable. The variable should be equal to PWM/Hz. but since Hz is the input signal and PWM is the output signal, I need another way to find the variable. Graph the values of PWM/Hz. and generate an equation. I put this equation on the spreadsheet, and the results are off from the PWM/Hz. I ran the motor, and recorded the speedometer readings at 5Hz. intervals starting at 15Hz. I then took the recorded MPH, and subtracted the Goal MPH to get the difference of how far off the display is. I made a graph of this set of numbers, and generated an equation. I’ll use this equation to smooth the other equation. This is convoluted, that’s why I’m writing in great detail. I think the first equation should be enough, but I’m not taking every data point, so it's off. If I try to use a greater dataset, the calculations should be more precise. Easier said than done. Look at 66 datapoints from 25mph to 90mph. The 2000ppm signal at 25mph is 13.89Hz. 26mph is 14.44Hz. 27mph is 15.00Hz. The Arduino is capable of handling floating point variables, but it doesn’t do so well. I might be able to multiply the 2000ppm signal by 100, run it through the code, and then divide the output by 100 to get the PWM values. I’ll look into that, but for now I’ll get this smoothing code working. I added this equation and add the results to the output, now the needle tracks as it should. I now have a working model. I’ll continue to make improvements, but it should work as is o.k. The bracket needs improvement. I need to order some electrical components to connect to the vehicle. I could look at the PID code. I’m not satisfied with the slower speeds, I might try a stronger motor. I’ll have to add an optical disk for that.
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
Old 04-07-2021, 03:30 PM   #11
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

As can be seen in the video, the needle movement has a slight delay. I thought about updating the input frequency more often. I found that it is impossible to read a 1Hz signal more than once every second. I chose to use the 2000ppm signal, the 128kppm signal would work better. Discussion here: https://forum.arduino.cc/?topic=731339#msg4921311 I’m sure I learned about that in school once…
I also wanted to eliminate the values on the right side of the decimal point to reduce fluctuation. That’s not good for the 2000ppm signal, but entirely possible with the 128kppm signal. For the 2000ppm signal, some values require the decimal places, example: 9mph at 5.00Hz, 10mph at5.56Hz, 11mph at 6.11Hz, 12mph at 6.67Hz, 13mph at 7.22Hz. Where the 128kppm signal values have a greater spread: 9mph at 320Hz, 10mph at 355.55Hz, 11mph at 391.11Hz, 12mph at 426.66Hz, 13mph at 462.22Hz.
The Needle jump at start may be from the PID comparing the previous value to the current value. If the previous value is zero(not moving), the difference is greatest. I may be able to pre-load the previous value to trick the PID into behaving nicely at start-up.
The noise coming through the stereo may be suppressed with a coil, or capacitor on the motor supply.
I’ll rewrite the code to use the 128kppm signal, work on eliminating the start-up jump, and try a capacitor on the power line. After that, I can work on my youtube video skills and try to get a better view of both speedometers side by side.
__________________
'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
Old 01-18-2022, 10:50 AM   #12
nsocwx
Registered User
 
nsocwx's Avatar
 
Join Date: Jan 2022
Location: NE
Posts: 9
Re: Mechanical speedometer drive solution

Did you get this working well enough to post your code somewhere? I was attempting something similar, but had a lot of issues getting a motor to drive the speedo at a stable speed. I think the encoder motor I got just didn't have the power to move the odometer and would dip hard every 1 mile. That pushed me down the road of replacing the guts with a digital stepper motor to just control the needle position directly.
nsocwx is offline   Reply With Quote
Old 01-18-2022, 03:28 PM   #13
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

Thanks for asking nsocwx, I have not posted any code yet but I’d be happy to it’s still evolving but it does work. I’m curious what encoder motor did you get, I was having a hard time finding any? This project has been on the back burner for awhile, but I’m still on it. I’ve re-written the code for the 128kppm signal, and in the process of making it work. With the 2kppm signal, the drive frequency was 1Hz to 60Hz. The 128kppm signal uses a range from 318Hz to 1750Hz. The folks at the Arduino forum thought the higher frequency would be more accurate. This is true but at a cost. From the Megashift website:” In addition to providing a clean square wave output of a few specific pulse/mile rates, a DRAC can also slow the signal frequency considerably, reducing the interrupt overhead in the code compared to handling the VSS signal directly.” I now know what this means after I changed the code to handle the higher frequency. The optical disk has 64 holes and the code is interrupted for each hole. This wasn’t a problem when the input frequency was below 60Hz. Now with the higher input frequency, there is contention between the optical counter and the input counter. With the lower frequency input, I was looking at how many times the signal transitioned in a second to determine the frequency. This was problematic below 1Hz(1mph) as 1Hz is one cycle per second. For the higher frequency I have changed the code to look at the duration between a high to low transition and a low to high transition to determine the frequency. At under 1mph, with the input at 34Hz, this time is about 42mS each, or about 84mS a cycle. If I use the same sample time of a second, that gives me about 11 cycles, or I may be able to use 5 cycles in half a second, or 2-3 cycles in 250mS. This also interrupts the code while determining transition time, and during this time the optical interrupts are overruled, or dropped. Both optical frequency, and input frequency are equally important, neither has priority over the other.
Now I am looking at a hardware solution to counting the frequency. I have an LM2907 frequency to voltage convertor set up to read the input frequency. It works well. Next I’ll set one up to read the optical disk.
__________________
'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
Old 01-18-2022, 03:44 PM   #14
nsocwx
Registered User
 
nsocwx's Avatar
 
Join Date: Jan 2022
Location: NE
Posts: 9
Re: Mechanical speedometer drive solution

I found an encoder motor on amazon and removed the 10:1 transmission from it to get a 6000RPM motor. After finding that didn't quite have enough torque I made a 4:1 gear for it, but the noise was pretty intense as I don't think it was perfectly round. This motor in particular does 12 pulse per rotation, 120 if you leave the transmission on.

I see what you mean about the VSS signal, it seems like you're kinda stuck on that. In my case I'm reading a 4000 PPM signal from a Holley Terminator and the low speed resolution of that seems to be acceptable. It's a PWM- output so I'm having to use a pull-up resistor circuit and interrupt on the descending change (this thread). I do notice some jitter where one cycle may catch 1 more pulse than another changing the speed by a few MPH. On that front I might suggest calcautating the frequency given method 2 shown here in the video. They count millis between pulses to calculate the frequency immediately and it can be updated with every pulse.

Funny that you mention the LM2907 I just came across that in my research today. I was having an issue understanding how you might calibrate the readings from that device and I also didn't see any prebuilt PCBs. I'm also not reading directly from a sensor.
nsocwx is offline   Reply With Quote
Old 01-18-2022, 05:16 PM   #15
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
Re: Mechanical speedometer drive solution

Thanks for the links, nsocwx, that’s quite a bit of information to digest. It looks like you have a working solution. I’ll be using a DRAC, and I found that when I connected the speedo driver to my ’90 chevy on the 2kppm line to the ECM it may have caused problems with the ECM, I’m not sure, it seemed hard to start. The 128kppm signal goes to the RWAL module so I’m less concerned with that. I could use any of the signals as there is a dedicated line for the speedo on the DRAC module. The LM2907 is set for operating range with a capacitor. The output is a voltage, for my Arduino I don’t want to go above 5v, so I use a 5v supply. The output is 0 to 3.98v with 3.98v at 4kHz with a 2200pF cap. The voltage is fed to an Analog in and scaled to 1023. This is read every iteration. There was some fluctuation so I add the reading to itself for a number of iterations and then divide by that number and get a smooth reading. The 0 to 1023 value is converted to the input frequency through an equation.

I just got that working by itself last week, and will set one up for the optical frequency and then implement both in the main code. I’m using a bench signal generator for now, eventually I’ll try it with the vehicle signals. I want to get away from using interrupts. I could also use the chip registers to count frequency, but that’s a whole other can of worms I’ll avoid for now. The issue is with reading more than one frequency. The motor encoder is one frequency, and the control signal is another frequency. I don’t know if using registers will work with more than one frequency input.
__________________
'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
Old 05-13-2022, 03:06 PM   #16
Second Series
Registered User
 
Second Series's Avatar
 
Join Date: May 2015
Location: Tukwila Washington
Posts: 374
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
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright 1997-2022 67-72chevytrucks.com