Pages: [1]   Go Down
Author Topic: Helicopter - autopilot  (Read 1396 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 178
Posts: 8064
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Speed control is usually done with analogWrite().

Increasing slowly from 0 is usually done with a loop:
Code:
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
}
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks very much smiley
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24317
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

USA
Offline Offline
Newbie
*
Karma: 1
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/* ========================== 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
« Last Edit: July 21, 2013, 11:23:35 pm by GunnerCAF » Logged

Pages: [1]   Go Up
Jump to: