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

reset() => getTotalVolume() #1

Closed
w0nk1 opened this issue Jan 2, 2018 · 15 comments
Closed

reset() => getTotalVolume() #1

w0nk1 opened this issue Jan 2, 2018 · 15 comments

Comments

@w0nk1
Copy link

w0nk1 commented Jan 2, 2018

Wouldn't it make sense to clear getTotalVolume() either during the reset() method?

@sekdiy
Copy link
Owner

sekdiy commented Jan 3, 2018

Question: in what scenario would this make sense for you and what's your intended use case?

The persistence of the total volume counter across calls of reset() is intentional.

The basic idea is that of a meter – in contrast to a simple counter.
Comparable to the speedometer in a car, the flow meter has two counters:

  • current value(s) inbetween resets,
  • total value(s) across resets.

Resetting the total value(s) wouldn't make much sense, since they would then never differ from the current value(s) in most scenarios.

Ideally, the total volume and flow rate would persist across power cycles (in order to make tampering more difficult).
But I don't consider this a responsibility of the FlowMeter class at this time.

I could add a way to store these values into non-volatile memory if there is demand for that.
Pull request are of course welcome.

@sekdiy sekdiy self-assigned this Jan 3, 2018
@sekdiy sekdiy added the question label Jan 3, 2018
@sekdiy sekdiy closed this as completed Jan 10, 2018
@w0nk1
Copy link
Author

w0nk1 commented Jan 11, 2018

In my special case I'm using it for a beverage machine with a bunch of meters. In this case I use a shift register to switch between those meters and need a variable to keep track of this. So it would be nice, to have a value which counts the poured liquid and is resettable.

@sekdiy sekdiy reopened this Jan 12, 2018
@sekdiy
Copy link
Owner

sekdiy commented Jan 12, 2018

Can you clarify how you intend to use the FlowMeter object in this?
Normally, you would just create multiple FlowMeter instances.
How you store them (e.g. in an indexed array) is up to your application.

I don't think you should count the flow rates of multiple sensors using just one FlowMeter object.
But if you must do it this way, why not use the getCurrentVolume() method instead?
The 'current' values will by zeroed by calling reset().

@w0nk1
Copy link
Author

w0nk1 commented Jan 12, 2018

The problem is, that the count of the flowMeters should be dynamic and I read them during startup of an SDCard via JSON. So I can't initialize it on top of the Application. So I came up with the solution to use just one Instance and cycle them through a shift register.

But I haven't seen the getCurrentVolume()method facepalm
This case could be closed! Sorry!! :-/

Thanks for clarifying!

@sekdiy
Copy link
Owner

sekdiy commented Jan 12, 2018

Okay, I see. So you'd like to load and store the state(s) of the meter(s).

This feature has been requested before, maybe it's worthwhile to integrate (since Arduino offers Flash memory anyway).

Until then I think it might be a possibility for you to just modify the library by adding setter methods (and then doing the initialisation that way).

You could probably get away with setting _totalDuration and _totalVolume, since the total flow rate will be recalculated from that:

void FlowMeter::setTotalDuration(totalDuration) {
    this->_totalDuration = totalDuration;
}

void FlowMeter::setTotalVolume(totalVolume) {
    this->_totalVolume = totalVolume;
}

Current values would then start from zero every time after startup, but this might be what you want anyway.

Depending on what other details you need, you could add further setters, e.g. for _totalCorrection in case you use the calibration feature.

@w0nk1
Copy link
Author

w0nk1 commented Jan 20, 2018

Thank you! :-) I'll check on that!

sekdiy pushed a commit that referenced this issue Feb 27, 2018
…ssue #1),

cleaned up code comments a little,
dropped Arduino 1.0 support,
bumped version number in order to reflect changes (see issue #2),
@sekdiy sekdiy closed this as completed Mar 24, 2018
@sekdiy
Copy link
Owner

sekdiy commented Aug 12, 2020

I'd like to reopen this issue in order to find a solution to the problem of wether to reset total values on a call to reset() or not.

Since the FlowMeter library would lose a feature – total values strictly being monotonic (i.e. never losing volume that has been accounted for) during runtime – I'm thinking about adding a third set of values to get instead.

The meaning would be:

  • get volume and average flow rate since last reset
  • accumulate the same way total flow rate and volume are accumulated
  • reset to zero on every call of reset()

I think it would be rather simple to accomplish this, but I can't come up with a good name right now.
It's not a set of current values, but also not a set of total values.
It's inbetween, but the only name I could come up with so far is getVolumeSinceLastReset()...

Issues affected: #13, #21

@sekdiy sekdiy reopened this Aug 12, 2020
sekdiy added a commit to outlandnish/FlowMeter that referenced this issue Aug 12, 2020
see sekdiy#1 for a possible solution to this feature
sekdiy added a commit to outlandnish/FlowMeter that referenced this issue Aug 12, 2020
see sekdiy#1 for a possible solution to this feature
@tasosman
Copy link

Hey how can I reset the total volume?I like to the amount of ml it push and after with one button I want to reset it to 0 and I start the measurements again .

@sekdiy
Copy link
Owner

sekdiy commented Dec 15, 2021

Hey @tasosman,

could you achieve your goal by using current volume instead of total volume?

Current volume – and other current values – are affected by a reset(), because they are intermittent (only relevant for one flow 'session').

Total volume – and other total values – are persistable values, i.e. for bookkeeping or long-term summation/statistics.

@tasosman
Copy link

Yes I check it when I use current volume is sawing l/s but me use the total so I can see how much ml run ,but I fix that I use what are you take off of your code so I put it back and now I can reset the total volume by using the reset .it is a little only difficult to calibrate my sensor now because I use coffee machine and is passing max 400 ml/minute

@sekdiy
Copy link
Owner

sekdiy commented Dec 15, 2021

Alright, thanks for the feedback.

Yes, modifying the code to also reset the total values is what most people do when they have an application like that.

Well, this thread/issue serves as a place for me to discuss this as a feature request.

So I consider your case another data point in favour of the feature. :)

@sekdiy
Copy link
Owner

sekdiy commented Dec 15, 2021

Coffee machines (I'm a LaCimbali Junior user) were one of my initial motivations to create this library, along with garden irrigation.

If you'd like to discuss your sensor and its calibration, please open another issue here.

@tasosman
Copy link

tasosman commented Dec 15, 2021 via email

@tasosman
Copy link

I will open new one

@sekdiy
Copy link
Owner

sekdiy commented Dec 9, 2022

I'm closing this issue due to inactivity.
If you have new information, please reopen it.

@sekdiy sekdiy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants