auto-sync
This commit is contained in:
parent
e0ead8983c
commit
4402853e99
|
@ -409,8 +409,8 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
* TPS
|
* TPS
|
||||||
*/
|
*/
|
||||||
engineConfiguration->tpsAdcChannel = EFI_ADC_2;
|
engineConfiguration->tpsAdcChannel = EFI_ADC_2;
|
||||||
engineConfiguration->tpsMax = 125; // convert 12to10 bit (ADC/4)
|
engineConfiguration->tpsMax = 625; // convert 12to10 bit (ADC/4)
|
||||||
engineConfiguration->tpsMin = 625; // convert 12to10 bit (ADC/4)
|
engineConfiguration->tpsMin = 125; // convert 12to10 bit (ADC/4)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IAT D15/W7
|
* IAT D15/W7
|
||||||
|
|
|
@ -17,6 +17,11 @@ Biquad::Biquad() {
|
||||||
z1 = z2 = 0;
|
z1 = z2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Biquad::initValue(float input) {
|
||||||
|
z1 = input * (1 - a0);
|
||||||
|
z2 = input * (1 - a0 - a1 + b1);
|
||||||
|
}
|
||||||
|
|
||||||
float Biquad::getValue(float input) {
|
float Biquad::getValue(float input) {
|
||||||
float result = input * a0 + z1;
|
float result = input * a0 + z1;
|
||||||
z1 = input * a1 + z2 - b1 * result;
|
z1 = input * a1 + z2 - b1 * result;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
class Biquad {
|
class Biquad {
|
||||||
public:
|
public:
|
||||||
Biquad();
|
Biquad();
|
||||||
|
void initValue(float input);
|
||||||
float getValue(float input);
|
float getValue(float input);
|
||||||
|
|
||||||
float a0, a1, a2, b1, b2;
|
float a0, a1, a2, b1, b2;
|
||||||
|
|
|
@ -25,11 +25,13 @@
|
||||||
#include "board_test.h"
|
#include "board_test.h"
|
||||||
#include "engine_controller.h"
|
#include "engine_controller.h"
|
||||||
#include "maf.h"
|
#include "maf.h"
|
||||||
|
#include "biquad.h"
|
||||||
|
|
||||||
/* Depth of the conversion buffer, channels are sampled X times each.*/
|
/* Depth of the conversion buffer, channels are sampled X times each.*/
|
||||||
#define ADC_BUF_DEPTH_SLOW 8
|
#define ADC_BUF_DEPTH_SLOW 8
|
||||||
#define ADC_BUF_DEPTH_FAST 4
|
#define ADC_BUF_DEPTH_FAST 4
|
||||||
|
|
||||||
|
Biquad biq[ADC_MAX_CHANNELS_COUNT];
|
||||||
|
|
||||||
static adc_channel_mode_e adcHwChannelEnabled[HW_MAX_ADC_INDEX];
|
static adc_channel_mode_e adcHwChannelEnabled[HW_MAX_ADC_INDEX];
|
||||||
static const char * adcHwChannelUsage[HW_MAX_ADC_INDEX];
|
static const char * adcHwChannelUsage[HW_MAX_ADC_INDEX];
|
||||||
|
@ -489,8 +491,14 @@ static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
|
||||||
for (int i = 0; i < slowAdc.size(); i++) {
|
for (int i = 0; i < slowAdc.size(); i++) {
|
||||||
int value = getAvgAdcValue(i, slowAdc.samples, ADC_BUF_DEPTH_SLOW, slowAdc.size());
|
int value = getAvgAdcValue(i, slowAdc.samples, ADC_BUF_DEPTH_SLOW, slowAdc.size());
|
||||||
adcsample_t prev = slowAdc.values.adc_data[i];
|
adcsample_t prev = slowAdc.values.adc_data[i];
|
||||||
slowAdc.values.adc_data[i] = (slowAdcCounter == 0) ? value :
|
float result = (slowAdcCounter == 0) ? value :
|
||||||
CONFIG(slowAdcAlpha) * value + (1 - CONFIG(slowAdcAlpha)) * prev;
|
CONFIG(slowAdcAlpha) * value + (1 - CONFIG(slowAdcAlpha)) * prev;
|
||||||
|
// if (slowAdcCounter == 0) {
|
||||||
|
// biq[i].initValue(value);
|
||||||
|
// }
|
||||||
|
// float result = biq[i].getValue(value);
|
||||||
|
|
||||||
|
slowAdc.values.adc_data[i] = result;
|
||||||
}
|
}
|
||||||
slowAdcCounter++;
|
slowAdcCounter++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue