Question about brushless motor PWM response

Hi all,

I am quite new to using motors and PWM signals in general so I am struggling to understand the response of my motors. I have looked around which has helped me understand certain aspects such as the duty cycle, but I can't quite understand why my motors are behaving in the way that they are.

I am currently trying to build a quadcopter and know that the Arduino mega 2560 (the board I am using for this) has 490Hz PWM on certain pins. As I understand it a motor can be driven using analogWrite, which has a range of 0 to 255, 0 being 0% duty cycle and 255 is 100% duty cycle. I have a simonk 30A ESC connected between the Arduino and the Motor (A2212/13T -1000KV), see attached diagram (I made up some of the blocks, but it should be representative. Note I have also powered the Arduino using the USB input instead too with no effect).

As output pin 5 is a 490Hz PWM, that would be a 2000us period. I thought that motors tended to respond between the region of 1000us to 2000us. However, when I went to drive the motor I found that the motors only responded in a around 3% of the analogWrite range (i.e. values of between 20 - 30 as an input to analogWrite). Approximately, at an input of 20, the motor would be at its minimum spin, at 30 it would be pretty much max. To me, this is a Ton time of 156us for the lower range and 236us for the upper range (?). Beyond this range, the motor would eventually just stop, I get no where near 255.

To keep it as simple as possible, I am simply trying to understand why my motor responds between input values of 20 - 30 rather than 0 - 255 in this code pasted below:

int motor = 5;      
int val = 0;        

void setup() {
  pinMode(motor, OUTPUT);  
  Serial.begin(9600); 
}

void loop() {
  while (val < 255) { //Simply stepping up through the range, watching the motor.
  analogWrite(motor, val); 
  delay(1000);
  val = val + 1;
  Serial.print(val);
  }
}

Just as a parts list:

Any advice would be much appreciated! I can normalise the response within this range if I have to, but I would just like to understand why this operating range is the case. Let me know if I've left any vital info out.

Thanks

Edit: https://photos.app.goo.gl/xQrhXsFc6MqdStbz7 photo wouldn't upload.

ESCs are normally driven using the Servo library (at 20Hz). If that ESC is supposed to work at 490Hz (I've never met one that does) then I would guess that the signal range is NOT 1000 to 2000. You probably need to ask somewhere that knows the SimonK firmware in detail.

It might be interesting to try the Knob example from the IDE which does use the Servo library and see how the ESC responds to that.

Steve

For quadcopter you want to track down a library equivalent to Servo but with a more frequent update rate. That 20Hz rate is going to destabilize control loops. I'm sure I've seen such libraries mentioned before.

Hi jwalkera,

Here's a link to some code that controls 12 servos at 50Hz, using the Mega's timers 1, 3, 4 and 5. The code can be modified to run at 490Hz with ESCs by simply chaning the ICRx registers from 20000 to 2039: controlling an array of 10 servos - Robotics - Arduino Forum.

PWM frequency = 16MHz / (2 * 8 * (2039 + 1)) = 490Hz

This method gives a higher PWM resolution at 11-bits (log(2039 + 1)/log(2)), while analogWrite() only provides 8-bits.

Loading the appropriate OCRxx register generates an equivalent pulse in microseconds at 490Hz, therefore 1000 = 1000us (ESC standby), 1500 = 1500us (ESC mid throttle), 2000 = 2000us (ESC full throttle). Note that these values are only approximate, as it's usually necessary to calibrate the ESCs against RC receiver's throttle output. For example, a traditional Spektrum RC receiver's throttle output will range between roughly 1100us and 1900us. The ESCs are calibrated so that they also expect standby to be at 1100us and full throttle at 1900us.

Warning: Please test with the propellers removed.