RC Groups

RC Groups
    Multirotor Talk
        Help! Controlling Brushless Motor through ESC using Arduino

#1 Skriptkid Jun 25, 2012 09:12 AM

Controlling Brushless Motor through ESC using Arduino
 
Hey,
I have a brushless motor and ESC, which I'm trying to control using an Arduino Uno for my first quadrotor project. And I'm failing miserably, which is why I'm here. I tried connecting the Arduino to the ESC and using the Servo library, but it didn't work. I even tried sending 10 pulses of width 1ms, with an interval of 20ms, but that didn't work either. All I get are three continuous short beeps on power and then short single beeps. I'm probably not able to even arm the ESC. This is the motor I'm using(Emax CF2822): http://www.yinyanmodel.com/En/ProductView.asp?ID=58 This is the Red Brick ESC's manual(Mine's the 20Amp Aircraft one, with Ni-MH and LiPo Auto-detect. Table 1.1): http://www.hobbyking.com/hobbyking/s...2X53414X39.pdf It's meant for an RC receiver and I have no idea how I can emulate one through my Arduino. All in all, I'm totally blank. If anybody could please help, I'd be real grateful. It'd be great if I could get the Arduino code also.

Thanks a lot. :)

#2 leprud Jun 25, 2012 10:37 AM

At power-up, you need to send 1ms pulse to "init" ESC for couple of seconds (usually, until you here starting sounds, like three continuous short beeps in your case). Only after that you can increase pulse up to 2ms (for full throttle). It's preprogrammed in ESC, as you can mistakenly power up ESC with your throttle signal not in lowest position.

PS Hope, you are trying without prop?

#3 Skriptkid Jun 25, 2012 10:44 AM

Yes, I'm trying without props. :) And I tried doing what you said(sending a 1ms and then increasing throttle.) But it still doesnt spin. When I connect the ESC to the battery, I hear three beeps and then short single beeps of every 1s. Could you please give me the code? That would make me understand much better.

#4 leprud Jun 25, 2012 10:53 AM

Actually, single beeps indicate either not 1ms pulse, or lack of pulses!
If all connections are right then, you can try this code http://www.rcgroups.com/forums/showp...7&postcount=21
Also, please see post 24 in the same thread. It's related to "throttle range calibration" setting in particular ESC

#5 Skriptkid Jun 25, 2012 11:10 AM

Oh, okay :) Thanks a lot, Leprud. Really helped :)

#6 leprud Jun 25, 2012 11:18 AM

:D
Please post success story soon!

#7 Skriptkid Jun 26, 2012 06:56 AM

No success :(
This is my code:

#include <Servo.h>

Servo esc;
int j;

void setup()
{
delay(5000); //Delay to give me enough time to control esc to battery
esc.attach(9);

for(int i=0; i<1000; i++) //Arming
{
esc.write(0);
delay(20);
}
}

void loop()
{
for(j=0; j<180; j++) //Running the motor
{
esc.write(j);
}
for(j=180; j>=0; j--)
{
esc.write(j);
}
}

It beeps till the setup() is done. and then goes blank.

#8 leprud Jun 26, 2012 07:00 AM

Double checked connections? Maybe post a picture?

Also, instead of
Quote:

for(int i=0; i<1000; i++) //Arming
{
esc.write(0);
delay(20);
try

Quote:

for(int i=0; i<1000; i++) //Arming
{
esc.write(45);
delay(20);
as mentioned in thread i linked

#9 Skriptkid Jun 26, 2012 07:20 AM

3 Attachment(s)
I tried the code you gave. It goes "beep beep beep" continously turning just slightly. And I've attached the pictures.

#10 TS00 Jun 26, 2012 07:25 AM

Please say you aren't powering that ESC from a PP3 battery...

#11 Skriptkid Jun 26, 2012 07:28 AM

Currenlt, yes. I'm trying with the 9V battery :o

#12 TS00 Jun 26, 2012 07:29 AM

Use something that can deliver more current. That battery will cause you problems, and is unlikely to ever run the motor.

#13 Skriptkid Jun 26, 2012 07:31 AM

So can that be the cause my motor isn't running? I'll use NiMH or LiPo(As it's writtent on the ESC.)

#14 TS00 Jun 26, 2012 07:35 AM

I'm not saying it's the only cause, but it's almost certainly one of the causes.

First, a PP3 won't deliver enough current - the voltage will drop very low as soon as the ESC puts a load on it.

Second, most ESCs (I don't know for certain that yours does) detect the voltage and try to figure out the battery type from the voltage (multiple of 1.2 or 3.7). They then cut off when the voltage drops below a preset level. So when you connect a 9V PP3, if your ESC is in NiMH mode it will think you have a weak 8-cell pack attached. It will cut out as soon as the voltage drops to ~7.5V, which it will do instantly.

#15 Skriptkid Jun 26, 2012 07:38 AM

:eek: Oh...okay. thanks TS00 :D I'll try using an NiMH. But is the code fine for running it?


All times are GMT -5. The time now is 10:26 PM.