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

init analog input w/o pullup #348

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

elral
Copy link
Collaborator

@elral elral commented Jan 6, 2025

Description of changes

In the actual code a pin for reading analog values is initialized with pullups enabled. When connecting a potentiometer to the pin this internal resistor is always parallel to the "upper" part of the potentiometer. The internal pullup resistor is ~35kOhm.
This results in a non linear behaviour of the potentiometer. For a 10kOhm potentiometer the deviation is max. 4% at 70% position, this increases for higher values of the potentiometer.
Examples are:
50kOhm: 16% deviation at 70% position
100kOhm: 26% deviation at 70% position
500kOhm: 56% deviation at 80% position

The code change is not to use the internal pullup resistor. Also setting the pinMode() is not required as this is done during the analogRead() function.

Fixes #347

@elral elral requested a review from DocMoebiuz as a code owner January 6, 2025 08:54
Copy link

github-actions bot commented Jan 6, 2025

Board and firmware folder for this pull request:
Mobiflight-Connector.zip

Copy link
Collaborator

@DocMoebiuz DocMoebiuz left a comment

Choose a reason for hiding this comment

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

We want to introduce a new device type so that

  • old, existing analog inputs maintain the current logic (with pullup)
  • newly added analog inputs will use no pullup

Copy link

github-actions bot commented Jan 6, 2025

Board and firmware folder for this pull request:
Mobiflight-Connector.zip

Copy link

github-actions bot commented Jan 7, 2025

Board and firmware folder for this pull request:
Mobiflight-Connector.zip

@elral elral requested a review from DocMoebiuz January 7, 2025 04:47
@elral
Copy link
Collaborator Author

elral commented Jan 7, 2025

With last commit a new device type is added to keep backwards compatibility

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.

Analog read shows non-linear behaviour
2 participants