# GPS to make speed limit

I am planning to build a electric go-kart for my grand children, (check thread)
Drivpaket från elcykel i trampbil - Svenska ElektronikForumet (sorry it is in Swedish)
but as they are just 5 years old I want to limit the speed in a way that is adjustable so that as they get better drivers daddy can increase the maximum speed.
My idea is to use a GPS-module on the Arduino uno and use the speed parameter as (if my internet survey is right) You get directly from the module but I do not have a clue on how to find the signal in the sketch.

This is not my first Arduino adventure.
I have made some simple sketches before mostly from the book "Franzis Arduino tutorial kit manual".

I have a working Arduino uno in my car that reads the lambda signal and converts it into a various light in a RGB-diode. The two lambdas lights the blue and green part of the diode, the red is used for another purpose.

Jörgen

I wonder if it would be easier to put a detector on the drive shaft and control the max RPM of the wheels. I think it would give more immediate feedback than a GPS.

A simple reflective optical detector and a few spots of white paint on the drive shaft may be sufficient - say 4 pulses per revolution?

...R

Krassegrand:
I am planning to build a electric go-kart for my grand children, (check thread)
Drivpaket från elcykel i trampbil - Svenska ElektronikForumet (sorry it is in Swedish)
but as they are just 5 years old I want to limit the speed in a way that is adjustable so that as they get better drivers daddy can increase the maximum speed.
My idea is to use a GPS-module on the Arduino uno and use the speed parameter as (if my internet survey is right) You get directly from the module but I do not have a clue on how to find the signal in the sketch.

This is not my first Arduino adventure.
I have made some simple sketches before mostly from the book "Franzis Arduino tutorial kit manual".

I have a working Arduino uno in my car that reads the lambda signal and converts it into a various light in a RGB-diode. The two lambdas lights the blue and green part of the diode, the red is used for another purpose.

Jörgen

GPS might work, but with 10m location uncertainty your reported speed might be widely inaccurate at low speeds and rapid bearing changes.

I would look for a way to attach a wheel speed sensor.

Chuck.

Robin and Todd’s ideas about speed sensing are valid, but since you requested GPS information, here:

I use Adafruit’s library that works with their Ultimate GPS device. You hook it to the serial lines and read the data that the device broadcasts. If you request the GPRMC NMEA sentence, it has speed information. Using the library, you have access to the speed in knots, just by referring to the variable GPS.speed. Convert it to miles per hour like this:

``````mph = (int)(GPS.speed * 1.150779)
``````

ChrisTenone:
you have access to the speed in knots, just by referring to the variable GPS.speed. Convert it to miles per hour like this:

``````mph = (int)(GPS.speed * 1.150779)
``````

What's wrong with knots that they have to be converted?

...R

Robin2:
What's wrong with knots that they have to be converted?

...R

Knots are cool. If folks haven't studied the theory, they might confuse a trefoil with a granny though.

I have more conversions (because ALL gps NMEA spit out speed in knots. Which is fine if you are a sea captain, or a pirate) but the rest of us prefer land-lubber speed units:

``````)
mps =   (int)(GPS.speed * 0.514444444444); // knots -> m/s
knots = (int)GPS.speed;                    // knots (conversion factor= 1)
mph =   (int)(GPS.speed * 1.150779);       // knots -> mph
fps =   (int)(GPS.speed * 1.68781);        // knots -> fps
nc =    (int)(GPS.speed * 1.71600196);     // knots -> speed of light^-9
kph =   (int)(GPS.speed * 1.852);          // knots -> kph
cps =   (int)(GPS.speed * 51.4444444444);  // knots -> cm/s
``````

Thank You guys for all the answers.
I was thinking about a GPS, not for any really practical reason but a little because I have never tried it before and also it might open for a lot of other features later. Maybe a tracking device for the parents to see where the kart have been.

So, what I do is to write a code to print the result from the "GPRMC NMEA" to see how to extract the speed.

I realize that it might be better to have a sensor at the axle. I will think about what to do.

Jörgen

Hey Jörgen,

What gps device do you have? Have you hooked it up directly to the serial monitor to read the output? Even if it isn’t the Adafruit Ultimate (which is a great device, I bought one … but forty bucks …!), I’d suggest that you read that tutorial (to get the basics of reading a GPS.

Playing with GPS because you want to learn how is a perfectly valid reason for doing it.

don’t worry, what happens on arduino.cc stays on arduino.cc

Sounds like a nice project. If you don’t have a GPS module yet, take a look at the ublox NEO-6M, 7M or M8N. They are fairly common and start at less than \$20 or so.

what I do is to write a code to print the result from the “GPRMC NMEA” to see how to extract the speed.

Yes, you could write your own “parser” to watch for a particular sentence (GPRMC), a particular field in that sentence, and verify the checksum.

Or you can use a library to parse the incoming bytes into the various values like lat/lon, time or speed. I do not recommend the Adafruit_GPS library, because it is very inefficient, it uses a lot of RAM (1/3rd of the UNO’s 1K!), and it does not verify the checksum of the sentence. This can allow bad values to be passed to your sketch.

I wrote the NeoGPS library to be very small, efficient and configurable. It could use as little as 28 bytes for your sketch. By default, it adds 115 bytes, still much less than other libraries. Here is a simple sketch that prints just the speed value:

``````#include <Arduino.h>
#include "NMEAGPS.h"

#include <AltSoftSerial.h>

AltSoftSerial gps_port; // always 8 and 9 on the UNO

NMEAGPS  gps;
gps_fix  fix;

//--------------------------

void setup()
{
// Start the normal trace output
Serial.begin(9600);
while (!Serial)
;

Serial.print( F("GPS Speed Limit\n") );

// Start the UART for the GPS device
gps_port.begin( 9600 );
}

//--------------------------

void loop()
{
while (gps.available( gps_port )) {

if (fix.valid.speed) {
Serial.print( fix.speed_kph() );
} else {
// No data yet
Serial.print( '?' );
}
Serial.println();
}
}
``````

Just sitting still, this will print random speed values, up to 1.5kph or so.

Also, be sure to use pins 8 & 9 for the GPS device so you can use the AltSoftSerial library:

``````#include <AltSoftSerial.h>

AltSoftSerial gps_port; // always 8 and 9 on the UNO
``````

Pin 8 will receive data from the GPS TX pin. Pin 9 will transmit configuration commands to the GPS RX pin (optional).

If you really can’t use those pins, I would recommend NeoSWSerial, a library I maintain. I don’t recommend SoftwareSerial.

Cheers,
/dev

I do not have a GPS-device yet.
Can You recommend one?

Jörgen

/dev:
If you don't have a GPS module yet, take a look at the ublox NEO-6M, 7M or M8N. They are fairly common and start at less than \$20 or so.

Sorry I missed this!

Jörgen

I found something here!

Jörgen

This

might be better 159+299 SEK does that seem ok?

There is even a suggestion for a code.

Jörgen

What do You think about [the MTK3339]?

Sure, lots of folks get that one. I think I've seen one report of a banggood seller advertising that module but delivering another. And I'd be a little wary of the cheapest modules, as I've heard they may lock on to fewer than 9-12 satellites. To get good, stable speed values, you'll want good reception and lots of satellites. I've never seen anybody complain about a real ublox module.

Cheers,
/dev

Supposing the kart is running near (but below) the permitted speed and the child presses the accelerator. How quickly can a GPS advise the increase in speed? What happens if the GPS is briefly obscured from the satellites by buildings.

I would need some convincing, based on experiments, that GPS is the correct solution for this problem.

...R

Robin2:
I would need some convincing, based on experiments, that GPS is the correct solution for this problem.

...R

I agree.... I think I will have to buy one and test.

Jörgen