In general you can control a brushless motor using an Electronic Speed Control (ESC), as used in RC aircraft and multirotors, using the Servo library but such a motor is not really suitable to be used to control a gimbal. You would almost certainly be better off using servos which can be precisely positioned at a given angle unlike a brushless motor.
Look at RC supply sites such as HobbyKing for both ESCs and Servos
sorry i forgot to say the linked motor is a gimbal specific motor. im sure these will work together. if they do will the PWM control speed or position??
That controller looks more like it turns a brushless motor into a continuous-rotation servo. It will be controlled through the Servo.h library, not PWM.
Look up Servo.writeMicroseconds() as you're going to be using it a lot.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 1000, 2000); // scale it to use it with the servo (value between 1ms and 2ms)
myservo.writeMicroseconds(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
so what i find odd is that this says it controls position but in their videos of the controller it shows it controlling speed rather than position? is this the case? BGMC2 Precision vs Speed - YouTube
another question
map(val, 0, 1023, 1000, 2000);
after mapping is 2000 max speed clockwise and 1000 max speed anticlockwise?
I watched their video too. Yes, it does appear to be controlling speed, not position. That's why I said it seems like a continuous-rotation servo.
Not the obvious way to do it, but I think there are subtle problems when trying to control position on the brushless motor which has no defined starting position. Speed control can be made to work.
cameroneeeee:
another question
map(val, 0, 1023, 1000, 2000);
after mapping is 2000 max speed clockwise and 1000 max speed anticlockwise?
very much appreciated
No. Those numbers are microseconds. Most hobby servos use 1000us to represent zero and 2000us to represent 180 degrees. Those numbers are approximate - it may be higher or lower for a specific servo. 1500us is nominally "center" or 90 degrees but it may not be.
For a contiuous rotation servo, 1000us may command it to go to its maximum speed but you would have to experiment or read the datasheet to find out. For the average CR servo, which is a conventional servo with the feedback pot disconnected, you would hit maximum speed well before those numbers.
Recently dissmandled a gimbal from Yuneec, they use brushless motors and hall sensors to track their position. Was able to use the hall sensor but running a bldc is not easy as the pwm signals vary depending on the motor...
OK, old post, but probably as good a place as any to point out gimbal motor control is different....
Gimbal motors are typically controlled using field oriented control and position feedback - this is
advanced motor control and is done without hall sensors or absolute position information.
The magnetic field strength and angle in the motor are outputs of a control loop, the angular
error (typically from an IMU measuring orientation) is the input.
The controller unit linked in the OP can only do open-loop control and will give a fraction of the
performance of a real gimbal motor setup, in particular its positional stiffness will be very low.