Forum Software Ferduino code ATO

ATO  [SOLVED]


ATO

Post Number:#1 Post Mon Mar 16, 2015 7:57 pm
Posts: 12
Topics: 2
Solve rating: 0
Joined: Fri Dec 12, 2014 2:49 am
Topics: 2
Age: 58
Gender: None specified
National Flag:
Great Britain
Hi
Need some help with ATO
Want to use 2 float switches High level & Low level
Low level turn pump on, High Level turn pump off , Max pump running time 120 seconds.
NO IDEA about coding, have looked but very complex and most comments in Portuguese, which confuses me.

Anybody run this with Ferduino, if so can you show that bit of code, would maybe be able to work things out if saw working example.
Using the Ferduino board
Thanks
Graeme

Post Number:#2 Post Mon Mar 16, 2015 10:31 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

What happens if 2 minutes wasn't enough to fill the sump?

This function will be checked with which periodicity?

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#3 Post Mon Mar 16, 2015 10:55 pm
Posts: 12
Topics: 2
Solve rating: 0
Joined: Fri Dec 12, 2014 2:49 am
Topics: 2
Age: 58
Gender: None specified
National Flag:
Great Britain
My sump design makes 2 mins ample time to bring level from low to high.
Need something like this in Ferduino code.

[codebender]https://codebender.cc/embed/sketch:94711[/codebender]

Not sure if that link works.. Here's the code

byte lowWaterPin = 6;   
byte highWaterPin = 7;   
byte pumpPin = 8;        // Relay to control the water pump


unsigned long maxRunTime = 120000;   // pump on for max of X miliseconds
unsigned long minOffTime = 60000;  // pump must be off for at least Y miliseconds
unsigned long switchDebounceTime = 3;  // Switch must be activated for at least Z miliseconds.

unsigned long lastPumpTime = 0;

unsigned long lastLowWaterDetectTime = 0;
boolean lastLowWaterState = HIGH;

boolean pumpRunning = true;


void setup(){
  pinMode(lowWaterPin, INPUT_PULLUP);
  pinMode(highWaterPin, INPUT_PULLUP);
  pinMode(pumpPin, OUTPUT);
}

void loop(){

  unsigned long currentMillis = millis();

  boolean lowWaterState = digitalRead(lowWaterPin);
  boolean highWaterState = digitalRead(highWaterPin);

  if(lowWaterState != lastLowWaterState){
    lastLowWaterDetectTime = currentMillis;
  }


  if (pumpRunning) {  // if the pump is on then let's see if we should turn it off yet

    if ((highWaterState == LOW) || (currentMillis - lastPumpTime >= maxRunTime)){
      digitalWrite(pumpPin, HIGH);
      pumpRunning = false;
      lastPumpTime = currentMillis;
    }
  }
  else {   // pump is not running, see if we need to turn it on

      if((lowWaterState == LOW)  &&  (currentMillis - lastLowWaterDetectTime >= switchDebounceTime) && (currentMillis - lastPumpTime > minOffTime)){   // switch is low and has been for at least 3 seconds
        digitalWrite(pumpPin, LOW);
        pumpRunning = true;
        lastPumpTime = currentMillis;
      }
  }

  lastLowWaterState = lowWaterState;

}
Last edited by Fernando Garcia on Tue Mar 17, 2015 8:45 am, edited 1 time in total.
Reason: Please use tags [code][/code] to post any code here.

Post Number:#4 Post Tue Mar 17, 2015 8:58 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

The link from codebender should be as this: https://codebender.cc/embed/sketch:94711 look to embed/ between .cc/ and sketch:.

Have you tested this code?

The function analogRead returns a value between 0 and 1023 so, I think better use < 400 or > 400 instead == LOW or == HIGH.

Best regards.
Last edited by Fernando Garcia on Tue Mar 17, 2015 9:57 am, edited 1 time in total.
Reason: Replaced digitalRead by analogRead
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#5 Post Tue Mar 17, 2015 9:25 am
Posts: 12
Topics: 2
Solve rating: 0
Joined: Fri Dec 12, 2014 2:49 am
Topics: 2
Age: 58
Gender: None specified
National Flag:
Great Britain
Hi
Yes have had that code running on a stand alone Mega 2560 and works.
trying to get my Ferduino board set to work ATO in the same manner.
No matter how many sensors I connect to the Ferduino can't get any output on the A8 pin on the relay 1 connection.
Need the Ferduino ATO to work with just 2 sensors i.e. Highwater---- Lowwater
Basically what change to ferduino code is needed so ATO can work with just 2 sensors connected
Hope you understand what I mean
Thanks
Graeme

Post Number:#6 Post Tue Mar 17, 2015 9:37 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Have you checked this topic viewtopic.php?f=8&t=73&p=525&hilit=ato ?

The level sensors are connected on pins A0 - A5
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#7 Post Tue Mar 17, 2015 9:45 am
Posts: 12
Topics: 2
Solve rating: 0
Joined: Fri Dec 12, 2014 2:49 am
Topics: 2
Age: 58
Gender: None specified
National Flag:
Great Britain
Yes saw that had sensors connected to A1 & A2 . i.e. sensor 2&3
If I understand the code they should activate pump on A8 which is on relay 1 ??? I get no output on A8

Ran your test code on the sensors and they work get 1023 and 0 readings
Thanks
Graeme

Post Number:#8 Post Tue Mar 17, 2015 10:11 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

You are talking about the connector RJ45 called RELAYS-1.

This code is using 3 digital pins not analog for it's using digitalRead instead analogRead.

To use the pins A8 the code should be:

byte pumpPin = A8;


or

byte pumpPin = 62;


The pin A8 is used to partial water change as I told on topic quoted above so, change the number of bomba3Pin to any other higher 80.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#9 Post Tue Mar 17, 2015 10:38 am
Posts: 12
Topics: 2
Solve rating: 0
Joined: Fri Dec 12, 2014 2:49 am
Topics: 2
Age: 58
Gender: None specified
National Flag:
Great Britain
So changed code to this

const byte bomba3Pin = 86; // A8; // Bomba que coloca água no sump. is this correct

Sensors connected to sensor 2&3

Still no output on A8 pin on Relays-1
Thanks

Post Number:#10 Post Tue Mar 17, 2015 10:54 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Using default code only change

const byte solenoide1Pin = 85;


To:

const byte solenoide1Pin = 62;



Because I'm using a solenoid instead pump to fill the sump but, it no matter.

Remember that the conditions to turn on the pump are:

if((analogRead(sensor3) > 400) && (analogRead(sensor2) > 400) && (bitRead(tpa_status,1) == false) && (bitRead(status_parametros,0) == false) && (bitRead(tpa_status,2) == false))


It mean:

Partial water change (PWC) not running;
Chiller OFF;
No errors during a PWC;
Normal level on sump.

After test it adjust the code using your example.
Last edited by Fernando Garcia on Tue Mar 17, 2015 11:01 am, edited 1 time in total.
Reason: Spelling
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#11 Post Tue Mar 17, 2015 12:16 pm
Posts: 12
Topics: 2
Solve rating: 0
Joined: Fri Dec 12, 2014 2:49 am
Topics: 2
Age: 58
Gender: None specified
National Flag:
Great Britain
That seems to be working very close to the way I want it, by using this

void reposicao_agua_doce () // abre a solenoide 1 se o nível estiver baixo e se a tpa não estiver em andamento
//e se o chiller estiver desligado e se o nível do sump não estiver anormal e se não houve falha durante uma tpa.
{
  if((analogRead(sensor3) > 400) && (analogRead(sensor2) < 400) && (bitRead(tpa_status,1) == false) && (bitRead(status_parametros,0) == false) && (bitRead(tpa_status,2) == false))
  {
    digitalWrite(solenoide1Pin,HIGH);
    bitWrite(Status,1,0); //sinaliza reposição em andamento
  }
  else
  {
    digitalWrite(solenoide1Pin,LOW);
    bitWrite(Status,0,1); // sinaliza reposição em andamento
  }
}


Thanks
Graeme kkl :-)
Last edited by Fernando Garcia on Tue Mar 17, 2015 12:57 pm, edited 2 times in total.
Reason: Please use tags [code][/code] to post any code here.




Return to Ferduino code





Who is online

Users viewing this topic: No registered users and 1 guest