# Speed Control of Brushless Motor [duplicate]

This question is an exact duplicate of:

I am working on a project(quad copter) which includes speed control of a brushless motor with raspberry pi.

To control the speed of the motor, I will use PID controller, however I could not find a way how to read rpm from ESC. I have read some articles about brushless motors and ESCs, and I understand the principle they work on. I also know that some ESCs use Back-EMF to detect which coil to power.

I have been looking for relevant article on reading motor position or directly rpm from the ESC for quite some time now, with little success. I would be grateful if someone could explain it in detail how to do it, or send a python/c/c++ code example.

## marked as duplicate by Chris Stratton, Daniel Grillo, Voltage Spike, Bence Kaulics, PeterJSep 2 '16 at 13:01

This question was marked as an exact duplicate of an existing question.

• @Barney, Please don't post duplicate questions. You need to be specific in your first question. People looked at your question and couldn't answer it because it wasn't specific enough. Edit your original question and provide the information and get it reopened. – Voltage Spike Sep 1 '16 at 16:33

## 2 Answers

You are already using a speed controller. You tell it the speed you want and it does it. It doesn't make sense to wrap that within your own control loop that tries to regulate speed. You want to wrap it in a control loop that tries to regulate something higher level, like the copter's attitude, speed, etc.

• Olin, do you live on this forum? LOL You answered before I could even submit a comment. That's what I call Fast Response! I agree - there's no point in trying to take control of the speed externally - that's the ESC's job. For a rough reference, you could measure the RPM at various throttle positions and use these values in other calculations... – Ryan Griggs Sep 1 '16 at 14:08
• @RyanGriggs Olin is very active on SE. – user86234 Sep 1 '16 at 14:09
• @tuskiomi Yes I know I'm just kidding him. :) – Ryan Griggs Sep 1 '16 at 14:09
• To the ESC i am sending PWM with a given duty-cycle. Is duty-cycle = speed of the motor even under load? I am new to the world of ESCs . I would be grateful if you could explain what you just wrote more in details.@OlinLathrop @RyanGriggs – Barney Sep 1 '16 at 14:13
• @Barn: ESC means electronic speed control. It is doing the speed controlling for you. You tell it how fast the motor should turn, and it takes care of it. If you're sending it PWM, then it may not be a speed controller, or it has some published relationship from duty cycle to speed. – Olin Lathrop Sep 1 '16 at 14:18

however i could not find a way how to read rpm from ESC.
I would be grateful if someone could explain it in details how to do it
To the ESC i am sending PWM with a given duty-cycle.

RPM can be calculated using the following formula, given the duty cycle mentioned and the type of battery you're using.

$Rpm_{motor} = (KV_{rating}) * N_{cells} *3.7_{V/cell}* \frac{DutyCycle_{us}}{2000_{us}}$

• @tuskomi : Thank you – Barney Sep 1 '16 at 14:37
• @Barney Any time. And to think that a moderator tried to delete this as they didn't think it was an answer. twice. – user86234 Sep 1 '16 at 14:46
• This is misleading, and not the formula when a deliberate speed controller is being used. If the speed controller works from duty cycle, then its documentation needs to tell you what speed you get for what duty cycle. Your formula makes a bunch of unstated assumptions, then appears to be assuming the raw PWM is applied to the motor windings with a fixed 2 ms PWM period. Again, this is misleading at best. – Olin Lathrop Sep 1 '16 at 14:47
• @OlinLathrop That's why a KV reading exists. All hobbyist brushless motors have a KV reading which will tell you How many RPM you get from a certain voltage (99.99% of the time, it's RPM/Volt). All hobbyist speed controllers are meant to adapt to the type of battery and KV rating of the motor, and use your duty cycle to control the motor based on the two. This is not misleading in the least. Given, I did assume that he was using lithium batteries for his copter, but I doubt that other batteries are even viable at this point. – user86234 Sep 1 '16 at 14:49
• @OlinLathrop all hobbyist brushless speed controllers ^ – user86234 Sep 1 '16 at 15:02