tom321
1
Hi
Why on serial plotter both Af and Bf are the same ?
#include <filters.h>
const float cutoff_freq = 5.0; //Cutoff frequency in Hz
const float sampling_time = 0.005; //Sampling time in seconds.
IIR::ORDER order = IIR::ORDER::OD3; // Order (OD1 to OD4)
// Low-pass filter
Filter f(cutoff_freq, sampling_time, order);
void setup() {
Serial.begin(115200);
}
void loop() {
int valueA = analogRead(PA5);//+++++++++++++++++++++++++++++++++++++++++
float filteredvalA = f.filterIn(valueA);
int valueB = analogRead(PA7); //+++++++++++++++++++++++++++++++++++++++
float filteredvalB = f.filterIn(valueB);
Serial.print("A = ");
//Serial.print(valueA, DEC);
Serial.print(" Af = ");
Serial.print(filteredvalA, 4);
Serial.print(" B = ");
// Serial.print(valueB , DEC);
Serial.print(" Bf = ");
Serial.println(filteredvalB , 4);
delay(5); // Loop time will approx. match the sampling time.
}
Perhaps because valueA and valueB are the same?
Did you run the examples coming with the library?
Try two Filter fA, fB
for separate signals A and B.
For the records: How that?
tom321
5
#include <filters.h>
const float cutoff_freqA = 5.0; //Cutoff frequency in Hz
const float sampling_timeA = 0.005; //Sampling time in seconds.
IIR::ORDER orderA = IIR::ORDER::OD3; // Order (OD1 to OD4)
///////////////////
const float cutoff_freqB = 5.0; //Cutoff frequency in Hz
const float sampling_timeB = 0.005; //Sampling time in seconds.
IIR::ORDER orderB = IIR::ORDER::OD3; // Order (OD1 to OD4)
//////////////////
// Low-pass filter
Filter fA(cutoff_freqA, sampling_timeA, orderA);
Filter fB(cutoff_freqB, sampling_timeB, orderB);
void setup() {
Serial.begin(115200);
}
void loop() {
int valueA = analogRead(PA5);//+++++++++++++++++++++++++++++++++++++++++
float filteredvalA = fA.filterIn(valueA);
int valueB = analogRead(PA7); //+++++++++++++++++++++++++++++++++++++++
float filteredvalB = fB.filterIn(valueB);
// Serial.print("A = ");
// Serial.print(valueA, DEC);
Serial.print(" Af = ");
Serial.print(filteredvalA, 4);
// Serial.print(" B = ");
// Serial.print(valueB , DEC);
Serial.print(" Bf = ");
Serial.println(filteredvalB , 4);
delay(5); // Loop time will approx. match the sampling time.
}
1 Like
Please post a link to the filter library you are using.
tom321
7
Thanks! Documentation is pretty weak but if it does what you want, fine.
system
Closed
9
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.