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

Flow Sensor not resetting for stations without flow meter #248

Open
bb09961 opened this issue Aug 27, 2023 · 1 comment · May be fixed by #251
Open

Flow Sensor not resetting for stations without flow meter #248

bb09961 opened this issue Aug 27, 2023 · 1 comment · May be fixed by #251

Comments

@bb09961
Copy link

bb09961 commented Aug 27, 2023

Only a few of my stations are plumbed in to my flow meter. When a station without the flow meter runs, the previous station's flow rate is stored in the logs. It should store a 0. The attached screenshot shows the entries in red that should be 0. The values in green are correct. This issue shows up in my case, but also would be present if a station did not water at all due to a valve not opening.

Flow_Rate_Not_Resetting

Based on the comments in flow_poll() function, this IF statement jumps out of the function if the sensor never drops from HIGH to LOW, OR it would also jump out if the sensor never changes at all. This is the case for my stations without a flow meter.

void flow_poll() {  
...  
	if(!(prev_flow_state==HIGH && curr_flow_state==LOW)) { // only record on falling edge  
		prev_flow_state = curr_flow_state;  
		return;  
	}

If the sensor never changes, then it will never get to execute any of the following initialization code inside flow_poll() :

	/* RAH implementation of flow sensor */
	if (flow_start==0) { flow_gallons=0; flow_start=curr;} // if first pulse, record time
	if ((curr-flow_start)<90000) { flow_gallons=0; } // wait 90 seconds before recording flow_begin
	else {	if (flow_gallons==1)	{  flow_begin = curr;}}
	flow_stop = curr; // get time in ms for stop
	flow_gallons++;  // increment gallon count for each poll
	/* End of RAH implementation of flow sensor */

Would it work to move or copy the "flow_gallons=0" from flow_poll() to the turn_on_station() function where the flow_start variable is also reset?

void turn_on_station(byte sid, ulong duration) {
	// RAH implementation of flow sensor
	flow_start=0;
	//Move or copy flow_gallons reset here?//
	flow_gallons=0

If flow_gallons=0 is moved, then the existing code in the turn_off_station() function should work properly to log a 0 for flow_last_gpm:

	// RAH implementation of flow sensor
	if (flow_gallons > 1) {
		if(flow_stop <= flow_begin) flow_last_gpm = 0;
		else flow_last_gpm = (float) 60000 / (float)((flow_stop-flow_begin) / (flow_gallons - 1));
	}// RAH calculate GPM, 1 pulse per gallon
	else {flow_last_gpm = 0;}  // RAH if not one gallon (two pulses) measured then record 0 gpm
bb09961 added a commit to bb09961/OpenSprinkler-Firmware that referenced this issue Sep 21, 2023
…ler#248

If a station did not have a flow meter or open properly, the code was recording the flow amount from the previous station run to the logs. This should reset the flow_gallons counter properly when a station starts.
@bb09961
Copy link
Author

bb09961 commented Sep 21, 2023

After testing, I've submitted Pull Request #251 with the suggested change from above.

@bb09961 bb09961 linked a pull request Sep 21, 2023 that will close this issue
@bb09961 bb09961 mentioned this issue Jul 27, 2024
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.

1 participant