Skip to content

Commit

Permalink
Correct PRS rate + Watchdog alt values
Browse files Browse the repository at this point in the history
  • Loading branch information
tilaktilak committed Apr 23, 2017
1 parent 81bbbe5 commit 4915311
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions altitude_filter/kalman.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
clear all;
clc;

data = csvread('log8.csv');
data = csvread('log11.csv');
time = data(:,1);
alt = data(:,2);
smoothed_alt = data(:,3);
Expand All @@ -15,7 +15,7 @@
figure
plot(rate);
hold on
plot(diff(rate)/0.08,'r');
%plot(diff(rate)/0.08,'r');
figure

fe = 125 % fréquence d'échantillonnage
Expand Down
2 changes: 1 addition & 1 deletion bmp280.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ float PressureBMP280(void) {


float AltitudeBMP280(void){
float press = PressureBMP280();
press = PressureBMP280();
float alt = 0.f;;
alt = (1.f - powf(((float)press)/101325.f,0.190284f))*145366.45f;
alt = alt * 0.3048f;
Expand Down
2 changes: 2 additions & 0 deletions bmp280.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ float AltitudeBMP280(void);

float PressureBMP280(void);

float press;

int32_t t_fine;
union {
struct {
Expand Down
22 changes: 15 additions & 7 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ int main(void)
_Accum const high_offset = 1100.f;


long int const prs_count_max = 10000;
long int const prs_count_max = 2;
int prs_count = 0;


Expand Down Expand Up @@ -266,11 +266,7 @@ int main(void)
putchar(c);
}

if(++prs_count>=prs_count_max && c=='\n'){ // Ensure NMEA end of line
prs_count = 0;
uint32_t inttp = (uint32_t)PressureBMP280();
printf("PRS %05lx\r\n",(unsigned long int)inttp);
}

/*
if(flag_volume_recv){
// SNPRINTF to get volume
Expand All @@ -283,11 +279,23 @@ int main(void)
}
//dt = count_dt* (1/1E6);
TIFR1 |= (1 << TOV1);

if(++prs_count>=prs_count_max && c=='\n'){ // Ensure NMEA end of line
prs_count = 0;
uint32_t inttp = (uint32_t)press;// Global var set by AltitudeBMP
printf("PRS %05lx\r\n",(unsigned long int)inttp);
}

time += dt;

alt = AltitudeBMP280();
kalman_predict(0.01f);
if(alt>0.f && alt<20000.f){
kalman_predict(0.01f);
}
// Check error values on measurement
//if(alt>0.f && alt<20000.f){
kalman_update(alt);
//}
//rate = 0.7*rate + 0.3*X[1];
rate = X[1];
//printf("%f,%f,%f,%f\r\n",(double)time, (double)X[0],(double)alt,(double) rate);
Expand Down

0 comments on commit 4915311

Please sign in to comment.