-
-
Notifications
You must be signed in to change notification settings - Fork 0
New and Improved ADC + EMA #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ialize the ADC groups
Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com>
Signed-off-by: rsargis <ryan_sargis@ucsb.edu>
…PT (joking) Co-authored-by: Shravya Salem Sathish, <Shrav816@users.noreply.github.com>
|
Please fix conflicts prior to marking as ready for review |
Signed-off-by: Anthony Ma <anthony497@ucsb.edu>
dchansen06
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make your changes to the ECU in a separate branch off of StateMachineImplementation, please keep the ADC changes here; thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this file changed? (And can you unchange it please)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot comment out everything else in a PR into main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this as it will be old by the time anyone has to use it
ADC
Problem and Scope
A classic sliding window function needs to track a certain number of previous ADC frame values for various different signals. This uses unnecessary memory, so we can fix this by using an exponential moving average. This directly smooths the ADC output based on an exponential output and the current frame.
Description
We implemented
ADC_UpdateAnalogValues_EMA(volatile uint16_t *new_values, int num_signals, double alpha, uint16_t *weighted_output)following https://en.wikipedia.org/wiki/Exponential_smoothing#Basic_(simple)_exponential_smoothing.
It returns the exponential moving average instead of a sliding window function to reduce memory usage (due to the window of previous ADC values).
Gotchas and Limitations
If the data are correlated in some way (i.e. a linear function), a simple exponential smoothing function will always lag behind and never reach the true value of the signal.
A solution would be to use Holt double exponential smoothing, which attempts to estimate the trend. This operation is still much faster than the sliding window function since we are again only looking at previous and new values and does not require more memory.
Testing
Testing Details
We tested this on a G4 board and played around with the weights.
Larger Impact
A working ADC with a customizable smoothing function and weight is essential for all other signals to be smoothed.
Additional Context and Ticket
#170