Welcome to Cockpitbuilders.com. Please login or sign up.

June 03, 2024, 06:33:38 PM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
162 Guests, 0 Users
Members
Stats
  • Total Posts: 59,642
  • Total Topics: 7,853
  • Online today: 171
  • Online ever: 831
  • (May 03, 2024, 12:39:25 PM)
Users Online
Users: 0
Guests: 162
Total: 162

COUNTDOWN TO WF2022


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

Amazing power of Teensy (and sketch programming)

Started by kurt-olsson, October 08, 2016, 12:11:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kurt-olsson

Insted of all the plug and play installations and hooking up to softwares etc.
This is all the code i use for my autothrottle to work.

I have a delta diff that configures how sensitive the "null-zone" is for engagement of movement.

This is the only code for making the throttles work and mapping against the autothrottle set position.
The first else in the code is if the autothrottle is armed.

The Serial.Print is just for debugging.

else {

    //This is if the Autothrottle is armed and Spd or N1 is engaged.

    float differential_limit_for_throttle_to_move_on = 0.03;
    float diff = XPF_THROTTLE_LEFT_POSITION - THROTTLE_LEFT_POSITION;
 
    if (abs(diff) > differential_limit_for_throttle_to_move_on) {
        if (diff < 0) {
            Serial.print("Back off throttle");
            Serial.print("\n");
            SetThrottleMovementToDecrease();
        }
        else {
            Serial.print("Advance throttle");
            Serial.print("\n");
            SetThrottleMovementToIncrease();
        }
    }
    else {
      StopThrottles();
      Serial.print("Stop");
      Serial.print("\n");
    }
  }


This works flawlessly... i cant belive this task was so simple, though it would be more than a 20 minute job. =)

Oh, and also my functions, this is just HIGH,LOW values for the pins.

void SetThrottleMovementToIncrease() {
   digitalWrite(0,HIGH);
   digitalWrite(1,LOW);
   analogWrite(4,255);

   digitalWrite(2,LOW);
   digitalWrite(3,HIGH);
   analogWrite(5,255);
}

void SetThrottleMovementToDecrease() {
   digitalWrite(0,LOW);
   digitalWrite(1,HIGH);
   analogWrite(4,255);
 
   digitalWrite(2,HIGH);
   digitalWrite(3,LOW);
   analogWrite(5,255);
}

void StopThrottles() {
  analogWrite(4,0);
  analogWrite(5,0);
}

https://www.youtube.com/watch?v=Asn07F0Lpv8

Like the Website ?
Support Cockpitbuilders.com and Click Below to Donate