<< Prev        Next >>

ID : 2895

Programming Examples of the Vision Tracking

The below shows programming examples of the vision tracking.

This program is designed for workpieces whose length are less than the tracking range.

Example

Vision tracking is achieved by the following three programs.

  1. "Main program"

    Main program is a initialization program with regard to the circular tracking.

  2. "Workpiece detection program"

    Workpiece detection program is a program that detects workpiece positions and saves the obtained data into tracking buffer.

  3. "Tracking motion program"

    The tracking motion program obtains the positional data of the workpiece from the tracking buffer area, and then
    executes tracking and picking up operation by use of obtained positional data.

1.Main program (VisionTracking.pcs (PCS:279B))

Clear the tracking buffer area of conveyor 1, and then start detecting a trigger from vision sensor signal.

TrackInitialize 1, 0

Execute workpiece detection program and tracking motion program concurrently.

Run Vision
Run Tracking

2. Workpiece detection program (Vision.pcs (PCS:4KB)

Initialize the vision sensor. The contents of initialization are written by the user for respective vision sensors used.

Call visInitialize

Execute workpiece detection processing with vision sensor. The contents of work detection processing are written by the user for respective vision sensors used.

Call visSearch

Obtain the number of detected workpieces by vision sensor. The contents of processing are written by the user for respective vision sensors used.

Call getWorkNum( workNum )

Obtain the vision sensor coordinates and the userdata values assigned to workpieces as much as the number of detected workpieces.
The contents of processing are written by the user for respective vision sensors used.

For index = 0 To workNum - 1
	Call getVisData( index, visionX, visionY, visionAngl, userData )
	...

Next index

The following program shows the contents of sub-procedure "getVisData()". Vision sensor detection coordinates and user data are returned to the caller of the procedure through a call-by-reference argument of procedure, as a set.
In the following example, a workpiece is considered as being detected when "x = 100[pixel]", "y = 100[pixel]", and "θ = 90[deg]".

Sub getVisData( _
 ByVal index As Integer, _
 ByRef visionX As Double, _
 ByRef visionY As Double, _
 ByRef visionAngl As Double, _
 ByRef userData As Integer _
 )

 visionX = 100
 visionY = 100 
 visionAngl = 90
 userData = 1
End Sub

Arrange the data obtained by "getVisData()" as an array, and then add it to the tracking buffer.

For index = 0 To workNum - 1
...

	arrayVis( index ) = V( visionX, visionY, visionAngl )
	arrayUser( index ) = userData
Next index

TrackSetVision 1, workNum, arrayVis, arrayUser

3. Tracking motion program (Tracking.pcs (PCS:2KB)

With a TrackStart command, move a robot arm to the home position before starting the circular tracking.
Please note that executing any commands designed for non-tracking mode, such as Move command, will interrupt the tracking motion. (Commands whose name do not start from "Track" will interrupt the tracking motion.)

Move P, P[50]

The main loop for the tracking and pick-up motion that is executed whenever a workpiece is detected.
In this program, turning ON of an internal I/O is specified as the loop continuation condition so that the loop can be stopped in the middle of the program.

Do
    P[10] = TrackTargetPos(1)
 
    ...
 
    TrackApproach P, P[10], 50
 
    ...
 
LOOP UNTIL IO[128] = ON

This is the processing within the loop.

Pick up a workpiece from the tracking buffer and then set it to the tracking target work.
If there are no workpieces detected, the program will wait until workpiece is detected and its data is stacked in the tracking buffer.

    P[10] = TrackTargetPos(1)

Start the tracking mode. The robot does not start its motion at the timing of this command execution.
The robot starts its motion once a tracking motion command, such as TrackApproach, is executed.

    TrackStart 1

Wait until the tracking target work enters the tracking range.

    Wait TrackInRange(1), 10000, timeoutFlg

With performing the catch up motion in order that the robot moves with the turntable speed, move the robot arm to the approach position which is 50 mm above of the tracking target work.

    TrackApproach P, P[10], 50

With the catch up motion, move the robot arm to the tracking target work.

    TrackMove P, P[10]

With the catch up motion, move the robot arm to the depart position which is 50 mm above of the tracking target work.

    TrackDepart P, 50

Terminate the tracking mode. Stop the catch up motion and reduce the robot arm speed until the robot fully stops.
If the workpiece moves across the downstream limit of the tracking range before executing this command, an error will be issued.

    TrackStop

Place the picked workpiece to the ejection position.

    Approach P, P[52], 50

ID : 2895

<< Prev        Next >>