I have recently switched my marine robotics project over to use the basic ESC. I was previously using the integrated BlueESC via i2c so this is the first time iv used PWM to control a thruster.
I’m using a raspberry pi, and as the pi only has one usable PWM output im using the Adafruit PCA9685 16 channel PWM board (i2c). My project is Java based and I use the Pi4J library. Ive integrated directly with i2c control values based on examples in github. I’v also found that Pi4j has built in PCA9685 support. I mention this because I’v been concerned im not setting up the right frequencies, but using the PCA9685 provider in pi4j i’m pretty sure im getting it right. I don’t have a scope to test.
Anyway, my issue is I cant seem to get the arming sequence right. The example code on the blue robotics shows a simple 1500 us pulse for 1 second to arm, then switch to 1700 to drive. When I do this I get the low tone for arming start but only get the high tone when i switch to 1700. but this becomes the throttle zero. The motor spins faster the further i move back to 1500.
So I tried starting low at 1000 and moving up to 1500 but it won’t arm with these combinations.
The advanced documentation says while arming throttling up and down can be used to calibrate the max thrust. I’v tried various combinations of values and timing and can’t get it right. I also read someone it was important to scale up the max while arming so Iv tried ramping the values up and down rather than an abrupt change, but this hasn’t seemed to change much.
The pertinent config values are as follows…
// This would theoretically lead into a resolution of 5 microseconds per step:
// 4096 Steps (12 Bit)
// T = 4096 * 0.000005s = 0.02048s
// f = 1 / T = 48.828125
BigDecimal frequency = new BigDecimal("48.828");
// Correction factor: actualFreq / targetFreq
// e.g. measured actual frequency is: 51.69 Hz
// Calculate correction factor: 51.65 / 48.828 = 1.0578
// --> To measure actual frequency set frequency without correction factor(or set to 1)
BigDecimal frequencyCorrectionFactor = new BigDecimal("1.0578");
// Create custom PCA9685 GPIO provider
I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1);
final PCA9685GpioProvider provider = new PCA9685GpioProvider(bus, 0x40, frequency, frequencyCorrectionFactor);
// Define outputs in use for this example
GpioPinPwmOutput[] myOutputs = provisionPwmOutputs(provider);
// Reset outputs
provider.reset();
provider.setAlwaysOff(PCA9685Pin.PWM_00);
delay(2000);
provider.setPwm(PCA9685Pin.PWM_00, 1500);
etc...