Shop OBEX P1 Docs P2 Docs Learn Events
Sending X-10 code ONLY when condition changes — Parallax Forums

Sending X-10 code ONLY when condition changes

FalconFalcon Posts: 191
edited 2011-07-30 00:02 in BASIC Stamp
Hello,
I am working on a security system project for my house using microswitches to monitor the condition of the door locks. Currently I have a microswitch attached to an X-10 Powerflash module that sends signals to my PC via a CM15A. I have Active Home Pro on my PC with the Active Phone Pro plug-in. I have the Active Phone Pro app on my Droid X that will let me change the modules, and will also display the current condition of all modules (ON or OFF.) I want to eventually monitor 6 doors and windows so I want to use the BS2e wto gather the condition of the sensors and send it to the PC, and ultimately my Droid X using the XOUT command. I want to avoid a bank of 6 Powerflash modules tying up all those outlets.

I have the basis of the code written but have the following question:

I want to minimize the number of XOUT commands sent to my phone so it doesn't continually receive updates that the same door is still locked. I want to ONLY send the ON and OFF codes when the condition changes. I assume I need to monitor the current condition of each door lock and set that as a variable but I'm at a loss for how to switch to monitoring the opposite condition once the lock condition in changed.

I have successfully used the XOUT commands before for a thermostat but that was several years ago and I haven't written any code since.

See code I've written so far in attachment, but not tested with circuit.

All replies are appreciated.

Falcon

Comments

  • RiJoRiRiJoRi Posts: 157
    edited 2011-06-30 08:09
    This is rather common in "micro-land." Pseudocode for it (I haven't worked with Stamps for a while) is:
    Initialize:
            OldPins = ReadPins  ' Read the inputs you want (Masking may be needed)
    
    Main:
            NewPins = ReadPins ' Again, masking may be needed
            IF NewPins <> OldPins THEN ' There's been a change
                    OldPins = NewPins  ' Save the new reading
                    ' Do your stuff
            ENDIF
            GOTO Main
    

    HTH,
    --Rich
  • FalconFalcon Posts: 191
    edited 2011-07-02 12:26
    I finally did get the whole thing to work. Just a matter of saving the current state and comparing.

    Thanks for the help RiJoRi
  • graffixgraffix Posts: 389
    edited 2011-07-02 12:34
    nice project. Do you have any other documentation or video?
  • FalconFalcon Posts: 191
    edited 2011-07-30 00:02
    graffix,
    Sorry for the delayed response. I'm out of the US right now with sporadic internet access.

    I initially used the X-10 function to monitor my sensors over the internet using the Active Phone Pro software and app. It's actually a nice app but I want to eventually expand to more functions.
    I've since switched to a PINK module and wrote a simple webpage to view the status changes. You can see a recent version of code in a thread called "Read state if INPUT in loop."
    I'm a noob code writer so it's probably pretty clunky as far as efficiency...but I'm working on that.

    falcon
Sign In or Register to comment.