Bringing up data from the ROV

Anything to do with programing the Arduino Platform.
Post Reply
User avatar
ThunderKeep
Posts: 9
Joined: Aug 26th, 2018, 9:08 pm

Bringing up data from the ROV

Post by ThunderKeep »

Hello All,
I am buliding my first UROV and I have chosen to control my UROV via an arduino Mega setup as a webserver with a webpage at an IP address that has the motor/servo/esc controls on it. I know the very basics of programming and have managed to splice and edit code to start designing my helm controls. Even got the buttons to turn on my breadboarded LEDs so I know I have a handle on this part.

My question is to how to see sensor data from the ROV - topside.... I read in the arduino playground that webservers were only designed to send commands to the Mega and that this was a one way communication? Is that correct? I would like to monitor water temp and pressure, battery voltage of my packs, maybe compass heading etc. Is that where a second ardunio setup as a webclient comes in? Because it can display a webpage with that data on it reading off the serial port. That would mean 2 arduinos with ether-shields plus my IP camera in my UROV, I know I would then need to go with an onboard switch so I could network all three on the ROV with 1 ethernet cable tether and then topside on my laptop I would have 3 tabs open, one helm control (Ard-Mega), one for sensor data(maybe an uno), one IP cam for nav(getting an Amcrest 2K Ip camera).

Am I heading down the right road on this for a beginner? since my programming skills are limited but im learning, I dont want to go down a road that is more complicated then what I can tackle but I also dont want to miss out on an easier way since i'm new to arduinos. I have a 3d printer, I can weld, wire and do plumbing etc so Im not a complete noob.

I have included a pic of my started helm controls, I need to add a few more controls like dive/surface but wanted to sort this question out before going to far down any one rabbit hole.
Attachments
Helm Controls.PNG
Helm Controls.PNG (19.16 KiB) Viewed 12249 times
User avatar
Bennachie
Posts: 113
Joined: Jul 6th, 2018, 11:38 am

Re: Bringing up data from the ROV

Post by Bennachie »

I commend your ambition!

I'd just say that your proposed method is rather more complicated than that used in the industry for most ROVs, so you might be at risk of over complicating things.
If you do wish to use IP as a link however, a couple of things spring to mind immediately.

Firstly, watch out for the time lag using video over IP. It can make flying the ROV annoying, even if the delay is quite short.

Secondly, Ethernet only uses 4 of the 8 conductors in your CAT5 cable (unless it's Gb Ethernet), so you could have a workaround where you have an Arduino uplinking through 4 wires totally independently of your downlink through the other 4. That may or may not work.

Thirdly, your control system using buttons to fly the ROV might not have enough finesse to be able to fly the ROV very well. It's more usual to use some sort of joystick to provide a level of proportional control. This is fairly easy if you are using an Arduino.
User avatar
ThunderKeep
Posts: 9
Joined: Aug 26th, 2018, 9:08 pm

Re: Bringing up data from the ROV

Post by ThunderKeep »

Thank you for your comments. I did have another control method I was curious about but didn't find any clear cut info on it and maybe it's because it is so simple it's a given. I only have 1 arduino for testing and didn't try it.

Can I connect two joystick modules and a couple buttons to an arduino topside as a controller and then send the data from the control ard to the Mega on the ROV via 1 or 2 pair of wires in my ether thether then 2 pairs for ip camera ? What does this connection look like? Do they read each other's seral port and I just draw up a sketch to post joystick pot values to serial? And when I say joystick modules I'm thinking the robotshop ones that have 5 solder pins (5V/GRD/x range/y range/z button) and then from bottom sensor data to top side the Mega writes sensor data to it's serial and top side Arduino reads it and displays it via a multi line display or webclient?

If I back burnered the idea of data from the rov is it simpler yet, power the joystick modules topside by a small 5v supply and connect the xy signal terminals to the ether tether, only 3 would need to be used, fwd/rev - left and right - up down. Again leaving 4 for ip camera
User avatar
Bennachie
Posts: 113
Joined: Jul 6th, 2018, 11:38 am

Re: Bringing up data from the ROV

Post by Bennachie »

The short answer is yes.

You can either read joystick modules and buttons directly using an Arduino, or you can use a PC joystick or even an X-Box controller. I am using a PC joystick. To do this it's easiest to use a little converter like this one-

http://www.hobbytronics.co.uk/usb-host-joystick

For interfacing with Arduino code it is much easier to program the device to output a hex string, not ASCII. To do that, and to change the baud rate, you'll need an RS232 to TTL converter such as this one-

https://www.amazon.com/SunFounder-FT232 ... B01K1RQE38

You can then use your Arduino to read the hex string and extract the values for the stick(s) and buttons. I am actually not using a topside Arduino at the moment, just a subsea one. Either way, you'll need to get the telemetry data down the tether. To do this, the best way is to convert the Arduino's TTL signals to RS-422. This can drive data signals over several kilometres. I recommend a pair of MAX488 chips (RS part no. 799-3038) to do this. You need one at each end. RS-422 requires two wires for the downlink, and another two for the uplink.

As an aside, there's a variation of this called RS-485 which uses only two wires in total, but that's more complicated as you have to control your uplink and downlink data in such a way that the signals don't clash with each other.

I think you'll find that trying to send a standard 5v signal down any reasonable length of tether won't work, that's why you need to convert to something like RS-422. You can however use a potentiometer directly down a tether for a few tens of meters, I've done it and it works. It's not the best method though, as you need a separate wire for each control, plus a 0v reference wire.

As for the camera, most people use analogue cameras because they are simple and have no lag. I'd be interested to see how you get on using an IP camera. Also analogue cameras only require two wires.
User avatar
ThunderKeep
Posts: 9
Joined: Aug 26th, 2018, 9:08 pm

Re: Bringing up data from the ROV

Post by ThunderKeep »

Ok, thanks again for the help, every post I learn more and more, I have been following your thread on your joystick USB controller and it is awesome, some day when I have finished learning the basics that will be my goal. For today I think I will build my own controller with analog thumbsticks on an UNO for this build to limit how many different types of communication I need to learn at once, lol.

Here is a local supplier where I think I can get the chips you mentioned, Are these the same as you suggested, I didnt have any luck with the part # you had there,
https://www.mouser.ca/ProductDetail/Max ... 8TpcOe0%3d

I have a few more questions, but i'll lay out my understanding thus far to make sure im on the same page.

(2 Analog Thumbsticks) - on 4 of the unos analog pins - {UNO} = 2 Wires for TX = 2 for RX (which Pins?) |||| all 4 connect to Driver Chip - I connect 4 unused wires from Ethernet tether to other 4 driver pins and then mirror the setup at other end - Driver - |||| to Mega (whichPins?) I have some visual aids attached

Questions are - which pins and I have found almost no info on sketches to start communications or is it because its using the existing 2 serial pins plus some others I see marked (see UNO pic) so you just start normal serial comms and the drivers are active taking care of the rest? Since the drivers do the transfer is there an INPUT side and OUTPUT side, I noticed in the pic of the chip it has a marking.....
Attachments
Pins marked with comms
Pins marked with comms
uno pins.png (471.67 KiB) Viewed 12219 times
Is the dot formed in an indication of input/output sides
Is the dot formed in an indication of input/output sides
Chip Pic.PNG (69.49 KiB) Viewed 12219 times
Chip Connections.PNG
Chip Connections.PNG (53.25 KiB) Viewed 12219 times
User avatar
Bennachie
Posts: 113
Joined: Jul 6th, 2018, 11:38 am

Re: Bringing up data from the ROV

Post by Bennachie »

Hi, sorry for the delay, I've been away.
I'll do a full reply to you shortly.
User avatar
Bennachie
Posts: 113
Joined: Jul 6th, 2018, 11:38 am

Re: Bringing up data from the ROV

Post by Bennachie »

Ok, so for a basic bi-directional ROV control system you'd be looking to build something like what's in the following drawing.

You'd read your joystick & buttons using an Arduino or similar, then compile these inputs in to some sort of serial data string. The string should ideally start with some sort of header character(s) and end with a checksum and/or some footer characters. The data values that you want to send will be in the middle of the string.

The Arduino in the ROV would read the serial string, looking for the header characters, the footer characters and/or checking the validity of the string using the checksum.
It would then control the thrusters and lights as commanded from the topside controller.

If required, the ROV could send sensor telemetry up to the controller in a similar fashion, and the controller could display it.

I think the standard serial transmission drivers would do the actual sending of the string, but it's up to you to design the string.
Attachments
Basic ROV telemetry schematic
Basic ROV telemetry schematic
Basic ROV telemetry schematic.jpg (127.42 KiB) Viewed 12192 times
HolgerHey
Posts: 4
Joined: Dec 15th, 2013, 8:04 pm
Location: Kangerlussuaq, Greenland

Re: Bringing up data from the ROV

Post by HolgerHey »

Try to read this thread:
viewtopic.php?f=15&t=1293
User avatar
ThunderKeep
Posts: 9
Joined: Aug 26th, 2018, 9:08 pm

Re: Bringing up data from the ROV

Post by ThunderKeep »

Hi, sorry for the delay, I've been away.
No problem Bennachie, just a hobby here, everyday life comes first,

Thank you Bennachie and HolgerHey for your comments.

I have been doing a lot of reading on serial communication and came to the conclusion that there so many ways to "skin the cat" so to speak that it doesnt really provide a clear cut answer on 1 way to do this. Code designers preference which makes it tough to follow as a new person to programming, but I have picked up some important details, like the starting and ending chara as you mentioned Bennachie, I found some examples where the coder used $ as the start and & as the end so as to be sure of the beginning and end of commands.

I have ordered and am waiting on the delivery of a set of Fathom S Tether Interface boards which is a commercial version of what you have built HolgerHey except your include the arduinos as well . I felt that it was a good move for my build as it provided the RS422 comms with a clear direction on how to connect them with the added bonus of power management and analog camera comms as well.
https://www.bluerobotics.com/store/elec ... thom-s-r1/

@HolgerHey - I watched your video and downloaded your code from your site to take a look at it, first thing I notice was the lack of print.serialln and read.serial commands in it, I noticed that you have something called EasyTransfer library added, does that remove the need to specify what goes to serial port? from a super beginner's stand point it looks like it simplifies the code, you dont have chara-strings that each side needs to sort out etc.... any downsides to it? you also have something called inline void, what role does that play? I read the wiki page on inline commands but did not understand the important of it.

I have been working on my code with just one arduino to test what Im writing and building on to it piece by piece, my intention was that I would be able to split it into 2 files, topside command - underwater receiver. I've posted it below for comments. I'd like to know if there are any fatal flaws in it before I keep adding/tweaking. And is there anything stopping me from applying the EasyTransfer library for the communication if thats the way to go..?

Code: Select all

//ThunderKeep's Helm Control
//spliced joystick control from - zoomkat dual pot/servo test 12-29-12
//view output using the serial monitor

#include <Servo.h> 
Servo LHServo; ///Left hand motor
Servo RHServo; /// Right hand motor
Servo LTLeft;
Servo LTRight;
Servo Dive;
Servo Surface;

int LHJoyY = 0;  //analog input pin A0
int LHJoyX = 1;
int LHJoySw = 7; //Left hand Joystick switch
int RHJoyY = 3;
int RHJoyX = 2;  
int RHJoySw = 8; //RH Joy swich
int RockerSw = 12;
int DivePot = 4; //pot for dive motor
int val; //Varable reading from analog pin of pot

int led = 52;//LED Flood lights
int led1 = 53;
int led2 = 51;
int dataLED = 13;
int newvalS1, oldvalS1;
int newvalS2, oldvalS2;
int newvalS3, oldvalS3;
int newvalS4, oldvalS4;

void setup() 
{
  pinMode(LHJoySw, INPUT_PULLUP); 
  pinMode(RHJoySw, INPUT_PULLUP);
  pinMode(RockerSw, INPUT_PULLUP);
  pinMode(led, OUTPUT);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(dataLED, OUTPUT);
  LHServo.attach(2);  
  RHServo.attach(3);
  LTLeft.attach(4);
  LTRight.attach(5);
  Dive.attach(9);
  Surface.attach(10);
Serial.begin(9600);  
  Serial.println("Data Streaming Initialized");
 

}

void loop() 
{ 
  newvalS1 = analogRead(LHJoyY);           
  newvalS1 = map(newvalS1, 0, 1023, 0, 179); 
  if (newvalS1 < (oldvalS1-2) || newvalS1 > (oldvalS1+2)){  
    LHServo.write(newvalS1);
    Serial.print("LHJoyY- ");
    Serial.println(newvalS1);
    oldvalS1=newvalS1;
  }

  newvalS2 = analogRead(LHJoyX);
  newvalS2 = map(newvalS2, 0, 1023, 0, 179);
  if (newvalS2 < (oldvalS2-2) || newvalS2 > (oldvalS2+2)){  
    LTLeft.write(newvalS2);
    Serial.print("LHJoyX- ");    
    Serial.println(newvalS2);
    oldvalS2=newvalS2;
  }

  newvalS3 = analogRead(RHJoyY);           
  newvalS3 = map(newvalS3, 0, 1023, 0, 179); 
  if (newvalS3 < (oldvalS3-2) || newvalS3 > (oldvalS3+2)){  
    RHServo.write(newvalS3);
    Serial.print("RHJoyY- ");
    Serial.println(newvalS3);
    oldvalS3=newvalS3;

  }

  newvalS4 = analogRead(RHJoyX);           
  newvalS4 = map(newvalS4, 0, 1023, 0, 179); 
  if (newvalS4 < (oldvalS4-2) || newvalS4 > (oldvalS4+2)){  
    LTRight.write(newvalS4);
    Serial.print("RHJoyX- ");
    Serial.println(newvalS4);
    oldvalS4=newvalS4;
  }
  { 
    val = analogRead(DivePot);
    val = map(val, 0, 1023, 0, 180);
    Dive.write(val);
    Serial.print("DivePot- ");
    Serial.println(val);
    delay(10);
  }
 if (digitalRead(LHJoySw) == LOW)
  {
    digitalWrite(led, HIGH);
  }
  if (digitalRead(LHJoySw) == HIGH)
  {
    digitalWrite(led, LOW);
  }
 if (digitalRead(RHJoySw) == LOW)
  {
    digitalWrite(led1, HIGH);
  }
  if (digitalRead(RHJoySw) == HIGH)
  {
    digitalWrite(led1, LOW);
  }
  if (digitalRead(RockerSw) == LOW)
  {
    digitalWrite(led2, HIGH);
  }
  if (digitalRead(RockerSw) == HIGH)
  {
    digitalWrite(led2, LOW);
  }

delay(100);
  }
  

User avatar
ThunderKeep
Posts: 9
Joined: Aug 26th, 2018, 9:08 pm

Re: Bringing up data from the ROV

Post by ThunderKeep »

So I have been messing around with the EasyTransfer library and my Fathom S tether interface boards connecting to my Mega and Uno and successfully gotten 2 - 10K Pots to control 2 servos for a camera tilt and pan via the serial communication. I'd still appreciate any thoughts or insight to my early post and code but I think Im going to be ready to start a new thread in the "show off your build" category pretty soon as I think I've pretty much nailed this part down.
Attachments
IMG_20180913_221645.jpg
IMG_20180913_221645.jpg (416.7 KiB) Viewed 12155 times
Post Reply