[MOD]: Changed PWM Config, Fixed PID

This commit is contained in:
but0n 2016-11-30 16:15:53 +08:00
parent b2c6db6a69
commit ff7c296117
3 changed files with 10 additions and 13 deletions

View File

@ -9,22 +9,19 @@
#define MOTOR3 TIM3->CCR3
#define MOTOR4 TIM3->CCR4
#define MOTOR_MAX (unsigned short)27360
#define MOTOR_MIN (unsigned short)10080
#define MOTOR_LOW (unsigned short)15000
#define MOTOR_MAX (unsigned short)34200
#define MOTOR_MIN (unsigned short)12600
#define MOTOR_LOW (unsigned short)18720
#ifdef MOTOR_NORMAL_STARTUP
#define MOTOR_SETTING() {\
motor_PWM_Init(28800,5);\
MOTOR1 = MOTOR_MIN;\
MOTOR2 = MOTOR_MIN;\
MOTOR3 = MOTOR_MIN;\
MOTOR4 = MOTOR_MIN;\
motor_PWM_Init(36000,4);\
MOTOR1 = MOTOR2 = MOTOR3 = MOTOR4 = MOTOR_MIN;\
delay(10000);\
}
#else
#define MOTOR_SETTING() {\
motor_PWM_Init(28800,5);\
motor_PWM_Init(36000,4);\
MOTOR1 = MOTOR_MAX;\
MOTOR2 = MOTOR_MAX;\
MOTOR3 = MOTOR_MAX;\

View File

@ -3,11 +3,11 @@
extern float g_Yaw, g_Pitch, g_Roll; //eular
#define OUTTER_LOOP_KP 0 //0.257 * 0.83 0.255
#define OUTTER_LOOP_KI 0
#define OUTTER_LOOP_KP 1.5f //0.257 * 0.83 0.255
#define OUTTER_LOOP_KI 0.02f
#define OUTTER_LOOP_KD 0
#define INNER_LOOP_KP 0.8f
#define INNER_LOOP_KP 0.25f
#define INNER_LOOP_KI 0
#define INNER_LOOP_KD 0

View File

@ -3,7 +3,7 @@
#include "motor.h"
void pid_SingleAxis(pid_pst temp, float setPoint) {
temp->Error = setPoint - *temp->Feedback;
temp->Error = *temp->Feedback - setPoint;
//Outter Loop PID
temp->i += temp->Error;
if (temp->i > PID_IMAX) temp->i = PID_IMAX;