Pages: [1]   Go Down
Author Topic: Arduino to Arduino for ROV  (Read 1044 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all, I am working on an ROV which requires communication over 50' of wire. The current design has an onboard Arduino which reads analog inputs from the surface. I currently have code which reads analog pot inputs and it works, even over 50' of wire (no noise issues). However, I would like to reduce the size and cost of the tether which runs to the ROV to supply power, video, and control input. The method that I have functioning requires 7 wires of an ethernet line for control input, power is supplied over 10 gauge wire, and video has its on line as well.

 The control inputs need to control a servo and the speed and direction of 6 thrusters. I would like to reduce the control input to 2 wires, using an Arduino on the surface to read the analog inputs and transmit this data to another arduino onboard the ROV.

Before I invest a lot of research time I want to make sure this is feasible. How feasible is it to establish RS232 or RS485 communication to accomplish this task? If possible point me in the right direction.


Thank you!

Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 51
Posts: 2276
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to get this post moved to project guidance.

Mark
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 300
Posts: 26219
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.ti.com/lit/ds/symlink/max232.pdf
http://arduino.cc/forum/index.php/topic,133970.msg1007882.html#msg1007882
« Last Edit: November 27, 2012, 09:03:16 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry about that, I should have been more specific.


Is the programming of this set up possible?
Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 51
Posts: 2276
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If this is what your asking about

Quote
The control inputs need to control a servo and the speed and direction of 6 thrusters. I would like to reduce the control input to 2 wires, using an Arduino on the surface to read the analog inputs and transmit this data to another arduino onboard the ROV.

Then yes, the uno can just cope. 2 pins for comms, 1 pin for the servo, 6 PWM pins (motor speed) and 6 direction pins for the motors. Connecting the two Unos via pins 0&1 will allow you to use Serial between the two.

Mark
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay here is what I want to do:

From the Arduino on surface I would like to send the following: Start  Case#  Speed    End     

Start would be the Start of packet marker,   <
Case # would determine which motors and which direction to fire motors, I have 10 possible cases  1-10
Speed would be the PWM value   0-255
End would be End of packet marker,   >

Then on the receiving side I would like to  process this information to make it comply with my will lol, I can handle the sending of the packet but I have no clue how to process this information on the receiving Arduino. I am finding some useful links and will post code if I can develop something post worthy.

Point me to some good examples if possible.     
Logged

France
Offline Offline
Edison Member
*
Karma: 37
Posts: 1005
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, the receiving part could be done with something like this:
Code:
void loop()
{
  if ( Serial.available() > 0 )
  {
    char c = Serial.read();
    static uint8_t i;
    static char input[12];

    if ( c != '\r' && i < 11)
      input[i++] = c;

    else
    {
      input[i] = '\0';
      i = 0;

      uint8_t var1;
      uint8_t var2;
      char output[20];

      if ( sscanf( input, "<%hhu %hhu>", &var1, &var2 ) == 2 )
      {
        sprintf( output, "case:%hhu speed:%hhu", var1, var2 );
        Serial.println( output );
      }
    }
  }
}

With this code, your other Arduino will need to send the following format to Serial:
Code:
<Case Speed>\r

Good luck smiley
« Last Edit: November 27, 2012, 09:24:43 pm by guix » Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9542
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Something like the below could be used on the receiving arduino to control servos.

Code:
//zoomkat 11-22-12 simple delimited ',' string parce
//from serial port input (via serial monitor)
//and print result out serial port
//multi servos added

String readString;
#include <Servo.h>
Servo myservoa, myservob, myservoc, myservod;  // create servo object to control a servo

void setup() {
  Serial.begin(9600);

  //myservoa.writeMicroseconds(1500); //set initial servo position if desired

  myservoa.attach(6);  //the pin for the servoa control
  myservob.attach(7);  //the pin for the servob control
  myservoc.attach(8);  //the pin for the servoc control
  myservod.attach(9);  //the pin for the servod control
  Serial.println("multi-servo-delimit-test-dual-input-11-22-12"); // so I can keep track of what is loaded
}

void loop() {

  //expect single strings like 700a, or 1500c, or 2000d,
  //or like 30c, or 90a, or 180d,
  //or 30c,180b,70a,120d,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >1) {
        Serial.println(readString); //prints string to serial port out

        int n = readString.toInt();  //convert readString into a number

        // auto select appropriate value, copied from someone elses code.
        if(n >= 500)
        {
          Serial.print("writing Microseconds: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.writeMicroseconds(n);
          if(readString.indexOf('b') >0) myservob.writeMicroseconds(n);
          if(readString.indexOf('c') >0) myservoc.writeMicroseconds(n);
          if(readString.indexOf('d') >0) myservod.writeMicroseconds(n);
        }
        else
        {   
          Serial.print("writing Angle: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.write(n);
          if(readString.indexOf('b') >0) myservob.write(n);
          if(readString.indexOf('c') >0) myservoc.write(n);
          if(readString.indexOf('d') >0) myservod.write(n);
        }
         readString=""; //clears variable for new input
      }
    } 
    else {     
      readString += c; //makes the string readString
    }
  }
}

Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank yall!! Extremely helpful. I've tested out the first batch of code with the Serial Monitor sending <Case Speed>/r to the Arduino and it works great. However, when I send it something random it freezes. Will I need to find a way to code this out or is this even a concern?
Logged

France
Offline Offline
Edison Member
*
Karma: 37
Posts: 1005
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry I made a little mistake in the code, it's corrected now but I'm not sure if that will solve your problem, try again smiley
Logged

Pages: [1]   Go Up
Jump to: