Results 1 to 8 of 8

Thread: Timing help

  1. #1
    Low Bitrate
    Join Date
    Sep 2003
    Location
    Thousand Oak, Ca
    Posts
    57

    Timing help

    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!

  2. #2
    Low Bitrate
    Join Date
    Sep 2003
    Location
    Thousand Oak, Ca
    Posts
    57
    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?

  3. #3
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,053
    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)

    So:
    variable i
    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.
    Fusion Brain Version 6 Released!
    1.9in x 2.9in -- 47mm x 73mm
    30 Digital Outputs -- Directly drive a relay
    15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
    Buy now in the MP3Car.com Store

  4. #4
    Low Bitrate
    Join Date
    Sep 2003
    Location
    Thousand Oak, Ca
    Posts
    57
    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?
    Thanks

  5. #5
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,053
    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.
    Fusion Brain Version 6 Released!
    1.9in x 2.9in -- 47mm x 73mm
    30 Digital Outputs -- Directly drive a relay
    15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
    Buy now in the MP3Car.com Store

  6. #6
    Low Bitrate
    Join Date
    Sep 2003
    Location
    Thousand Oak, Ca
    Posts
    57
    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.

  7. #7
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    10,053
    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.
    Fusion Brain Version 6 Released!
    1.9in x 2.9in -- 47mm x 73mm
    30 Digital Outputs -- Directly drive a relay
    15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
    Buy now in the MP3Car.com Store

  8. #8
    Low Bitrate
    Join Date
    Sep 2003
    Location
    Thousand Oak, Ca
    Posts
    57
    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.

Similar Threads

  1. K301 Timing Parameters for 800 x 480?
    By JimLyon in forum LCD/Display
    Replies: 4
    Last Post: 10-10-2007, 03:59 AM
  2. Modifying the timing of navigation voice prompts
    By froalskiner in forum Wiki Discussion Threads
    Replies: 0
    Last Post: 08-16-2007, 05:33 PM
  3. Trying to fix timing issues with M2
    By matt11601 in forum Power Supplies
    Replies: 0
    Last Post: 06-06-2007, 09:51 PM
  4. M1-ATX not timing, not turning on PC
    By sYx66 in forum Power Supplies
    Replies: 2
    Last Post: 02-20-2006, 09:13 AM
  5. New M1-ATX timing schemes?
    By andrewb in forum Power Supplies
    Replies: 2
    Last Post: 02-17-2005, 11:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •