ADICON Support Forum Applied Digital, Inc.
Page 1 of 1 1
Topic Options
#21069 - 05/06/09 06:18 PM Help code newbie with Timer...
sbessel Offline
newbie


Registered: 02/04/04
Posts: 21
Loc: Folsom, CA.
Greetings...

I have had my Ocelot and 2 SECU16's running for ~6 years, all being used only by HomeSeer with no CMAX code.

I recently added a 3rd SECU16 to control my pool equipment. I am using the following CMAX program to control the remote switches I have at the box, and HomeSeer to control the automatic on/off schedule.

What I want to do is have 2 more functions.

1> Be able to turn off the pool sweep (Module #3 SECU16 Relay #10) if for any reason Module #3 SECU16 Relay #8 or Module #3 SECU16 Relay #9 are off or turn off

2> Place a hard max-on timer on each relay. I.E. Module #3 SECU16 Relay #8 can only be on for a max of 12 hours. Regardless of who turned it on.

Would this be posible? I am a code newbie, and it took me a few versions just to get the stuff below working right.

 Code:
 0001 - IF Module #3   -SECU16 Input #0 Turns ON          //  
 0002 -   AND Module #3   -SECU16 Relay #8 Is OFF         //  
 0003 -     THEN Module #3   -SECU16 Relay #8 Turn ON     //  
 0004 - IF Module #3   -SECU16 Input #0 Turns ON          //  
 0005 -   AND Module #3   -SECU16 Relay #8 Is ON          //  
 0006 -     THEN Module #3   -SECU16 Relay #8 Turn OFF    //  
 0007 - IF Module #3   -SECU16 Input #1 Turns ON          //  
 0008 -   AND Module #3   -SECU16 Relay #9 Is OFF         //  
 0009 -     THEN Module #3   -SECU16 Relay #9 Turn ON     //  
 0010 - IF Module #3   -SECU16 Input #1 Turns ON          //  
 0011 -   AND Module #3   -SECU16 Relay #9 Is ON          //  
 0012 -     THEN Module #3   -SECU16 Relay #9 Turn OFF    //  
 0013 - IF Module #3   -SECU16 Input #2 Turns ON          //  
 0014 -   AND Module #3   -SECU16 Relay #10 Is OFF        //  
 0015 -     THEN Module #3   -SECU16 Relay #10 Turn ON    //  
 0016 - IF Module #3   -SECU16 Input #2 Turns ON          //  
 0017 -   AND Module #3   -SECU16 Relay #10 Is ON         //  
 0018 -     THEN Module #3   -SECU16 Relay #10 Turn OFF   //  
 0019 - IF Module #3   -SECU16 Input #5 Turns ON          //  
 0020 -     THEN Module #3   -SECU16 Relay #8 Turn OFF    //  
 0021 -     THEN Module #3   -SECU16 Relay #9 Turn OFF    //  
 0022 -     THEN Module #3   -SECU16 Relay #10 Turn OFF   //  
 0023 - End Program                                       //  

 


Thanks!

Scott

Top
#21070 - 05/06/09 06:31 PM Re: Help code newbie with Timer... [Re: sbessel]
sbessel Offline
newbie


Registered: 02/04/04
Posts: 21
Loc: Folsom, CA.
In case anyone is interested here are a couple of pictures:



Scott

Top
#21071 - 05/06/09 06:50 PM Re: Help code newbie with Timer... [Re: sbessel]
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
Since it is possible to directly test the status of an output relay, you could just code your functions something like this:

"1> Be able to turn off the pool sweep (Module #3 SECU16 Relay #10) if for any reason Module #3 SECU16 Relay #8 or Module #3 SECU16 Relay #9 are off or turn off"

IF Module #3 -SECU16 Relay #8 Turns OFF //
OR Module #3 -SECU16 Relay #8 Turns OFF //
THEN Module #3 -SECU16 Relay #10 Turn OFF //

To also test for a static off condition requires keeping track of status with a flag variable, to avoid jamming the bus with constant relay on or off commands, such as:

IF Module #3 -SECU16 Relay #8 Is OFF //
AND Module #3 -SECU16 Relay #9 Is OFF //
AND Variable #1 = 0 //if flag is not yet set
THEN Module #3 -SECU16 Relay #10 Turn OFF
THEN Variable #1 = 1 //set the flag too

IF Module #3 -SECU16 Relay #8 Is ON //
OR Module #3 -SECU16 Relay #9 Is ON //
THEN Variable #1 = 0 //reset the flag

This way, any time one of the two outputs is turned on, the flag gets reset, and whenever both outputs are off for a first time, Relay 10 is turned off and the flag is set.


"2> Place a hard max-on timer on each relay. I.E. Module #3 SECU16 Relay #8 can only be on for a max of 12 hours. Regardless of who turned it on."

IF Module #3 -SECU16 Relay #8 Turns ON //
THEN Timer #1 = 1 //start timer

IF Module #3 -SECU16 Relay #8 Turns OFF //
THEN Timer #1 = 0 //stop timer

IF Timer #1 becomes > 43200 //if ON more then 12 hours
THEN Module #3 -SECU16 Relay #8 Turn OFF //turn off relay
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#21072 - 05/06/09 07:14 PM Re: Help code newbie with Timer... [Re: Guy Lavoie]
sbessel Offline
newbie


Registered: 02/04/04
Posts: 21
Loc: Folsom, CA.
That is great help. I think this functionality really adds to my system, and will help if (or should I say when) HS crashes as it won't leave any part of my pool on for longer than needed.

I have another question, if my HS system turns off an already off relay will it trigger a "Turn Off" event?

Is there any limitation to timers that I will run into with this? (possibly having 2 running at the same time)

Also is the CMAX code documented anyplace? I couldn't find it.

Is there also a way to test stuff like this? Perhaps an emulator? I can see issues trying to test the timers and such...

thanks...

Scott


Edited by sbessel (05/06/09 08:01 PM)

Top
#21073 - 05/07/09 05:16 AM Re: Help code newbie with Timer... [Re: sbessel]
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
No, turning off an already off relay will not produce any event, since it's status will not change.

There is no limit to the number of timers running. You can have all 64 going at the same time if you want.

Here is a link to the documentation (first link) and other useful things such as the latest version of C-Max, etc.

There is not emulation program for this, but you could test it by temporarily setting the timer values to much shorter times in order to see the effect. For example, in my code posted earlier you could change:

IF Timer #1 becomes > 43200 //if ON more then 12 hours

to

IF Timer #1 becomes > 15 //if ON more then 15 seconds

for testing.
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#21075 - 05/07/09 05:19 PM Re: Help code newbie with Timer... [Re: Guy Lavoie]
sbessel Offline
newbie


Registered: 02/04/04
Posts: 21
Loc: Folsom, CA.
great... but I seem to be missing the links \:\)

HomeSeer only reads variables and I would like to view the current timers (runtime) but I am unable to find out how to set a variable = timer.

is this possible?

Scott

Top
#21076 - 05/07/09 05:30 PM Re: Help code newbie with Timer... [Re: sbessel]
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada

Something happened... docs:

http://www.appdigusers.com/forums/ubbthreads.php/ubb/showflat/Number/15305#Post15305

You can have a variable "track" a timer using the load to variable instruction:

IF Timer #1 is > 0
THEN Load to: Variable #1
ELSE Variable 1 = 0

Do this for every timer that you need to track. Note that any timer can be loaded into any variable this way.
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#21077 - 05/07/09 05:47 PM Re: Help code newbie with Timer... [Re: Guy Lavoie]
sbessel Offline
newbie


Registered: 02/04/04
Posts: 21
Loc: Folsom, CA.
well fine... if you want to make it easy for me \:\)
Top
#21079 - 05/08/09 12:43 PM Re: Help code newbie with Timer... [Re: sbessel]
dahlheim Offline
junior


Registered: 12/31/08
Posts: 43
 Originally Posted By: sbessel
well fine... if you want to make it easy for me \:\)


yeah Guy has a habit of doing that.

Top
Page 1 of 1 1


Moderator:  Dan Smith, Monte G, ADI Tech Support, Guy Lavoie 
Hop to:
Who's Online
0 registered and 49 anonymous users online.
Recent Posts
Shout Box

Newest Members
brigiel, vevevie, zhutree, 416, saiqul
3003 Registered Users
Forum Stats
3003 Members
19 Forums
4000 Topics
23426 Posts

Max Online: 132 @ 11/13/16 10:07 AM
August
Su M Tu W Th F Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31