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.
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.
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.
Something like the below could be used on the receiving arduino to control servos.
//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
}
}
}
Thank yall!! Extremely helpful. I've tested out the first batch of code with the Serial Monitor sending /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?