Will This APEX Code Work?

Ty Hamatake

Hi, my name is Ty and I'm a Reefer...
View Badges
Joined
Nov 5, 2016
Messages
1,938
Reaction score
1,901
Rating - 0%
0   0   0
It's super simple and it was my first try at writing and code using the advanced settings trying to get my powerhead setup (copy/pasted/edited from other settings).

Fallback OFF
If Time 09:00 to 21:00 Then ON
If FeedA 5 Then OFF

SO for this, the fallback mode is off (I have three total and I will be setting the two smaller ones to fallback off with the bigger one fallback on).
It turns on at 9 AM and off at 9 PM (I guess technically 9:01, but I like using the even number for my OCD's sake :))
And it will turn off for feed mode "A".

Did I miss anything? Thanks guys.
 

Bob Escher

Welcome to Saltwater
View Badges
Joined
Aug 8, 2015
Messages
2,918
Reaction score
1,675
Location
Nashotah Wisconsin
Rating - 0%
0   0   0
It's super simple and it was my first try at writing and code using the advanced settings trying to get my powerhead setup (copy/pasted/edited from other settings).

Fallback OFF
If Time 09:00 to 21:00 Then ON
If FeedA 5 Then OFF

SO for this, the fallback mode is off (I have three total and I will be setting the two smaller ones to fallback off with the bigger one fallback on).
It turns on at 9 AM and off at 9 PM (I guess technically 9:01, but I like using the even number for my OCD's sake :))
And it will turn off for feed mode "A".

Did I miss anything? Thanks guys.
Your time needs 3 numerals
Also use a SET ON. After the fallback line
Other than looks good
 
OP
OP
Ty Hamatake

Ty Hamatake

Hi, my name is Ty and I'm a Reefer...
View Badges
Joined
Nov 5, 2016
Messages
1,938
Reaction score
1,901
Rating - 0%
0   0   0
Your time needs 3 numerals
Also use a SET ON. After the fallback line
Other than looks good
Cool, thank you.

I don't know if you remember our conversation before about using the powerhead setting and just entering the time, but I tried that and got strange results. I tried setting it up so that all three came on at different times, with two overlapping eachother at a time. So it was similar to, 1 on at 1 AM (entered into the "On Time" as 001:00) and off at 1 PM (entered into the "Off Time" as 013:00 [the rest were entered in the same manner]), 2 on at 7 AM and off at 7 PM, 3 on at 1 PM and off at 1 AM. It was around noon when I plugged them all in and they all seemed to randomly turn on and off, not on the schedule I had tried to set up. I'm confusing myself, so I'm sure this was hard to read through, but do you have any idea of what I could've done wrong?
One more thing, the "Initial Off Time" on all three was set to 000:00. Not sure this matters, letting you know just in case.
And last thing, sorry, the corrected code should look like this?
Fallback OFF
SET ON
If Time 009:00 to 021:00 Then ON
If FeedA 5 Then OFF
 

Rick.45cal

2500 Club Member
View Badges
Joined
Jan 14, 2016
Messages
3,693
Reaction score
9,214
Location
Lakeland Florida
Rating - 0%
0   0   0
Cool, thank you.

I don't know if you remember our conversation before about using the powerhead setting and just entering the time, but I tried that and got strange results. I tried setting it up so that all three came on at different times, with two overlapping eachother at a time. So it was similar to, 1 on at 1 AM (entered into the "On Time" as 001:00) and off at 1 PM (entered into the "Off Time" as 013:00 [the rest were entered in the same manner]), 2 on at 7 AM and off at 7 PM, 3 on at 1 PM and off at 1 AM. It was around noon when I plugged them all in and they all seemed to randomly turn on and off, not on the schedule I had tried to set up. I'm confusing myself, so I'm sure this was hard to read through, but do you have any idea of what I could've done wrong?
One more thing, the "Initial Off Time" on all three was set to 000:00. Not sure this matters, letting you know just in case.
And last thing, sorry, the corrected code should look like this?
Fallback OFF
SET ON
If Time 009:00 to 021:00 Then ON
If FeedA 5 Then OFF


The times listed in the pump settings are hours, minutes, seconds. So if you want the pump to run for 7 mins. You set it for 00:07:00 (It isn't 12:07am).

One hour and 7 minutes would be. 01:07:00 (not 1:07am). Understand. It's setting how long of an interval you want the pump to run, not like the time on a clock. :)
 

Pongo

Active Member
View Badges
Joined
Dec 27, 2016
Messages
492
Reaction score
695
Location
Vacaville, CA
Rating - 0%
0   0   0
It's super simple and it was my first try at writing and code using the advanced settings trying to get my powerhead setup (copy/pasted/edited from other settings).

Fallback OFF
If Time 09:00 to 21:00 Then ON
If FeedA 5 Then OFF

SO for this, the fallback mode is off (I have three total and I will be setting the two smaller ones to fallback off with the bigger one fallback on).
It turns on at 9 AM and off at 9 PM (I guess technically 9:01, but I like using the even number for my OCD's sake :))
And it will turn off for feed mode "A".

Did I miss anything? Thanks guys.


Page 55 of the manual:

Time

If Time [TIME] to [TIME] Then [ON/OFF/PROFILE]

The “If Time” statement is one of the simplest to use statements. There are only two things you need to know to use it properly. First, the time is entered as HH:MM in a 24 hour format. Second, the Apex controller is smart enough to know when a time range spans midnight. If you want a time statement that runs from 9pm – 3am the next morning, you can do it with a single statement like

If Time 21:00 to 03:00 Then ON

So your time format should be correct.

You don't need a Set ON command, you're already telling the pump to only come on if the TIME is true.
If you used a Set ON command, then your TIME statement would be [TIME] to [TIME] Then OFF. Basically the reverse of what you're already doing.

Feed format: If FeedA 005 Then OFF.
This will keep the pumps off for 5 minutes after the FeedA timer has reached 000
 

Pongo

Active Member
View Badges
Joined
Dec 27, 2016
Messages
492
Reaction score
695
Location
Vacaville, CA
Rating - 0%
0   0   0
The times listed in the pump settings are hours, minutes, seconds. So if you want the pump to run for 7 mins. You set it for 00:07:00 (It isn't 12:07am).

One hour and 7 minutes would be. 01:07:00 (not 1:07am). Understand. It's setting how long of an interval you want the pump to run, not like the time on a clock. :)

hour/mins/seconds format is used in the OSC command.
Which could be used to tell a pump to switch off and on several times a day or even each hour.
 

Pongo

Active Member
View Badges
Joined
Dec 27, 2016
Messages
492
Reaction score
695
Location
Vacaville, CA
Rating - 0%
0   0   0
This post in the Apex forum helped me better understand the OSC command for powerhead timing, if you want to try that sort of thing.

Link
 

Rick.45cal

2500 Club Member
View Badges
Joined
Jan 14, 2016
Messages
3,693
Reaction score
9,214
Location
Lakeland Florida
Rating - 0%
0   0   0
hour/mins/seconds format is used in the OSC command.
Which could be used to tell a pump to switch off and on several times a day or even each hour.

He's wondering why he is plugging times into the OSC command and the pumps are not running at times according to the clock in the center of the message. (I'm not talking about the code writing, only the OSC "pump" commands.) He has two questions going on in the same message. (I should have been more specific). I'm trying to explain that those settings are interval settings for the pump.

I'll leave it too y'all
 

DLHDesign

Ex-Noob
View Badges
Joined
Jun 7, 2016
Messages
3,259
Reaction score
5,448
Location
Lathrop, CA
Rating - 0%
0   0   0
Fallback OFF

This says, "If a module communication fails, it's default state should be OFF".
If this isn't on a module (for example; if it's a plug on the energy bar), then this bit of code is actually ignored.

Set OFF

This says, "Unless anything below says otherwise, turn this plug OFF". This is the default state, in other words.

If Time 09:00 to 21:00 Then ON

If the current time is between 9am and 9pm, turn the plug ON. Because this instruction is after the "Set OFF" instruction, it will override it. Eg; the lower an instruction is, the more precedence it has. Note that the current time relies upon you having configured the Apex to use your time zone, otherwise it could be offset from what a local clock would have.

If FeedA oo5 Then OFF

If FeedA has been triggered, turn this plug OFF, and then keep it off for 5 minutes after the feed cycle ends. Note that the duration of the feed cycle is configured elsewhere.
Because this instruction is below the Time instruction, it will turn the plug OFF even if it's between 9am and 9pm.

So the final program that you seem to be looking for (assuming this is on a plug in the main unit and not a module of some sort) would be:

Set OFF
If Time 09:00 to 21:00 Then ON
If FeedA oo5 Then OFF
 
Last edited:

Pongo

Active Member
View Badges
Joined
Dec 27, 2016
Messages
492
Reaction score
695
Location
Vacaville, CA
Rating - 0%
0   0   0
OK. I guess I got confused because none of that coding looks like he's trying to use the OSC command.

It's missing "OSC". :D

And again. TIME command does not require a 3 digit number, e.g.. xxx:xx.
It's simply a 24hr military time format.
 

Rick.45cal

2500 Club Member
View Badges
Joined
Jan 14, 2016
Messages
3,693
Reaction score
9,214
Location
Lakeland Florida
Rating - 0%
0   0   0
.
OK. I guess I got confused because none of that coding looks like he's trying to use the OSC command.

It's missing "OSC". :D

And again. TIME command does not require a 3 digit number, e.g.. xxx:xx.
It's simply a 24hr military time format.

The first part of the message I think he was trying to set up the outlet as a pump, and that's when it prompts you with the interval settings. Initial time off, Time on, time off etc. Hence some of the confusion as to why they didn't follow a schedule like a clock ;).

(Sometimes it takes someone equally confused to understand the confused person's question :D). (That's me being equally confused, not you)
 

Bob Escher

Welcome to Saltwater
View Badges
Joined
Aug 8, 2015
Messages
2,918
Reaction score
1,675
Location
Nashotah Wisconsin
Rating - 0%
0   0   0
You won't always see the OSC line
It depends on what it is and if he has switched between advanced or specified a certain item
He be better off just running adavanced as we suggested
 
OP
OP
Ty Hamatake

Ty Hamatake

Hi, my name is Ty and I'm a Reefer...
View Badges
Joined
Nov 5, 2016
Messages
1,938
Reaction score
1,901
Rating - 0%
0   0   0
Oh man, sorry for all the confusion guys. I should've been more clear about what I was wanting to do, instead of just posting about the code.

I am trying to avoid using the OSC command, because I want my powerheads to run off of time and not at intervals (@Rick.45cal hit the nail on the head). I was just going to use the "light" preset for a simple On/Off cycle, but it didn't have the option to use the "feed" mode. My solution was to literally copy and paste the lines of code I wanted (On/Off times from the "light", and the FeedA from the "OSC"). What I originally posted is what I ended up with.

Now, what I should've done, is gone straight to the manual (thanks again @Pongo for helping the new guy) and figured this out myself. Thank you for the corrections @Bob Escher and @Salty1962 and for the detailed clarification of each line @DLHDesign. I really appreciate everyone's help, and again I apologize for all the confusion.
 

Rick.45cal

2500 Club Member
View Badges
Joined
Jan 14, 2016
Messages
3,693
Reaction score
9,214
Location
Lakeland Florida
Rating - 0%
0   0   0
I'm pretty sure I was the cause of the majority of the confusion! You're farther along than me, everytime I think about writing code for my APEX it makes me have flashbacks of writing line after line of code on the Commodore 64 as a kid, only to find out that somewhere along the way you did something wrong :rolleyes:
 

Salty1962

Wrasse and SPS Lover
View Badges
Joined
Jan 28, 2015
Messages
8,484
Reaction score
7,741
Location
Charlotte, NC
Rating - 0%
0   0   0
Just think, If you make a mistake in the future you'll know what to and what not to do in coding. All of us operate our tanks differently and sometimes there's more than one way to skin a cat:) That's what makes this group so great!! If you don't ask, you'll never know.;)
 
OP
OP
Ty Hamatake

Ty Hamatake

Hi, my name is Ty and I'm a Reefer...
View Badges
Joined
Nov 5, 2016
Messages
1,938
Reaction score
1,901
Rating - 0%
0   0   0
Really feeling the love guys. I'll try to pass it on.
 

DLHDesign

Ex-Noob
View Badges
Joined
Jun 7, 2016
Messages
3,259
Reaction score
5,448
Location
Lathrop, CA
Rating - 0%
0   0   0
...flashbacks of writing line after line of code on the Commodore 64 as a kid
I have these all the time. But since I'm now I work as a programmer (to pay for my reefing habit), the flashbacks are more along the lines of, "Oh... **sigh** Back when it was easy...". ;-)
 

Creating a strong bulwark: Did you consider floor support for your reef tank?

  • I put a major focus on floor support.

    Votes: 49 42.6%
  • I put minimal focus on floor support.

    Votes: 24 20.9%
  • I put no focus on floor support.

    Votes: 39 33.9%
  • Other.

    Votes: 3 2.6%
Back
Top