Please login or register.

Login with username, password and session length
Advanced search  

News:

The X10 Community wants to know how you use your X10 system!
Share your story in the Automated Home Showcase.

Author Topic: "Looping" Macros revisited  (Read 287 times)

LAF

  • Full Member
  • ***
  • Helpful Post Rating: 0
  • Posts: 47
"Looping" Macros revisited
« on: August 31, 2017, 01:48:45 PM »

I don't know if this has been fixed as a search for "looping macros" only turns up old, previous AHP versions, posts.

Anyhow, I have run a macro experiment and am getting poor results.  My program consists only of two simple macros each of which delays for 2 seconds and then triggers the other via an appliance On command.  So, it cycles back and forth between the 2 macros and seems to continue indefinitely.  Until however, a command is received from a remote controller, either via power line or RF, not matter what HC the remote is set to.  When that happens, the macros stop (but not always if only one command is received, sometimes two or three are required i.e. it seems kind of random in that respect).

Now, I see no logical reason why any of that should happen so I'm wondering if the past admonishments against using looping macros are still valid?  If only a single macro which triggers itself after some delay was being used, I can see why that might cause problems as the macro would be re-entered repeatedly without ever exiting and causing a stack overflow or some-such thing but the two macros triggering each other do not do that so I don't see why it shouldn't work.
« Last Edit: August 31, 2017, 03:16:36 PM by LAF »
Logged

LAF

  • Full Member
  • ***
  • Helpful Post Rating: 0
  • Posts: 47
Re: "Looping" Macros revisited
« Reply #1 on: August 31, 2017, 03:19:41 PM »

Update:  Tried it with only one macro triggering itself (after 2 sec delay).  It's now gone over 1200 iterations w/o stopping (but also will halt if a remote command is executed as the two macro case).
Logged

LAF

  • Full Member
  • ***
  • Helpful Post Rating: 0
  • Posts: 47
Re: "Looping" Macros revisited
« Reply #2 on: August 31, 2017, 04:12:41 PM »

OK, I think I've answered the question why other commands are stopping the macros.  The macro trigger commands are on the power line and the remote commands are stepping on them.  This even happens with an RF remote command as the resultant command is also put on the power line(??).

This, if the case, is IMO bad news as it implies that anything triggering a macro, a remote command or a command from another macro, can be randomly defeated.  :(  B:(

It looks like X10 does not handle "party line" communication very gracefully.
« Last Edit: August 31, 2017, 04:14:48 PM by LAF »
Logged

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 237
  • Posts: 6719
  • I don't work for X10, I use it successfuly!
    • Tuicemen Software
Re: "Looping" Macros revisited
« Reply #3 on: August 31, 2017, 06:08:13 PM »

There are situations where one would wish looping macros.
But you must create an exit like using a flag, time, module condition

If you only have polite transmitters you shouldn't have signals stepping on each other
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Find extra info @ My forum

LAF

  • Full Member
  • ***
  • Helpful Post Rating: 0
  • Posts: 47
Re: "Looping" Macros revisited
« Reply #4 on: August 31, 2017, 08:20:16 PM »

What's a polite transmitter?

I still don't see why an exit is a necessity - my test macro(s) seem to run w/o problems (other than the signal collisions but that could occur with looping macros or not).
Logged

Brian H

  • Community Organizer
  • Hero Member
  • **
  • Helpful Post Rating: 280
  • Posts: 12050
Re: "Looping" Macros revisited
« Reply #5 on: September 01, 2017, 06:09:56 AM »

Polite Transmitters. Are modules that hold power line transmitting if there is a X10 power line transgression in progress.
The RR501 and PAT01 are polite transceivers. TM751 and PAT02 with no power line receivers in them are not. They will stomp on a power line signal in progress.
I believe the CM15A and security consoles also are polite
Logged

dhouston

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 34
  • Posts: 2084
    • davehouston.org
Re: "Looping" Macros revisited
« Reply #6 on: September 01, 2017, 07:15:44 AM »

Polite Transmitter Protocol
Quote
When a transmitter has a message it wishes to transmit, it must wait for access to the powerline for either 8, 9, or 10 half mains cycles - during which the line must have been continuously clear of data '1' bits. If a '1'bit is detected, it must restart it's access timing and wait for another 8, 9, or 10 cycles.
 
After line access has been achieved, the transmitter must check the line during the transmission of a '0' bit (no carrier) to see that no other transmitter is transmitting. If a collision occurs, the transmitter must abort its transmission immediately and again go though the line access procedure. 
 
The choice of 8, 9, or 10 half cycles is chosen randomly for each line access attempt.
The CM11A, CM15A, RR501, PAT01 and most, if not all, security consoles are polite. The TM751/PAT02 are not polite as they do not listen to the powerline.

The PL513/TW523 (and PSC04/PSC05) are not polite and third party controllers that use them cannot be polite, nor detect/avoid collisions, as their report of powerline activity is delayed for 11 cycles of the powerline.
« Last Edit: September 01, 2017, 04:02:10 PM by dhouston »
Logged
This message was composed entirely from recycled letters of the alphabet using only renewable, caffeinated energy sources.
No trees, wabbits, chimps or whales died in the process.
https://www.laser.com/dhouston

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 237
  • Posts: 6719
  • I don't work for X10, I use it successfuly!
    • Tuicemen Software
Re: "Looping" Macros revisited
« Reply #7 on: September 01, 2017, 07:53:42 AM »

stevenR posted an example of a looping macro and how to exit it here:
http://forums.x10.com/index.php?topic=14912.0
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Find extra info @ My forum

dave w

  • Expert Advisor
  • Hero Member
  • *
  • Helpful Post Rating: 132
  • Posts: 5632
Re: "Looping" Macros revisited
« Reply #8 on: September 01, 2017, 12:21:30 PM »

I still don't see why an exit is a necessity -
Exit stops the looping, otherwise the loop continues and the powerline is flooded with non stop PLC. In your first post you create a 2 second window between macros which is the only time an X10 command can get back to the CM15A to stop the loop. The reason yours does not stop reliably "(but not always if only one command is received, sometimes two or three are required i.e. it seems kind of random in that respect)."

The "randomness" is because if the X10 command does not hit that 2 second window, it does not get received and only corrupts the PLC being transmitted.
Logged
"This aftershave makes me look fat"

LAF

  • Full Member
  • ***
  • Helpful Post Rating: 0
  • Posts: 47
Re: "Looping" Macros revisited
« Reply #9 on: September 01, 2017, 04:55:34 PM »

Dave et al, thank you for the info re impolite devices transmitting on the power line.  I see now what the problem is.

In any case, what if you want the loop to go continuously (there are programming instances where you might want to do that)?  And, the fast looping I set up as a test was only done that way to try to see if there was a max number of iterations the loop could make without breaking something (I ran it up to about 3,000 iterations without a stoppage in one try).  In real life, I would expect the looping to maybe take place much more slowly, so the power-line isn't burdened unduly, but I would want it to run non-stop.  Even so, AHP needs a way of internally triggering a macro by another macro (or by itself) so the power-line is not involved (or so it seems to me).
« Last Edit: September 01, 2017, 08:27:45 PM by LAF »
Logged

dave w

  • Expert Advisor
  • Hero Member
  • *
  • Helpful Post Rating: 132
  • Posts: 5632
Re: "Looping" Macros revisited
« Reply #10 on: September 01, 2017, 09:34:32 PM »

In any case, what if you want the loop to go continuously (there are programming instances where you might want to do that)?  In real life, I would expect the looping to maybe take place much more slowly, so the power-line isn't burdened unduly, but I would want it to run non-stop. 
The problem I see, is putting unneeded PLC signals on the powerline, which means, on a very regular basis the macro will be sending out PLC, busying out the power line rendering your CM15A receiver deaf to any other X10 commands for a second or so (length of a command).  I could foresee many times when you wanted to turn on a lamp with a remote,  or a motion sensor sending an ON signal, and nothing happens due to signal collisions. Don't know what your goal is, but if you are trying to turn something on and off at short intervals 24/7, then  X10 is a good way to start and stop the flashing cycle, but not a good way to make the cycle (if that makes sense...been a long day for the ole geezer).

This is interesting. 
Logged
"This aftershave makes me look fat"
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.