-
Notifications
You must be signed in to change notification settings - Fork 0
/
dane.h
159 lines (131 loc) · 3.21 KB
/
dane.h
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include "naglowki_include.h"
#ifndef _DANE_H_
#define _DANE_H_
#define SREDNIA 64
#define PRZESUN 6
#define BLEDY 64 //ilosc bledow gromadzonych w I
#endif
typedef struct
{
uint8_t timer;
uint8_t wartosc_pocz;
uint8_t pwm1;
uint8_t pwm2;
uint8_t pwm3;
uint8_t pwm4;
} PWMTypeDef;
typedef struct
{
uint8_t akcel_x_l;
uint8_t akcel_x_h;
uint8_t akcel_y_l;
uint8_t akcel_y_h;
uint8_t akcel_z_l;
uint8_t akcel_z_h;
int32_t akcel_x_kat_rad;
int32_t akcel_y_kat_rad;
uint8_t akcel_ktora_srednia;
uint8_t akcel_x_srednia;
uint8_t akcel_x_srednia_tab[SREDNIA];
uint8_t akcel_y_srednia;
uint8_t akcel_y_srednia_tab[SREDNIA];
} AkcelTypeDef;
typedef struct
{
uint8_t zyro_x_l;
uint8_t zyro_x_h;
uint8_t zyro_y_l;
uint8_t zyro_y_h;
uint8_t zyro_z_l;
uint8_t zyro_z_h;
uint16_t zyro_kalibr_ktory;
int32_t zyro_y_kat_mdeg;
int32_t zyro_x_kat_mdeg;
int32_t zyro_z_kat_mdeg;
double zyro_y_deg_sec;
double zyro_z_deg_sec;
double zyro_x_deg_sec;
int32_t zyro_y_kalibracja; //sluzy do kalibrowania odczytow, przez pierwsze 256 odczytow quadro MUSI stac
int32_t zyro_z_kalibracja;
int32_t zyro_x_kalibracja;
} ZyroTypeDef;
typedef struct
{
uint8_t press_out_xl;
uint8_t press_out_l;
uint8_t press_out_h;
uint8_t temp_out_l;
uint8_t temp_out_h;
uint8_t temp_celsius;
int16_t press_mbar;
uint8_t ktory; // do kalibracji
} BaroTypeDef;
typedef struct
{
int32_t kat_x;
int32_t kat_y;
} KatTypeDef;
typedef struct
{
uint8_t magnet_x_l;
uint8_t magnet_x_h;
uint8_t magnet_y_l;
uint8_t magnet_y_h;
uint8_t magnet_z_l;
uint8_t magnet_z_h;
} MagnetTypeDef;
typedef struct
{
uint8_t kP; //wspolczynnik regulacji P
uint8_t kI;
uint8_t kD;
int32_t I_x_bledy_tab[BLEDY];
int32_t I_y_bledy_tab[BLEDY];
int32_t I_x_bledy_srednia;
int32_t I_y_bledy_srednia;
uint8_t I_ktory_blad;
} PIDTypeDef;
typedef struct
{
uint32_t poziom;
uint8_t poziom_procent;
uint32_t ktora;
} BateriaTypeDef;
/*
* https://github.com/TKJElectronics/KalmanFilter/blob/master/Kalman.h
* Trochê magii z Hogwartu!
*/
typedef struct
{
double Q_angle; // Process noise variance for the accelerometer
double Q_bias; // Process noise variance for the gyro bias
double R_measure; // Measurement noise variance - this is actually the variance of the measurement noise
double angle; // The angle calculated by the Kalman filter - part of the 2x1 state vector
double bias; // The gyro bias calculated by the Kalman filter - part of the 2x1 state vector
double rate; // Unbiased rate calculated from the rate and the calculated bias - you have to call getAngle to update the rate
double P[2][2]; // Error covariance matrix - This is a 2x2 matrix
double K[2]; // Kalman gain - This is a 2x1 vector
double y; // Angle difference
double S; // Estimate error
} KalmanTypeDef;
typedef struct
{
uint8_t bufor; //
} USARTTypeDef;
typedef struct
{
PWMTypeDef pwm; //struktura PWM
ZyroTypeDef zyro;
MagnetTypeDef magnet;
AkcelTypeDef akcel;
BaroTypeDef baro;
PIDTypeDef pid;
KatTypeDef kat;
BateriaTypeDef bateria;
USARTTypeDef usart;
KalmanTypeDef kalman_x;
int32_t temp;
uint8_t czy_polaczony; //zeby awaryjnie wylaczyc (systick)
uint16_t opoznienie; //¿eby zainicjalizowaæ silniki oraz dla bezpieczeñstwa
} daneTypeDef;
void inicjalizacja_dane();