Messages Programming

Anthony A.

Active Member
i want to display messages on the lcd screen every 2 weeks when its garbage day. i can't seem to figure out how. the only thing i think that may work would be making a flag, but the problem is that i have no idea what a flag is, what its used for, and how to create one. if anyone can help that would be great.

PS. i want the system to alert me on tuesday of every other week that "tomorrow is garbage day". basically twice a month.
 
A flag is just a tool to keep track of things.
It's like a notebook for the controller.
When you want it to check the status of something not otherwise monitored by the system you can use one.
So when you want it to take an action only if something else has ocuurred, you tell it to consult its notebook and look at the flags entries to see if the condition is met.

Your trash night is Tuesday

You could create a flag named Trash Night
Via PCAccess you'll have to set the initial state fo the flag.
Since the code changes it at midnight on Monday you have to set it correctly.
If this week is trash week and it is after trash day, set it to "ON".
If this week is not trash week and it is after Monday, set it to "OFF".
If this week is not trash week and it is before Monday, set it to "ON".
If this week is trash week and it is before Monday, set it to "OFF".
(That sounds a bit confusing just think about it)

Then create a message "Trash Night"

Then your code would look like this:
Assuming you want notice the night before (which would be Monday)

TIMED 12:01AM MONDAY
TOGGLE Trash Night

WHEN Trash Night ON
Show message "Trash Night"

TIMED 12:01PM TUESDAY
Clear message "Trash Night"


The first set of code toggles the flag on and off every week.
You have to set the initial state correctly, otherwise it will be out of synch.
But there are only two options so one Has to be correct.
The second set of code only takes action when it is turned ON, which happens every two weeks
The third set removes the message from the display at Noon on Tuesday (Assuming the trash is already by tthe curb so you don't need the alert anymore).

Once you get the hang of flags you can do a lot more with them.
They can count the number of times something happens and be used as timers as well.
 
okay, so i setup the messages and flag. im now programming the rules but are the 3 rules you set 3 separate automation blocks? and if so, then i would do:

first automation block:

1.) add trigger: timed 8:01pm - tuesday
2.) add action: then garbage day TOGGLE
-----------------
second automation block:

1.) add trigger: WHEN garbage day ON
2.) add action: then show "garbage day"
-----------------
third automation block:

1.) add trigger: timed 11:01am wednesday
2.) add action: then clear "garbage day"


is this correct? if so, i guess it would seem to work from your experience but how exactly does it know to toggle every other week (twice a month).

thanks.
 
okay, so i setup the messages and flag. im now programming the rules but are the 3 rules you set 3 separate automation blocks? and if so, then i would do:

first automation block:

1.) add trigger: timed 8:01pm - tuesday
2.) add action: then garbage day TOGGLE
-----------------
second automation block:

1.) add trigger: WHEN garbage day ON
2.) add action: then show "garbage day"
-----------------
third automation block:

1.) add trigger: timed 11:01am wednesday
2.) add action: then clear "garbage day"


is this correct? if so, i guess it would seem to work from your experience but how exactly does it know to toggle every other week (twice a month).

thanks.

That looks correct (yes three blocks).
More detail.

The first line executes every week at 8:01 PM, every week.
That is where the toggle command comes in.

The "Toggle command" toggles the state of the flag OFF/ON. So if the flag is OFF, when the toggle command executes, it changes it to ON. When the flag is ON, it changes it to OFF. Like a toggle switch that operates a light.

So one week it will change it to ON, the next week it will change it to OFF.
The program only takes action when the change of state occurs from OFF to ON. Which occurs every 2 weeks.
The flag will "be" ON for a week at a time, but the controller only looks for changes.
It will do nothing while the flag remains ON. And will do nothing when it changes to OFF.
The complete cycle takes two weeks.

The third line, first of the second block, takes action, as I stated above, ONLY when the flag changes to ON.
So at 8:01 PM on every other Tuesday the flag turns ON, and this line executes.
Once that condition is met, it executes the "show" command.

Then at 11:01 AM on Wednesday the message is cleared.
Note this last block does NOTHING to affect the state of the flag. So it remains ON.
Also, this line will execute EVERY Wednesday at 11:01 AM, but since there is no message being displayed, it will appear as if nothing is happening.

So your alert will only begin at 8:01PM on Tuesday evening (you put the garbage out late! :horse: )
Then turn off the next morning.


The initial state of the flag is critical to get this to run correctly.

You can do it two ways.
One is to upload the program to the controller.
Then while still connected to the controller, go to the flags status page and set the value appropriately for the current week.
Use "1" for ON and "0" for OFF. You can use ANY non zero number for ON, but the binary 1/0 is the normal convention.

The other way is to add a programming block to automatically set the flag. By having these two lines in your code, if you ever lose power and the flags reset, or you edit you prrogram and reset the flags with a new upload, you can edit the date and state of the flag as appropriate for the week.

Simply add the next appropriate ON state's date.

If this coming Tuesday is your trash day, add these lines

TIMED 10/26 8:01 PM
THEN garbage day ON

You have to put that block below the toggle block that is listed up above, or the toggle command will change the state immediately to OFF after this block sets it to ON and you will be out of synch.

If this coming Tuesday is not your trash day, add these lines

TIMED 10/26 8:01 PM
THEN garbage day OFF


That block FORCES the flag to the proper state. From that point forward the toggle command just switches it back and forth.
You only need one or the other (whichever is appropriate)

Make sure you don't select the "Yearly" option.
If you do, the code will execute every year on October 26th and could cause an out of synch condition.


1.) add trigger: timed 8:01pm - tuesday
2.) add action: then garbage day TOGGLE
-----------------
second automation block:

1.) add trigger: timed 10/26 8:01pm
2.) add action: then garbage day ON
-----------------
third automation block:

1.) add trigger: WHEN garbage day ON
2.) add action: then show "garbage day"
-----------------
fourth automation block:

1.) add trigger: timed 11:01am wednesday
2.) add action: then clear "garbage day"


Hope I didn't confuse you too much.
 
thanks so much for the help. you have made it easy to follow and understand. so im thinking that ALL flags need to be monitored for their correct state, when doing changes, ram resets, etc.
 
I don't have access to my controller right now.
But, IIRC, the flags do NOT change state in memory if you simply upload a new program to a controller that is running.
They DO revert to all "0" = OFF if the controller loses all power.
Same thing for any User Settings.

You can monitor this in PC Access. Just change the state of a flag, then upload a program and look at the flags status page to see if they changed back or not.

A lot of times, synchronization isn't critical because you have code blocks that explicitly set one state or another.
You could add extra lines to the above code to force the condition to turn the flag on and off. This would ensure it doesn't get out of synch, but would make the programming more complicated. Once the controller is up and running, it shouldn't get out of synch. If it does, it's easy to detect (message on the wrong week) and change it to the correct state. From that point forward it should continue to operate properly.

Once you understand how the controller thinks, it's very logical and straight forward.

I've used a similar scheme with mine and it has been running with no problems.
I have trash weekly, but biweekly recyling. So I use code similar to what I detailed here for you.
 
But, IIRC, the flags do NOT change state in memory if you simply upload a new program to a controller that is running.

That's correct. Uploading new code does not, in itself, change anything about the state of the system.

I have a trash reminder too. I didn't go to quite this much trouble with mine. I have this block of code that displays the trash message on Mondays when the alarm is disarmed:

Code:
71.	WHEN OFF
		AND IF DAY OF WEEK IS IN M------ 
		AND IF TIME IS GREATER THAN 4:00 PM 
			THEN SHOW TRASH NIGHT! WITH BEEP

This way, I see the message when I arrive home from work on Monday; it pops up as soon as I disarm the alarm, which makes it hard to ignore.

To clear it, I added a button to the message screen on my 5.7e that does a "clear all messages".
 
Back
Top