Vision Task
The design is to have a Vision Base object that can have all things needed to setup and run a camera and take a picture. Then the extended classes would be implement the ProcessImage in order to handle the processing as needed. From the base class, three types of vision handling are given to use:
- Object Detection - Results at a minimum are x,y,a relative to origin of image
- Measurement - Results are Pass fail or Offset or distance value
- Inspection - Results are Pass fail
- Combo of Tools - Array of method pointers to choose the tools you want to use
- Video Playback - Images are put together to create a AVI file when a fault occurs
NOTE: You can create an extended FB and handle vision as you need if our 3 components do not fit your solution.
FB_VisionBase
1 |
|
Class Diagram
classDiagram
class FB_ComponentBase
class FB_VisionBase{
<<ABSTRACT>>
Camera : FB_VN_SimpleCameraControl
ABSRACT ProcessImage()
CyclicLogic()
Reset()
CreateEvents()
GetResults()
ReadParamDINT()
SetParamDINT()
}
FB_ComponentBase<|--FB_VisionBase
HMI
The HMI tag will be connected to the Vision Task component since this is where all the status and commands will go directly. The PLC task will not have HMI tags.
Name | Type | HMI Type | Description |
---|---|---|---|
Trigger | BOOL | Command | If the vision is in Aquisition with mode trigger on and source software, it will trigger camera to take picture |
StartAquisition | BOOL | Command | This will start the camera state engine for taking pictures and processing |
StopAquistion | BOOL | Command | This will stop the camera from taking pictures and processing |
Running | BOOL | Status | Is the Camera state engin running |
CameraState | ETcVnCmaeraState | Status | This will show the actual state of the camera |
ElementsFound | ULINT | Status | This is the number of elements found in last image/processing |
ProcessImage Function
1 |
|
ReadParamDINT
SetParamDINT
Alarms
The alarms array will be in the PLC Task so that the framework can handle them correclty for the machine. The Vision Task will have to send Error and ErrorID over the TwinCAT Process Image.
To Do
- Switch between real camera and simulation
- Define a results Structure that fits the given solutions
- Position (x,y,a)
- Pass/fail
- Measurement
- Offset
- distance
- roundness
- Other result types
- HMI user object for this component. Still use the TcVision HMI items, but a quick user control for layout in SPT HMI
Overall Diagram
classDiagram
class FB_ComponentBase
class FB_VisionBase{
<<ABSTRACT>>
eState : ETcVnCameraState;
VisionBaseAlarms : ARRAY[1..x] of FB_TcAlarm
ProcessImage()
CyclicLogic()
Reset()
CreateEvents()
GetResults()
}
class FB_VisionDetection{
ProcessImage()
ProcessImage_Blob()
ProcessImage_Color()
ProcessImage_Contour()
}
class FB_VisionMeasurement{
ProcessImage()
}
class FB_VisionInspection{
ProcessImage()
}
FB_ComponentBase<|--FB_VisionBase
FB_VisionBase<|--FB_VisionDetection
FB_VisionBase<|--FB_VisionMeasurement
FB_VisionBase<|--FB_VisionInspection
class E_VisionTools{
<<Enumeration>>
Blob
Contour
Color
}
class I_VisionBase{
<<Interface>>
ProcessImage()
GetResults()
}