Commit 433e40df authored by Quirin Apfel's avatar Quirin Apfel
Browse files

Merge branch 'master' of gitlab.cs.fau.de:diygrp2/diy-project

parents 5c69c4e3 0cb04197
......@@ -19,6 +19,12 @@
*/
float complementary_filter(float phi_acc, float gyro_rate, uint16_t f_sampling);
/*! \brief Implements a iir Filter
* \param phi_acc angle phi calculated from accelero data
* \returns filtered phi_acc
*/
float iir_filter(float phi_acc);
/*! \brief Resets filter angle
*/
void reset_filter(void);
......
#include "control.h"
#include <math.h>
#include "ezs_io.h"
#include "filter.h"
//defines
#define OUT_MAX 100 //maximum output in percent
......@@ -101,8 +102,9 @@ float offset_control(float motor_signal)
float max_offset = 6.0;
float min_offset = 0.0;
sum_offset += K*motor_signal/F_CONTROL;
float new_offset = sum_offset;
// sum_offset += K*motor_signal/F_CONTROL;
float new_offset = iir_filter(K*motor_signal/F_CONTROL);
if(new_offset > max_offset){
new_offset = max_offset;
sum_offset -= motor_signal/F_CONTROL;
......
......@@ -4,7 +4,11 @@
static float phi_cor = 0;
/* IIR filter with butterworth coefficients */
static float iir_filter(float phi_acc)
/*
* Implements a IIR filter with butterworth coefficients
*/
float iir_filter(float phi_acc)
{
static float in_1 = 0;
static float in_2 = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment