Go Down

Topic: ESC  (Read 362 times) previous topic - next topic

Michaelboeding

Jul 14, 2019, 06:35 am Last Edit: Jul 14, 2019, 07:19 pm by Michaelboeding Reason: add more information
--------------------------------------

EDITED:

I have attached my code, what you will most likely want to look at is the armMotor() function, but I figured I'd include it all incase something was wrong.

My signal wire for the ESC is connected to pin 9 so the esc/motor is named m1.

I am using a 4S battery attached to a relay that supplies power to the ESC(see picture).

I have also attached an image of my setup, and the manual for the ESCs. Any help is appreciated, thanks!


The other functions and stuff is just sensor/radio setup and its still a it of a mess since I've been trying to set everything up.


--------------------------------------


Hi I'm pretty new to Arduino and in the process of making a drone, but I've come across a problem.

I bought some 30 amp ESCs and have been working on controlling my motor with them. After awhile I was able to get them armed by using the servo motor library, but once it's running I can't write new speeds to it....such as

ESC.writeMicroseconds(1200); etc

It stays at a constant speed no matter what values I feed it.

There's a throttle calibration section in the manual for the ESCs but it isn't very specific and is based off of BHeli Suite, which I have no idea what that is. I'm trying to do everything through Arduino code.


From all the tutorials I've seen they just feed in different data and it works, any ideas why mine stays at a constant speed? Thanks








Robin2

There's a throttle calibration section in the manual for the ESCs but it isn't very specific
It must be a lot more specific in your hands than the manual that we cannot see and your test program that we cannot see.

Post a link to the manual and post your test program.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

slipstick

So show us the Arduino code you've been trying. Also how a circuit diagram showing how everything is connected and powered. And more details of the ESCs than just "30A" might also be useful.

It's quite difficult to diagnose problems with no real information. It could be insufficient power or bad connections or wrong code or even something like trying to connect high current devices via a breadboard.

Steve

Michaelboeding

So show us the Arduino code you've been trying. Also how a circuit diagram showing how everything is connected and powered. And more details of the ESCs than just "30A" might also be useful.

It's quite difficult to diagnose problems with no real information. It could be insufficient power or bad connections or wrong code or even something like trying to connect high current devices via a breadboard.

Steve
It must be a lot more specific in your hands than the manual that we cannot see and your test program that we cannot see.

Post a link to the manual and post your test program.

...R
I have updated my original post with more information, if you need anything else let me know. Thanks

slipstick

I've never seen anyone using a relay to switch power to an ESC. On a drone it would just be adding extra weight and failure points. What's the reason for doing that? What is the specification of that relay?

Sorry but you have far too much code that is commented out making it seriously difficult to work out what's going on. You really need to write (and post here inline so it's easier to read) a simple test program with just the motor running code and which shows the problem.

Your arming sequence is like nothing I've ever seen before but if you're getting the correct beeps from the motor then I guess it must be o.k.

Steve

slipstick

I've never seen anyone using a relay to switch power to an ESC. On a drone it would just be adding extra weight and failure points. What's the reason for doing that? What is the specification of that relay?

Sorry but you have far too much code that is commented out making it seriously difficult to work out what's going on. You really need to write (and post here inline so it's easier to read) a simple test program with just the motor running code and which shows the problem.

Your arming sequence is like nothing I've ever seen before but if you're getting the correct beeps from the motor then I guess it must be o.k.

Steve

Robin2

I have updated my original post with more information, if you need anything else let me know. Thanks
Please don't require people to re-read earlier Posts in a Thread. Put new material in a new Reply in the proper chronological order so people can simply read the Thread from top to bottom.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Michaelboeding

#7
Jul 14, 2019, 09:55 pm Last Edit: Jul 14, 2019, 10:36 pm by Michaelboeding
Heres the code with just the servo and motor in it, I'm using a relay so that I don't pass 14.8V from the battery through my Arduino, I may change this when I have everything working but for now it allows me to turn the battery on and off for the arming sequence when I was trying to figure out the correct sequence/times.


The throttle calibration part of the manual I haven't been able to replicate, but it says the default is a 1000-2000us signial so I think im ok there.

And just to repeat myself it does work but it will not change speed, it stays at a constant speed even if I write a different speed amount to it.

Thanks



Code: [Select]



#include <Servo.h>

//init relay pin and ESC
 int relay = 8;
 Servo m1;


void armMotor(){
//turns the relay on
digitalWrite(relay, HIGH);
Serial.print("Beggining arming sequence\n");
delay(2000);
m1.write(1400);
Serial.print("Throttle signial sent\n");
delay(2000);
Serial.print("Zero throttle signial sent\n");
m1.write(1000);
delay(2000);
Serial.print("Motor is ready, arming sequence complete\n");
}



void motorOFF(){
//turns the relay off
Serial.print("OFF\n");
digitalWrite(relay, LOW);
delay(3000);
}

void setup() {
// put your setup code here, to run once:

//attachs the esc with the digital 9 pin, min and max value.
m1.attach(9,1000,2000);





}





void loop() {
// put your main code here, to run repeatedly:


  //arms the motor
armMotor();


 

//turns the motor off
motorOFF();


}

jremington

Please edit your post to add code tags ("</>" button).

slipstick

In your latest code you don't write anything to the ESC after it is armed. The last write is 1000 so the motor shouldn't be running at all. What actually happens and what beeps are you getting from the motor (should be 4 short and 2 long I think).

Steve

Michaelboeding

In your latest code you don't write anything to the ESC after it is armed. The last write is 1000 so the motor shouldn't be running at all. What actually happens and what beeps are you getting from the motor (should be 4 short and 2 long I think).

Steve
What actually happens is I get the beeps that the arming sequence details in the manual(attached to previous post). I get the three power up beeps, a lower tone beep (throttle signial detected), and then I get high pitch beep and then the motor will run for (in this current case) 2 seconds. Then the relay will turn the device off, and it will start the process again. So i beleive that my arming sequence is correct, but you are also correct in saying that the motor shouldnt run, because I wrote 1000 to the device, which should be 0% motor speed.....but it still runs at the same constant speed.


Do I need to do some sort of throttle calibration? The manual details another sequence for throttle calibration but I can't seem to replicate it...but is it even neccessary?


The manual also talks about some software Bheil Suite or something like that to use for calibration, do I need to use the software to set throttle calibration values? (Id rather do it in my arduino code if possible)

Thanks





vinceherman

Some comments on your code:
Auto Format (under the tools menu or CTRL-T) makes the code much easier to read
Remove extra blank lines - makes the code easier to read
Move the call to the arming routine to the setup.  It only needs to run once.

I do not like that the motor is running with low throttle (1000).  I wonder if you should write 1000 to the ESC just before you attach.

Michaelboeding

Some comments on your code:
Auto Format (under the tools menu or CTRL-T) makes the code much easier to read
Remove extra blank lines - makes the code easier to read
Move the call to the arming routine to the setup.  It only needs to run once.

I do not like that the motor is running with low throttle (1000).  I wonder if you should write 1000 to the ESC just before you attach.
I actually tried to run that code in the setup and it didn't work, its almost like it needs to run twice before it will start the motor? I believe it misses the "throttle signal detected" for some reason. Maybe this could be a problem?


But even if I wrote another value to the ESC later on it wouldn't increase/decrease speed.

vinceherman

#13
Jul 15, 2019, 09:22 pm Last Edit: Jul 15, 2019, 09:22 pm by vinceherman
If you need more steps in the arming sequence, do them in the arming routine and call it from setup().
Calling it from the loop runs it over and over and you simply do not know what is working and what is not.

What values did you write later that produced no results?

I see that you write 1400 during the arm sequence.  Any particular reason you chose that value?  I would have expected 2000 for full throttle which is how most of my ESCs arm.  Zero throttle on power up.  Wait a bit of time (1 or 2 seconds?)  Full throttle for a second or two.  Then zero throttle. 

Do you have access to a potentiometer?  Wire it up like the knob tutorial.  Have it write out the values to the serial monitor.  Use that to troubleshoot the arming procedure.

Michaelboeding

If you need more steps in the arming sequence, do them in the arming routine and call it from setup().
Calling it from the loop runs it over and over and you simply do not know what is working and what is not.

What values did you write later that produced no results?

I see that you write 1400 during the arm sequence.  Any particular reason you chose that value?  I would have expected 2000 for full throttle which is how most of my ESCs arm.  Zero throttle on power up.  Wait a bit of time (1 or 2 seconds?)  Full throttle for a second or two.  Then zero throttle. 

Do you have access to a potentiometer?  Wire it up like the knob tutorial.  Have it write out the values to the serial monitor.  Use that to troubleshoot the arming procedure.
To arm my specific ESC the sequence is(look at manual) :

Power->Throttle Signal Detected->Zero Throttle->Then motor starts


I wrote the 1400 value to be the "Throttle signial Detection" then "Zero Throttle" which is 1000.


I haven't tried using a potentiometer, but I have ran a while loop that incriments the power and then decreases the power until it is at zero throttle. So that should have done the same thing?



Go Up