I'm trying to turn on a output for 1 hour when a button is pushed. Can this be done within MDX graphically? if not a real timer function would be a great addition. Currently what are referred to as timers seem to be more like internal clocks.
FB is great, thanks!
Ok, think I have figured this out, I used a button to set a variable to 60 the created a loop that subtracts .001666(=min using the 100ms logic timer) from the variable each time around. And use compare to turn on the output any time it’s above 0. Once the timer gets below zero it goes into negative numbers and keeps going. I don’t think there’s any issue with this but is there a way to stop the counter from continuing below zero? Will it ever run out of digits and start counting down from some large positive number if it just keeps counting down?
Yes and yes.
(Sorry to have missed your question to begin with. If Tim or I dont respond to your post in a day or so, PM one of us and bring it to our attention)
Once it gets to −2,147,483,648 it will then become +2,147,483,647 and continue counting down.
Using whole numbers probably is a little easier on the logic. Basically you need to count to 36000 with 100ms update interval (1hour/100ms = 36000)
if(i is inbetween inclusively 1 and 36000) then turn on output else turn off output
if(i is inbetween inclusively 1 and 36000) then i = i + 1
if(i > 36000) then i = 0
when button is clicked, i = 1
That should work. Using then/anti-then logic you can put it into more consise terms, but this is easier to understand (I think). Also note that the two comparisons that are the same dont need separate logic statements, only an additional then statement.
The reason I was counting in minutes was so I could display how many minutes were left by displaying the variable. I guess I could do the math on what you have above and still have my display read correctly. ie 36000-i= Display time/600. does that sound right?
You want to show how much time is left in minutes right?
So 36000 - i is the time left in 100ms chunks.
(36000 - i)/10 is the time left in seconds
((36000 - i)/10)/60 is the time left in minutes.
So yes, (36000 - i)/600 is the time remaining in minutes.
Can i just put "change variable [HIGH] --i--i = i + 1" in output section of the logic block or do i need to put this directly in the XML. i tried in the logic block and it didn't count up.
when you go to change variable put in "d-1" which is "delta minus one", or "subtract one from whatever it is".
You can also do things like d4 which is d+=4, and all sorts of good stuff.
It worked! would the "d+=4" add 4 each time through the loop? or should it have been d=+4 as += are on the same key and easy to reverse. as I learn more I keep thinking of new ways to use this board. thanks.