I am programming a ProMini to serve as a motor run timer for free flight models. It is not rocket science, still it took me several days to get it to work as I intended.
The sketch contains code for a safety plug to be removed, and after 2 seconds this lets the motor slowly run up to the max. rpm as set by a pot.
Now, "slowly" is the conundrum. I got it to work ok, but I needed much smaller increases per frame in pulse length than I calculated.
This is how I calculate the pulse length and a subsequent time length to get to a frame rate of 50 Hz, Speed varies from 950 to 2050:
Code: Select all
digitalWrite(ESCout, HIGH); delayMicroseconds(Speed); digitalWrite(ESCout, LOW);
delayMicroseconds(20000 - Speed ); // interval for 20ms/50Hz frame
I figured 2 seconds @ 50 Hz is 100 frames, and therefore I should increase the pulse length 1100/100 = 11 microseconds per frame.
It turns out I get to the 2 seconds (after the initial 2 seconds rest) using an increase of just 2 microseconds per frame!
Code: Select all
// start ramping up motor speed after 2 seconds (if not yet in timed run mode)
if ((millis() - preStart) >= 2000 && Flag == true) Speed += 2;
For your information: the text printed on the ProMini is not clear about the timing, could be 8 MHz, 16MHz or 29 MHz. So I set the Arduino IDE to 16 MHz and ran a "burn Bootloader" using Usbasp. Uploading is done with Usbasp as well.
The throttle pulses are correct, same motor behaviour as with a regular Tx/Rx. But it seems the frames are much shorter than calculated?
Anybody?
Cheers,
Max.