Go Down

Topic: Arduino nano with drone motors using ESC (Read 155 times) previous topic - next topic

Mihemine

Hello,

I used to own a drone I really enjoyed for it's easy electronics but had to return it for a variety of reasons, and have now built my own setup (that isn't a drone but uses drone components) with an arduino nano, 3 RS30A racestar esc's and 3 DYS brushless motors and a 4s batt.

Everything is plugged in, the ESC's do the 3 beeps they are supposed to but I can't seem to find code to control the motors (previously I had a dedicated controller that I just copy-pasted code for).

I can't seem to find anything online about how I should talk to the ESC's (PWM frequency, pulse length)(I am not a pro).

I understand that throttle is set via a PWM signal with a varying duty cycle but have no idea how to apply this to code.

These are the ordered ESC's http://www.racerstar.com/Racerstar-RS30A-Lite-BB1-ESC-p-71.html

I can't seem to find a manual on line, but I have the paper copy. The useful information I can see might be the following :

Submitted under motors because it seemed the most appropriate :)

Thank you!

alka

#1
Mar 19, 2017, 10:45 pm Last Edit: Mar 20, 2017, 12:26 am by alka
The multiwii project is a good start. It's an Arduino program to control multirotors. It's a bit older now but still works very well.

With three motors you will need a servo as well to control yaw.

It all hinges on the gyro providing the feedback for stability. A critical part of any multirotor.

To just control the esc's you can use the servo library.


Mihemine

What I get from this code (I've tried a few variations with the same results) is just the two beeps of calibration but no movement at all

Code: [Select]

# include <Servo.h>
int value = 0;
Servo m1;

void setup () {
  m1.attach(3);
  delay(1);
  m1.write(10);
  delay(200);
  m1.write(100);
  delay(1000);
  }

void loop() {
    m1.write(10);
    delay(10);
    m1.write(80);
    }

alka

#3
Mar 21, 2017, 01:23 am Last Edit: Mar 21, 2017, 01:24 am by alka
Are you trying to arm the esc or calibrate? It's unclear from.your code.

To calibrate starting sending a high signal on power up (180) untill you hear two beeps then send a low signal (0)  you should hear another beep followed by a long beep indicating it's armed.

You don't need to calibrate however, you can just use m1.write(1000) in setup for as long as it needs to arm. (Up to 2 seconds).

I don't like the look of the main loop though, this esc has active braking you are changing throttle by a large jump every 10 milliseconds. Will break something pretty quickly.


Mihemine

Hello,
I was playing around with the values in the loop to try and get my motor to do something
The noises are a beep beep beep (3 different pitches, one low, medium, high) then another long low, then long high and then nothing.

I can't get the motors to move at all and this is where I'm stuck.

Do you have any tutorials you can recommend ? Once I get the motors working in a state where I can set the speed through code then I'm golden as the rest of the code is easier

Thanks for your answer ! :)


alka

Hello,
I was playing around with the values in the loop to try and get my motor to do something
The noises are a beep beep beep (3 different pitches, one low, medium, high) then another long low, then long high and then nothing.

I can't get the motors to move at all and this is where I'm stuck.

Do you have any tutorials you can recommend ? Once I get the motors working in a state where I can set the speed through code then I'm golden as the rest of the code is easier

Thanks for your answer ! :)


After the esc has been armed ( after the long solid beep while getting a 1000us signal) you THEN should be able to give other values to actually spin the motor... The signal should not be interrupted.. the esc should always be getting some type of signal otherwise it will require arming again. 

your loop as written above does nothing except give the esc the same "m1.write(10);" again and again. This would not make the motor start.
 
If you think this is the tricky part of the code for controlling a multi-rotor then you are in for shock!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy