straight forward float valve control

Request new hardware or ideas for the controller
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Can you load this code?

Code: Select all

/**
 * I2CScanner.pde -- I2C bus scanner for Arduino
 *
 * 2009, Tod E. Kurt, http://todbot.com/blog/
 *
 */

#include "Wire.h"
extern "C" { 
#include "utility/twi.h"  // from Wire library, so we can do bus scanning
}

// Scan the I2C bus between addresses from_addr and to_addr.
// On each address, call the callback function with the address and result.
// If result==0, address was found, otherwise, address wasn't found
// (can use result to potentially get other status on the I2C bus, see twi.c)
// Assumes Wire.begin() has already been called
void scanI2CBus(byte from_addr, byte to_addr, 
                void(*callback)(byte address, byte result) ) 
{
  byte rc;
  byte data = 0; // not used, just an address to feed to twi_writeTo()
  for( byte addr = from_addr; addr <= to_addr; addr++ ) {
    rc = twi_writeTo(addr, &data, 0, 1);
    callback( addr, rc );
  }
}

// Called when address is found in scanI2CBus()
// Feel free to change this as needed
// (like adding I2C comm code to figure out what kind of I2C device is there)
void scanFunc( byte addr, byte result ) {
  Serial.print("addr: ");
  Serial.print(addr,HEX);
  Serial.print( (result==0) ? " found!":"       ");
  Serial.print( (addr%4) ? "\t":"\n");
}


byte start_address = 1;
byte end_address = 128;

// standard Arduino setup()
void setup()
{
    Wire.begin();

    Serial.begin(57600);
    Serial.println("\nI2CScanner ready!");

    Serial.print("starting scanning of I2C bus from ");
    Serial.print(start_address,DEC);
    Serial.print(" to ");
    Serial.print(end_address,DEC);
    Serial.println("...");

    // start the scan, will call "scanFunc()" on result from each address
    scanI2CBus( start_address, end_address, scanFunc );

    Serial.println("\ndone");
}

// standard Arduino loop()
void loop() 
{
    // Nothing to do here, so we'll just blink the built-in LED
    digitalWrite(7,HIGH);
    delay(300);
    digitalWrite(7,LOW);
    delay(300);
}
Then open Tools->Serial Monitor, make sure that it is baud 57600 and paste the result here?
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

won't compile:


The following feature was automatically added:
Watchdog Timer
Version Menu

The following features were detected:
Simple Menu
C:\Program Files (x86)\Reef Angel Controller\libraries\Wire/utility/twi.h: In function 'void scanI2CBus(byte, byte, void (*)(byte, byte))':
C:\Program Files (x86)\Reef Angel Controller\libraries\Wire/utility/twi.h:44: error: too few arguments to function 'uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t)'
sketch_jun23a:23: error: at this point in file
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

bump. Any ideas?
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Sorry, the Arduino team changed the wire library.
Use this:

Code: Select all

/**
 * I2CScanner.pde -- I2C bus scanner for Arduino
 *
 * 2009, Tod E. Kurt, http://todbot.com/blog/
 *
 */

#include "Wire.h"
extern "C" { 
#include "utility/twi.h"  // from Wire library, so we can do bus scanning
}

// Scan the I2C bus between addresses from_addr and to_addr.
// On each address, call the callback function with the address and result.
// If result==0, address was found, otherwise, address wasn't found
// (can use result to potentially get other status on the I2C bus, see twi.c)
// Assumes Wire.begin() has already been called
void scanI2CBus(byte from_addr, byte to_addr, 
void(*callback)(byte address, byte result) ) 
{
  byte rc;
  byte data = 0; // not used, just an address to feed to twi_writeTo()
  for( byte addr = from_addr; addr <= to_addr; addr++ ) {
    rc = twi_writeTo(addr, &data, 0, 1, true);
    callback( addr, rc );
  }
}

// Called when address is found in scanI2CBus()
// Feel free to change this as needed
// (like adding I2C comm code to figure out what kind of I2C device is there)
void scanFunc( byte addr, byte result ) {
  Serial.print("addr: ");
  Serial.print(addr,HEX);
  Serial.print( (result==0) ? " found!":"       ");
  Serial.print( (addr%4) ? "\t":"\n");
}


byte start_address = 1;
byte end_address = 128;

// standard Arduino setup()
void setup()
{
  Wire.begin();
  pinMode(7,OUTPUT);
  Serial.begin(57600);
  Serial.println("\nI2CScanner ready!");

  Serial.print("starting scanning of I2C bus from ");
  Serial.print(start_address,DEC);
  Serial.print(" to ");
  Serial.print(end_address,DEC);
  Serial.println("...");

  // start the scan, will call "scanFunc()" on result from each address
  scanI2CBus( start_address, end_address, scanFunc );

  Serial.println("\ndone");
}

// standard Arduino loop()
void loop() 
{
  // Nothing to do here, so we'll just blink the built-in LED
  digitalWrite(7,HIGH);
  delay(300);
  digitalWrite(7,LOW);
  delay(300);
}
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

Thx Roberto:

Code: Select all

I2CScanner ready!
starting scanning of I2C bus from 1 to 128...
addr: 1       	addr: 2       	addr: 3       	addr: 4       
addr: 5       	addr: 6       	addr: 7       	addr: 8       
addr: 9 found!	addr: A       	addr: B       	addr: C       
addr: D       	addr: E       	addr: F       	addr: 10       
addr: 11       	addr: 12       	addr: 13       	addr: 14       
addr: 15       	addr: 16       	addr: 17       	addr: 18       
addr: 19       	addr: 1A       	addr: 1B       	addr: 1C       
addr: 1D       	addr: 1E       	addr: 1F       	addr: 20 found!
addr: 21       	addr: 22       	addr: 23       	addr: 24       
addr: 25       	addr: 26       	addr: 27       	addr: 28       
addr: 29       	addr: 2A       	addr: 2B       	addr: 2C       
addr: 2D       	addr: 2E       	addr: 2F       	addr: 30       
addr: 31       	addr: 32       	addr: 33       	addr: 34       
addr: 35       	addr: 36       	addr: 37       	addr: 38 found!
addr: 39       	addr: 3A       	addr: 3B       	addr: 3C       
addr: 3D       	addr: 3E       	addr: 3F       	addr: 40       
addr: 41       	addr: 42       	addr: 43       	addr: 44       
addr: 45       	addr: 46       	addr: 47       	addr: 48       
addr: 49       	addr: 4A       	addr: 4B       	addr: 4C       
addr: 4D       	addr: 4E       	addr: 4F       	addr: 50 found!
addr: 51       	addr: 52       	addr: 53       	addr: 54 found!
addr: 55       	addr: 56       	addr: 57       	addr: 58       
addr: 59       	addr: 5A       	addr: 5B       	addr: 5C       
addr: 5D       	addr: 5E       	addr: 5F       	addr: 60       
addr: 61       	addr: 62       	addr: 63       	addr: 64       
addr: 65       	addr: 66       	addr: 67       	addr: 68 found!
addr: 69       	addr: 6A       	addr: 6B       	addr: 6C       
addr: 6D       	addr: 6E       	addr: 6F       	addr: 70       
addr: 71       	addr: 72       	addr: 73       	addr: 74       
addr: 75       	addr: 76       	addr: 77       	addr: 78       
addr: 79       	addr: 7A       	addr: 7B       	addr: 7C       
addr: 7D       	addr: 7E       	addr: 7F       	addr: 80       

done
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Ok, so I know the module is being seen by the controller.
How do you have the float switch on channel 0 wired up?
Is it like this:
Image
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

there is my possible problem, will fix later today. Ground wire is plugged into the power connection (last on right) not second or third to right...

Do you think this will potentially fix my buzzer issue as well (low hum when plugged before uploading) constant load hum after?

THx
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

took the extra minute. That works. Will play more later. Appreciate the answer on the buzzer for later
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

The faint hum is because the pin is setup as input by default and has a internal pull-up, which causes it to have a very weak draw of current if you use it as output.
Does it buzz when you use the float switch?
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

The buzzer works great, the low hum is gone when wired up properly...there is just one problem ;)

It is completely backward. It buzzes when the float valve is not tripped, and turns off when the float valve is tripped. Pls help me correct this wayward buzzer...

Thx as always
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Cool.
Just add an exclamation mark :)

Code: Select all

digitalWrite(highATOPin,!ReefAngel.IO.GetChannel(0)); 
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

thx, buddy, works like a charm.
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

Well, I built my bracket, installed everything, and it works like a charm. However, the buzzer is not very loud. It is plugged into ato high, as described earlier,

Is there a way to make it louder, or does someone sell one that will SCREAM when this float valve triggers? :shock:

Thx, as always, in advance.
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

You can get a little bit louder if you use one of the PWM ports.
ATO ports = 5V
PWM ports = 10V
But if you need something much louder, you will need to use on of the relay ports and a stand alone buzzer.
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

rimai wrote:You can get a little bit louder if you use one of the PWM ports.
ATO ports = 5V
PWM ports = 10V
But if you need something much louder, you will need to use on of the relay ports and a stand alone buzzer.
So then...how would I change this line of code:

Code: Select all

 //turn off port 8 - main pump when switch is tripped and sound buzzer 
     ReefAngel.Relay.Set(Port8,ReefAngel.IO.GetChannel(0));
     pinMode(highATOPin,OUTPUT);
     digitalWrite(highATOPin,!ReefAngel.IO.GetChannel(0)); 
to use the pwm port. Thx in advance
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Which port would you want to use? Actinic or Daylight?
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

daylight
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Replace the above with this:

Code: Select all

//turn off port 8 - main pump when switch is tripped and sound buzzer 
     ReefAngel.Relay.Set(Port8,ReefAngel.IO.GetChannel(0));
     ReefAngel.PWM.SetDaylight(ReefAngel.IO.GetChannel(0)*100); 
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

rimai wrote:Replace the above with this:

Code: Select all

//turn off port 8 - main pump when switch is tripped and sound buzzer 
     ReefAngel.Relay.Set(Port8,ReefAngel.IO.GetChannel(0));
     ReefAngel.PWM.SetDaylight(ReefAngel.IO.GetChannel(0)*100); 
This ALMOST works. I put in the line of code and now the buzzer screams when the switch is NOT TRIPPED rather than when it is. I tested by tripping the switch and it turned off. I probably need a !, but not sure where to put it. Thx
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Try this:

Code: Select all

//turn off port 8 - main pump when switch is tripped and sound buzzer 
     ReefAngel.Relay.Set(Port8,ReefAngel.IO.GetChannel(0));
     ReefAngel.PWM.SetDaylight(100-(ReefAngel.IO.GetChannel(0)*100)); 
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

First Question:
rimai wrote:Try this:

Code: Select all

//turn off port 8 - main pump when switch is tripped and sound buzzer 
     ReefAngel.Relay.Set(Port8,ReefAngel.IO.GetChannel(0));
     ReefAngel.PWM.SetDaylight(100-(ReefAngel.IO.GetChannel(0)*100)); 
This works as designed. Thanks. As I was testing, I got to thinking, however. I read a blurb on here recently where once the overflow trips, you want it to stay tripped until you can get to the tank and clear the blockage or whatever was causing the overflow switch to stop the pump. This would prevent the tank from draining, resetting the float switch, restarting the pump until it backed up and tripped the switch again. Is this possible?

Second Question
Oh, in this case it is simple.
You can use one of the custom variables.
CODE: SELECT ALL
ReefAngel.CustomVar[0]=ReefAngel.IO.GetChannel(0);
ReefAngel.CustomVar[7]=1;

Then, on the Portal, you can set a trigger to send you alerts when C0 = 0.
How long does it take the portal to pick up these alerts and send out the emails? Again I was testing tonite, held the switch tripped for 40-50 seconds, at least, but still didn't send. LMK and Thanks as always.
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

The controller sends data to portal every 5 minutes.
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

so that means it would have to stay tripped for whatever length of time elapses from when it happens until the controller next sends, yes?

Then that makes my first question very important... how do you make it stay tripped, once tripped? THx
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Wouldn't it stay tripped if it does trip?
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

actually no. The water level in the tank with the pump off is below the float valve. So when the water rises enough to trip the float valve, the pump stops and the water level falls (which is what I want.) However, under the current design when the water falls, it resets the switch and the pump turns back on.

While this is not catastrophic I was referring to the post regarding letting a pump cycle on and off and it not being good for it. LMK what you think. Thx
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Is it an overflow you are trying to measure or is it something else?
Just curious.
If you want to make it trip and disable the pump until you inspect, we can do that.
Right now, it will turn on /off the port depending on the state of the float switch.
We can also leave the pump the way it is and make the custom variable stick, so if it does trip, the custom variable will change and not go back until you inspect.
Which one you prefer?
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

It is an overflow and it is working like you said...

Your idea:
We can also leave the pump the way it is and make the custom variable stick, so if it does trip, the custom variable will change and not go back until you inspect.
sounds like exactly what I want. Keep in mind we have a setting on the portal to send a email\text message when CustomField0 changes from 1 to 0. Don't want this new code to override that. Thx
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: straight forward float valve control

Post by rimai »

Change this:

Code: Select all

ReefAngel.CustomVar[0]=ReefAngel.IO.GetChannel(0);
To this:

Code: Select all

if (ReefAngel.IO.GetChannel(0)) ReefAngel.CustomVar[0]=1;
It will require you to reboot the controller once the flag is set, though.
You shouldn't be having this happening at all to begin with.
If you are, there is an underlying problem and this is not going to be your solution.
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: straight forward float valve control

Post by rossbryant1956 »

You are right. I am attempting to fix a problem with my glass-holes overflow, but this is not the answer. I'll keep thinking. Thx
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
Post Reply