ROV tether code.

HI!

I`m building an ROV sub, and as i am an Arduino noob and need help writing some code.

the 6 rov motors are currently controlled with on and off switches in an arcade joystick, and relays.

I want to reduce the number of cables, an im hoping to use the rx/tx on the arduino. I will have one arduino on the surface and one in the water.

can someone please help me getting started with a simple code that I can build upon?

" push a button connected to the surface ardunio , and make the other arduni write a pin high"

im sure it is super simple. (not for me) :P

thanks from Norway. :D

Aren't you going to post a photo of the sub ?

Below simple serial code for sending data from one arduino to another. An ethernet connection might be of interest if video from the ROV is desired.

//zoomkat 3-5-12 simple delimited ',' string tx/rx 
//from serial port input (via serial monitor)
//and print result out serial port
//Connect the sending arduino rx pin to the receiving arduino rx pin. 
//Connect the arduino grounds together. 
//What is sent to the tx arduino is received on the rx arduino.
//Open serial monitor on both arduinos to test

String readString;

void setup() {
  Serial.begin(9600);
  Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}

void loop() {

  //expect a string like wer,qwe rty,123 456,hyre kjhg,
  //or like hello world,who are you?,bye!,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >1) {
        Serial.print(readString); //prints string to serial port out
        Serial.println(','); //prints delimiting ","
        //do stuff with the captured readString 
        readString=""; //clears variable for new input
      }
    }  
    else {     
      readString += c; //makes the string readString
    }
  }
}

You want to use RS485 over the link because you're going to have a long tether and the 0V to 5V, non differential signaling of TTL serial is much more susceptible to interference. To implement RS485 it just requires a couple of MAX485 (or equivalent) chips which are quite inexpensive, and with twisted pair wires you're good for a few thousand feet of tether.

http://johanneskinzig.de/hardware/arduino-communicates-via.html

For the software side I'd suggest the EasyTransfer library. What it does is just keep a struct synchronized between two Arduinos -- kinda like both sides are reading the same variables -- and handles bad data (performs checksumming) for you.

http://www.billporter.info/2011/05/30/easytransfer-arduino-library/

What range does TTL work? Is that just 2 wire Rx & Tx?

[quote author=Andy R link=topic=240470.msg1727619#msg1727619 date=1400362624] What range does TTL work? Is that just 2 wire Rx & Tx?[/quote]

You usually also have a ground wire with a tx/rx setup.

About 20 feet