I am working on my first Arduino project.  I have a pretty good understanding of the hardware, and some basic→moderate programing skills.  I have familiarized myself with the basic Arduino programming language, and the hardware requirements, but I am looking for some help/advice on my project. 

 

I am creating an autopilot for a trolling motor on a boat.  I am proceeding in several phases.

 

 

Phase one – Integrate the hardware controls to manipulate the motor, and create an Arduino script that allows me to control it from a wired remote.  ***Complete – See notes below***

 

Phase two – Integrate a 3-axis magnetometer (an possibly 3-axis gyro and 3-axis accelerometer to steady the readings) to allow the Arduino to control the direction and maintain a heading.

 

Phase three – integrate a gps unit and create trolling modes (i.e. zigzag, figure 8, or loop)

 

Phase four – integrate NMEA output from external GPS (i.e. garmin) into Arduino project to allow the Arduino to follow waypoints.

 

Phase five – Create wireless control.

 

 

My progress thus far incorporates a potentiometer and servo to control the throttle (attached to the carb linkage), and a pair of relays powering a hydraulic pump and cylinder to control the steering.  I would like to use a linear actuator rather than hydraulics.  I am currently using an Arduino Uno, and I know I will likely need a mega to handle the needed I/O ports.

 

For the wired control, I am using an (on)/off/(on) toggle for the steering switch, an on/off/(on) switch for the run/idle and mft (momentary full throttle), an off/(on) switch for the start and stop buttons, and a 10k potentiometer for the throttle control.  This requires a large project box for the wired control, I would like to slim this down by making a custom PCB based keypad, but I would need to waterproof it, I would appreciate any suggestions on creating a DIY rubber keypad.

 

Here is my script:

 

// Trolling Motor Throttle Control //

// by Adam Rogowicz a.rogowicz@gmail.com //

 

#include <Servo.h>

 

// hardware libraries:

Servo myservo;  // create servo object to control a servo

const int buttonPin_idle = 7;  // set the pin number of the run/idle button ** on/off button **

const int buttonPin_mft = 6;  // set the pin number of the mft button ** off/(on) button **

const int buttonPin_left = 5;  // set the pin number of the left control button ** off/(on) button **

const int buttonPin_right = 4;  // set the pin number of the right control button ** off/(on) button **

// !!not in use yet!! // const int buttonPin_heading = 8;  // set the pin number of the set heading button

const int relayPin_left =  3;  // set the pin number of the left control relay ** NO relay **

const int relayPin_right =  2;  // set the pin number of the right control relay ** NO relay **

const int relayPin_start =  11;  // set the pin number of the start control relay ** NO relay **

const int relayPin_stop =  10;  // set the pin number of the stop/kill engine control relay ** NC relay **

const int buttonPin_start =  13;  // set the pin number of the start button

const int buttonPin_stop =  12;  // set the pin number of the stop/kill engine button

 

// variables:

int buttonState_idle = 0;  // variable for reading the run/idle button status

int buttonState_mft = 0;  // variable for reading the mft button status

int buttonState_left = 0;  // variable for reading the left control button status

int buttonState_right = 0;  // variable for reading the right control button status

// !!not in use yet!! // int buttonState_heading = 0;   // variable for reading the set heading button status

int relayState_left = 0;  // variable for reading the left control relay status

int relayState_right = 0;  // variable for reading the right control relay status

int relayState_start = 0;  // variable for reading the start relay status

int relayState_stop = 0;  // variable for reading the stop/kill relay status

int buttonState_start = 0;  // variable for reading the start button status

int buttonState_stop = 0;  // variable for reading the stop/kill button status

int potpin = 0;  // analog pin used to connect the potentiometer ** 10K pot **

int val;  // variable to read the value from the analog pot pin

 

void setup() {

  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

  // initialize the pins as an input or output:

  pinMode(buttonPin_idle, INPUT);

  pinMode(buttonPin_mft, INPUT);

  pinMode(buttonPin_left, INPUT);

  pinMode(buttonPin_right, INPUT);

  pinMode(buttonPin_heading, INPUT); 

  pinMode(relayPin_left, OUTPUT);

  pinMode(relayPin_right, OUTPUT);

  pinMode(relayPin_start, OUTPUT);

  pinMode(relayPin_stop, OUTPUT);

  pinMode(buttonPin_start, INPUT);

  pinMode(buttonPin_stop, INPUT);

}

 

void loop() {  // Start of loop

 

  buttonState_idle = digitalRead(buttonPin_idle); // read the state of the rin/idle button value

  buttonState_mft = digitalRead(buttonPin_mft); // read the state of the rin/idle button value

  buttonState_left = digitalRead(buttonPin_left); // read the state of the left control button value

  buttonState_right = digitalRead(buttonPin_right); // read the state of the right control button value

  buttonState_heading = digitalRead(buttonPin_heading); // read the state of the set heading button value

  // !!not in use yet!! // relayState_left = digitalRead(relayPin_left); // read the state of the left control relay value

  // !!not in use yet!! // relayState_right = digitalRead(relayPin_right); // read the state of the right control relay value

  buttonState_start = digitalRead(buttonPin_start); // read the state of the start button value

  buttonState_stop = digitalRead(buttonPin_stop); // read the state of the stop/kill button value

  // !!not in use yet!! // relayState_start = digitalRead(relayPin_start); // read the state of the start relay value

  // !!not in use yet!! // relayState_stop = digitalRead(relayPin_stop); // read the state of the stop/kill relay value

 

 

  if (buttonState_start == HIGH && buttonState_stop == LOW) {  // Start engine statement

    delay(15);

    digitalWrite(relayPin_stop, LOW);

    delay(15);

    digitalWrite(relayPin_start, HIGH);

    delay(15);  }

  else if (buttonState_stop == HIGH && buttonState_start == LOW) {  // Stop/Kill engine statement

    delay(15);

    digitalWrite(relayPin_start, LOW);

    delay(15);

    digitalWrite(relayPin_stop, HIGH);

    delay(15);  }

  else {

    digitalWrite(relayPin_start, LOW);

    digitalWrite(relayPin_stop, LOW);  }

 

 

  if (buttonState_idle == HIGH) {   // run/idle button statement

    myservo.write(15); }  // if run/idle button engaged, servo to 0 position

  else if (buttonState_mft == HIGH) {   // mft button statement

    myservo.write(164); }  // if mft button engaged, servo to 17 position

  else {

    val = analogRead(potpin);  // reads the value of the potentiometer (value between 0 and 1023)

    val = map(val, 0, 1023, 15, 164);  // scale it to use it with the servo (value between 0 and 180)

    myservo.write(val);  // sets the servo position according to the scaled value

    delay(15); }  // waits for the servo to get there

 

 

  if (buttonState_left == HIGH && buttonState_right == LOW) {  // left control statement

    delay(15);

    digitalWrite(relayPin_right, LOW);

    delay(15);

    digitalWrite(relayPin_left, HIGH);

    delay(15); }

  else if (buttonState_right == HIGH && buttonState_left == LOW) {  // right control statement

    delay(15);

    digitalWrite(relayPin_left, LOW);

    delay(15);

    digitalWrite(relayPin_right, HIGH); 

    delay(15); }

  else {

    digitalWrite(relayPin_left, LOW);

    digitalWrite(relayPin_right, LOW); }

 

}  // End of loop

 

At this point, I need to know if I need a 3-axis gyro and 3-axis accelerometer to accomplish my goal.  I assume it will help, but I don’t want to overcomplicate my project if it is unnecessary.

 

I would appreciate any advice on hardware, and I need a starting point for the software for phases two, three, and four, and any advice on hardware for phase five, wireless controller.

 

I would also love to integrate a means to put the Arduino into sleep mode (low power) when the motor is off.  I am not sure how this would work since the start button would need to be operative while in sleep mode.  I would also like to incorporate a small LCD in the wired control, a way to determine the engine RPMs (tachometer), and display RPMs, Mode, water temp and???  Another thing I would like to incorporate if possible is a way to read depth from a sonar transducer, and have the autopilot follow a bottom depth.

 

 

Views: 218

Reply to This

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service