we are having trouble using the Basic ESC with a Raspberry Pi 2 Model B. We have successfully used the ESC with an Arduino to control a T100 motor. However, our design plans make the Raspberry Pi necessary. Any help with the PWM and software would be greatly appreciated!
Thanks for the reply, here is the code we’ve come up with. It uses PWM at a frequency of 50Hz, and we’ve calculated the duty cycles for forward, reverse, and stopped at 9.5%, 5.5%, and 7.5%. Let us know what you think!
Thanks for sharing your code. I’ve been looking in the GPIO library that you are using, “RPi.GPIO”, and it looks like that might be the issue. That library uses “software PWM” meaning that the timing for the PWM signal is managed by the main processor instead of a dedicated timer. That makes it relatively inaccurate.
If you have an oscilloscope, I’d recommend checking the outputs. Most likely they are not exactly what they are supposed to be. When the ESC starts, it needs to be initialized at 1500 µs (+/- 25 µs) and it might not be in that range.
Our results are not great. We tried using the other library you linked, and had little success with operating the ESC. It would initiate, and we were able to send forward/reverse signals to operate the T100, but the library is very unreliable. Any quick changes to the pulse would cause glitchy movement in the T100; we never encountered this erratic movement using Arduino. Also we do have a spare PCA9685 Board from Adafruit (Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface [PCA9685] : ID 815 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits) however we’ve had no success with that either.
Do you have access to an oscilloscope? That would really help to verify what’s going on here. I can give your code a shot early next week and see how it looks.
What have you tried with the Adafruit board? I believe there is a scaling issue in there that causes the pulses to be a little wider than expected. I think you should be able to get a decent pulse from the Adafruit board but you might have to multiple the input by a factor like 0.9. In fact, in their Arduino version of the library, they added the scaling factor in (Fix #11 by scaling frequency by 0.9. · adafruit/Adafruit-PWM-Servo-Driver-Library@02ab36e · GitHub), but that seems to be missing from the Raspberry Pi version. You might try that and see if it works.
Unfortunately, we do not have access to an oscilloscope in our local area (Although it would be cool!!). We didn’t have much luck with multiplying the signal by a factor of 0.9 either. Still no initiation of the Basic ESC. Tell us what you think of the code we’ve attached.
Okay. If you have an Arduino available you can use the “pulseIn” function to check the pulse width that’s being output and make sure it is correct. Here’s an example: https://www.arduino.cc/en/Reference/PulseIn
I looked at your code and the Adafruit library. The 0.9 correction is actually for the frequency, not the input signal. You might try pwm.setFreq(int(60*0.9)) instead and see if that helps.
If that doesn’t work, I have the same board sitting at the office and I can try your code our tomorrow with an oscilloscope.
It works!! Using the pulseIn() function on the Arduino was a great help; we used it to more accurately pinpoint the correct signal we needed to send from the Adafruit board. We’ve uploaded a copy of the code if you want to take a look.
Thanks so much for helping, we are really grateful for your support!