Help coding 3 motor ROV
Posted: Apr 16th, 2019, 11:10 am
Hi, Im helping to build an ROV for a local competition but have ran into some difficulty. My role is to provide code to help the motors operate. The motors will run off of 3, 2 input H-bridges with mosfets…
How many pwm pins should the rov need per motor? Ive been told from some people that each motor should require 2 pwm pins (Forward & Back), although ive heard from another source that each motor should have 4 pins.
FYI the ROV is to be controlled by 2 Joysticks, the left joystick will control the forwards and backwards motion of the rov when pressed up&down, and will control the vertical motion of the rov when pushed left/right. The right joystick will turn the rov.
#include <Servo.h>
// Joystick Settings
static const int JS_CENTER_0 = 511; // Analog reading at center, 0-1023
static const int JS_CENTER_1 = 511;
static const int JS_CENTER_2 = 511;
static const int JS_RANGE_0 = 128; // Analog range, 0-1023
static const int JS_RANGE_1 = 128; //
static const int JS_RANGE_2 = 128;
static const int JS_DIR_0 = 1; // +1 or -1
static const int JS_DIR_1 = 1;
static const int JS_DIR_2 = 1;
// Arduino Pins
static const byte JS_ADC_0 = A0;
static const byte JS_ADC_1 = A1;
static const byte JS_ADC_2 = A2;
static const byte THRUSTER_LEFT_FWD = 9;
static const byte THRUSTER_LEFT_REV = 5;
static const byte THRUSTER_RIGHT_FWD = 3;
static const byte THRUSTER_RIGHT_REV = 10;
static const byte THRUSTER_VERTICAL_UP = 11;
static const byte THRUSTER_VERTICAL_DOWN = 12;
// Servos
Servo thrusterLeftForward;
Servo thrusterLeftReverse;
Servo thrusterRightForward;
Servo thrusterRightReverse;
Servo thrusterVerticalUp;
Servo thrusterVerticalDown;
That’s the code I have so far, If anyone has any tips on where to go now then that would be really helpful.
How many pwm pins should the rov need per motor? Ive been told from some people that each motor should require 2 pwm pins (Forward & Back), although ive heard from another source that each motor should have 4 pins.
FYI the ROV is to be controlled by 2 Joysticks, the left joystick will control the forwards and backwards motion of the rov when pressed up&down, and will control the vertical motion of the rov when pushed left/right. The right joystick will turn the rov.
#include <Servo.h>
// Joystick Settings
static const int JS_CENTER_0 = 511; // Analog reading at center, 0-1023
static const int JS_CENTER_1 = 511;
static const int JS_CENTER_2 = 511;
static const int JS_RANGE_0 = 128; // Analog range, 0-1023
static const int JS_RANGE_1 = 128; //
static const int JS_RANGE_2 = 128;
static const int JS_DIR_0 = 1; // +1 or -1
static const int JS_DIR_1 = 1;
static const int JS_DIR_2 = 1;
// Arduino Pins
static const byte JS_ADC_0 = A0;
static const byte JS_ADC_1 = A1;
static const byte JS_ADC_2 = A2;
static const byte THRUSTER_LEFT_FWD = 9;
static const byte THRUSTER_LEFT_REV = 5;
static const byte THRUSTER_RIGHT_FWD = 3;
static const byte THRUSTER_RIGHT_REV = 10;
static const byte THRUSTER_VERTICAL_UP = 11;
static const byte THRUSTER_VERTICAL_DOWN = 12;
// Servos
Servo thrusterLeftForward;
Servo thrusterLeftReverse;
Servo thrusterRightForward;
Servo thrusterRightReverse;
Servo thrusterVerticalUp;
Servo thrusterVerticalDown;
That’s the code I have so far, If anyone has any tips on where to go now then that would be really helpful.