My "MINIRAY" Rov.

What are you working on .... Show off your Rov's Projects here.
Post Reply
User avatar
bigbadbob
Posts: 272
Joined: Nov 28th, 2011, 10:24 am

Re: My "MINIRAY" Rov.

Post by bigbadbob »

Today's job was coding for the arduino's.
This code is a good simple baseline for anyone wanting to control three thrusters with ESC's over RS485 with a single 24awg twisted pair using a ps2 controller.
It's a simplified version of techmonkey's code. Thanks Hamish. :-)
And thanks to Bill Porter for the libraries. :-)
I cut out Hamish's sensor data as I do that with a seperate minimosd video overlay board.
and I only send data to the rov using the arduino's so comms are one way.
I also only have one vertical thruster so I cut out the code one for his two verticals.
And my vertical ESC is a one way one for a quadcopter so has down thrust only.
I'll need to re-code when I get a bi-directional ESC.

top side-(controller)

Code: Select all

/*
Simplified version for MiniRay by Bigbadbob, Jan 2020.
Based on ROVPS2Control_Masterv8.ino
by Hamish Trolove
http://www.techmonkeybusiness.com
This sketch takes control commands from a PS2 handset and transmits the
commands using Bill Porter's EasyTransfer Library over a 9600 baud serial
link (100m tether).

This sketch is designed for an Arduino Nano with only one Serial Port.

Pin assignments are:

3.3V output to PS2 red Pin
gnd connection for PS2 Black Pin
Pin D10 to PS2 yellow pin (chip select)
Pin D11 to PS2 orange pin (Mosi)
Pin D12 to PS2 brown pin (Miso)
Pin D13 to PS2 blue pin (clock)


Communications
Serial Connection: Topside D1 (TX) to ROV D0 (RX)
Serial Connection: Topside D0 (RX) to ROV D1 (TX)
Connect the GND on both
Or use RS485 converter boards.


The coding pulls on the PSX library developed by Bill Porter.
See http://www.billporter.info for the latest from Bill Porter and to
download the library.

The controls for the ROV are;
Left Stick -  Y-axis, fwd=down
Right Stick - X-axis = Yaw, Y-axis = forward/back


*/


#include <PS2X_lib.h> // Bill Porter's PS2 Library
#include <EasyTransfer.h> // Bill Porter's Easy Transfer Library


PS2X ps2x; //The PS2 Controller Class
EasyTransfer ETin, ETout; //Create the two Easy transfer Objects for two way communication
 
int ForwardVal = 0; //Value read off the PS2 Right Stick up/down.
int YawLeftVal = 0; //Value read off the PS2 Right Stick left/right
int UpVal = 0; //Value read off the PS2 Left Stick up/down

struct SEND_DATA_STRUCTURE{
int Vraw; //Variables to carry the actual raw data for the ESCs
int HLraw;
int HRraw;
};

SEND_DATA_STRUCTURE txdata;

void setup()
{
ps2x.config_gamepad(13,11,10,12, false, false);
//setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?)
//We have disabled the pressure sensitivity and rumble in this instance and
//we know the controller type so we have not bothered with the error checks
 

delay(4500); //The 4.5 second delay to allow thruster calibration in slave and prevent a comms clash.
Serial.begin(9600); //Begin Serial to talk to the Slave Arduino
ETout.begin(details(txdata), &Serial);//Get the Easy Transfer Library happening through the Serial
}

void loop()
{
ps2x.read_gamepad(); //This needs to be called at least once a second to get data from the controller.

// now read the stick values
ForwardVal = ps2x.Analog(PSS_RY);
YawLeftVal = ps2x.Analog(PSS_RX);
UpVal = ps2x.Analog(PSS_LY);


//and do the yaw maths
txdata.HLraw = -(128-ForwardVal)+(128-YawLeftVal); //This will be up to a value of 256
txdata.HRraw = -(128-ForwardVal)-(128-YawLeftVal); //This will be up to a value of 256
txdata.Vraw = UpVal; //This will be up to a value of 256. no Roll maths needed as I only have one vertical thruster.

//Scale the values to be suitable for ESCs
// These values will be able to be written directly to the ESCs

txdata.Vraw=map(txdata.Vraw,128,0,0,179); //128 from ps2 = 90 to ESC //vert is down only remember.
txdata.HLraw=map(txdata.HLraw,-256,256,0,179);
txdata.HRraw=map(txdata.HRraw,-256,256,0,179);
ETout.sendData();// send the ESC commands.
delay(100);
}


And here's the ROV code-

Code: Select all

/*
Slave receiver for MiniRay ROV by Bigbadbob, jan 2020
based on code by Hamish Trolove
http://www.techmonkeybusiness.com
This sketch takes commands sent to it from the Master unit with
the PS2 Controller attached and converts it to motor ESC commands,
The data is sent fromthe controller (Master) to the ROV(Slave) using Bill Porter's EasyTransfer
Library over a 9600 baud serial link (100m tether).

Data sent from the Master are raw settings for the ESC control.

This sketch is designed for an Arduino Nano with only one Serial Port.

The pin assignments are;


D9 = ESC Horizontal Right (stbd)
D10 = ESC Horizontal Left (port)
D11 = ESC Vertical



Communications
Serial Connection: Topside D1 (TX) to ROV D0 (RX)
Serial Connection: Topside D0 (RX) to ROV D1 (TX)
Connect the GND on both

or connect via ttL serial to RS485 converter

Please note that the ESCs will all have been programmed by this
point in the project.
*/

#include <Servo.h>
#include <EasyTransfer.h> // Bill Porter's Easy Transfer Library


EasyTransfer ETin, ETout; //Create the Easy transfer Object for
// two way communication


Servo ESCV; // Create Servo Object ESC Vertical
Servo ESCHL; // Create Servo Object ESC Horizontal Left
Servo ESCHR; // Create Servo Object ESC Horizontal Right



struct RECEIVE_DATA_STRUCTURE{
int Vraw; //Variables to carry the actual raw data for the ESCs
int HLraw;
int HRraw;
};
//give a name to the group of data
RECEIVE_DATA_STRUCTURE rxdata;


void setup()
{
ESCV.attach(11,600,2250); //attach the ESCV to pin 11
ESCHL.attach(10,600,2250); //attach the ESCHL to pin 10
ESCHR.attach(9,600,2250); //attach the ESCHR to pin 9


//Due to problems with the ESC recognising the maximum
//position at the default settings, the figures after
//the pin number are the microsecond signals for the 
//minimum and maximum that the ESC will recognise.
// 600 and 2250 work.

//calibrate ESC's
//0=min,90=neutral,180=max
ESCV.write(180); //set vertical throttle to max for calibration.
ESCHL.write(180); //Set the LEFT throttle to the max position.
ESCHR.write(180); //Set the RIGHT throttle to the max position.
delay(2000);
ESCV.write(0); //set the vertical throttle to the min position
ESCHL.write(0); //Set the left throttle to the min position.
ESCHR.write(0); //Set the RIGHT throttle to the min position
delay(2000);



Serial.begin(9600); //Begin Serial to talk to the Master Arduino

ETin.begin(details(rxdata), &Serial); //Get the Easy Transfer Library happening through the Serial

}

void loop()
{
ETin.receiveData();

ESCV.write(rxdata.Vraw); //Set the ESCVR signal to the defined throttle position.
ESCHL.write(rxdata.HLraw); //Set the ESCHL signal to the defined throttle position.
ESCHR.write(rxdata.HRraw); //Set the ESCHR signal to the defined throttle position.
}

This code now tested and working on the bench. happy days.
Last edited by bigbadbob on Jan 26th, 2020, 12:21 pm, edited 4 times in total.
User avatar
bigbadbob
Posts: 272
Joined: Nov 28th, 2011, 10:24 am

Re: My "MINIRAY" Rov.

Post by bigbadbob »

New vertical thruster arrived today-
£50 off ebay so not the cheapest but worth it if it does the job.
rated at 12v 1.3Kg thrust 6.5A with 60mm prop, and up to 24V, 2.4Kg thrust, 11.7A
going by the specs I think it's 350kv
I plan to run it at low throttle.

I've got a 50mm prop for it to reduce thrust and current.
It's brushless so my brushed ESC's wont work with it but I'll order a brushless one and see how it goes.
It does seem quite good quality and the cable has kevlar strands through it so is nice and strong for pulling it tight into the penetrator.
Supposedly good for down to 100m too. we'll see.... ;)


Image
User avatar
Ianth3impler
Posts: 38
Joined: Jul 7th, 2019, 5:16 pm
Location: Virginia

Re: My "MINIRAY" Rov.

Post by Ianth3impler »

What is the depth rating on those motors?
User avatar
bigbadbob
Posts: 272
Joined: Nov 28th, 2011, 10:24 am

Re: My "MINIRAY" Rov.

Post by bigbadbob »

bigbadbob wrote:Supposedly good for down to 100m too. we'll see.... ;)
User avatar
Ianth3impler
Posts: 38
Joined: Jul 7th, 2019, 5:16 pm
Location: Virginia

Re: My "MINIRAY" Rov.

Post by Ianth3impler »

Also I see that you used the .250 inch tubing for your motor wires. How well did that work? When I'm done with my current build Scout I'm planning on making a 1000 foot diveable ROV. I want to do something similar.
User avatar
bigbadbob
Posts: 272
Joined: Nov 28th, 2011, 10:24 am

Re: My "MINIRAY" Rov.

Post by bigbadbob »

Yes, I've used 6mm pu tubing and push-fit pneumatic fittings screwed into the ABS hull.
the tubing ends in the fitting and is potted with resin around the wires on the inside of the hull.
The only problem I foresee is if water gets into the thruster it will wick along the inside of the wire and get into the hull.
The thrusters are potted all round the motor apart from the shaft which has it's own seal so fingers crossed.
I havn't been to any decent depth yet so don't know if this will happen.
User avatar
bigbadbob
Posts: 272
Joined: Nov 28th, 2011, 10:24 am

Re: My "MINIRAY" Rov.

Post by bigbadbob »

List of things I plan to do: (update)

replace tether to ROV connector with 8 pin mini impulse connector. (as used in videoray) this will be lighter and have 2 extra pins. Done.
replace tether video coax and comms lines with 2x 24AWG twisted pairs stripped out of CAT5. these will be lighter and less noisy. Done.
fit video baluns both ends to enable video over twisted pair.
replace velleman control system with arduino nano's top and bottom and add rs485 converters to each.
replace switched joystick with PS2 controller.
replace relay board with 3 ESC's for thrusters. Done.
replace vertical thruster. Done.
Add 12v to 48v dc-dc converter to top side and 48v to 12v dc-dc converter to ROV to reduce current in tether to 1/4 of what it was with 12v supply and therefore reduce volt drop to 1/4 of what it was too. Done.
bottom end converter will be mounted external to the ROV as it's potted and waterproof so will be watercooled.Done.
Move MINIMOSD head-up-display board from ROV to controller and add sensor code to ROV arduino.
Minimosd will receive data transmitted by the ROV over RS485 and superimpose it on the video signal.
Upgrade compass to 3 axis tilt compensated CMPS12.
Spend a fortune on e-bay. Done. :lol:

ESC's are china specials off e-bay.
Port and Stbd are brushed 80A with reverse.
Image

Vertical is brushless, currently an RW.RC 40A fwd only which I can calibrate to zero at the middle of the vertical joystick so it just does down but not up. I've tested these on the bench using a servo tester and all is well so far.
It's supposed to have SimonK firmware in it but the firmware is locked so I can't read what version it is. I've contacted the seller to see if he can tell me what version it is so I can compile a version with reverse capability and flash it. I don't hold out much hope of getting a sensible answer though.
Failing that I've ordered a 30A brushless china special with reverse.

Image

There's still a lot to do on this upgrade but I'm getting there and it's keeping me out of the bar. :D
Pics to follow when I remember my Flikr login details. :lol:
User avatar
bigbadbob
Posts: 272
Joined: Nov 28th, 2011, 10:24 am

Re: My "MINIRAY" Rov.

Post by bigbadbob »

Today's job was wiring up the two arduinos, two TTL-rs485 converters, the ps2 controller etc, basically everything to get the controls working on the bench.
All now more or less working and the coding is close to finalised. the maths for the yaw control was making my brain hurt as my port thruster runs anticlockwise so the two are counter-rotating.
No issues with using the hardware serial port on the Nano, I just make sure all the setup and ESC calibration is done before I start transmitting on the bus.
I'll edit the code above when it's all done but I have a problem with the ESC's drawing a lot of current in certain combinations of throttle settings.
It's now 1:00 AM so time for bed. :lol:
User avatar
bigbadbob
Posts: 272
Joined: Nov 28th, 2011, 10:24 am

Re: My "MINIRAY" Rov.

Post by bigbadbob »

OK, Miniray is looking good. all working on the bench.
Just a bit of wiring and bouyancy checks to do before a test dive.
I must find somewhere to host pics n video as photobucket is no longer free and I can't remember my flikr login.
With a fresh head this morning I sorted the problems (don't drink beer while you're coding).
the high current problem was just motor startup current tripping my current limited power supply.
I use that in case of screwups but it actually caused one.
I've updated the code in my previous post in case someone wants to use it.
fryslan76
Posts: 290
Joined: Dec 18th, 2012, 4:52 pm
Location: Netherlands

Re: My "MINIRAY" Rov.

Post by fryslan76 »

Buying ROV parts is a good way to have no money and time left for a bar ;)
Post Reply