ADICON Support Forum Applied Digital, Inc.
Page 1 of 1 1
Topic Options
#9084 - 08/22/04 01:35 PM Could someone please look at my code?
Code Monkey Offline
newbie


Registered: 06/07/04
Posts: 13
Loc: SF Bay Area
I am getting realy inconsistant results but can not figure out why, I would be greatful if someone could look at my code and tell me if there is anything I could do to better my results.

Thanks!!!

http://www.zippyfinder.com/files/CodeMonkey1.pgm

Top
#9085 - 08/22/04 03:15 PM Re: Could someone please look at my code?
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
I'm looking at your program but it would help me if you could explain exactly what you want to happen (there appears to be 2 identical routines for controlling two different lights with motion sensors). Also, could you explain what is not working right?
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#9086 - 08/22/04 06:27 PM Re: Could someone please look at my code?
Code Monkey Offline
newbie


Registered: 06/07/04
Posts: 13
Loc: SF Bay Area
Line 1 through eight are designed as a backup means of switching in and out of night mode. This is sent from my HAL program.

9 through 15 are for forcing sleep mode by hitting my bedside or main remote. 9 is instant and 10 is recieved after a 5 minute delay from HAL.

16 through 21 are the main switch in and out of night mode.

If in night mode:

22 through 23 turns the entry light on when the front door is opened.

24 through 39 are occupancy for my bedroom light.
If the light is off at the point of initial motion then light light is turned on until 5 minutes after last motion. If the light was already on, then do nothing.

40 through 55 do the same for my office light.

I hope that helps.
The problems that I have are that sometimes it takes only 1.5 seconds for a light to come on, and sometimes it takes 5 to 10 seconds. That realy sucks when entering a dark room. I just want to make sure that my coding is clean and to the point. I do not want to be sending any confusing commands to the occelot. If you can see any places that could be optimized please let me know.

Thanks again!

CodeMonkey

Top
#9087 - 08/22/04 07:03 PM Re: Could someone please look at my code?
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
One possible cause of problems is that you are looking for the current X10 state of the switch to determine if an X10 command should be sent. If you have regular X10 switches (ie: the majority of them) they do not send out an X10 command whenever they are manually operated. This means that unless you only use an X10 controller like a palmpad, minicontroller, etc to control your switches, it might certainly happen that you will sometimes turn the switch off manually but the X10 status table in the Ocelot still thinks its "on" because it turned it on with motion. Then you walk back in the room and the switch does not turn on because the program thinks its still on and does nothing. The best way to avoid this problem is to forget about verifying the switch's current status and just send out the X10 commands every time. this means removing lines 25, 30, 41 and 49. Also, what are you trying to do with timers 1 and 2, do you want to turn off the lights 5 minutes after the last OFF command was received from a motion sensor? I just want to be sure because most people look for any ON command from a motion sensor to retrigger a timer and then issue an OFF command after a certain time when no more ONs are received, and ignore the motion sensor's OFF command completely.
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#9088 - 08/23/04 02:02 AM Re: Could someone please look at my code?
Code Monkey Offline
newbie


Registered: 06/07/04
Posts: 13
Loc: SF Bay Area
Thanks for your input!

Well I figured out something tonight by accident. I was sitting around watching my x10 traffic and I realized that about 1 out of every 5 times I sent a wireless commant to Ocelot it was only sending half of the command. As an experiment, I moved the wirless reciever to the same wall outlet as the Ocelot xciever and repeted the test, now it fires every time!

Here is the follow up to your latest thread:

I made sure that the lights which are controlled by Ocelot will always report status. The reason for this is to allow for a non timed on state should I need it. If I turn the light on by HAL before I enter the room, the light will stay on until I command otherwise. A perfect example of this nessesity is reading my Ocelot manual in bed.

I created one timer for each room. You are correct they are timing 5 minutes from off. I went from off to try to reduce the amount of x10 traffic. Is this faulty logic? I just figured that there would already be tons of motion on commands already, to add the light on command to each one seemed excessive.

Top
#9089 - 08/23/04 10:37 AM Re: Could someone please look at my code?
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
[QUOTE]Originally posted by Code Monkey:
[qb]...I made sure that the lights which are controlled by Ocelot will always report status.
[/qb][/QUOTE]Are your switches sending status commands or actual on/off commands? This is important because the Ocelot will not update its status table when status commands for an X10 address are received. You can verify this by using the "Monitor X10" utility in C-Max to watch the status of your switch's house/unit code as you manually opaerate the switch.

[QUOTE]Originally posted by Code Monkey:
[qb]
A perfect example of this nessesity is reading my Ocelot manual in bed.
[/qb][/QUOTE]Are you by chance reading the printed manual that came with the Ocelot? There is a much more up to date downloadable manual available from the appdig site. Just follow the links to the manuals.

[QUOTE]Originally posted by Code Monkey:
[qb]
I created one timer for each room. You are correct they are timing 5 minutes from off. I went from off to try to reduce the amount of x10 traffic. Is this faulty logic? I just figured that there would already be tons of motion on commands already, to add the light on command to each one seemed excessive.[/qb][/QUOTE]No, it is not faulty logic...you can program it in whatever way suits you best. The only potential problem with this routine is if the X10 status table in the Ocelot is not up to date due to the limitations on receiving status from switches as I explained earlier.
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#9090 - 08/23/04 08:37 PM Re: Could someone please look at my code?
Code Monkey Offline
newbie


Registered: 06/07/04
Posts: 13
Loc: SF Bay Area
[QUOTE]Are your switches sending status commands or actual on/off commands? This is important because the Ocelot will not update its status table when status commands for an X10 address are received. You can verify this by using the "Monitor X10" utility in C-Max to watch the status of your switch's house/unit code as you manually opaerate the switch. [/QUOTE]They are exclusivly controlled by my remote so there will always be an on or off command.

[QUOTE] Are you by chance reading the printed manual that came with the Ocelot? There is a much more up to date downloadable manual available from the appdig site. Just follow the links to the manuals.[/QUOTE]I am reading the downloaded manual.

Thanks again for all of your input. The thing is working briliantly since I solved the wireless bit. The only other problem (besides the IR) that I have occationaly had (about once every few months) is that I find that I have to re-program the Ocelot. What happens is I start to see tons of bogus status requests ever few seconds which act like a block for all legitimate requests. A reprogram solves the problem every time. I also noticed that I need to program with the x10 interface unplugged or I have the same problem.

Regards,

CodeMonkey

Top
#9091 - 08/24/04 05:19 AM Re: Could someone please look at my code?
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
About the bogus status requests; do you have a CM11A anywhere in the house? Those have been known to start doing this for no apparent reason. Next time it happens try this test: watch the LED on the TW-523 and see that it is blinking off every few seconds. Then, while leaving the TW-523 plugged in the wall, unplug the RJ11 cable going to it and see if the blinking continues. If it does, then you'll know that the Ocelot is not the source of the status requests. After that you can unplug any other X10 signal sources like RF transceivers or CM11A's and see if it stops. That's how I found a flakey CM11A in my home.
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#9092 - 08/24/04 10:45 AM Re: Could someone please look at my code?
Code Monkey Offline
newbie


Registered: 06/07/04
Posts: 13
Loc: SF Bay Area
I heard about that, on the Hal forum and actually performed such a test. The blinking stopped as soon as I unplugged the RJ11 cable from the TW-523. Also, only then was I able to send wireless commands directly to x10 devices.
Top
#9093 - 08/24/04 10:57 AM Re: Could someone please look at my code?
Guy Lavoie Administrator Offline
Beyond All Hope
*****

Registered: 12/21/02
Posts: 6548
Loc: Montreal, QC, Canada
You mention HAL, but do you use HAL yourself? If so, have you tried disconnecting the serial port between the PC and the Ocelot to see if HAL or the Ocelot itself is sending the status requests? Also, by "reprogramming" the Ocelot, do you mean that you reload the C-Max program in it to stop the status requests?
_________________________
"If you don't know what you're doing, do it neatly..."

Top
#9094 - 08/24/04 10:09 PM Re: Could someone please look at my code?
Code Monkey Offline
newbie


Registered: 06/07/04
Posts: 13
Loc: SF Bay Area
[QUOTE] You mention HAL, but do you use HAL yourself? If so, have you tried disconnecting the serial port between the PC and the Ocelot to see if HAL or the Ocelot itself is sending the status requests? Also, by "reprogramming" the Ocelot, do you mean that you reload the C-Max program in it to stop the status requests? [/QUOTE]Yes I use hal. I did disconnecte everything one by one to isolate the problem. It was without a doubt coming from the Ocelot. By reprogramming, I mean that I had to reload my C-max program. (the code that I wrote)

I also had to make sure that, during the reload, the x10 module was unplugged. It seems that any 10 signals recieved during the program load cause the program have problems even though it apears to finish correctly.

Top
Page 1 of 1 1


Moderator:  Dan Smith, Monte G, ADI Tech Support, Guy Lavoie 
Hop to:
Who's Online
0 registered and 62 anonymous users online.
Recent Posts
Ocelot not working
by JPO
11/08/17 06:02 AM
Shout Box

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

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