Im building a speedometer where i want have fast/ accurate gps. At specific speeds between 10mph and 50mph i want to take actions but i dont want it to lag which its doing a bit today using tinygps++ and a neo6m module.
The attached post above references increasing frequency from 1 hz to 10hz by tracking acceleration/deceleration… “interpolated speed”
Does anyone know how to do this?
Doe most libraries update 1 per second and i do my own calcs in between and adjust the “truth” every 1000ms? Would love to improve the speedo response.
Doing a calculation every 100ms on Arduino is quite straightforward. In principle you either configure a hardware timer or you continuously check millis() to see if 100ms has elapsed since your last action.
Knowing the speed at the beginning of the second and knowing the acceleration you can calculate (guess) the speed at 100ms intervals until the beginning of the next second.
Can you also increase the frequency of data delivery by configuring you GPS receiver say using the equivalent of the ublox u-center?
What, incidentally, is the display device. Some displays are slow and you may not benefit much from the improved resolution. E-Paper would definitely not, but liquid crystal displays can be quite sluggish.
There is no display device. My setup needs quick mph readings because it controls the beam pattern of an off-road light and needs to adjust quicker than 1 time per second.
The light has a series of spot and floor leds that pass there 2 different lenses and im able to vary the brightness of each spot/flood group to change the over all beam pattern… 10 times a second seem good, if i need it faster i will increase my estimated refresh rate.
Now a 1 more question.
How do i know when i have a “stale” speed reading and should start my 10hz “estimated” speed if tiny gps always returns a speed when i call it? Should i just wait for the first gps speed number change and then just start a counter based on millis() ?
You can't interpolate into the future, because you are lacking a future data point. The best estimate of your current speed is the last reading. Position is different because the equations of motion do allow a good approximation because velocity = distance/time therefore an interpolated distance can be obtained from distance plus delta distance / delta time. If you know what I mean.
Velocity offers no clues, or trend, except that delta velocity is limited by mass. Even then, it is influenced by unpredictable factors, e.g. a car might be able to stop faster than it can accelerate. Also you can not predict when the brakes will be activated.
Given some velocity and inertia, you can approximate future velocity because it is an integral. But to improve on the accuracy of the last reading, you would need to know the forces of acceleration that are at work.
It’s just a guess based on the previous 1s interval acceleration (the delta in speed over one second) of course you can’t predict when the driver will stop that current behavior (accelerating or slowing down).