Helicopter - autopilot

Hello

I am making a project where my helicopter gradually starts up it's 4 motors as an autopilot feature, but i do not know how to slowly increase the speed from 0 to speed X (whatever speed it hovers at).

The helicopter looks like this from above:

motor
|
|
motor -----arduino-----motor
|
|
motor

I only got my arduino yesterday so i really need help on these little things before my project can truly begin.

Thanks in advance- any functions that you can think of would be useful :slight_smile:

Speed control is usually done with analogWrite().

Increasing slowly from 0 is usually done with a loop:

for (int speed = 0; speed <= HOVER_SPEED; speed++) {
    analogWrite(Motor1Pin, speed);
    analogWrite(Motor2Pin, speed);
    analogWrite(Motor3Pin, speed);
    analogWrite(Motor4Pin, speed);
    delay(RampUpDelay);  // The higher the number the slower the ramp
}

Thanks very much :slight_smile:

Increasing slowly from 0 is usually done with a loop:

...but if you want to do other stuff, like looking at gyros or accelerometers, you're probably best not using for loops, and doing the work of the loop explicitly as part of a state machine.

I am working on a single motor airplane, and I am not using delays. This is the function I am using to ramp up and down the motor speed:

/* ========================== MOTOR POWER ==========================
/ GWS ICS-300E
/ note: min power = 70, full power = 120
/ This ramps up or down the power settings for smooth power changes
*/
void motorPower() {
  if (millis() >= motorTimer) {                // check motor timer
    motorTimer = millis() + 30;                // set next timer
    if ((motorTarget + mv) > motorVal) {       // if target speed is greater than current setting
      motorVal++;                              // increment motor power setting
    }
    if ((motorTarget + mv) < motorVal) {       // if target speed is less than current setting
      motorVal--;                              // deincrement motor power setting
    }
    motorVal= constrain((motorVal), 60, 130);  // limit motor values
    motorServo.write(motorVal);                // adjust power to new value
  }
}

motorTimer = Every 30 ms the speed continues the ramp up or ramp down.
motorTarget = This is my target motor speed
motorVal = Current motor speed
mv = This is a value from my radio control so I can override the autopilot if needed.

Maybe you can get some ideas from this for your project.

Good luck,

Dave