Skip to content

[2.0.x] Ensure ADC conversion is complete before reading#11336

Merged
thinkyhead merged 1 commit intoMarlinFirmware:bugfix-2.0.xfrom
gloomyandy:pr_fix_adc_readings
Jul 26, 2018
Merged

[2.0.x] Ensure ADC conversion is complete before reading#11336
thinkyhead merged 1 commit intoMarlinFirmware:bugfix-2.0.xfrom
gloomyandy:pr_fix_adc_readings

Conversation

@gloomyandy
Copy link
Contributor

Description

This PR extends the HAL interface to allow code to check if the ADC conversion is complete and uses this to ensure correct temperature and other ADC based readings.

The current implementation relies on an interrupt timer to start the conversion and read the ADC value. However in some circumstances other interrupts can delay the start point which can result in the conversion not being complete by the time the ADC value is read. This PR checks to see if the conversion has been completed and if not it delays the read until the next timer interrupt.

Note: This PR only provides HAL implementations for AVR and LPC1768 variants, place holders are provided for other HALs and these may need to be modified (but without any change things are essentially as before).

Benefits

With the current implementation invalid temperature readings can be made in some circumstances (particularly on AVR based systems) resulting in fluctuations in the hotend (and to a lesser extent) bed temperature. This change provides a more consistent temperature.

Related Issues

See issue: #11323

@gloomyandy
Copy link
Contributor Author

@thinkyhead I have no idea why this pull request includes changes committed by you on the 25th June to the configuration files. Sorry about that. Do I need to revert them from my fork and then resubmit this?

@gloomyandy
Copy link
Contributor Author

Currently investigation a potential issue with this, please do not merge.

@gloomyandy
Copy link
Contributor Author

Latest changes have been tested and it looks pretty good. No glitches on hotend, or heated bed.

Should be OK to merge I hope.

@thinkyhead
Copy link
Member

I can fix this up — just needs a rebase, as the source branch probably got rebased.

@thinkyhead thinkyhead force-pushed the pr_fix_adc_readings branch 2 times, most recently from 69b50e6 to 45eee00 Compare July 26, 2018 07:44
@thinkyhead thinkyhead changed the title Fix: Ensure ADC conversion is complete before reading [2.0.x] Ensure ADC conversion is complete before reading Jul 26, 2018
@thinkyhead thinkyhead force-pushed the pr_fix_adc_readings branch 3 times, most recently from 1229af6 to fc80036 Compare July 26, 2018 08:31
The current Marlin implementation makes relies on a timer interrupt to start the ADC conversion and read it. However in some circumstances the interrupt can be delayed resulting in insufficient time being availabe for the ADC conversion. This results in a bad reading and false temperature fluctuations. These changes make sure that the conversion is complete (by checking the ADC hardware via the HAL) before reading a value.

See: MarlinFirmware#11323
@thinkyhead thinkyhead force-pushed the pr_fix_adc_readings branch from fc80036 to b366323 Compare July 26, 2018 08:46
@thinkyhead thinkyhead merged commit 624986d into MarlinFirmware:bugfix-2.0.x Jul 26, 2018
@gloomyandy gloomyandy deleted the pr_fix_adc_readings branch August 9, 2018 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants