Go Down

Topic: Helicopter - autopilot (Read 1 time) previous topic - next topic

Rixterz

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 :)

johnwasser

Speed control is usually done with analogWrite().

Increasing slowly from 0 is usually done with a loop:
Code: [Select]

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
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e


AWOL

Quote
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.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

GunnerCAF

#4
Jul 22, 2013, 06:18 am Last Edit: Jul 22, 2013, 06:23 am by GunnerCAF Reason: 1
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:

Code: [Select]

/* ========================== 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

Go Up