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

Erroneous data after setSamplesInUse() #46

Closed
sonic74 opened this issue Sep 28, 2020 · 4 comments
Closed

Erroneous data after setSamplesInUse() #46

sonic74 opened this issue Sep 28, 2020 · 4 comments

Comments

@sonic74
Copy link

sonic74 commented Sep 28, 2020

When doing

LoadCell.begin();
long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
LoadCell.start(stabilizingtime, _tare);
LoadCell.setCalFactor(calibrationValue); // user set calibration value (float)
LoadCell.setSamplesInUse(1)
if (LoadCell.update()) newDataReady = true;
//get smoothed value from data set
if (newDataReady) {
  float a = LoadCell.getData();
}

I get wrong data. Shouldn't

long lastSmoothedData;

be initialized to 0?

@olkal
Copy link
Owner

olkal commented Sep 28, 2020

Hi!
Initializing lastSmoothedData in the .h file should not be required as it is being assigned to a value before use (in line 258 of the .cpp file).

I'm not able to replicate an error using setSamplesInUse(1), output data is as expected. Could you please provide the complete sketch?

@sonic74
Copy link
Author

sonic74 commented Sep 29, 2020

Initializing lastSmoothedData in the .h file should not be required as it is being assigned to a value before use (in line 258 of the .cpp file).

Only when calling getData() before setSamplesInUse()

@olkal
Copy link
Owner

olkal commented Sep 29, 2020

You're right. I have revised the header file according to your comment, thanks.

@olkal olkal closed this as completed Sep 29, 2020
@sonic74
Copy link
Author

sonic74 commented Oct 2, 2020

Unfortunately, the missing initialisation doesn't seem to have been the culprit. As a workaround I now added refreshDataSet() after setSamplesInUse()

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

No branches or pull requests

2 participants