Home        Store        Docs        Blog

Controlling 6 Brushless Motors with a controller through Arduino

I am currently working on a control system to drive 6 t100 brushless motors with an xbox controller (but could 3d print one if needed) on an underwater rov. I am trying to use an arduino to control all the motors but all tutorials i have seen require the controller to be connected to a laptop which is connected to the arduino. I don’t want to do this as the ardunio is going to be in an airtight tube on the rov and would much rather a direct connection to the arduino. Is this possible with a usb controller and would it require a shield to work?

Hi Kyle,

This is because your Arduino cannot act as a USB OTG host - i.e. it can’t run all the drivers necessary to interpret the USB signals from the gamepad. You would need something like an STM32 to achieve that. Even then, writing the code will be challenging if you are new to 32-bit MCU’s.

Whereas it’s pretty easy to read gamepad commands on a PC and resend them as USB HID data to and Arduino.

The solution would be to build yourself a custom controller - which is also pretty easy with and Arduino.

SROV

Thanks for the reply, i have already switched to two joysticks that i’ve connected to the arduino but i’m having issues with the initialization of the motors. I am sending the stop signal from the arduino for 8 seconds and then sending a signal of 1700microsecs to the esc but it is not working. I keep getting the fifth low beep awhile after the first four beeps and the motor isn’t turning.
Thanks.

Which Arduino are you using?

Arduino uno

You may be asking to much out of the Arduino uno I’m using an Arduino M0 that I make myself and even though it is probably some 5 times more powerful than an Uno I’ve started to find its limitations but it works fine for my Xbee remote control application, I’ll see if I can send you the Xbee remote control code maybe you can use parts of it, Just remember to comment out or erase SerialUSB function if you are gone use it on an Uno.

/*
APteck

Written By: Anthony Pirotta.
Date: 26/04/2017.
Revised: 1/09/2019.
Name Of Code: RobBoat Receiver.
Written For: Neutrino or any other ATSAMD21G18 microcontroller board.
Purpose Of Code: Xbee receiver.
*/

#include <Wire.h>
#include <SPI.h>
#include <Servo.h>

//Servo objects.
Servo one;
Servo two;
Servo three;
Servo four;

int B = 90;

//Integers for left stick.
int L_stick_x = 0;
int L_stick_y = 0;

//Integers for right stick.
int R_stick_y = 0;
int R_stick_x = 0;

//Switch values.
int Switchs = 0;

//Toggle state values.
int state2 = 0;
int old_val2 = 0;
int state3 = 0;
int old_val3 = 0;

//Triggers autonomous mode if there is no signal from Xbee.
int NO_SIG = 0;

//Vehicle battery power level.
float V_PowerL = 0;
int VoltageSensor = 0;

void setup() {

SerialUSB.begin(9600); //For USB laptop/PC debugging.

Serial.begin(9600); //To/From Xbee module.

Serial1.begin(9600); //GPS or any other UART device.

pinMode(7, OUTPUT); //On/Off output.

pinMode(8, OUTPUT); //On/Off output.

pinMode(9, OUTPUT); //On/Off output.

pinMode(4, OUTPUT); //On/Off output.

one.attach(11); //Attach servo to…

two.attach(12); //Attach servo to…

three.attach(5); //Attach servo to…

four.attach(6); //Attach servo to…

one.writeMicroseconds(1500); // send “stop” signal to ESC.
delay(7000); // delay to allow the ESC to recognize the stopped signal

}

void loop() {

VoltageSensor = map(analogRead(A0), 737, 942, 0, 100);

//Send data to receiver.
Serial.print(VoltageSensor);
Serial.println(’\n’);

//Get data from Xbee.
if(Serial.available()>0){

if(Serial.read() == ‘\n’){

L_stick_y = Serial.parseInt();

L_stick_x = Serial.parseInt();

NO_SIG = false;

}
//If no data from Xbee.
}else{

L_stick_y = 90; //Set servo in center position.

L_stick_x = 1500
; //Turn motor off.

NO_SIG = true;

}

one.writeMicroseconds(L_stick_x);

two.write(L_stick_y);

//SerialUSB.println(L_stick_y);

} //END