dRehmFlight VTOL - Teensy (Arduino) Flight Controller and Stabilization

Scotto

Elite member
To add channels requires a lot of extra variables, but they follow the same pattern as the existing channels. It helps to really understand how the code works by watching the videos that Nick has published.

You will need to add (to the best of my knowledge):

[user-specified variables]
unsigned long channel_XX_fs = 1500; //failsafe value
const int servoXXPin = YY; // if you will map a channel to a servo - flaps?
PWMServo servoXX;
unsigned long channel_XX_pwm; // PWM value for new channel
float flaps_des; // or some name to represent your desired state of flaps
float sXX_command_scaled; // for your flaps servo
float sXX_command_PWM;

[void setup]
servoXX.attach(servoXXPin, 900, 2100);
channel_XX_pwm = channel_XX_fs;
servoXX.write(90); // startup servo position

//Command actuators
servoXX.write(sXX_command_PWM);

[controlMixer]
sXX_command_scaled = 0.5 + flaps_des;

[getDesState()]
flaps_des = (channel_XX_pwm - 1000.0)/1000.0; //Between 0 and 1
flaps_des = constrain(flaps_des, 0.0, 1.0); //between 0 and 1

[scaleCommands()]
sXX_command_PWM = sXX_command_scaled*180;
sXX_command_PWM = constrain(sXX_command_PWM, 0, 180);

[getCommands()]
// I use SBUS, so the PWM value is pulled form the SBUS section
channel_XX_pwm = sbusChannels[XX] * scale + bias;

[failSafe()]
channel_XX_pwm = channel_XX_fs;

I'm sure I missed a few, but follow through the code and it should be pretty understandable. Good luck!
Thank you very much. I might have guessed a few of those, but my poor brain is struggling with this. It took me 2 days to realize I was just missing a } for the controlmixer. It is slowly sinking in though. Thanks.