Improve ADC Readings with Averaging Filter #105

Merged
sb10q merged 1 commits from linuswck/thermostat:improve_adc_readings into master 2024-08-17 17:37:18 +08:00
Owner

Description

This PR reverts this PR and adds an averaging filter on the pins adc readings in order to reduce noise due to hardware flaws or STM32f4x ADC. Please refer to the original PR for the details of hardware issue.

Mainly, 16 point averaging on adc readings on I_TEC current readings are added as this may be plotted in latter release of GUI program

According to AN4073, STM32F4x Internal ADC has a high dispersion on the adc readings(+-20LSB). The dispersion can be reduced via a simple averaging filter.

This is a hot fix patch to reduce the noise of the readout. The i_tec and v_tec readings should be handled by a DMA instead, which will be done in another PR.

Experiment with Different Number of Averaging Points

HW Rev2_2_1 without Capacitor Fix:

No Averaging 8-point Averaging 16-point Averaging
image image image

HW Rev2_2_1 with Capacitor Fix:

No Averaging 8-point Averaging 16-point Averaging
image image image

Kirdy Thermostat's Readings

Kirdy's Thermostat section and the Thermostat here share very similar hardware. Kirdy already has a voltage buffer on the ITEC current readout pin. The readout is done by 8 point averaging with DMA handling the adc data readout.
image

Proposed Hardware Fix

For applications requiring low I_TEC current readings noise on Thermostat hw rev2_2_1, you can add two 10nF capacitor onto STM32 pins.
image

# Description This PR reverts [this PR](https://git.m-labs.hk/M-Labs/thermostat/pulls/96) and adds an averaging filter on the pins adc readings in order to reduce noise due to hardware flaws or STM32f4x ADC. Please refer to the original PR for the details of hardware issue. Mainly, 16 point averaging on adc readings on I_TEC current readings are added as this may be plotted in latter release of GUI program According to [AN4073](https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.st.com/resource/en/application_note/an4073-how-to-improve-adc-accuracy-when-using-stm32f2xx-and-stm32f4xx-microcontrollers-stmicroelectronics.pdf&ved=2ahUKEwipmOLYzO6FAxUjlK8BHbf9DE4QFnoECBgQAQ&usg=AOvVaw3oKTgjGyUDBAic8qdOj0ri), STM32F4x Internal ADC has a high dispersion on the adc readings(+-20LSB). The dispersion can be reduced via a simple averaging filter. This is a hot fix patch to reduce the noise of the readout. The i_tec and v_tec readings should be handled by a DMA instead, which will be done in another PR. # Experiment with Different Number of Averaging Points ## HW Rev2_2_1 without Capacitor Fix: | No Averaging | 8-point Averaging | 16-point Averaging | |---|---|---| | ![image](/attachments/3b23de31-7d1a-48a4-b395-9216b6040399) | ![image](/attachments/e7d67ec5-3d1a-4a47-8e69-9a002523b1b7) | ![image](/attachments/696bd9ef-45a4-4518-89fd-a933d797761f) | ## HW Rev2_2_1 with Capacitor Fix: | No Averaging | 8-point Averaging | 16-point Averaging | |---|---|---| | ![image](/attachments/d24ab2d3-6066-4710-a2f3-7324fd605dab) | ![image](/attachments/3e57e3e7-8e88-463c-9a43-2068f199297d) | ![image](/attachments/dec3a2e5-e5d9-4f70-90c5-b26e694e732e) | ## Kirdy Thermostat's Readings Kirdy's Thermostat section and the Thermostat here share very similar hardware. Kirdy already has a voltage buffer on the ITEC current readout pin. The readout is done by 8 point averaging with DMA handling the adc data readout. ![image](/attachments/0efd2360-3cd9-408b-9f68-430ab5b75f11) ## Proposed Hardware Fix For applications requiring low I_TEC current readings noise on Thermostat hw rev2_2_1, you can add two 10nF capacitor onto STM32 pins. ![image](/attachments/681b849e-82b5-4e4d-a187-fd920160203b)
linuswck added 2 commits 2024-05-02 17:45:30 +08:00
1fcfe41a63 Add averaging filter on the pin_adc readings
- Adapted from Kirdy Firmware
- Can reduce the i_tec readings noise dispersion
linuswck added 1 commit 2024-05-02 17:49:30 +08:00
linuswck changed title from [WIP] Improve ADC Readings with Averaging Filter to Improve ADC Readings with Averaging Filter 2024-05-02 17:49:42 +08:00
sb10q merged commit 8c1cb3117c into master 2024-05-02 19:16:14 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/thermostat#105
No description provided.