Announcement

Collapse
No announcement yet.

Tiing outputs in Genie

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tiing outputs in Genie

    Hi , I need to delay an output without stalling the program . I am new to 4d and need some help to setup a 20 sec delay. Could I please have the reference notes to solve my problem or a few lines that might help ..


    cheers
    Terry

  • #2
    Hello Terry,

    Welcome to the forum!

    Assuming that you are using arduino to write your program for Visi Genie, I will suggest using millis() function to set-up a non-blocking delay. You can find an example on how to implement this function by going to the Arduino IDE > File > Examples > Digital > BlinkWithoutDelay. (See attached file in case you have trouble finding it.)

    However, if you are using the Visi Genie Magic (only in Pro Version of Workshop4), you can use either the sys_T or the sys_SetTimer functions. Note that all of these functions count in milliseconds.

    For reference, below is an example code on how to use sys_T() to delay your output for 20 seconds:

    Declare global variables(s):
    Code:
    var previous_time := 0;
    On your main loop:
    Code:
    var current_time;
    var interval := 20000;
    
    current_time := sys_T();
    if(current_time - previous_time >= interval)
    previous_time := current_time;
    // do something every 20 seconds
    endif

    This other example shows how to use sys_SetTimer:

    On Global:
    Code:
    func output()
    // do something every 20 seconds
    sys_SetTimer(TIMER0, 20000); // resets the timer
    endfunc
    On your setup:
    Code:
    sys_SetTimer(TIMER0, 20000); // You can use one of the eight timers available (TIMER0 - TIMER7).
    sys_SetTimerEvent(TIMER0, output); // calls the function when timer reaches 0.
    If you have further questions regarding this, feel free to ask.

    Best regards,
    Kimberly
    Attached Files
    Last edited by Kimberly; 23rd May 2018, 04:15 PM.

    Comment


    • #3
      Hi Kimberly,
      Thank you for your prompt reply . I am using the 4d pa gpio direct to my own shield to handle 4-20ma on 3 gauges and 6 voltage divided input and 3 outputs on darlington with

      genie pro . I wont be needing another processor as the I am just monitoring hydraulic functions and only turning off Led's and buzzers .. Just stuck on timing without delay but
      that could be sorted soon with what you have provided .


      cheers





      Comment


      • #4
        Hello Terry,

        We are glad to have provided you with a solution. If you encounter any more problems, we will be pleased to assist you.

        Good luck!

        Best regards,
        Kimberly

        Comment


        • #5
          Hi Terry,

          We moved your most recent inquiry regarding String objects here.

          This helps other forum users easily find the forum threads related to their inquiries.

          Best Regards,
          Juniel Cruz

          Comment

          Working...
          X