File tree 4 files changed +10
-6
lines changed
4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,11 @@ An EMA (**Exponential Moving Average**) filter behaves like an RC lowpass filter
55
55
An EMA filter is implemented by e.g. the following statement:
56
56
57
57
``` c++
58
- int16_t Lowpass5 += ((InputValue - Lowpass5) >> 5 ;
58
+ int16_t sLowpass3 ;
59
+ int16_t Lowpass5;
60
+ ...
61
+ sLowpass3 += ((aInputValue - sLowpass3 ) + (1 << 2 )) >> 3 ; // 1.8 us, alpha = 0.125, cutoff frequency 22.7 Hz @1kHz
62
+ sLowpass5 += ((aInputValue - sLowpass5 ) + (1 << 4 )) >> 5 ; // 2.5 us, alpha = 1/32 0.03125, cutoff frequency 5.13 Hz @1kHz
59
63
```
60
64
which takes ** 2.5 µ ; s on a 16 MHz Arduino Uno** .
61
65
Original file line number Diff line number Diff line change @@ -481,7 +481,7 @@ void readAndPrintVCCVoltageMillivolt(Print *aSerial) {
481
481
void readVCCVoltageSimple (void ) {
482
482
// use AVCC with (optional) external capacitor at AREF pin as reference
483
483
float tVCC = readADCChannelWithReferenceMultiSamples (ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT, 4 );
484
- sVCCVoltage = (1023 * 1.1 * 4 ) / tVCC;
484
+ sVCCVoltage = (1023 * ((( float ) ADC_INTERNAL_REFERENCE_MILLIVOLT) / 1000 ) * 4 ) / tVCC;
485
485
}
486
486
487
487
/*
Original file line number Diff line number Diff line change 35
35
#include <stdint.h>
36
36
37
37
#define DISTANCE_TIMEOUT_RESULT 0
38
- #define US_DISTANCE_DEFAULT_TIMEOUT_MICROS 20000
39
- #define US_DISTANCE_DEFAULT_TIMEOUT_CENTIMETER 343 // Timeout of 20000L is 3.43 meter
38
+ #define US_DISTANCE_DEFAULT_TIMEOUT_MICROS 20000 // Timeout of 20000L is 3.43 meter
39
+ #define US_DISTANCE_DEFAULT_TIMEOUT_CENTIMETER 343 // Timeout of 20000L is 3.43 meter
40
40
41
- #define US_DISTANCE_TIMEOUT_MICROS_FOR_1_METER 5825 // Timeout of 5825 is 1 meter
41
+ #define US_DISTANCE_TIMEOUT_MICROS_FOR_1_METER 5825 // Timeout of 5825 is 1 meter
42
42
#define US_DISTANCE_TIMEOUT_MICROS_FOR_2_METER 11650 // Timeout of 11650 is 2 meter
43
43
#define US_DISTANCE_TIMEOUT_MICROS_FOR_3_METER 17475 // Timeout of 17475 is 3 meter
44
44
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ void initUSDistancePin(uint8_t aTriggerOutEchoInPin) {
137
137
138
138
/*
139
139
* Start of standard blocking implementation using pulseInLong() since PulseIn gives wrong (too small) results :-(
140
- * @param aTimeoutMicros timeout of 5825 micros is equivalent to 1 meter, default timeout of 20000 micro seconds is 3.43 meter
140
+ * @param aTimeoutMicros timeout of 5825 micros is equivalent to 1 meter, default timeout of 20000 micros is 3.43 meter
141
141
* @return 0 / DISTANCE_TIMEOUT_RESULT if uninitialized or timeout happened
142
142
*/
143
143
unsigned int getUSDistance (unsigned int aTimeoutMicros) {
You can’t perform that action at this time.
0 commit comments