Turning a port on for 1 minute, twice a day.

Do you have a question on how to do something.
Ask in here.
Post Reply
vonjankmon
Posts: 17
Joined: Tue Jan 08, 2013 6:43 am

Turning a port on for 1 minute, twice a day.

Post by vonjankmon »

Trying to setup a seahorse feeding solution that will flush some mysis shrimp into their food dish at set times during the day. I need to run a small pump for about a minute twice a day at set times.

Would the below work?(copied some code from another thread and tried editing it) Or is there a better way to do it?

Code: Select all

if ( (hour() =9) && (minute() =30) )
  ReefAngel.Relay.Set(Port4, now()%60<60);
else
  ReefAngel.Relay.Off(Port4);
Also what is the "or" command for Arudino? Their webpage is down right now so I can't look it up.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Turning a port on for 1 minute, twice a day.

Post by lnevo »

Yes that would work...but you have one problem...

You need to do hour()==9 instead of hour()=9.

Or is ||
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Turning a port on for 1 minute, twice a day.

Post by lnevo »

Also I don't think you need the now()%60<60

This will always succeed..you could just turn the port on...

I believe the original was now()%600<60 which meant every 10 minutes run for the first minute...

Yours says ever minute run for a minute..

You could turn the whole if block into one relay.set command by

doing now()%number of seconds in 12 hours < 60...

Sorry i didn't do the math for 12 hours..

The if block was intended for restricting the operation to a specific few hours..

Try again and we'll fine tune this for you.
vonjankmon
Posts: 17
Joined: Tue Jan 08, 2013 6:43 am

Re: Turning a port on for 1 minute, twice a day.

Post by vonjankmon »

Ok so how about this:

Code: Select all

if ( (hour() ==9) && (minute() ==30) ||  (hour() ==19) && (minute() ==30))
  ReefAngel.Relay.On(Port4);
else
  ReefAngel.Relay.Off(Port4);
So this should turn the port on for a minute at 9:30am and for a minute at 7:30pm right? Once it becomes 9:31 it should turn off correct? Same at 7:31 I believe.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Turning a port on for 1 minute, twice a day.

Post by lnevo »

Close. Try this though

Code: Select all

if ( ( (hour()==9) && (minute()==30) ) ||  ( (hour()==19) && (minute() ==30) ) )
  ReefAngel.Relay.On(Port4);
else
  ReefAngel.Relay.Off(Port4);
The conditions on either side of the or needed to be grouped into one condition.
vonjankmon
Posts: 17
Joined: Tue Jan 08, 2013 6:43 am

Re: Turning a port on for 1 minute, twice a day.

Post by vonjankmon »

Ah, thank you. So next question linked to what I am trying to do, what is the command to put my Reef Angel into Feeding mode? I need that to activate also when the port does so that the food that will be flushed into seahorses feeding dish does not all blow out.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Turning a port on for 1 minute, twice a day.

Post by rimai »

Code: Select all

ReefAngel.FeedingModeStart();
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Turning a port on for 1 minute, twice a day.

Post by lnevo »

If you add another command to the if statement you'll need to add {}

If (whatever) {
Yada yada
Yada yada
} else {
Whatever
Whatever
}

So jealous, I want seahorses one day :)
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Turning a port on for 1 minute, twice a day.

Post by rimai »

Me too :)
Let us know how the seahorse tank progresses.
I don't have the space nor time to dedicate in order to keep them flourishing :(
Just as curiosity, which pump are you using and how do you keep the food refrigerated until next meal time?
Roberto.
vonjankmon
Posts: 17
Joined: Tue Jan 08, 2013 6:43 am

Re: Turning a port on for 1 minute, twice a day.

Post by vonjankmon »

Thanks for all of the help everyone, I'm still building the feeder but I'll post some pics and how it works once I get it all together.

The feeder is just for daily use, I've seen some folks build one into a mini freezer but I don't have room for that. Due to my work schedule I have to keep my lights on for 13 hours a day to allow for the two feedings that seahorses require. This is causing me some minor algae problems that I would like to get rid of so I'm building this feeder so that I can drop a frozen cube into it when I leave for work in the morning and have it flush the food in a couple hours later so I can keep my lights on just 10 hours or so. Same if I want to go somewhere in the evening or anything like that without having to worry about feeding them. I'm just using a small rio pump for this, I don't need much flow to flush the food in and too much will flush it out of their food dish.

I've been keeping seahorses for about 4 years now, even did a bit of breeding but my work schedule prevented me from being very successful, only managed to raise half a dozen to adulthood(babies need to eat about 5 times a day). Sold off 5 and kept one. Keeping seahorses isn't do difficult but you do need to build your tank around them, nothing that can sting at all in the tank, no aggressive fish, and I have to keep a mesh around my MP40 to prevent any tails from having their tips chopped off. Seahorses have a lot of personality though, fun little guys.
vonjankmon
Posts: 17
Joined: Tue Jan 08, 2013 6:43 am

Re: Turning a port on for 1 minute, twice a day.

Post by vonjankmon »

Ok so slight problem, the pump I got is a bit more powerful than I thought it would be so a minute is WAY to long to run the pump, all the food will get flushed out of the seahorse food dish. I need to run it for something like 5-10 seconds.

Right now this is the code I have:

Code: Select all

if ( ( (hour()==9) && (minute()==30) ) ||  ( (hour()==19) && (minute() ==30) ) )
ReefAngel.FeedingModeStart();  
ReefAngel.Relay.On(Port4);
else
ReefAngel.Relay.Off(Port4);
How do I go about editing this to make it only run for like 5 seconds?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Turning a port on for 1 minute, twice a day.

Post by lnevo »

I would do the following:

instead of ReefAngel.Relay.On(Port4);

Go back to the Relay.Set and use this:

ReefAngel.Relay.Set(Port4,now()%60<5);

That will only run the pump for the first 5 seconds of every minute... You can change the 5 to 10 if you wanted 10 seconds. Since you are controlling the hour and minute with the if statement, you'll only get the pump from 9:30:00-9:30:04 and same for 7:30.
vonjankmon
Posts: 17
Joined: Tue Jan 08, 2013 6:43 am

Re: Turning a port on for 1 minute, twice a day.

Post by vonjankmon »

So got it all built and coded. And it works well, I ended up running it for 4 seconds and I may be reducing that to 3, still on the fence about it as if the food has defrosted a bit 4 seconds tosses a bit of it out of the dish.
DSCN0119.JPG
DSCN0119.JPG (115.35 KiB) Viewed 2859 times
Here's the whole setup. I used a cheap hang on acclimation container and drilled two holes in it and put the small pump in the frag tank next to my DT.
DSCN0117.JPG
DSCN0117.JPG (58.98 KiB) Viewed 2859 times
Close up of the container.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Turning a port on for 1 minute, twice a day.

Post by rimai »

Nice :)
Roberto.
Post Reply