Program Example 5.1

Example Type:
Flat Platform - 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: Flat
  • Pick Area: Pick Region B
  • Camera Orientation: Fixed Downward Camera


Description
For this example, a standard Flat Platform is being used. Normally [System processes vibration for part] in Menu - [Tool] - [Part Feeding] - [Part] - [Vibration] would be selected for a Flat plate.
For this example, we will demonstrate how you can select [User processes vibration for part via PF_Feeder callback] to handle the vibration action yourself. The user’s vibration code will be performed inside the PF_Feeder callback. [User processes vibration for part via PF_Feeder callback] is required when you want a different vibration strategy than what the system can provided. When using a custom platform (i.e., holes, slots or pockets), you must handle the vibration yourself via the PF_Feeder callback.
Refer to the following for further details.
Program Example 5.2

Even if the [User processes vibration for part via PF_Feeder callback] is selected (for Standard Flat, Anti-stick and Anti-roll platforms), the system will make the determination of how to best vibrate the part in different situations. The part judgement is provided to the PF_Feeder callback using a parameter called "state". The different states are defined with constants in the "PartFeeding.inc" file.
For example, the constant "PF_FEEDER_PICKOK" means that a parts are now available for pick-placement by the robot. As another example, the constant "PF_FEEDER_FLIP" is passed to the PF_Feeder callback when the system has determined that the best action is to Flip the parts. It is entirely up to the user whether to use the "state" recommendation or not.

Conceptually, the user can recreate the System Processing via the PF_Feeder state and the appropriate vibration statements. Once again, normally the [System processes vibration for part] would be selected for a Flat tray. That said, this example demonstrates how to mimic the System Processing using the PF_Feeder callback and vibration commands.

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

    Select state

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

         ' Supply more parts
        Case PF_FEEDER_SUPPLY
            PFControlReturnVal = PF_Control(PartID, PF_CONTROL_SUPPLY_FIRST)
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Parts are spread out but need to be flipped
         Case PF_FEEDER_FLIP
            PF_Flip PartID
            ' Restart and re-acquire images
            PF_Feeder = PF_CALLBACK_RESTART

        ' Shift parts into pick region
        Case PF_FEEDER_SHIFT
            PF_Shift PartID, PF_SHIFT_FORWARD
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Center, Flip and Separate
        Case PF_FEEDER_CENTER_FLIP
            PF_Center PartID, PF_CENTER_LONG_AXIS
            PF_Center PartID, PF_CENTER_SHORT_AXIS
            PF_Flip PartID
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Hopper is empty
        Case PF_FEEDER_HOPPER_EMPTY
            PFStatusReturnVal = PF_Status(PartID, PF_STATUS_NOPART)
            PFControlReturnVal = PF_Control(PartID, PF_CONTROL_SUPPLY_FIRST)
            ' Center, Flip and Separate
            PF_Center PartID, PF_CENTER_LONG_AXIS
            PF_Center PartID, PF_CENTER_SHORT_AXIS
            PF_Flip PartID
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Parts have gathered against the platform wall
        Case PF_FEEDER_SHIFT_BACKWARDS
            PF_Shift PartID, PF_SHIFT_BACKWARD
            PF_Feeder = PF_CALLBACK_RESTART

        ' Hopper Supply, Center, Flip and Separate
        Case PF_FEEDER_SUPPLY_CENTER_FLIP
            PFControlReturnVal = PF_Control(PartID, PF_CONTROL_SUPPLY)
            PF_Center PartID, PF_CENTER_LONG_AXIS
            PF_Center PartID, PF_CENTER_SHORT_AXIS
            PF_Flip PartID
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Too many parts
        Case PF_FEEDER_TOO_MANY
            PFStatusReturnVal = PF_Status(PartID, PF_STATUS_TOOMANYPART)
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

        ' Wrong part
        Case PF_FEEDER_WRONGPART
            PFStatusReturnVal = PF_Status(PartID, PF_STATUS_WRONGPART)
            PF_Feeder = PF_CALLBACK_RESTART ' Restart and re-acquire images

    Send

Fend