You are here: Start » Program Examples » HMI Run - Run once
HMI Run - Run once
Aim:
The task is to create a simple application where the user activates an inspection mode through the HMI Panel. It can be run continuously or once.
Hints:
In this project, the Registers will be useful.
Solution (FIS):
-
In the Project Explorer section, right click on the Main Task macrofilter and choose Add Macrofilter Register for the context menu and create a new macrofilter register named Once of type Bool.
-
Add the Loop filter to the ACQUIRE section.
-
In the PROCESS section, create a new Step macrofilter and name it SetHMI.
-
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.
-
-
Go back to the Main macrofilter. Set the SetHMI inputs:
- the RunEnabled to False
- the RunOnceEnabled to True
- the PauseEnabled to True
-
Add a new Task macrofilter and name it LoopInspection. Drag the Main* macrofilter register input to the new task to create an input.
-
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:
- Drag the outImage output to the Macrofilter Outputs section and name the new output as LastImage.
-
-
Inside the ProcessImage macrofilter, add the ThresholdImage filter. Connect its inImage to the step input.
-
Return to the Main macrofilter. Add another SetHMI step after the LoopInspection** task. Set its inputs:
- the RunEnabled to True
- the RunOnceEnabled to True
- the PauseEnabled to False
-
Create a new Task macrofilter and name it LoopPause. Drag the LoopInspection output to the new task to create an input.
-
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.
- Add the MakeConditional filter with the Image type. Connect the Image macrofilter input to the inObject input.
- Add the ProcessImage step and connect its input to the outConditionalObject output.
-
-
Return to the Main macrofilter. Connect the LoopPause output with the Once register output.
-
Open the HMI Designer. It is available in a View tab, or in a Toolbar.
-
To allow the user to set the lower limit of the 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.
- Connect its outValueChanged with the inCondition inside the LoopPause macrofilter.
-
Add to the HMI 3 ImpulseButton controls and set their Text parameter to Run, Run Once and Pause.
-
Go to the SetHMI macrofilter. Connect the formula outputs to the Enabled inputs of the added HMI buttons.
-
Go to the LoopInspection macrofilter. Connect the formula inputs to the Value outputs of the Run Once and the Pause HMI buttons.
-
Go to the LoopPause macrofilter. Connect the formula inputs to the Value outputs of the Run and the Run Once HMI buttons.
-
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
- Image Processing - A comprehensive introduction to Image Processing.