Arduino GPS speed pulse generator for digital speedometer

Hello, I'm new to Arduino but I've already picked first project (learning by need) :)

I have motorcycle digital speedometer that is driven by hall sensor connected to the wheel (1 pulse per wheel revolution). I was thinking of replacing hall sensor with signal from GPS driven Arduino. Unfortunately I'm not sure how that signal is generated (don't have oscilloscope to check). I assume this is simple signal.

I would appreciate beginners help explanations (I'm quite familiar with general electronics and c# but new to Arduino)

Based on my research I think I'll be able to pull GPS values for speed however how to convert that into signal that I can connect to speedometer is a mystery a bit. I would appreciate any help even guiding for documentation for this project

Thank you

I assume this is simple signal.

You have the GPS. It has a data sheet. There is no reason to assume anything.

Based on my research I think I’ll be able to pull GPS values for speed

If you don’t even know what kind of signal it is, I’m not sure how you reached this conclusion.

On the other hand, most GPSs output serial data, where the current position is a string. Knowing where you are, and where you were, and the difference in time between there and here, you can compute the change in location and the speed.

however how to convert that into signal that I can connect to speedometer is a mystery a bit.

Without knowing anything about your speedometer, yes, it is.

I was thinking of replacing hall sensor

Why? That system will work anywhere, at any speed (though I suspect that your assumption of one pulse per revolution is wrong). A GPS works only outdoors, and only gives reasonable results when you are moving fairly quickly.

Hi PaulS, Thank you for your fast reply.

I was able to get speed reading from GPS shield in km/h. I have this value in integer but need to get proper signal out that connects to my speedometer.

  1. Number of revolutions per wheel turn is 1 (this is how the current setup is working). Based on that and wheel diameter I should be able to calculate frequency for the signal from gps

Making my post short I have everything to the point where I need to generate signal that will replace what's coming from standard Hall sensor.

If I'm calculating correctly my hall sensor generates 1.65pps at 100km/h (21in wheel - 1 pulse per wheel turn). The only problem is I'm not sure how to generate proper signal. I'm not sure if its pwm or just fixed width fulses.

The reason for this is that this is custom motorcycle and I don't want to rout cables for hall sensor to sprocket or front disc brake (those are a bit bulk). Plus thought it might be good starting project.

This is very similar to what people are doing with speed sensor "healers" where they interupt hall sensor pps and re-calculate it to get updated pps

Thanks

Michnik: my hall sensor generates 1.65pps at 100km/h (21in wheel - 1 pulse per wheel turn)

No way. Show your math.

Ok it might be wrong just did it quick,

Radius of 21'' wheel in front (21'' * 2.54 *3.14) - 1.6748m Turns per 100km: 100000 / 16.748 = 59708.62193 Turns per second : 59708.62193 / 3600 = 16.58572831

Ups ate one 0, of course its ~ 16.6 turns per second. Which is 16.6Hz right ?

I'll try to play with it and set fixed pulse width to 10ms and see if that gets picked up by speedo, just need to figure out if its High or Low driven but that should be ok by measuring hall sensor pins.

I'll for now just set it to 100khm, get same wheel radius in the speedo and see what it shows / if it shows anything.

My cheap and rather old etrex GPS outputs my current velocity in any desired units in nice big numerals on the display. I mount it between the handlebars and drive off!

Ok I've got simple test with pulse generation. Both pulse width and delay is configurable. Pulse will be fixed, delay will be set by the value coming from GPS speed.

const int pinOut = 13; unsigned long previousMicros = 0; int pulseState = LOW; long pulseDelay = 500000; long pulseWidth = 10000;

void setup() { pinMode(pinOut, OUTPUT); Serial.begin(9600); Serial.println("Start"); }

void loop() {

unsigned long currentMicros = micros();

if (Serial.available()) { long ch = Serial.parseInt(); if (ch > 0) { pulseDelay = ch; Serial.println(ch); } }

if(currentMicros - previousMicros > pulseDelay) {

previousMicros = currentMicros; pulseState = HIGH; digitalWrite(pinOut, pulseState); //Serial.println("On"); }

if ((currentMicros - previousMicros > pulseWidth) && (pulseState== HIGH)){ pulseState = LOW; digitalWrite(pinOut, pulseState); //Serial.println("Off"); }

}

Michnik: Radius of 21'' wheel in front (21'' * 2.54 *3.14) - 1.6748m... Which is 16.6Hz right ?

radius (r) is the distance from centre to the outside, (diameter (d) is twice that circumference = 2 * pi * r

radius (r) is the distance from centre to the outside, (diameter (d) is twice that circumference = 2 * pi * r

Of course you are right I've used d * pi (diameter not radius) in my calculation Thanks

Well, if it's a 21 inch radius then the circumference is 132 inches = 3.35 metres. 2 * 3.14159 * 21 = 132 in 132 in * 2.54cm = 335 cm = 3.35 m 100 km/h / 60 / 60 = 27.78 m/s (metres per second) 27.78 / 3.35 = 8.29 revolutions / sec [8.3 Hz]

Ok of course its 21’’ diameter, sorry for I’m mixing those up.
I’ve got gps speed readout and got it transfered to pulse signal, right now speed is updated once per second I need to change data rate to double it.

Once I get it up I’ll post sketch. Not too advanced but hey first project :slight_smile: