Skip to content

Conversation

Jay947462
Copy link

Reads current from HAS-50 current sensor (blue thing with hole in middle) with an accuracy of around +-50 mA.

float current = raw / SENS_SCALE;

return current;

Copy link
Member

Choose a reason for hiding this comment

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

I'd set the resolution back to 10 here. That way, this function has no side effects, and you don't need to keep track of the order of read() calls or wonder what the resolution is for any given function in a year or two when you come back to this

Copy link
Contributor

Choose a reason for hiding this comment

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

"Set back" in which meaning:

At the end of the function call analogReadResultion(10);

Or just never change it at all?

Copy link
Member

Choose a reason for hiding this comment

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

Reset it at the end of the function. Idk enough about the sensor or the Teensy to know if it needs to be changed in the first place, but if it does, either confirm that you can use 12 bits everywhere (and only change it once in setup(), or err on the side of caution and reset it back to 10 at the end of this function

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.

3 participants