Arduino UNO R3 using two outputs dependent to different inputs

what causes storage tank pump to start?

Storage tank not full signal through the cyclic on/off timer and if flow senses then pump will continue to run until storage tank full signal active=5v

ok. there are 2 pump connected to the storage tank. one from the OH tank and one pumping elsewhere, the "suction pump"?

what cause the "suction pump" to turn?

suction pump is the storage tank filling pump, that is the 1st pump (That logic/codes are working fine with timer and two inputs, Pin#3 & Pin#4. output is Pin#8 for this pump)

Input Pin #5 tank empty= 0v, will not allow the Pump to run, means Digital output Pin # 9 will be 0V, Wen HIGH if level is enough to pump, 5v, this will allow the pump to run Digital out pin # 9 will be 5v if ohtankfull input Pin # 7 is not activated means "LOW" 0V and ohtanklow signal at pin# 6 is activated, LOW, 0V( This pin we take 0v as activated)

ohtanklow #6 overhead tank level low signal, low = LOW , 0v

ohtanklow #6 overhead tank level low signal, low = LOW , 0v

ohtankfull #7 overhead tank level full signal full = HIGH, 5V, when this becomes HIGH, 5V, will stop the pump relay (Digital output pin # 9)

you're explaining how it works, not what is does?

sounds like you don't have a problem i can help you with.

Several times I explained, the part of my logic with input Pin# 3, 4 and Output Pin# 8 with timer function is working fine.
But the part in which 2nd pump involved, with input pin # 5, 6, 7 and output Pin # 9 is not functioning at all.

Take exactly these lines out of your top posted code:

  if (tankempty == LOW && ohtankfull == HIGH) {
    motorState = 3;//turns off.
    counterFunction(motorState);
  }
  if (tankempty == LOW && ohtanklow == LOW) {
    motorState = 4;//turns on.
    counterFunction(motorState);
  }
  if (tankempty == HIGH && ohtanklow == LOW ) {
    motorState = 3;// not pressed.
    counterFunction(motorState);

  }
  Serial.println(motorState);

and replace them with these lines:
// fix the following lines, if needed, for what means 0 and 5 volts
  bool ohTankFull = digitalRead(ohtankfull);
  bool ohTankLow = !digitalRead(ohtanklow);
  bool tankOK = digitalRead(tankempty);

// select reset Pump 2 status:
  static bool okToPump = true;

  if (ohTankFull)
    okToPump = false;

  if (ohTankLow)
    okToPump = true;

  bool motorUp = okToPump && tankOK;

  digitalWrite(motorUpPin, motorUp); 
  if (motorUp)
    Serial.println("Pump 2 is OFF...");
  else
    Serial.println("Pump 2 is ON:...");

Please read the comment and adjust the logical polarity of the reports from you sensors. Here's where some better names and hiding the 0, 5 volt LOW and HIGH stuff would help.

The pump can be on or off at reset, that is to say ready to run or not if there is fluid available

That's beyond tapped out for me. You have not shown any interest, so I'm just having fun.

a7

And get rid of the non-sensical lines near the top of your loop - pointed out earlier, commented out here:

//  int tankempty = digitalRead(tankempty);
//  int ohtanklow = digitalRead(ohtanklow);
//  int ohtankfull = digitalRead(ohtankfull);

a7

Alto, thanks a lot, highly appreciated your help. Now logic for “ohTank “has started working. Some minor issues are there with input Pin# 6 (ohTanklow) & 7 (ohTankfull), Pin # 5 (storage tank LOW) is perfectly functioning.
• If Pin # 5 is “HIGH” storage tank level not LOW and Pin # 6 high comes, it is starting the “motorup” digital output Pin# 9, which is fine, but after filling the tank Pin # 7 will become high (ohTankfull), that should stop the “motorup” digital output Pin# 9, which is not happening.
• If manually I give Pin # 5 “HIGH” storage tank level not LOW and first simulating Pin # 7 signal “HIGH”, pump not running, with that I give Pin # 6 signal, pump starting even I remove the Pin # 6 signal, it keeps running until I remove the Pin # 7 signal (ohTankfull). That is wrong function.
Our required conditions are as below.
• If Pin # 5 is “HIGH” storage tank level not LOW and Pin # 6 “LOW”, it should start the “motorup” digital output Pin# 9, but during filling first Pin#6 will chage to “HIGH”, that time Pin#9 output should remain on till filling the tank and Pin # 7 become high (ohTankfull), then should stop the “motorup” digital output Pin# 9 [ Pin #5, HIGH + Pin #6 “LOW” + Pin # 7 “LOW” = Output Pin #9 should be “HIGH” (motor running)]
• If Pin # 5 is “HIGH” + Pin # 6 “HIGH” + Pin# 7”LOW” = Output Pin# 9 should be “HIGH” (motor running)
• If Pin # 5 is “HIGH” + Pin # 6 “HIGH” + Pin# 7”HIGH” = Output Pin# 9 should be “LOW” (motor stop)
• In any condition if Pin#5 becomes “LOW”, should stop the output Pin#9 (motor stop)

Please show us the code you are currently talking about in a new post.

If you used my code suggestion, did you carefully verify the polarity of the sensor readings and make any necessary adjustments?

Write an English description of the function of the OH tank and how the three sensors control the pump motor.

DO NOT USE THESE WORDS or symbols: pin, HIGH, LOW, low, output, voltage, #, 5, 6, 7, 9.

Like this:

The OH tank is filled from the storage tank using Pump #2.


There is one sensor for OH tank empty, and second sensor for OH tank full.


If the OH tank is empty, run Pump #2 until the OH tank is full.


Pump #2 should turn on again when the OH tank becomes empty.


Pump #2 should no run if there is no water for it: There is a sensor that can report that condition, it should inhibit Pump #2 from running in any case.

a7

Hi Alto,
Below I have tried to explain the phenomenon of Pump 2 without using symbolic terms, hope it will clear my point.

The function of Pump 2 is to fill the overhead tank; pump sucks the water from storage tank. In storage tank I use one sensor at bottom of tank for (Low level signal = Pin#5) this sensor must be activated (Giving -5 volts to Pin#5) for permission to run the Pump 2 in all conditions.
In overhead tank I am using two sensors, one in bottom of tank for Low Level signal and other is top of tank for Tank full signal. (Low Level signal is -5 volts to Pin# 6, Tank full signal is -5 volts to Pin# 7).
If the OH tank is empty, and storage tank is not giving Low Level input, it will run Pump #2 until the OH tank is full.
Pump #2 should turn on again when the OH tank becomes empty and storage tank is not giving Low Level input.
Note: My all digital inputs are negative 5 volts.

As far as I can tell, the code I wrote should do exactly what you are trying to accomplish, and what I have said several times without contradiction or correction from you.

Again:

Please show us the complete program you are currently talking about in a new post.

If you used my code suggestions, did you carefully verify the polarity of the sensor readings and make any necessary adjustments?

I got the rest of my life here. You only delay progress by failing to answer our questions and requests.

a7

Sensor polarity I have checked, as I told earlier, my all sensors giving negative 5 volts to digital input pins of Arduino. Independently sensors are performing well. Below I am posting the existing running program after using your code suggestions.

Did you deliberately ignore the advice on posting code in the forum ?

Please follow the advice given in the link below when posting code. Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

If you remove these lines exactly

  if (ohTankFull)
    okToPump = false;

  if (ohTankLow)
    okToPump = true;

and replace them with

  if (ohTankLow)
    okToPump = true;

  if (ohTankFull)
    okToPump = false;

that will make it respond differently to the impossible tank is full AND empty condition.

ohTankFull true means the OH tank is past the full level sensor.
ohTankLow true means the tank is below the low level sensor.

If ohTankLow is true and ohTankFull is false, the OH tank is very empty.

if ohTankLow is false and ohTankFull is false, the tank is between full and empty.

if ohTankLow is false and ohTankFull is true, the tank is very full.

if ohTankLow is true and ohTankFull is true, this is "impossible".

This is an opportunity to think about a sensor fault condition, one each for both tanks. Neither tank nor any real tank can be simultaneous full and empty; this should be reported as a malfunction. Naturally in this case there is a decision to be made about how the system responds.

a7

Thanks a lot, Alto777, now logic is working as expected.

Sorry UKHeliBob,
I am quite new in the forum and Arduino Learning, I have not done deliberately, next time will take care.
Thanks for reminding me.
takecare

Please edit your post and add the code tags

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.