Вы находитесь на странице: 1из 16

Visual Control Plugin

f o r E a s y P L C v. 5

Table of Contents
1. Visual Control Editor
2. Visual Control Plugin

www.nirtec.com

Visual Control for EasyPLC


This guide helps you to use the Visual Control Plugin for the EasyPLC Software Suite.

The Visual Control Plugin allows you to use a simple webcam, as system of optic recognition.
You will be able to add to your logic programs a big quantity of resources, you will be able to take
photographs in certain moments, to recognize parts/elements in function of their color, or for
example, to activate a relay when the camera detects movement in the area or areas that previously
you have configured.

1. Visual Control Editor


The Visual Control Editor is a stand-alone application that allow you to configure the Visual Control
Plugin, in order to select the camera to use, the resolution, the regions to control, and the parts to
detect.
Go to the EasyPLC\Plugins folder and execute the Visual Control Config.exe program.

From left panel, select the video source you have available in your system (previously you have to
install your webcam drivers) and select the resolution you want to use in the bottom combo box.
Press Start Button to preview the webcam image.
Press Camera Properties to access to your webcam image properties.
Press Take Photo button to save the webcam image in your hard disk as a photograph.

Regions.
The Regions are used in V.C Plugin as an area to control. You can create as many regions you
need, each one can detect movement or kinds of parts in function their colour.
To create a region, press the Create Region Button in the Regions tab.

First select the region colour, this is to see the marked area over the image, second press the
mouse left button and drag a rectangle to fill the selected region area:

In the regions grid you can change the region position and size, the colour, density and the
Sensibility.
The Density is used for averaging the colour of all the pixels inside the region. The Sensibility is
used to activate the motion detection in function of the color change of the pixels averaged.
Press Show Regions or Hide Regions to show/hide the created regions.
If Show Work is checked, when motion is detected, the region where the motion has been detected
will be visible for a moment.

Parts.
The Parts are used in V.C Plugin to recognize elements. You can create as many parts as you
need.
First you need to create the regions to discriminate the parts, after create the Parts and configure
the regions.
Example:
Put a part to be detected, create the regions (two in this example), press the Create New Part
Button in the Parts tab, a new id is associated to this part and you can use the regions you need to
recognize this part. If you want to use region 1 and 2, with the camera seeing the part, make double
click in Part grid row for id 0, and Region 0 column:

Then make click in the id 0 row and Region 1 column.


As you can see, all the regions columns for each part, stores
the colours (for Red, Green and Blue).
The Tolerance allows to give a margin of error for the light
compensation or parts difference. Open it or close it in
function of the restrictions you need.

Press the Read Part Button to detect the part type.


Now lets create other Part, this new part has a lateral yellow, the double click over the regions cell
to configure the regions colours.
Now, put part 0 and press Read Part button:

Part 0 is detected!

Now place part 1 and press Read Part Button:

Part 1 is detected!

Once the configuration is finished, can be saved. File -> Save.


Press the Calibrate Button to make a quickly capture of the colour of the regions for one Part, this is,
instead of make double click in each region to learn the regions colour, press this button to calibrate
the part. This must be done after create a part manually.

10

2. Visual Control Plugin

Start EasyPLC Program and create a new program. On Project Explorer tree, make mouse right
click on Plugins node, and select Add Plugin, from the Select Plugin window, select the
VisualControlPLG.dll, click on the new VisualControlPLC node and you will be able to see all the
methods & functions provided by the plugin.
Here is shown an example for motion detection:
First is necessary to initialize the plugin, in the init procedure, the program created with the Visual
Control Editor must be passed, then for motion detection the call to the MotionDetection procedure
must be called.

11

Now in the main section the following program is written. Here are scanned two regions, when
movement is detected, a digital output is active during 1.5 seconds and a sound is played. If the
movement is detected in region 1, also a photograph is saved in the PC hard drive.

Use the Script Wizard tool to write the program (double click) and see the Plugin methods & functions.

12

This example is used to detect parts.


Here two different kind of coins are detected:

13

Here are explained the methods & functions available in Visual Control Plugin:

Void Init(string Filename)


Initializes the webcam, and loads the program passed (created with the Visual Control Editor).
String Message()
Returns a string with message errors (useful for info in the camera initialization).
Void ClosePanel()
Closes the camera window, but the detection is still active.
Void TakePhoto()
Saves the current webcam frame in the PC Hard disk (in the EasyPLC installation folder and this the data_time
file name).
Void TakePhoto(string path)
Saves the current webcam frame in the PC Hard disk in the passed path and file name.
Object Frame()
Returns the current webcam frame image.
Void CheckMotion()
Used to call manually to the motion detection routines (for timer user requirements)
Int RegionsCount()
Returns the number of regions for the current program.
Bool CheckRegMotion(int n)
Return true if is detected motion in the passed region.
Void ResetDetections()
14

Reset all the regions detections flag.


Void ResetRegionDetection(int n)
Reset the detection flag for the passed region.
Byte CurrRegColorR(int n)
Returns the Red Color of the passed region.
Byte CurrRegColorG(int n)
Returns the Green Color of the passed region.
Byte CurrRegColorB(int n)
Returns the Blue Color of the passed region.
Void MotionDetection(bool v)
Enables/Disables the motion detection.
Void ShowRegions(bool v)
Shows or hide in the V.C. window the regions.
Void CheckRegions(bool v)
If true shows the regions when motion or part detection.
Int ReadPart()
Return the Id of the detected Part.
Bool Ready()
Return true when V.C Plugin is ready to work (camera and program initialized ok!).
Int CalibratePart(int id)
Makes a calibration of the passed part id. (this is the regions colors are updated with the current camera values).
String VersionInfo()
Returns a string with the info of the V.C Plugin version.
Void Stop()
Closes the Plugin application.

15

Idea, Design & Programming by Rafael Izquierdo


Valencia (Spain)
Copyright Rafael Izquierdo 2014

EasyPLC Software Suite

www.nirtec.com
16

Вам также может понравиться