ADICON Support Forum Applied Digital, Inc.
Page 1 of 1 1
Topic Options
#17473 - 02/14/07 05:25 PM is their a better way
bobbymac Offline
newbie


Registered: 02/01/07
Posts: 21
Loc: new jersey
Guy
This is what I'm trying to get happen.We install driveway cartells with x-10 powerflash.One big problem that you have with a setup like that you are pretty limitted to what you can do.Then I found the ocelot.Based on receiving X-10 command I should be able to do alot more.Attached is a copy of a program for your reveiw.Any and all input would be great.Thanks
bobbymac
0001 - IF Time of Day is > 06:59 // 7:00 am or greater
0002 - ELSE Skip to line 4 //
0003 - THEN Variable #1 = 1 // flag for X-10 chimes / down stairs
0004 - IF Time of Day is > 08:59 // 9:00 am or greater
0005 - ELSE Skip to line 7 //
0006 - THEN Variable #2 = 1 // flag for x-10 chimes /upstairs
0007 - IF Time of Day is > 23:01 // when past 11:00 pm
0008 - THEN Variable #1 = 0 // reset counter
0009 - THEN Variable #2 = 0 // reset counter
0010 - IF Receive X10, C - 1 // out going powerflash from cartell
0011 - AND Variable #1 is = 1 // flag for x-10 chime/
0012 - THEN X-10 House A / Unit 1, Turn ON // chime down stairs /rings
0013 - IF Variable #2 is = 1 // flag for x-10 chime
0014 - THEN X-10 House A / Unit 2, Turn ON // chime upstairs /rings
0015 - IF Time of Day is > 22:59 // 11:00 pm or greater
0016 - THEN Variable #3 = 1 // flag for landcape lights
0017 - THEN Variable #4 = 1 // flag for interior lights
0018 - IF Time of Day becomes = Sunrise offset 0 minutes // day break
0019 - THEN Variable #3 = 0 // reset flag
0020 - THEN Variable #4 = 0 // reset flag
0021 - IF Receive X10, C - 1 // power flash from cartell
0022 - AND Variable #3 is = 1 // flag set
0023 - THEN X-10 House L / Unit 1, Turn ON // turn on landscape lights
0024 - THEN Timer #1 = 1 // start timer
0025 - IF Timer #1 is = 601 // 10 minute timer landscape lights
0026 - THEN X-10 House L / Unit 1, Turn OFF // landscape lights off
0027 - THEN Timer #1 = 0 // reset timer
0028 - IF Variable #4 is = 1 //
0029 - THEN X-10 House H / Unit 1, Turn ON // garage interrior lights
0030 - THEN X-10 House H / Unit 2, Turn ON // hallway down stairs
0031 - THEN X-10 House H / Unit 3, Turn ON // lights kitchen
0032 - End Program //

Top
#17474 - 02/14/07 06:59 PM Re: is their a better way [Re: bobbymac]
Just Another Joe Offline
enthusiast
****

Registered: 09/02/03
Posts: 204
Loc: Adanac
Bob, I know you asked Guy, not me, so if the following is not useful, just let me know and I'll go back to my corner .

It appears to me that when C1 is received, you want the downstairs chimes to ring if variable 1 is set, and the upstairs chimes to ring if variable 2 is set, correct? The way you have the program now, the downstairs chimes should work correctly, but the upstairs chimes will be turned on, on every program pass when variable 2 is set. When you use the IF statement, any previous condition is discarded and a new conditional is begun. So, in line 13, you want to test for receiving C1, AND for variable 2 being set, just as you did at line 12:

0013a- IF Receive X10, C - 1 // out going powerflash from cartell
0013b- AND Variable #2 is = 1 // flag for x-10 chime/
0014 - THEN X-10 House A / Unit 2, Turn ON // chime upstairs /rings

And the same thing again at line 28.

Also, it appears that A1 and A2 are never being turned off. After you turn them on to ring the chimes, should you not turn them off, so that they can be turned on again the next time?

Finally, the ELSE Skip statements at lines 2 and 4 are not needed, and can be removed.
_________________________
Just Another Joe
Why be politically correct, when you can be right?

Top
#17475 - 02/14/07 08:07 PM Re: is their a better way [Re: Just Another Joe]
bobbymac Offline
newbie


Registered: 02/01/07
Posts: 21
Loc: new jersey
Joe
thank you for the reply,I understand what you are saying.The (if) should have been (and).Now as far as I understand powerflashes have a few different settings.Once it is triggered it will only send c-1 house code.With no on or off.Chimes are the same way.They will announce regardless if followed by on or off x-10 hc code.Also looking at the program now it should have been transmit a-1 instead of quick-on command,the on-off code was set to turn lamp modules on.The driveway is long and the lights would come on before anybody gets to the house.
thanks again
bobbymac

Top
#17476 - 02/14/07 09:22 PM Re: is their a better way [Re: bobbymac]
bobbymac Offline
newbie


Registered: 02/01/07
Posts: 21
Loc: new jersey
0001 - IF Time of Day is > 06:59 // 7:00 am or greater
0002 - THEN Variable #1 = 1 // flag for X-10 chimes / down stairs
0003 - IF Time of Day is > 08:59 // 9:00 am or greater
0004 - THEN Variable #2 = 1 // flag for x-10 chimes /upstairs
0005 - IF Time of Day is > 23:01 // when past 11:00 pm
0006 - THEN Variable #1 = 0 // reset counter
0007 - THEN Variable #2 = 0 // reset counter
0008 - IF Receive X10, C - 1 // out going powerflash from cartell
0009 - AND Variable #1 is = 1 // flag for x-10 chime/
0010 - THEN Transmit X10, A - 1 // chime down stairs /rings
0011 - AND Variable #2 is = 1 // flag for x-10 chime
0012 - THEN Transmit X10, B - 1 // chime upstairs /rings
0013 - IF Time of Day is > 22:59 // 11:00 pm or greater
0014 - THEN Variable #3 = 1 // flag for landcape lights
0015 - THEN Variable #4 = 1 // flag for interior lights
0016 - IF Time of Day becomes = Sunrise offset 0 minutes // day break
0017 - THEN Variable #3 = 0 // reset flag
0018 - THEN Variable #4 = 0 // reset flag
0019 - IF Receive X10, C - 1 // power flash from cartell
0020 - AND Variable #3 is = 1 // flag set
0021 - THEN X-10 House L / Unit 1, Turn ON // turn on landscape lights
0022 - THEN Timer #1 = 1 // start timer
0023 - AND Variable #4 is = 1 // flag/house interior lights
0024 - THEN X-10 House H / Unit 1, Turn ON // garage interrior lights
0025 - THEN X-10 House H / Unit 2, Turn ON // hallway down stairs
0026 - THEN X-10 House H / Unit 3, Turn ON // lights kitchen
0027 - IF Timer #1 is = 601 // 10 minute timer landscape lights
0028 - THEN X-10 House L / Unit 1, Turn OFF // landscape lights off
0029 - THEN Timer #1 = 0 // reset timer
0030 - End Program //

Top
#17477 - 02/14/07 09:57 PM Re: is their a better way [Re: bobbymac]
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
Joe's comments about lines 13 and 14 are probably the most important thing that needed to be addressed. You would have had quite a few X-10 problems because of this. The same problem would have occurred with lines 28 through 31; as long as variable #4 was set to 1, it would have kept sending X-10 commands.

Other then that, there are probably a half dozen equally viable ways of implementing the logic you wanted. Whatever is "better" can be a matter of taste and style. Some like to shorten routines as much as possible, others like to reduce variable usage, etc. But one important thing is to try and keep the code readable and easy for you to understand.

Here are some modifications that I would probably make to your routine:

- Use only one variable (var #1) to distinguish between 3 time periods:

1 = between 7 and 9 AM (morning)
2 = between 9 AM and 11 PM (daytime)
3 = past 11 PM or before 7 AM (nighttime)

0001 - IF Time of Day is > 06:59 // between 7 and 9 AM
0002 - AND Time of Day is < 09:00 //
0003 - THEN Variable #1 = 1 // flag for X-10 chimes / 1 = down stairs
0004 - IF Time of Day is > 08:59 // between 9 AM and 11 PM
0005 - AND Time of Day is < 23:01 //
0006 - THEN Variable #1 = 2 // flag for x-10 chimes / 2 = upstairs
0007 - IF Time of Day is > 23:00 // when past 11 PM
0008 - OR Time of Day is < 07:00 // or before 7 AM
0009 - THEN Variable #1 = 3 // set flag to 3

0010 - IF Receive X10, C - 1 // out going powerflash from cartell
0011 - AND Variable #1 is = 1 // flag for x-10 chime = morning
0012 - THEN X-10 House A / Unit 1, Turn ON // chime down stairs /rings

0013 - IF Receive X10, C - 1 // out going powerflash from cartell
0014 - AND Variable #1 is = 2 // flag for x-10 chime = daytime
0015 - THEN X-10 House A / Unit 2, Turn ON // chime upstairs /rings

0016 - IF Receive X10, C - 1 // if power flash from cartell
0017 - AND Variable #1 is = 3 // flag for x-10 chime = nighttime
0018 - THEN X-10 House L / Unit 1, Turn ON // turn on landscape lights
0019 - THEN Timer #1 = 1 // and start interval timer

0020 - IF Timer #1 becomes > 600 // 10 minute timer for landscape lights
0021 - THEN X-10 House L / Unit 1, Turn OFF // turn landscape lights off
0022 - THEN Timer #1 = 0 // and stop interval timer

0023 - IF Time of Day becomes > 23:00 // at 11 PM
0024 - THEN X-10 House H / Unit 1, Turn ON // garage interior lights
0025 - THEN X-10 House H / Unit 2, Turn ON // hallway down stairs
0026 - THEN X-10 House H / Unit 3, Turn ON // lights kitchen

0027 - IF Time of Day becomes = Sunrise offset 0 minutes // day break
0028 - THEN X-10 House H / Unit 1, Turn OFF // garage interior lights
0029 - THEN X-10 House H / Unit 2, Turn OFF // hallway down stairs
0030 - THEN X-10 House H / Unit 3, Turn OFF // lights kitchen

0031 - End Program //


I'm assuming several things here, such as the fact that you only want the "landscape lights" to turn on for 10 minutes if the cartell trips during the night, and for nothing else. As you can see, I'm not using flags when a direct time of day test can be used to do something like turn lights on or off. Flags are handy when the value it represents is something more complex like a time interval or other multiple conditions.
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#17478 - 02/15/07 07:28 PM Re: is their a better way [Re: Guy Lavoie]
bobbymac Offline
newbie


Registered: 02/01/07
Posts: 21
Loc: new jersey
Guy
I have a two part question, the first is h-code in the above program was intended to come on if the driveway cartell was activated.After reading your reply should I add a # 4 to variable # 1.Thank god this is just a practice in code writing.After seeing that you included a sunrise off time in case nobody entered the house is a very good idea.
Second question is, if I use the debug timers and variables do I then have to reinstall the program back into cpuxa.
Thanks again
bobbymac

Top
Page 1 of 1 1


Moderator:  Dan Smith, Monte G, ADI Tech Support, Guy Lavoie 
Hop to:
Who's Online
0 registered and 65 anonymous users online.
Recent Posts
Ocelot Battery
by ADI Tech Support
Today at 07:38 AM
Comms Retry Error
by HDTVPete
09/18/17 04:04 PM
Cmax Message: Failed to set data for a 'delay'
by HDTVPete
09/16/17 04:36 PM
Shout Box

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

Max Online: 132 @ 11/13/16 10:07 AM
September
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