4 Basic Program
- 格式:ppt
- 大小:1.96 MB
- 文档页数:15


<>seriesR-J3*MODEL C*RVision Two-Dimensional Compensation ManualA-86844EN/01©FANUC LTD, 2006A-86844EN/01 Contents TABLE OF CONTENTS1BASICS OF TWO-DIMENSIONAL COMPENSATION (1)1.1 ROBOT POSITION COMPENSATION (2)1.2 FIXED FRAME OFFSET AND TOOL OFFSET (3)1.3 STATIONARY CAMERA AND ROBOT-MOUNTED CAMERA (4)2BASIC OPERATIONS (5)2.1 OPENING THE ROBOT HOMEPAGE (6)2.2 MAIN SETUP PAGE (8)2.3 CREATING OR DELETING VISION DATA (9)3MOUNTING THE CAMERA AND SETTING THE USER FRAME (11)3.1 CAMERA AND USER FRAME LAYOUT (12)3.2 CAMERA SETUP (14)4CAMERA CALIBRATION (17)4.1 CALIBRATION METHODS (18)4.2 GRID PATTERN CALIBRATION (19)4.3 S IMPLE 2-D C ALIBRATION (25)5TEACHING AND TESTING A VISION PROCESS (29)5.1 TEACHING A VISION PROCESS (30)5.2 TEACHING THE GPM LOCATOR TOOL (33)5.3 GPM LOCATOR TOOL DETECTION TEST (41)5.4 SETTING THE REFERENCE POSITION (43)6RUNNING A VISION PROCESS FROM THE ROBOT (44)6.1 VISION COMMANDS (45)6.2 PROGRAM EXAMPLES (47)7OTHER FUNCTIONS (49)7.1 VISION RUN-TIME (50)7.2 VISION LOG (52)A GRID PATTERN FIXTURE (54)B LOCATOR TOOL TEACHING GUIDELINES (56)B.1 OVERVIEW OF THE LOCATOR TOOL (57)Contents A-86844EN/01B.2 TEACHING A MODEL PATTERN (63)B.3 DETECTED PATTERN (68)B.4 ADJUSTING THE DETECTION PARAMETERS (71)C ALARM CODES (80)1.BASICS OF TWO-DIMENSIONAL COMPENSATIONA-86844EN/011 BASICS OF TWO-DIMENSIONALCOMPENSATIONThis chapter explains the basics of how i RVision accomplishes two-dimensionalcompensation.1.BASICS OF TWO-DIMENSIONAL COMPENSATION A-86844E/01 1.1ROBOT POSITION COMPENSATIONFANUC's robots are of the teaching-playback type. Under the teaching-playbacksystem, some specific tasks are taught in advance to robots, which in turn workexactly as they are taught. Programs that specify what robots are to do are calledrobot programs. The process of generating robot programs is called teaching, andthe act of executing the taught robot programs is called playback. With thisteaching-playback approach, what robots can do is limited to what they are taught inadvance. This means that, if you want every workpiece to be handled in the sameway, you need to place the workpiece at exactly the same position for each operation.i RVision eliminates the need to do so. Its vision sensor enables compensation of therobot position.Relative position compensationThere are two methods for sensor-based robot position compensation - absoluteposition compensation and relative position compensation. Under the absoluteposition compensation method, the sensor informs the robot of the absolute positionof the workpiece it detects and the robot moves to the informed position. Therelative position compensation method, by contrast, has the sensor measure howmuch the workpiece is deviated from the position specified in the robot program(relative position) and informs the robot of this relative position. The robot movestaking into account the position taught by the robot program as well as the amount ofdeviation reported from the sensor. i RVision adopts the latter approach - relativeposition compensation.Reference position and actual positionThe amount of deviation of the workpiece is calculated from the workpiece positiontaught by the robot program and the current workpiece position. The workpieceposition taught by the robot program is called the reference position, and the currentworkpiece position is called the actual position. The reference position is measuredat the time of robot program teaching and stored in i RVision's internal memory.1.BASICS OF TWO-DIMENSIONAL COMPENSATION A-86844EN/011.2FIXED FRAME OFFSET AND TOOL OFFSETThere are two forms of robot position compensation - fixed frame offset and tool offset.iRVision supports these two forms of compensation.Fixed frame offseti RVision sees the workpiece placed on the turntable or at some other place through acamera, measures how much the workpiece is deviated, and compensates the robotmotion so that the robot can hold the workpiece properly.Tool offseti RVision sees the workpiece held by the robot through a camera, measures how muchthe position where the robot is holding the workpiece is deviated, and compensatesthe robot motion so that the robot will properly place the workpiece at the presetlocation.1.BASICS OF TWO-DIMENSIONAL COMPENSATION A-86844E/01 1.3STATIONARY CAMERA AND ROBOT-MOUNTED CAMERAThe camera that i RVision uses for measuring can be mounted in two ways -stationary camera and robot-mounted camera. i RVision supports these twopositioning methods.Stationary cameraThe camera is fixed at the top of the pedestal or some other location. This way, thecamera always sees the same place from the same distance. The merit of astationary camera is that the entire cycle time can be reduced because i RVision canconduct vision measurement while the robotis engaged in some other task.Robot-mounted cameraThe camera is mounted on the wrist unit of the robot. By moving the robot,measurement can be conducted at different locations with a single camera or thedistance between the workpiece and the camera can be changed. When arobot-mounted camera is used, i RVision calculates the position of the workpiecewhile taking into account the amount of camera movement resulting from the robotbeing moved.2.BASIC OPERATIONS A-86844EN/012 BASIC OPERATIONSThis chapter explains the basic operations of i RVision.2.BASIC OPERATIONS A-86844E/01 2.1OPENING THE ROBOT HOMEPAGETeaching i RVision is done via the Ethernet using a PC connected to the robotcontroller. On the PC screen, click the [Start] button and start Internet Explorer. Inthe [Address]field, enter the IP address of the robot controller.When the i RVision option is installed in the robot controller, the robot homepagedisplays the following three i RVision items.1. Vision Setup2. Vision Log3. VisionRuntimeTo teachi RVision, click [Vision Setup].CAUTIONTeaching i RVision requires that the Vision UIF controls be installedon your PC. For information about how to install the Vision UIFcontrols, refer to the iRVision Setup Manual.2.BASIC OPERATIONS A-86844EN/012.BASIC OPERATIONSA-86844E/012.2MAIN SETUP PAGEWhen you log in to [Vision Setup] of iRVision, a window like the one shown below is displayed. This window is the Main Setup Page for [Vision Setup] of iRVision.Teaching data for iRVision is called vision data. of vision data, as described below. right side.For iRVision, there are three typesClicking one of the items shown on the left sideof the Main Setup Page displays a list of the vision data of the selected type on theCamera SetupThis item is used to set such data as the type of camera, and how the camera is mounted.Camera CalibrationThis item is used to establish the correspondence between the coordinate systems of the camera and the robot.Vision ProcessThis item is used to set data related to the image processing performed by iRVision,and other pertinent details.-8-A-86844EN/012.BASIC OPERATIONS2.3CREATING OR DELETING VISION DATAThe Main Setup Page lets you perform such operations as creating new vision data and deleting existing vision data.Creating new vision dataClick the button.In [Name], enter the name of the vision data you are going to create. The name may be up to 8 alphanumeric characters in length. In [Type], select the type of the data you are going to create. Click the [OK] button.Deleting vision dataClick the button.Click the [OK] button.Copying vision dataClick the button.-9-2.BASIC OPERATIONSA-86844E/01In the text box, enter the name of the destination to which you want to copy the data. Then, click the [OK] button.Renaming vision dataClick the button.In the text box, enter the new name of the data, and then click the [OK] button.- 10 -A-86844EN/013.MOUNTING THE CAMERA AND SETTING THE USER FRAME3MOUNTING THE CAMERA AND SETTING THE USER FRAMEMount the camera and set the user frame. Then, set up the camera and check whether or not it operates properly.- 11 -3.MOUNTING THE CAMERA AND SETTING THE USER FRAMEA-86844E/013.1CAMERA AND USER FRAME LAYOUTIn two-dimensional compensation, the robot motion is compensated on a plane that is parallel to the XY plane of the user frame. Therefore, when mounting the camera and setting the user frame, make sure that the following conditions are met: 1. 2. The camera must be vertical to the XY plane of the user frame. The XY plane of the user frame must be parallel to the plane on which the workpiece is moved.Typical caseThis is a case where the workpiece is moved two-dimensionally on a nearly horizontal plane. Mount the camera so that its optical axis is vertical to the plane. Make sure that the plane on which the workpiece is moved is the XY plane of the user frame.CameraZ User frame X XIf the workpiece is not moved horizontallyThis is a case where the workpiece is moved on a plane that is not horizontal. Mount the camera so that its optical axis is vertical to the plane on which the workpiece is moved. Make sure that the plane on which the workpiece is moved is the XY plane of the user frame.- 12 -A-86844EN/013.MOUNTING THE CAMERA AND SETTING THE USER FRAMECameraZUser frame X- 13 -3.MOUNTING THE CAMERA AND SETTING THE USER FRAMEA-86844E/013.2CAMERA SETUPSet up the camera and check whether it operates properly. In the Main Setup Page, click [Camera Setup Tools].Click thebutton.In [Name], enter the name of the camera data you are going to create. In [Type], choose [Progressive Scan Camera]. Click the [OK] button.- 14 -A-86844EN/013.MOUNTING THE CAMERA AND SETTING THE USER FRAMESelect the created camera data, and click the be displayed. Set each item as necessary. each setup item.button.The following screen willRefer to the items below for details onCommentA supplementary description may be added to the camera data as needed. (Up to 30 one-byte characters can be entered.)Port NumberSelect the port number of the port to which the camera is connected.Camera TypeSelect the type of the camera.Default Exposure TimeSet the exposure time to be applied when camera images are snapped using this window. CAUTION The value you set here will not be used during vision process runtime.Camera is Held by a RobotCheck this box when the camera is mounted on the hand of the robot.Robot Holding the CameraWhen a robot-mounted camera is used, set the robot that is holding the camera.Checking the operationClick the button to check that the camera image is properly snapped.- 15 -3.MOUNTING THE CAMERA AND SETTING THE USER FRAMEA-86844E/01Saving the dataTo save the data you have set, click the [Save] button. To close the camera data window, click the [Close] button.- 16 -A-86844EN/014.CAMERA CALIBRATION4CAMERA CALIBRATIONCalibrate the camera.- 17 -4.1CALIBRATION METHODSRVision detects the workpiece based on the image fed from i the camera and informs e workpiece. To compensate the robot Grid pattern calibrationIt supports a wider range of applications than simple 2-D s more accurate camera calibration as well. Simple 2-D calibrationthe robot controller of the position of th motion based on the workpiece position reported from i RVision requires that the positioning data of the image detected by i RVision be converted to the positioning data for the robot's coordinate system (user frame). Such data conversion entails establishing the correspondence between the camera's coordinate system and the user frame. This process is called camera calibration .i RVision provides the following two camera calibration methods.This camera calibration method can be used for both two- and three-dimensional compensation. calibration and enableThis camera calibration method is intended exclusively for two-dimensional compensation. Assuming that the XY plane of the robot's user frame is parallel to the camera's image plane, it converts the scale between the two planes and the X- and Y-axis directions. This method is simple and can be used for many kinds of two-dimensional compensation applications.4.2 GRID PATTERN CALIBRATIONIn the Main Setup Page, click [Camera Calibration Tools].Click the button.In[Name], enter the name of the calibration data you are going to create.In [Type], choose [Grid Pattern Calibration Tool].Click the [OK] button.Select the created calibration data, and click the button The following screen will be displayed. Set each item as necessary. Refer to the items below for details n each setup item.oCommentSelect the camera you want to calibrate. Exposure Timeet the exposure time to be applied when camera images are snapped using this window. runtime.A supplementary description may be added to the camera calibration data as needed. (Up to 30 one-byte characters can be entered.)Camera SetupSCAUTIONThe value you set here will not be used during vision processSpecify the user frame number, which you have s Application User Frameet properly as instructed in "3. OUNTING THE CAMERA AND SETTING THE USER FRAME".Grid Spacinget the spacing between grid points on the grid pattern fixture to be used. Number of Planeshoose between 1-plane calibration and 2-plane calibration.Fixture on RobotIf you will perform calibration with the grid pattern fixture fixed onto the turntable or another location, choose [No] for [Fixture on Robot]. If you will perform calibrationM SCwith the grid pattern fixture mounted on the robot hand, choose [Yes] for [Fixture On Robot].If you choose [Yes] for [Fixture On Robot], specify the robot that is holding the grid pattern fixture.Set the information that indicates the position of the grid pattern fixture. When the grid pattern fixture is fixed onto the turntable or another location, this information must be set to the robot's user frame. When the grid pattern fixture is mounted on Robot Holding FixtureCalibration Grid Framee robot hand, it must be set to the robot's tool frame. er Operator's Manual . Override Focal DistanceStatus of fixture positione grid pattern fixture is mounted on the robot hand, this item is disabled. the next step of finding the grid pattern. Finding the grid patterncaptures the image of the grid pattern fixture, click the button. ] button specifies the range of the grid with a red rectangle. thFor information about how to set the user frame and tool frame, refer to the R-J3iC ControllWhen you are done with setting the coordinate system, enter the number of the user frame or tool frame for which you have set the grid pattern fixture positioning information.Usually, leave this item set to [No]. When the grid pattern fixture is detected, the focal distance will be calculated automatically.When the grid pattern fixture is fixed onto the turntable or another location, click the [Set] button. Based on the data of the specified user frame, i RVision calculates how and where the grid pattern fixture is positioned in the user frame and saves the result.When th The positioning information of the grid pattern is calculated and saved when you performToClicking the [FindClick the [OK] button at the upper right corner of the image.When the grid is successfully detected, each grid point appears with the + mark in its nter. ceDeleting unnecessary grid pointsCheck that a light blue + mark is shown in the center of each of the four large grid points.Also, check that a green + mark is shown in the center of each of the small grid points.There is no problem if one or two small grid points fail to be detected.If any + mark is shown outside the grid range, delete the point in question as instructed below.Double-click the [Points] tab.In [Point Number], enter the index number of the grid point you want to delete, and then click the [Delete] button.Setting the relationship of Calibr d erify that the Frame entries are correct before pressing the Set Button. After the Set ation frame and Application FrameTo complete the calibration training, the relationship of the calibration grid an application frames must be set.V button and Find buttons have been pressed, the Calibration status will change to Trained.Modification of the frame relationship entries will change the Fixture Position Status to Not Set, the Plans Status to Not Found, and the Calibration Status to Not Trained.Checking the resultDouble-click the [Data] tab.heck that the focal distance is set to an adequate value.the calculated value is inadequate, check to see whether there is any point detected Saving the datao close the calibration data window, click the [Close] button.C If outside the grid range. If there is no point detected improperly, change the [Override Focal Distance] setting to [Yes] and enter the focal distance of the lens in use.Check that adequate values are set for the camera position seen from the grid pattern fixture and the grid pattern fixture position seen from the user frame.To save the data you have set, click the [Save] button. T4.3SIMPLE 2-D CALIBRATIONIn the Main Setup Page, click [Camera Calibration Tools]. Previous entries will beisplayed. dClickthe button.I I oose [Simple 2-D Calibration Tool]. lick the [OK] button.n [Name], enter the name of the calibration data you are going to create. n [Type], ch CSelect the created calibration data, and click the button. The following screen will be displayed. Set each item as necessary. Refer to the items below for details on each setup item.A supplementary description may be added to the camera calibration data as needed. (Up to 30 one-byte characters can be entered.)Select the camera you want to calibrate.Set the exposure time to be applied when camera images are snapped using this window. CommentCameraExposure TimeThe value you set here will not be used during vision processCAUTIONruntime.Application User Frameed in "3. OUNTING THE CAMERA AND SETTING THE USER FRAME". Detecting calibration pointsetect calibration points from the camera image, and set their coordinates on the lick thebutton to snap the camera image.Specify the user frame number, which you have set properly as instruct MD image.Cdisplayed red rectangle.Click the [OK] button.Repeat these steps for [Calibration point 2].Touching upSet the coordinates of the calibration points on the robot's user frame.First, prepare a tool coordinate system that represents TCPs for touching up, and thenselect it as the current tool coordinate system.Next, jog the robot and touch up the center of calibration point 1 using a TCP. Then,click the [Record] button for [Calibration point 1].Repeat these steps for [Calibration point 2].4.CAMERA CALIBRATIONA-86844E/01Saving To save the calibration data, click the [Save] button.To close the datathe calibration data window, click the [Close] button.5.TEACHING AND TESTING A VISION PROCESSA-86844EN/015 TEACHING AND TESTING A VISIONPROCESSTeach and test a vision process.5.TEACHING AND TESTING A VISION PROCESSA-86844E/015.1TEACHING A VISION PROCESSIn the Main Setup Page, click [Vision Process Tools].Click the button.e [2-D Single –View Vision Process]. lick the [OK] button.In [Name], enter the name of the vision process you are going to create. In [Type], choos C5.TEACHING AND TESTING A VISION PROCESSA-86844EN/01Set each item as necessary. Refer to the items below for details . Select the created vision process, and click the button.The following screen will be displayed. on each setup itemCamera CalibrationSelect the calibration data you want to use.Exposure TimeSet the camera's exposure time to be applied for measurement.Offset ModeChoose Fixed Frame Offset or Tool Offset.Robot Holding the PartIf you have chosen [Tool Offset] for [Offset Mode], specify the robot that is holding the workpiece.User Tool NumberIf you have chosen [Tool Offset] for [Offset Mode], specify the tool frame for which you will perform compensation.Image Logging ModeChoose one of the following to specify how images are to be logged when the vision process is run. 1. Don’t Log 2. Log Failed Images 3. Log All Images5.TEACHING AND TESTING A VISION PROCESS A-86844E/01 Ref. Data Index To UseApp. Z Coordinate Choose one of the following to specify how the reference position is to be selected.1. This Index2. Model IDEnter the height of the top side of the workpiece as seen from the user frame.If you have chosen [Model ID] for [Ref. Data Index To Use], click the button and create new reference data. Then, enter the Model ID and App. Z Coordinate value.5.TEACHING AND TESTING A VISION PROCESS A-86844EN/015.2 TEACHING THE GPM LOCATOR TOOLWhen you click [GPM Locator Tool 1] in the tree view in the upper right of the SetupWindow, the page in the lower right of the window changes to the teaching windowfor the GPM Locator Tool. See the following screen for an example.Place the workpiece you want to teach to the tool in the center of the camera view,and click the button to snap its image.5.TEACHING AND TESTING A VISION PROCESS A-86844E/01Teaching the model patternClick the [Teach Pattern] button, and enclose the workpiece within the displayed redrectangle.Click the [OK] button.The model pattern you have taught is displayed. The features of the taught modelpattern are represented by green lines.Setting the model originSet the model origin, which is the position that represents the detected workpiece.At the time of the initial teaching, the model origin is located in the center of the5.TEACHING AND TESTING A VISION PROCESS A-86844EN/01rectangle surrounding the workpiece. Since compensation can be done normally nomatter where the model origin is positioned, the task of setting the model origin is notnecessarily required. Still, placing the model origin in a part of the pattern that isunique to that particular model makes it easier to judge whether the detection result iscorrect.CAUTIONDo not change the position of the model origin after setting thereference position. Doing so makes the tool unable to performcompensation normally.To relocate the model origin, click the [Set Origin] button and move the displayedcross cursor to the position where you want to place the model origin.Click the [OK] button.When the workpiece is symmetrical, you can set the model origin in the rotationcenter of the taught workpiece by clicking the [Center Origin] button.5.TEACHING AND TESTING A VISION PROCESS A-86844E/01Setting training masksIf the model pattern has any unnecessary objects in the background, any superfluousfeature not found in all other parts, or any blemish, you can remove it from the patternby using a training mask.To set a training mask, click the [Edit Trn. Mask] button in [Training Mask].5.TEACHING AND TESTING A VISION PROCESS A-86844EN/01Using the buttons shown on the left side of the window, select the pen type and fillpattern. Then, fill those parts you do not want taught as the model with the color ofred.When you are done with setting training masks, click the [OK] button at the upperright corner of the window.5.TEACHING AND TESTING A VISION PROCESS A-86844E/01The model pattern you have taught is di m splayed. Those parts on which trainingasks are set appear in red, with their green lines eliminated.Setting the emphasis areaForample, if the characteristic part that determines the orientation of the workpiece issmall, as shown below, orientation detection may become unstable. In such cases,llUse this function when the position or orientation of the workpiece cannot bedetermined correctly unless attention is paid to a specific part of that workpiece. ex specifying the reference part for determining the orientation as the emphasis area wi enable stable orientation detection.Part with Triangular cutoutsuccessfully detected if the score of the detected emphasis area isequal to or higher than the value set in [EA Score Threshold]. If the score is lowerEnable Emphasis Area and train (blue shaded area)The work piece is5.TEACHING AND TESTING A VISION PROCESS A-86844EN/01than the set value, the workpiece is not detected. Refer to the items below for details Model IDbelongs to, you assign a distinct model ID to each model. This ay, you can identify the type of the detected model by checking its model ID. Score Thresholdgher shold value. If the score is lower, the workpiece is not detected. Set a alue between 10 and 100. The default value is 70. The lower the value is, the more likely inaccurate detection becomes. Contrast Thresholdlue If the tool is prone to detect blemishes inadequately and other perfluous objects with low contrast, try setting a larger value. Those image features whose contrast is lower than the threshold are ignored. Area Overlap, leaving only the one with the higher ore. The ratio of overlap is determined by the area where the models' external rectangular frames overlap. If you specify 100% as the limit value, the detection ElasticityHowever, e larger the value is, the more likely inaccurate detection becomes.Ignore Polarity at this function makes inaccurateetection more likely.on each setup item. When you have two or more models taught and want to identify which model the detected workpiece w The accuracy of the detection result is expressed by a score, with the highest score being 100. The workpiece is successfully detected if its score is equal to or hi than this thre v Specify the threshold for the contrast of the image to be detected. The default va is 50. If you set a small value, the tool will be able to detect obscure images with low contrast but take longer to complete the detection process. The specifiable minimum value is 10. su If two detected workpieces partially overlap each other, the one with the lower score may be deleted, depending on the ratio of overlap. If the ratio of overlap of the detected workpieces is higher than the ratio specified here, then the detection result for the workpiece with the lower score is deleted sc results will not be deleted even if the workpieces overlap. Specify a pixel value to indicate how much the pattern in the image is allowed to be deviated (distorted) in geometry from the taught model pattern. Setting a large value enables the tool to detect images that are greatly deviated in geometry. th The dark/light polarity is ignored. If you check [Ignore Polarity], you can have"white circles" with a "black circle" model. Note th d。
精心整理BASIC 语言入门一.BASIC 语言简介 1.什么是BASIC 语言BASIC 是Beginner'sAll-purposeSymbolicInstructionCode 的缩写。
意即初学者通用符号指令代码。
它是一种国际通用的计算机高级语言。
一般认为它是从FORTRAN 中提炼、简化而来。
因此简单易学,BASIC 入门了,再学其它高级语言也就不难了。
2.BASIC 语言的版本电脑语言一般都有版本序列。
BASIC 语言也经历了不断的发展与改进,形成了不同环境下的不同版本。
如BASIC 、BASICA 、F-BASIC 、H-BASIC 、Q-BASIC 等等。
但一般来说都大同小异、基本的东西不变、较高版本兼容较低版本。
(1(2(3说要在(18~26页)二分)2人,拡40LETD=2 50LETU=A+B+C+D60LETG=(5*A+4*B+3*C+2*D)/U 70PRINTG 80END由上例可以得知BASIC 程序的结构与规则1.一个程序由若干行(LINE )组成,一行写一个语句(STATEMENT ),程序执行时按行号顺序进行。
行号一般取正整数,留有余数,以便修改时插入。
2.一个语句一般分为三个部分,即行号(或者叫行标)、语句定义符、语句体(或者叫表达式),其顺序与格式都不能错。
3.每个程序一般都以END结束。
RUN回车,运行程序;NEW回车,清除程序;LIST回车,列出程序等等以及屏幕最下面一行的提示,这些都是BASIC语言的命令,以回车结束并立即产生对应的效果。
三.BASIC的语句1.打印语句(PRINT语句)用途:(1)打印出变量或者表达式的值(2)使打入的字符串原样照印用法:(1)可以打印一个或多个(用逗号分开)常量的值。
(2)常量表达式的值,但不能起赋值的作用,如PRINTX=3+5则是错的(3)如果表达式含有变量,则变量必须先赋值,否则会作零或被视为非法(4)可以输出字符串,必须用双引号界定,且双引号本身不能当做字符串来使用输出格式:可以同时输出多项(如变量、表达式或字符串),但需用逗号分开(标准格式输出),各项之间用分输出。