Skip to content

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:

  1. Object Detection - Results at a minimum are x,y,a relative to origin of image
  2. 🚧 Measurement - Results are Pass fail or Offset or distance value
  3. 🚧 Inspection - Results are Pass fail
  4. 🚧 🤔 Combo of Tools - Array of method pointers to choose the tools you want to use
  5. 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
FUNCTION_BLOCK ABSTRACT FB_VisionBase EXTENDS FB_ComponentBase IMPLEMENTS I_VisionBase

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
METHOD PUBLIC ABSTRACT ProcessImage
This method needs to be overriden in the Extended function block.

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

  1. Switch between real camera and simulation
  2. Define a results Structure that fits the given solutions
    1. Position (x,y,a)
    2. Pass/fail
    3. Measurement
      1. Offset
      2. distance
      3. roundness
    4. Other result types
  3. 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()
}