You are here: Start » Program Examples » HMI Run Run once Sequence

HMI Run Run once Sequence

Aim

The task is to create a simple application where user activates an inspection mode through the HMI Panel. It can be run continously or once.

Solution (AVS)

  1. Add the Loop filter to the ACQUIRE section.

  2. In the PROCESS section create a new Step macrofilter and name it SetHMI.

  3. Inside the new step:

    • add a formula.

      outRunEnabled = inRunEnabled

      outRunOnceEnabled = inRunOnceEnabled

      outPauseEnabled = inPauseEnabled

    • Drag the Formula inputs to the Macrofilter's Inputs to create the inputs.

  4. Go back to the Main macrofilter. Set the SetHMI inputs:

    • the RunEnabled to True
    • the RunOnceEnabled to True
    • the PauseEnabled to False
  5. Create a new Task macrofilter and name it LoopPause. Inside the LoopPause:

    • In the ACQUIRE section:

      • Add a formula with 2 inputs of type Bool and name the inputs: RunClick and RunOnceClick.

        outLoop = not inRunClick and not inRunOnceClick

        outOnce = inRunOnceClick

      • Add the Loop filter and connect its input to the Loop formula output.

      • Drag the formula Once output to the Macrofilter Outputs to create an output.
    • In the PROCESS section:

      • Add the Delay filter and set its input to 50.
  6. Return to the Main macrofilter. Add another SetHMI step after the LoopPause** task. Set its inputs:

    • the RunEnabled to False
    • the RunOnceEnabled to True
    • the PauseEnabled to True
  7. Add a new Task macrofilter and name it LoopInspection. Drag the LoopPause* output to the new task to create an input.

  8. Inside the LoopInspection task:

    • In the ACQUIRE section:

      • Add a formula with 2 inputs of type Bool and name the inputs: RunOnceClick and PauseClick.

        outExit = inRunOnceClick or inPauseClick

      • Add the Exit filter and connect its input to the formula output.

      • Add the GrabImage_FromFiles to load a single image from a file.
    • In the PROCESS section:

      • Add the Delay filter and set its input to 100.
      • Create a new Step and name it ProcessImage. Drag the outImage ouput to the new step to create an input.
      • Add another Exit filter and connect its input with the Once input of the Macorfilter.
  9. Inside the ProcessImage macrofilter add the ThresholdImage filter. Connect its inImage to the step input.

  10. Open the HMI Designer. It is available in a View tab, or in a Toolbar.

  11. To allow the user to set the lower limit of threshold range, add to the HMI the TrackBar control available in the Controls category of HMI Controls.

    • Connect its outValue with the inMinValue inside the ProcessImage macrofilter.
  12. Add to the HMI 3 ImpulseButton controls and set their Text parameter to Run, Run Once and Pause.

  13. Go to the SetHMI macrofilter. Connect the formula outputs to the Enabled inputs of the added HMI buttons.

  14. Go to the LoopInspection macrofilter. Connect the formula inputs to the Value outputs of the Run Once and the Pause HMI buttons.

  15. Go to the LoopPause macrofilter. Connect the formula inputs to the Value outputs of the Run and the Run Once HMI buttons.

  16. Add to the HMI a VideoBox control. Connect its Image input to the outMonoImage output inside the ProcessImage step.

Macrofilter Main.

Macrofilter LoopInspection.

Macrofilter LoopPause.

Macrofilter SetHMI.

Macrofilter ProcessImage.

Further Readings