GPS cruise control

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
T1tch
 
Posts: 1
Joined: Tue Jul 22, 2014 5:03 am

GPS cruise control

Post by T1tch »

Hello, as my title suggests I am trying to create a GPS/Arduino driven cruise control/speed limiter system for my boat. Speed limits on the water are pretty strict in my area, also the ability to keep a constant speed would be useful for skiing/wakeboarding, the throttle on my outboard engine is on the end of the tiller arm and works in the same way as a motorcycle throttle, it is also pretty twitchy, as in small movements have a large effect on the speed of the boat. Most of all, this project would just serve to satisfy my inner geek and I hope that someone can relate to that and guide me through the programming. I must say at this stage that safety will be my primary concern. All systems will be designed to fail in a safe condition, as an aircraft engineer this is something I have plenty of experience with.

I plan to use a servo to control the throttle on the outboard. The servo will either control the throttle directly and have some way of clutching when the cruise control isn't engaged, or the servo will control an adjustable throttle stop at its upper limit. In this way the throttle can be closed as normal, even with the system engaged. The throttle would need to be held against the stop with hand pressure at all times but this adds another element of safety as releasing the throttle would return the engine to idle regardless of servo position. The speed will be measured using a GPS receiver, giving an accurate speed regardless of tidal flow or wind conditions. The GPS receiver will be read by an Arduino, and a PID loop will be used in conjunction with a rotary encoder or pot to set the required speed. The speed function of the NMEA data is all that is required all the other data is redundant for this project. Here is the code I have so far, it isn't much but it reads my GPS receiver and prints speed in knots to the Arduino serial monitor every time the GPS is updated. This isn't entirely my code, I have adapted some of the example code that comes with the TInyGPS++ library.


#include "TinyGPS++.h"
#include <SoftwareSerial.h>

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

TinyGPSPlus gps;

SoftwareSerial ss(RXPin, TXPin);

void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
}

void loop()
{

while (ss.available() > 0)
gps.encode(ss.read());

if (gps.speed.isUpdated())
Serial.println(gps.speed.knots());
}

Now I have come to a dead end. I have the data that I need but I cant find any more example code to help me move things forward. Fundamentally I am unsure how to take numerical data in the serial monitor and put it to good use in a PID loop. All the examples seem to just read a variable then print it, very few actually then use it in further code. A rotary encoder could provide the variable setpoint in the PID for the speed limit between 1 and 20 knots (maximum).

Any advise, even if just showing me how to use the data in my serial monitor would be much appreciated. Regards, Chris

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: GPS cruise control

Post by Barry914 »

You can convert the ASCII representation of the GPS speed to an int in several ways. See the Arduino language reference for Serial. Serial.parseInt() is one way, or use the function atoi(), which is not documented in the reference but can be found in any C/C++ language reference (Google "atoi()", which I did and got this hit: http://www.cplusplus.com/reference/cstdlib/atoi/)

User avatar
fmbfla
 
Posts: 110
Joined: Fri Jun 08, 2012 6:48 pm

Re: GPS cruise control

Post by fmbfla »

Not to discourage you, but what you describe is very dangerous!
1. The tiller control you explain controls not only the throttle linkage but the timing armature for the ignition timing, a simple servo would not work.. this might be accomplished more easily with throttle cables connected to a standard helm's control's with a large Stepper motor.
2. Attempting to modify the throttle/timing linkages on a (KICKER) could cause the throttle to lock into it's current position (WOT, IDLE or anywhere in between).
3. Some(not all) current OB's MFG's do use fly by wire that can use "cruise control" BUT, they do not recommend using it in the ICW.
4. Don't forget the dead man effect and connect the kill switch to the driver not the console

5. OR, you can get a trolling motor that will do what you want :-)

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: GPS cruise control

Post by Barry914 »

I agree an electric trolling motor would be a lot easier to control, but not as much of a challenge and therefore maybe not as much fun to design. I'd like to know what you decide to do and how it comes out. fmbfla's warning and cautions are very valid, but given your familiarity with fail safe systems in a demanding environment I'd say go for it. Let us know what you decide to do and how it turns out.

User avatar
wdickenson
 
Posts: 184
Joined: Fri Nov 16, 2012 8:43 pm

Re: GPS cruise control

Post by wdickenson »

This is a problem I am painfully familiar with and I would echo the previous comments, this can be a major headache to retrofit an existing motor. But I will go ahead and share our experience. My son and I built a boat(2), electric drive, speed controller, 48v battery, and a basic autopilot. We built a small (4ft) boat to test the ideas on but candidly, we ended up on the full sized (14 ft) boat very fast. If I did it today, I would push the software harder.

Steering - We started with a chain driven stepper for the steering, We made modifications to add a solenoid "clutch" that defaulted to disengaged. We activated this using a dead man switch on the handle. Later version used a kill switch. Chain rusted but it worked fine. I would probably use a belt today. Could not get the throw we needed from the hydraulics. Make sure the belt does not slip. My dock got a few dings on this one. .

Throttle - First gas powered one we added a stepper to the handle and a simple gear. It was a camels hump and again, easily overiden by hand. we added fixed platform around the motor housing.

We started with fly by wire (steering without mechanicals) and did that for a few weeks while we worked out the GPS.

Our final version used an electric motor (Look at Glen L Witts design) in a motor well. We downgeared (2X) with a home made belt drive. We purchased a golf cart speed control, rigged 4 car batteries and then wired this up to the propeller. I kludged a servo to drive a pot so we didnt have to electrically "connect" the two. Because the throw was so small (rotating around a simple point) the last version just had a geared stepper with 1/4 chain.

All were easily disconnected both electronically (kill switch) or we cut power to both steppers and steered by hand. However my son will attest to that being uncomfortable since he had to do it coming in from the middle of the lagoon (about 8 miles).

Just before we moved onto to the next project, we added battery monitors to each battery. Never did wholly automate BUT i suspect that the latest generation of autopilots has probably made this a whole lot easier. This reminded me that we ran across the issue of the waves and wind altering both direction and speed. But as yo said, PID software here will handle that much easier than the crude averaging algorithm we used. And not to add fuel to the fire, but you might want to look at the latest ArduPilot and find the waypoint navigation. That would have made our lives infinitely easier.

My son followed up with an automated RC boat which went out to a way point, collected water data and then came back but he did that with off the shelf stuff and the waypoints earlier.

User avatar
fmbfla
 
Posts: 110
Joined: Fri Jun 08, 2012 6:48 pm

Re: GPS cruise control

Post by fmbfla »

"wdickenson", I like your Ideas and end results, If we were only younger again and to know as much then as we do now,
We would all be living like the Jetson's :-)

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”