Skip to content

some code issues #1

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

Closed
AsimHex opened this issue Apr 4, 2021 · 4 comments · Fixed by #2
Closed

some code issues #1

AsimHex opened this issue Apr 4, 2021 · 4 comments · Fixed by #2

Comments

@AsimHex
Copy link

AsimHex commented Apr 4, 2021

In Header file :

//The value of the sense resistor for voltage measurement in Ohms
int _senseResistance = ACS37800_DEFAULT_SENSE_RES;

//The value of the divider resistance for voltage measurement in Ohms
int _dividerResistance = ACS37800_DEFAULT_DIVIDER_RES;

This code is what we have it should be float not int

//The value of the sense resistor for voltage measurement in Ohms
float _senseResistance = ACS37800_DEFAULT_SENSE_RES;

//The value of the divider resistance for voltage measurement in Ohms
float _dividerResistance = ACS37800_DEFAULT_DIVIDER_RES;

@PaulZC
Copy link
Collaborator

PaulZC commented Apr 4, 2021

Hi @AsimHex ,
I believe the code is correct.
Looking at _senseResistance:
Here is where it is stored as int
Here is where the default value is defined as const int
Here is the function definition to change the resistance - it expects an int
Here is the code for that function - the parameter is int
Here is one of two places where the resistance is used. The first thing that happens is that the resistance is cast to a float.
I am going to close this as I believe the code is correct, but please reopen if you think I have missed something.
Best wishes,
Paul

@PaulZC PaulZC closed this as completed Apr 4, 2021
@AsimHex
Copy link
Author

AsimHex commented Apr 5, 2021

did you try it on arduino uno??
int in arduino uno is from -32,768 to 32,767 and the "_dividerResistance " is 2000000 you define it in your code which will get an error number "bug" second thing resistor should be in float format since it's measurable value and can lead to a higher accuracy if you input the measured one rather typing an integer value

Best wishes
Asim

@PaulZC
Copy link
Collaborator

PaulZC commented Apr 5, 2021

Oh, yes, OK Asim - thank you,
I will investigate that.
Best wishes,
Paul

@PaulZC PaulZC reopened this Apr 5, 2021
@PaulZC PaulZC linked a pull request Apr 5, 2021 that will close this issue
@PaulZC PaulZC closed this as completed in #2 Apr 5, 2021
@PaulZC
Copy link
Collaborator

PaulZC commented Apr 5, 2021

Thank you Asim (@AsimHex ),
Corrected in v1.0.2
Best wishes,
Paul

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 a pull request may close this issue.

2 participants