-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.h
More file actions
51 lines (39 loc) · 1.02 KB
/
control.h
File metadata and controls
51 lines (39 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef CONTROL_H_
#define CONTROL_H_
/*
* control.h
*
* Author: Coppy Nawaphanarat (44035285), Grant Wong, Will Archer
*/
#include "motor.h"
#include "slider.h"
typedef enum pidInput {ALTITUDE, YAW} PIDInput;
typedef struct {
float proportionalGain;
float integralGain;
float derivativeGain;
} PID;
typedef struct {
float measuredValue;
float desiredValue;
float errorIntegral;
float error;
} Instant;
void initPID(void);
// void pidControl(Instant* previous, Instant* current, PID constants);
void pidControl(int32_t measuredValue, int32_t desiredValue, PIDInput pidInput, Rotor rotor);
int32_t getMainControl(void);
int32_t getTailControl(void);
#define PID_FREQUENCY 120
// Real Helicopter
#define MAX_ALTITUDE_CONTROL 80
#define MIN_ALTITUDE_CONTROL 10
#define MAX_YAW_CONTROL 60
#define MIN_YAW_CONTROL 5
// Emulator
//#define MAX_ALTITUDE_CONTROL 80
//#define MIN_ALTITUDE_CONTROL 40
//#define MAX_YAW_CONTROL 70
//#define MIN_YAW_CONTROL 20
//#define YAW_REF_DUTY 20
#endif /* CONTROL_H_ */