Loading ...

Translate

Sunday, 5 November 2017

Classic Mini 1275GT Electronic GPS Speedometer and multifunction display revisited.

A few months ago (was it really that long?) I created an electronic solution to the classic Mini speedo (here)

When I posted the article up on a couple of sites, there were a few comments from people that they didn't like the movement of the speedo needle. I can see why, as it only moves in discreet "clicks" every 1 mph. They would like it smoother.

"Easy" I thought.... oh how wrong I was!

I initially started by changing the speed value from an integer to a float, and dumping the map function. It was an improvement, but had a tendency to jitter about. Nope. Not good enough.

Back to integer speed, and an attempt to control the update rate by creating an array and loading the array with the car's speed every time it updated (every 250mS). I then got the microcontroller to detect the slope of the changes in speed and move the needle quicker when the car was accelerating (or decelerating) hard, and slowly when the acceleration wasn't so hard.

Well, it didn't work very well. I could see the sketch was working, but the amount of data needed to sample, and the time it took to calculate the amount of delay to add to the pointer caused the update rate to slow to an unacceptable amount, and the speedo to appear "laggy". I attempted to improve the speed of the sketch, and revised the code a number of times, and even forced the compiler to optimise for speed over code size, all to little avail. The idea of delaying the speed of the pointer seemed sound though.

I drank some tea .....

A few weeks passed, and I had another idea. Don't attempt to measure the acceleration of the car. Control the acceleration of the needle with regards to it's position. The sketch now sampled the speed, and set the needle motor target position to that value. Now change the motor position, one step at a time, towards the target position. As the pointer approaches the target, increase the delay between each step. A few tweaks to the amount of delay applied, and it works! In effect I've created a PID controller for  the pointer position (actually, there's no D).

I've also changed the code to the multifunction display, which now displays a warning for ice, no GPS, and no charge (ICE, GPS or CHG are displayed)

The revised code (including the required libraries) can be found here :  https://github.com/andydoswell/GPS_Speedo_Smooth

Just click on "Clone or download" and download the zip. Unzip into your Arduino directory. Place the libraries in the library directory.



No comments:

Post a Comment