Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Loop in Trigger Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
lllxx
Newbie
Newbie


Joined: September 03 2005
Online Status: Offline
Posts: 6
Posted: September 03 2005 at 06:26 | IP Logged Quote lllxx

Hi,

I just purchased my PH and I try to resolve a stupid problem.

I need to repeat as RF some X10 command because some of my plugs do not receive commands from everywere.

My only problem is that doing that I create trigger loop adn I do not have any idea to how resolve that (basically I receive a a1 on and I repeat the same on RF) only problem my transceiver put the a1 on back on the powerline and I get the command again.

any idea?

Thanks
Luigi
Back to Top View lllxx's Profile Search for other posts by lllxx
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: September 03 2005 at 10:50 | IP Logged Quote dhoward

Luigi,

Should be simple enough to correct. I'll need a little more info on your system however.

It sounds as if you're using a CM17A to transmit RF (what controller number is it?) as well as a powerline based X-10 controller (such as the CM11A). Also, if you could give me just a little more info about the trigger, it would help.

Im going to go ahead and take a crack at it though. It sounds as if you have a trigger on A1 ON incoming X-10 (powerline, not RF). When this trigger fires, it repeats the A1 ON command using a CM17A. The problem is a transceiver picks up the RF and puts the A1 ON back on the powerline only to fire the trigger again.

If that is correct, I would probably look at setting my A1 ON incoming trigger to call a macro. The first line of this macro would check to see if this macro is already in the macro waiting queue. If not, send the command and then wait for a second or two. So the first time the A1 On triggers the macro, we check to see if it is waiting and it's not. So we send the RF command and then the macro starts waiting. This of course winds back up on the powerline and fires the trigger. The macro is called, the first line checks to see if it is waiting (it is), so we just exit the macro and break the loop.

Let me know how this goes or if Im on the right track.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: September 03 2005 at 11:00 | IP Logged Quote TonyNo

Dave responded as I was doing the same! His was better!

Edited by TonyNo
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
lllxx
Newbie
Newbie


Joined: September 03 2005
Online Status: Offline
Posts: 6
Posted: September 03 2005 at 18:46 | IP Logged Quote lllxx

HI,

Thanks for the reply, so some info I use for the RF a CM17A and for PL a Powerlinc USB.

The A1 On is already a Macro, and is set as Immediate and not queued.

My only question is how can I exit from a macro? I don't find any command that stop a macro execution so where I need to see?

Thanks
Luigi
Back to Top View lllxx's Profile Search for other posts by lllxx
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: September 03 2005 at 19:00 | IP Logged Quote TonyNo

One way to exit a macro is to do a JUMP 999.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
lllxx
Newbie
Newbie


Joined: September 03 2005
Online Status: Offline
Posts: 6
Posted: September 03 2005 at 19:04 | IP Logged Quote lllxx

Hi,

I found the way using the Jump instruction in the Macro and I used this formula as line 10 (first)
ph_ismacrowaiting("1WLON)*100

I suppose that if the macro is waiting is going to return the number of macros, so multiplied by 100 is going the exit from the macro.
I added also a delay of 1500 millisecond.

With this costruction is working, is the correct way to do that or there is a better or more elegant way to do that?

Thanks
Luigi
Back to Top View lllxx's Profile Search for other posts by lllxx
 
lllxx
Newbie
Newbie


Joined: September 03 2005
Online Status: Offline
Posts: 6
Posted: September 03 2005 at 20:16 | IP Logged Quote lllxx

Hi,

I still having the same problem the loop is endless.
I modified the macro in this.

I tried also to modify the macro in this :
10 JUMP [ if(ph_ismacrowaitin("1WLOFF")>0, 3, 1)
20 X10 2 A 1
30 X10 2 A OFF
40 Formula immediate ph_killmacrowait("1WLOFF")
50 Delay    1500

Any Idea?
Thanks
Luigi
Back to Top View lllxx's Profile Search for other posts by lllxx
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: September 03 2005 at 22:18 | IP Logged Quote TonyNo

Change Delay 1500 to Wait 2 (Wait is in seconds). A Delay just does nothing for that time.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
lllxx
Newbie
Newbie


Joined: September 03 2005
Online Status: Offline
Posts: 6
Posted: September 03 2005 at 23:18 | IP Logged Quote lllxx

Thanks

now work fine.

Luigi
Back to Top View lllxx's Profile Search for other posts by lllxx
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: September 05 2005 at 16:58 | IP Logged Quote dhoward

Luigi,

I see Tony has filled in in my absence .

Anyways, the difference between the Delay and Wait commands is that a Delay pauses ALL execution until the Delay is finished. Really only useful for very small timings such as to keep Infrared commands from being spaced to close together. The Wait command however, takes a snapshot of the macro's variables, terminates the macro, and allows other events to be processed. After the Wait period is over, the macro is reloaded with it's saved variables and execution continues where it left off.

As far as executing a macro, a macro terminates when it the last statement is reached, so as Tony indicated, by jumping to a statement beyond the last (999 in his example), the macro will terminate. You can also use the "End Macro" macro command.

Concerning your macro, I would structure it as follows:

10 Jump if(ph_ismacrowaiting("1WLOFF") > 0,999,1)
20 X-10 2 A 1
30 X-10 2 A OFF
40 Wait 2

The first line checks if the macro is already waiting. With the first occurence of A1 OFF, it wont be so we'll jump to the next line. Here we'll send the A1 and A OFF X-10 commands. We'll then Wait for 2 seconds. Sometime within this 2 second wait, we should receive the repeat A1 Off command from the powerline command we just issued. The trigger will call the macro again and this time we'll be waiting. So we'll just jump 999 and exit the macro thereby breaking the loop.

Hope this helps,

Dave.

PS, Thanks Tony!!
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum