From 20f006a0ca2b93de69a67eb00b849708d6597fb5 Mon Sep 17 00:00:00 2001 From: philsson Date: Tue, 11 Oct 2016 18:02:11 +0200 Subject: [PATCH] Some changes to yaw inversion and changed some possible negative ints to int --- UAV-ControlSystem/inc/drivers/motormix.h | 2 +- UAV-ControlSystem/src/drivers/motormix.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/UAV-ControlSystem/inc/drivers/motormix.h b/UAV-ControlSystem/inc/drivers/motormix.h index e2c3966..c01139a 100644 --- a/UAV-ControlSystem/inc/drivers/motormix.h +++ b/UAV-ControlSystem/inc/drivers/motormix.h @@ -45,7 +45,7 @@ typedef struct { uint16_t minCheck; // In Non Airmode: If throttle is below minCheck we set motors to minCommand bool pid_at_min_throttle; // When enabled PIDs are used at minimum throttle bool motorstop; // If enabled motors will stop spinning at no throttle when Armed - uint8_t yaw_motor_direction; // Default should be 1. Can be either -1 or 1 + bool yaw_reverse_direction; // Default should be 1. Can be either -1 or 1 } mixerConfig_s; /* Global mixerConfig to bee available to EEPROM */ diff --git a/UAV-ControlSystem/src/drivers/motormix.c b/UAV-ControlSystem/src/drivers/motormix.c index e11eebf..ce4b9e0 100644 --- a/UAV-ControlSystem/src/drivers/motormix.c +++ b/UAV-ControlSystem/src/drivers/motormix.c @@ -93,7 +93,7 @@ void mix() /* Calculate what "hover" could be. Not used now but might be useful later */ //uint16_t throttleIdle = mixerConfig.minThrottle + (throttleRange / 2); - uint16_t RPY_Mix[MOTOR_COUNT]; // Roll Pitch and Yaw variables array + int16_t RPY_Mix[MOTOR_COUNT]; // Roll Pitch and Yaw variables array uint16_t RPY_Mix_Min = 0; // Stores the minimum desired command for any motor uint16_t RPY_Mix_Max = 0; // Maximum desired command for any motor uint16_t throttle = sbusChannelData.chan3; // Import throttle value from remote @@ -111,7 +111,7 @@ void mix() RPY_Mix[i] = \ PID_Out[PITCH] * mixerUAV[i].pitch + \ PID_Out[ROLL] * mixerUAV[i].roll + \ - PID_Out[YAW] * mixerUAV[i].yaw * mixerConfig.yaw_motor_direction; + PID_Out[YAW] * mixerUAV[i].yaw * ((mixerConfig.yaw_reverse_direction) ? -1 : 1); // Update min and max values if (RPY_Mix[i] > RPY_Mix_Max) RPY_Mix_Max = RPY_Mix[i]; @@ -167,13 +167,13 @@ void mix() throttle * mixerUAV[i].throttle + \ PID_Out[PITCH] * mixerUAV[i].pitch + \ PID_Out[ROLL] * mixerUAV[i].roll + \ - PID_Out[YAW] * mixerUAV[i].yaw * mixerConfig.yaw_motor_direction; + PID_Out[YAW] * mixerUAV[i].yaw * ((mixerConfig.yaw_reverse_direction) ? -1 : 1); // Find the maximum motor output if (RPY_Mix[i] > maxMotor) maxMotor = RPY_Mix[i]; } - uint16_t maxThrottleDifference = 0; + int16_t maxThrottleDifference = 0; if (maxMotor > mixerConfig.maxThrottle) maxThrottleDifference = maxMotor - mixerConfig.maxThrottle;