go_away

Author Topic: ROV project, advice, brain storm and help needed  (Read 1135 times)

0 Members and 1 Guest are viewing this topic.

Offline JacobJTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
ROV project, advice, brain storm and help needed
« on: May 19, 2012, 02:24:22 PM »
Hello all

I am new to this forum and hope this is posted in the right place.

In 2 weeks I have sommer holidays for about 2 month, so I have planned a ROV project. I have brained the idea the last week and have searched for information about other projects on the internet, to see how others do it.

My idea atm. sounds like this:

Build up, dimensions and features.
Make a "cube"-shaped frame, either out of stainless steel or plastictubing. Dimensions: L50xW50xH40.

Then I put 3, maybe 4 12v DC brushed motors on it. 1 on each side of the cube pointing forward/backward and 1 in the middle of the top frame, that points up/down. Maybe I will put a 4'th motor very close to the center of gravity, that is pointing to the side, so that I can pan the ROV's camera over a larger object.

The forward and backward thrust is done by the two motors on each side of the cube. The turning is done by putting either one of those thrusters in reverse. In my mind it should turn on the spot. But more about turning in a moment.

In the middel of the cube-structure I will have a 20cm in diameter stainless watertight tube with a plexiglass window in the one end and a watertight hatch in the other end, so I can get to all the electronics. Inside this tube there will be an arduino, two motor controllers (dual channel once) and maybe some relays if needed. Also there will be the camera and a 12v scooter/small car battery.

The controlling of the ROV is done by a cat5 cable (50 meters I think..) which is connected to a PS2 controller.

The electronics/heart of the ROV

The idea for wiring

The PS2 controller needs 4 pins on the arduino and the PS2X library from Bill Porter as far as I know of. I am not totally sure if it also needs ground and 3.3volts too, but I will read up on that later on. But one thing that is sure is, that I need to change the pins used by the PS2 controller, because I need all 6 PWM pins available, or thats what I think. Well the PS2 controller is connected to 4 wires in the cat5 cable, plus 1 more for lights. Maybe two more to transfer the video-signal, but this I will ask for help to later on.

Then from the arduinos 6 PWM pins (its actually a freeduino board based on the Diecimila board) there runs 6 wires, a pair into each of the two motor controllers. The motor controllers will be two L293D chips. Maybe I need to hook up some relay circuit to those two L293D chips, if the motors sink to many amps, but I am not sure if that is a reliable way to do it. I am not totally sure if the 6 pins need to be PWM pins, because I dont think the L293D chips can handle a PWM signal through its input channel. I maybe think the PWM must go into the enable channels, but then I just need 6 regular pins and then 3(maybe 4) PWM pins, that run to the enable pins of the L293D chips.

All the power needed for the motors, the arduino, the two L293D chips, the light and maybe even the video-camera (canon MV800) is supplied by the 12v battery.

As lighting I have thought of using halogen bulbs from a car. They are 12v and they light up very nicely.

The video-camera sends a live signal to the surface and will be put into a 19" computer screen, through its VGA connector. The screen is driven of the boats 12V, which is connected to an inverter, that transforms 12V to 220V.

The Programming

Okay. I must admit that I am very new to electronics and programming, but this is what I got so far:

I understand that the PS2X library makes the PS2 controllers buttons available for programming. Then I will just use a lot of if statements to say, if I push the up-key on the arrow-pad, then the two pins going to motor controller will be HIGH and the ROV will turn on the two side motors and the ROV will go forward. If I push the left or the right buttons on the arrow-pad the arduino opens for the right digitaloutput pins and the motors will spin acordingly. Then I will have to make sure that if I push both the forward or backward and one of the side arrow-keys, then the ROV will move forward/backward turning slightly to either side. And it is here that I need the PWM signals, so I can analogWrite a value of lets say 51 (255/5) to the one of the side motors, so it will only spin at half speed and make the ROV turn slowly to either side.

For diving and climbing (don't know what the right word would be) in the water I have thought of this: If I press R2 it makes the motor on top turn to one side and it will make the ROV climb. Then if I press the R3 key it will dive. Easy but I need a way of holding the ROV steady in the depth I am in. So I thought of this: Before I dive into the deep, I put my ROV in the water. Then I use the L2 and L3 to make it neutral boyanced. This is done by sending a PWM signal to the motor controller of the top motor and by each press of the L3 it will speed up a little. I thought of increasing speed at 10 each time (analog signal is 0 to 255 right..?). So there will be 25,5 steps from motor turned off to motor at full speed. If the increments isnt enough, I just change it to a lower. The idea is then, that when I put the ROV in the water and push a few times on the L3 button it will be neutral boyanced. It will then continue running at that speed. If I press the R3 or R2 buttons it will go full speed the one or the other way and when I release those buttons it will fall back to the speed set at the beginning of the dive.

The triangle button must toggle the light on and off and the rest of the buttons can be used for other things in the future. Maybe an arm, a metaldetector or something else could be cool to play with, but first I just need to get down there.


Have I forgot something.. I am sure I have, but then just ask.

My questions to you guys, if you are still reading this, is the following:
1. Can I use a cat5 cable to transfer a video-signal from the camcorder?
2. Do I have to watertighten those DC motors or can I run them as is in salt water?
3. Is my thoughts about the programming of the arduino close or have I forgot/missed something?
4. Any thoughts on how to make watertight wire seals? I have seen other threads about this, but the connectors seem very expensive.

Last but not least, is there some of my ideas that won't work? Anything that I havnt explained, I will be more than happy to elaborate.

Thanks to you all in advance and sorry for my poor english skills, but I hope you all understand what I am trying to say/write.

/Jacob

Offline JacobJTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: ROV project, advice, brain storm and help needed
« Reply #1 on: May 20, 2012, 02:13:43 PM »
Tomorrow I will try to upload the code I intend to use. As I said, I have never made a program for the arduino before, so any advice or help is very much appreciated.

Code is comming here:


Offline JacobJTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: ROV project, advice, brain storm and help needed
« Reply #2 on: May 21, 2012, 01:40:20 PM »
Okay, as I said before, I am very new to arduino and programming and tbh. this is my first sketch. I tried to verify it and that turned out fine, but that I am sure isnt something that tells you if this will work in real life. So if you guys can see anything wrong in the coding I would be glad to know.

Also I don't know if the code will work of if I need some other checkings or failsafes to account for any errors in the field test.

Code: [Select]
/* ROV controller sketch. PS2X library by Bill Porter used.

What needs to be done
 - hmmm

*/

#include <PS2X_lib.h>  //for v1.6

PS2X ps2x; // create PS2 Controller Class

//right now, the library does NOT support hot pluggable controllers, meaning
//you must always either restart your Arduino after you conect the controller,
//or call config_gamepad(pins) again after connecting the controller.
int error = 0;
byte type = 0;
byte vibrate = 0;

//Motor1 is the right motor, when you look at the ROV from its front. Motor2 is the left motor. Motor3 is the top-motor.

int M1forwardPin = 0;            //To input1 on the first L293D chip
int M1backwardPin = 1;           //To input2, changes the direction of motor1
int PWM_M1_Pin = 3;              //To enable1 on the first L293D chip. Maybe the bank-motors PWM will also be connected here.

int M2forwardPin = 2;            //To input3
int M2backwardPin = 4;           //To input4
int PWM_M2_Pin = 5;              //To enable2 on the first L293D

int M3upPin = 7;                 //To input1 on second L293D chip
int M3downPin = 8;               //To input2
int PWM_M3_Pin = 6;              //To enable1 on the second L293D chip

int steerfactor = 1.5;           // 255/steerfactor = turn speed when going forward or backwards at the same time a side is pressed
int idle = 0;                    // This is the analog value for the PWM on motor3
int diveIncrement = 10;          // The analog value that the will increase or decrease the idle value
//int bankleftPin = 8;
//int bankrightPin = 9;


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

 //CHANGES for v1.6 HERE!!! **************PAY ATTENTION*************
 
 error = ps2x.config_gamepad(13,11,10,12, false, false);   //setup pins and settings:  GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
 
 if(error == 0){
   Serial.println("Found Controller, configured successful");
   Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;");
   Serial.println("holding L1 or R1 will print out the analog stick values.");
   Serial.println("Go to [url=http://www.billporter.info]www.billporter.info[/url] for updates and to report bugs.");
 }
   
  else if(error == 1)
   Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit [url=http://www.billporter.info]www.billporter.info[/url] for troubleshooting tips");
   
  else if(error == 2)
   Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit [url=http://www.billporter.info]www.billporter.info[/url] for troubleshooting tips");
   
  else if(error == 3)
   Serial.println("Controller refusing to enter Pressures mode, may not support it. ");
   
   //Serial.print(ps2x.Analog(1), HEX);
   
   type = ps2x.readType();
     switch(type) {
       case 0:
        Serial.println("Unknown Controller type");
       break;
       case 1:
        Serial.println("DualShock Controller Found");
       break;
     }
     
pinMode(M1forwardPin, OUTPUT);
pinMode(M1backwardPin, OUTPUT);
pinMode(M2forwardPin, OUTPUT);
pinMode(M2backwardPin, OUTPUT);
pinMode(M3upPin, OUTPUT);
pinMode(M3downPin, OUTPUT);
pinMode(PWM_M1_Pin, OUTPUT);
pinMode(PWM_M2_Pin, OUTPUT);
pinMode(PWM_M3_Pin, OUTPUT);


//pinMode(bankrightPin, OUTPUT);
//pinMode(bankleftPin, OUTPUT);
}



void loop()
{
//needed for the PS2X library

if(error == 1) //skip loop if no controller found
  return;
 
ps2x.read_gamepad();          //read controller


       analogWrite(PWM_M1_Pin, 255);            //Goes to enable1 and makes the first pair of input pins on the first L293D chip live
       analogWrite(PWM_M2_Pin, 255);            //Goes to enable2 and makes the second pair of input pins on the first L293D chip live
       analogWrite(PWM_M3_Pin, idle);           //Goes to enable1 and makes the first pair of input pins on the second L293D chip live

      if(ps2x.Button(PSB_PAD_UP)) {             //will be TRUE as long as button is pressed
       digitalWrite(M1forwardPin, HIGH);        //Motor1 og Motor2 turns and make the ROV go forward
       digitalWrite(M2forwardPin, HIGH);
        Serial.print("ROV forward");
        Serial.println(ps2x.Analog(PSAB_PAD_UP), DEC);
        }
      if(ps2x.Button(PSB_PAD_RIGHT)){
       digitalWrite(M1forwardPin, HIGH);        //Motor1 drives forward, Motor2 backwards, which makes the ROV turn to the right
       digitalWrite(M2backwardPin, HIGH);
        Serial.print("ROV right turn");
        Serial.println(ps2x.Analog(PSAB_PAD_RIGHT), DEC);
        }
      if(ps2x.Button(PSB_PAD_LEFT)){
       digitalWrite(M1backwardPin, HIGH);        //Motor2 now drives forward, Motor1 backwards, which makes the ROV turn to the left
       digitalWrite(M2forwardPin, HIGH);
        Serial.print("ROV left turn");
        Serial.println(ps2x.Analog(PSAB_PAD_LEFT), DEC);
        }
      if(ps2x.Button(PSB_PAD_DOWN)){
       digitalWrite(M1backwardPin, HIGH);        //Motor1 and Motor2 turns on and make the ROV go backwards
       digitalWrite(M2backwardPin, HIGH);
       Serial.print("ROV backward");
       Serial.println(ps2x.Analog(PSAB_PAD_DOWN), DEC);
        }
     
      //Up and right key pressed at the same time makes the ROV go forward, turning slightly to the right.
       if((ps2x.Button(PSB_PAD_UP)) && (ps2x.Button(PSB_PAD_RIGHT))){
       digitalWrite(M1forwardPin, HIGH);                  //Motor1 goes forward
       digitalWrite(M2forwardPin, HIGH);                  //Motor2 goes forward
       analogWrite(PWM_M2_Pin, (255/steerfactor));        //Motor2 tho running at limited speed
       Serial.print("ROV forward + turn right");
      }     
     
      //Up and left key pressed at the same time makes the ROV go forward, turning slightly to the left.
       if((ps2x.Button(PSB_PAD_UP)) && (ps2x.Button(PSB_PAD_LEFT))){
       digitalWrite(M1forwardPin, HIGH);                  //Motor1 goes forward
       digitalWrite(M2forwardPin, HIGH);                  //Motor2 goes forward
       analogWrite(PWM_M1_Pin, (255/steerfactor));        //Motor1 tho running at limited speed
       Serial.print("ROV forward + turn left");
      }       
     
      //Down and right key pressed at the same time makes the ROV go backward, turning slightly to the right.
       if((ps2x.Button(PSB_PAD_DOWN)) && (ps2x.Button(PSB_PAD_RIGHT))){
       digitalWrite(M1backwardPin, HIGH);                  //Motor1 goes backward
       digitalWrite(M2backwardPin, HIGH);                  //Motor2 goes backward
       analogWrite(PWM_M2_Pin, (255/steerfactor));         //Motor2 tho running at limited speed
       Serial.print("ROV backward + right");
      }     
     
      //Down and left key pressed at the same time makes the ROV go backward, turning slightly to the left.
       if((ps2x.Button(PSB_PAD_UP)) && (ps2x.Button(PSB_PAD_LEFT))){
       digitalWrite(M1backwardPin, HIGH);                  //Motor1 goes backward
       digitalWrite(M2backwardPin, HIGH);                  //Motor2 goes backward
       analogWrite(PWM_M1_Pin, (255/steerfactor));         //Motor1 tho running at limited speed
       Serial.print("ROV backward + left");
      }
     
      //FAILSAFES
     
       //Up, down and left key pressed at the same time will result in turning left
       if((ps2x.Button(PSB_PAD_UP)) && (ps2x.Button(PSB_PAD_LEFT)) && (ps2x.Button(PSB_PAD_DOWN))){
       digitalWrite(M1backwardPin, HIGH);                  //Motor2 goes backward
       digitalWrite(M2forwardPin, HIGH);                   //Motor1 goes forward
       Serial.print("Failsafe, up + down + left = left");
      }     
     
       //Up, down and right key pressed at the same time will result in turning right
       if((ps2x.Button(PSB_PAD_UP)) && (ps2x.Button(PSB_PAD_RIGHT)) && (ps2x.Button(PSB_PAD_DOWN))){
       digitalWrite(M1forwardPin, HIGH);                   //Motor2 goes forward
       digitalWrite(M2backwardPin, HIGH);                  //Motor1 goes backward
       Serial.print("Failsafe, up + down + right = right");
      }     
     
       //Up, right and left pressed at the same time will result in the ROV going forward
       if((ps2x.Button(PSB_PAD_UP)) && (ps2x.Button(PSB_PAD_RIGHT)) && (ps2x.Button(PSB_PAD_LEFT))){
       digitalWrite(M1forwardPin, HIGH);                  //Motor2 goes forward
       digitalWrite(M2forwardPin, HIGH);                  //Motor1 goes forward
       Serial.print("Failsafe, up + left + right = up");
      }     
     
       //Down, right and left pressed at the same time will result in the ROV going backward
       if((ps2x.Button(PSB_PAD_DOWN)) && (ps2x.Button(PSB_PAD_RIGHT)) && (ps2x.Button(PSB_PAD_LEFT))){
       digitalWrite(M1backwardPin, HIGH);                  //Motor2 goes backward
       digitalWrite(M2backwardPin, HIGH);                  //Motor1 goes backward
       Serial.print("Failsafe, down + left + right = down");
      }       
     
//divefactor
     
      //Checks if the idle variable is within the acceptable range and changes it if not.
      if (idle < 0)
      {
        idle = 0;
      }
     
      if (idle > 255)
      {
        idle = 255;
      }
     
      //If L2 is pressed, the variable "idle" will increase by the value of the diveIncrement
        if(ps2x.Button(PSB_L2))
        {
         idle = idle + diveIncrement;
         Serial.println("L2 pressed, idle increase to: ");
         Serial.print(idle);
        }
     
      //If L3 is pressed, the variable "idle" will decrease by the value of the diveIncrement
        if(ps2x.Button(PSB_L3))
        {
         idle = idle - diveIncrement;
         Serial.println("L3 pressed, idle decrease to: ");
         Serial.print(idle);
        }
     

     
     
      //simple up and down of the ROV with R2 and R3
     
        if(ps2x.Button(PSB_R2))        //is R2 pressed?
        {
         analogWrite (PWM_M3_Pin, 255);
         digitalWrite (M3upPin, HIGH);
         Serial.println("R2 pressed, climb at full speed");
        }
       
        else if(ps2x.Button(PSB_R3))  //Else is R3 pressed?
        {
         analogWrite (PWM_M3_Pin, 255);
         digitalWrite (M3downPin, HIGH);
         Serial.println("R3 pressed, dive at full speed");
        }
        else                            //Niether pressed? Then go back to idle-mode
        {
        //Turn m3 on
        digitalWrite (M3downPin, HIGH);
        analogWrite (PWM_M3_Pin, idle);
        }
     
 delay(50);
}

Offline mstacho

  • Supreme Robot
  • *****
  • Posts: 375
  • Helpful? 10
Re: ROV project, advice, brain storm and help needed
« Reply #3 on: May 23, 2012, 06:56:00 AM »
Hm, got to this one a bit late.   Truth is that this is about 40 topics in one :-P May I suggest you simplify, working on one part of the project at a time, and getting ideas in smaller chunks?

From a quick glance: yes, the L293D can handle PWM inputs.  But you need to use 2 PWM inputs per motor, one for forward, one for reverse.  If you want to save PWM pins, you can rig up a simple logic circuit.  Basically, if I have two inputs, A and B, then driving forward means A is high and B is low, and driving backwards is the opposite.  So if you make a simple logic circuit (AND gates and a NOT gate or two...) you can have one digital pin enabling/disabling the inputs, and then pass PWM through the enabled one.

EVEN EASIER: buy a breakout board motor controller.  They essentially do this for you.

MIKE
Current project: tactile sensing systems for multifingered robot hands

 


Get Your Ad Here