Currently I am working on a project the purpose of which is to test filling process of a reservoir. Filling process has a medium: an airgap with 3 floating switches: 1. lower level 2. upper level 3. overflow. The way it has to go is I fill an airgap with a city water. Inlet of water is controlled by a solenoid valve (in code - upper_relay; needs to be in LOW state due to SPDT (single-pole-double-throw) relay). Once I reach lower level floating switch, I activate airgap-draining pump (in code: lower_relay, needs to be HIGH). The reality is that airgap pump flow rate is smaller that the one for inlet valve, thus I have evacuate function of level things up. In case water hits overflow floating switch (#3), I drain water up to upper limit floating switch (#2).
While doing all this, I monitor pressure switch, which is mounted inside a big reservoir, which I try to fill up to a certain level (nearly 8 liters). So, once I reached 8 liters, I go to cycle_complete function, where I drain airgap to a lower level floating switch (#1), and then activate another function - chamber_drain which drains the reservoir completely (i.e. all 8 liters).
The code worked fine just before I inserted 2 functions:
- final drain //to drain airgap to a lower level floating switch #1
- chamber_drain //to drain 8 liters
These 2 functions are getting called in a cycle_complete function, but they mess up all the code, or cause it to malfunction…
Please help me to understand the reasoning behind it… I’ve been trying to fix it for over 1 week…
I attached picture with test setup.
The code is attached as well (cannot show it here, since will exceed max limit)
reservoir_filling.txt (17.2 KB)