Skip to content
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

Use analogReadMilliVolts for esp32 and update hysteresis #635

Conversation

tyeth
Copy link
Contributor

@tyeth tyeth commented Sep 27, 2024

For CI assets, testing https://github.com/tyeth/Adafruit_Wippersnapper_Arduino/blob/50f17026832ba9a53d0f919a69b8e9106302fe55/src/components/analogIO/Wippersnapper_AnalogIO.cpp#L90

Combined PR including millivolt change and updated hysteresis method:

This PR now switches both periodic and on_change to use the same functions, along with using analogReadMilliVolts for ESP32 based boards.

Also this modifies the on_change event to use a sliding scale of hysteresis. Originally the code awaited a 2% change in the last raw value.
Now the scale is divided into thirds, with the lower third using the default hysteresis value of 2% applied to the whole 16bit max value (65k), which results in less bounce around 0 due to wifi / power fluctuations, the middle third using double that threshold change, and the last third quadruple that default hysteresis (where a 200mV spike was generally observed around 3.1v). There is also a 500ms anti-hammer situation on top of the hysteresis requirement.

Tested with a 10k stemma Potentiometer, and separately with a resistor divider to test stability.

It occurs to me that 500ms might be too long for some people, maybe it can be configurable in the future.

brentru added a commit that referenced this pull request Oct 3, 2024
@tyeth tyeth force-pushed the use_analogReadMilliVolts-for-esp32-scaledAnalogRead-false branch from 50f1702 to f7eebe6 Compare October 11, 2024 16:45
@tyeth tyeth marked this pull request as ready for review October 15, 2024 17:27
@tyeth tyeth force-pushed the use_analogReadMilliVolts-for-esp32-scaledAnalogRead-false branch from 6129e63 to e74fb1b Compare October 15, 2024 17:34
@tyeth tyeth changed the title Use_analogReadMilliVolts-for-esp32-scaledAnalogRead-false Use analogReadMilliVolts for esp32 and update hysteresis Oct 15, 2024
@tyeth tyeth requested a review from brentru October 15, 2024 18:58
@tyeth
Copy link
Contributor Author

tyeth commented Oct 15, 2024

@brentru this is ready for review

@tyeth tyeth force-pushed the use_analogReadMilliVolts-for-esp32-scaledAnalogRead-false branch 2 times, most recently from 07b2512 to 603f0c9 Compare October 21, 2024 13:04
@tyeth tyeth force-pushed the use_analogReadMilliVolts-for-esp32-scaledAnalogRead-false branch from 603f0c9 to 7b10b13 Compare October 25, 2024 17:14
@tyeth tyeth force-pushed the use_analogReadMilliVolts-for-esp32-scaledAnalogRead-false branch from 2b3be79 to 9c6187f Compare November 14, 2024 15:26
@tyeth tyeth requested a review from brentru November 15, 2024 15:13
@tyeth
Copy link
Contributor Author

tyeth commented Nov 15, 2024

@brentru this should be ready again, retested it after the refactor

Copy link
Member

@brentru brentru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I have no further comments

@tyeth tyeth merged commit 0e9993b into adafruit:main Nov 15, 2024
39 checks passed
@tyeth tyeth deleted the use_analogReadMilliVolts-for-esp32-scaledAnalogRead-false branch November 15, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants