Program Example 5.2

Example Type:
Custom Platform with Holes - User Processes vibration for Part via PF_Feeder Callback

Configuration

  • Number of Robots: 1
  • Number of Feeders: 1
  • Number of Parts Types on the Feeder: 1
  • Number of Placement Positions: 1
  • Platform Type: Holes
  • Pick Area: Anywhere
  • Camera Orientation: Fixed Downward Camera

Description
Because this is a custom platform, the [User processes vibration for part via PF_Feeder callback] is automatically selected.

After vision acquires an image and the part queue is loaded, the PF_Feeder callback is called. The user’s code must judge how to vibrate the feeder inside the PF_Feeder callback. The quantity of "front" and "back" parts are provided to the PF_Feeder callback. The parameters are called "NumFrontParts" and "NumBackParts". For this example, if the NumFrontParts is greater than 0 then no vibration is required since parts are available to be picked up by the robot. In that case, the callback return value is "PF_CALLBACKSUCCESS". This return value tells the system to go ahead and call the PF_Robot callback.

If the NumFrontParts equals 0 then the sample code VRun’s the Part Blob sequence to determine if there is a clump of parts or whether there are no parts at all. If the Part Blob sequence does not find any parts, then the hopper is turned on. If the Part Blob sequence finds something then the feeder Flips, Shifts Forward and then Shifts backward so that parts can fall into the holes. After parts have been vibrated on the feeder, the system must re-acquire vision images. (the location of the parts has changed due to vibration) This is accomplished by setting the return value to "PF_CALLBACKRESTART". "PF_CALLBACKRESTART" will restart the Part Feeding process from the beginning, re-acquire new images, reload the part queue and then call PF_Feeder once again to determine if any further action is required.

TIP


A Flip, a long duration Shift Forward and a short duration Shift Backward is the typical feeding strategy for Custom Platforms.

KEY POINTS


The constant PF_FEEDER_UNKNOWN is passed to PF_Feeder when the Platform Type is Holes, Slots or Pockets. In the case of Custom Plates, the system has no knowledge of how the plate is machined and consequently, the system cannot properly determine how to best feed the parts.

Sample Code
Main.prg

Function main
    If Motor = Off Then
        Motor On
    EndIf
    Power Low
    Jump Park
    PF_Start 1
Fend

PartFeeding.prg

Function PF_Robot(PartID As Integer) As Integer
    Do While PF_QueLen(PartID) > 0
        P0 = PF_QueGet(PartID)
        Jump P0
        On Gripper; Wait 0.2
        Jump Place
        Off Gripper; Wait 0.2
        PF_QueRemove PartID
        If PF_IsStopRequested(PartID) = True Then
            Exit Do
        EndIf
    Loop
    PF_Robot = PF_CALLBACK_SUCCESS

Fend


Function PF_Feeder(PartID As Integer, NumFrontParts As Integer, NumBackParts As Integer, state As Integer) As Integer

' Example for Structured Platform with holes state = PF_FEEDER_UNKNOWN

    Integer PFControlReturnVal
    Integer numFound

    Select True

        ' OK to Pick
        Case NumFrontParts > 0
            ' Call PF_Robot because there are parts ready to pick
            PF_Feeder = PF_CALLBACK_SUCCESS '

        ' No Front parts were found but there are Back parts
        Case NumFrontParts = 0 And NumBackParts <> 0

            ' Flip, long Shift Forward and short Shift Backward
            PF_Flip PartID, 500
            PF_Shift PartID, PF_SHIFT_FORWARD, 1000
            PF_Shift PartID, PF_SHIFT_BACKWARD, 300

            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' There are no Front or Back parts found
        ' Either there is a clump of parts or there are no parts on the tray
        ' Acquire an image from the Part Blob sequence to make a determination
        Case NumFrontParts = 0 And NumBackParts = 0

            PF_Backlight 1, On ' Backlight on
            VRun PartBlob ' Acquire Image
            PF_Backlight 1, Off 'Backlight off
            VGet PartBlob.Blob01.NumberFound, numFound ' Were any Blobs found?

            If numFound > 0 Then ' Clump of parts found

                ' Flip, long Shift Forward and short Shift Backward
                PF_Flip PartID, 500
                PF_Shift PartID, PF_SHIFT_FORWARD, 1000
                PF_Shift PartID, PF_SHIFT_BACKWARD, 300

            Else ' No parts found

                ' Call the Control callback to supply more parts
                PFControlReturnVal = PF_Control(PartID, PF_CONTROL_SUPPLY_FIRST)
            EndIf

            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

    Send

Fend