Download The University of California at Riverside Department
Transcript
Final Report of Senior Design Project Winter/Spring 2002 The University of California at Riverside Department of Electrical Engineering Machine Vision Interface With Seiko Robot Arm II Prepared by: Zhi Xu and Ghazi Ting Technical Faculty Advisors: Mr. Dan Giles, Principal Electronics Technician Dr. Gerardo Beni, Electrical Engineering Faculty of the University of California at Riverside This project is support by the Electrical Engineering Department of the University of California at Riverside Submitted on June 7, 2002 at 5:00 PM Executive Summary - The objectiveof this project is to createa third party vision systemto be utilized by the SeikoD-TRAN RT3200robot arm that belongsto the Electrical EngineeringDepartmentof VCR. Working with the Visual Basic 6.0 platform startedby last year's seniordesigngroup,the industrial imageprocessingsoftware VisionBlox is usedto designa vision systemcapableof live image. A user-friendly interfacehasbeendevelopedto integratethe Seiko robot with the vision systemso the two componentscan operatetogether. In addition, with the interfaceuserscancontrol the robot and usethe vision systemwithout any prior knowledgeof DARL commandsor VisionBlox. With the aid of the vision system,the arm is ableto perform regular industrial type task suchasperformancecheck,object detection,and objection recognitionautomatically. The developedvision systemhasmadethe robot muchmore userfriendly and its capabilitieshaveincreasedtremendously.An updatedrobot was developedby Seiko modelD-TRAN RT330 that hasthe vision feature,which showsthe importanceof our project and the real life applicability of a vision systemfor the RT3200 robot arm. Keywords - robotics,vision system,serialport communications,automation,object detection Table of Contents Page Chapter 1 - Introduction 1.11ntroduction 1.2 Historic Background 1.3 A Glossaryof Acronyms and Abbreviations Chapter 2 -Design and Technical Formulation 2.1 Introduction 2.2 Problem Statement 2.3 Design Specification 2.4 DesignApproach 2.5 Alternative Approaches Chapter 3 3.3 Design Comparison/ Design Trade Off 4.3 Marketability 9 9 9 - Meeting Expectations 5.1 Introduction 5.2 Design Constraints 5.3 Elementsof Design Chapter 6 4 4 8 -Administration 4.11ntroduction 4.2Budget/ CostAnalysis Chapter 5 2 2 2 3 3 -Design Evaluation 3.1Introduction 3.2 TestPlan and Result Chapter4 1 1 1 10 10 10 -Conclusions 6.1 Introduction 6.2 Design Expansion / Improvement Suggestions 6.3 User's Manual Appendix A: Parts List Appendix B: PX610 DLL Library Code Appendix C: Visual Basic Form Codes 11 11 12 Appendix D: Technical Specifications 15 16 22 23 24 26 33 References Acknowledgement 36 37 - Livelmage - Controller - Commands - Chapter 1 Introduction 1.1 Introduction The driving force for this designis to fulfill the seniordesigncourserequirements for the Electrical EngineeringDepartmentat the University of California, Riverside. For two quarters,everyundergraduatestudentin the Electrical Engineeringmajor at the University of California, Riversidemust presenta designproject to the Electrical EngineeringDepartmentprior to graduation. The undergraduate studenthasthe freedom to selectany designproject ashe or shepleases,but with the approvalof the advising professors.For our seniordesignproject, we decidedto continuethe Machine Vision Interfacewith Seiko Robot Ann project startedby prior undergraduatestudentsat University of California, Riverside. The main objectiveis to developa machinevision interfacefor the Seiko RT3200Robot Ann in one of the UCR' s Electrical Engineering DepartmentLaboratory. The Seiko RT3200 Robot Ann is an industrial robot that can be usedfor many applications,andby addinga vision systemto the robot will greatly improve its capabilitiesand value. Also, oncethe vision systemis complete,it can be marketedand implementedfor other Seiko RT3200 Robot Ann that needsa vision system. Section 1.2talks aboutthe Historic Backgroundof the robotic industry and section 1.3containsa Glossaryof Acronyms and Abbreviationsimportantto this report. 1.2 Historic Background The SeikoRT3200Robot arm is an industrial robot, and it is of the cylindrical type. It is a hybrid mix that incorporatesthe rotary motion of the SCARA andthe linear motion of a CARTESIAN. Therearefour axis of movementfor the robot. (x, y, z, a). The x-axis and the y-axis take careof the flat surfaceof the robot's movementwhile zaxis mapsthe height of the robot. The a-axisis rotationalmovementof the end-effector on the robot. The RT3200hasa standardcycle time of 0.8 secondsthat the robot can work in, a very high speedcompareto any other kind of robot. DARL is the original imagedevelopedby Seiko for the RT3200model robot, which is very similar to the programminglanguageBASIC. 1.3 A Glossary of Acronyms and Abbreviations UCR - University of California. Riverside DARL - ~Tran AssemblyRobot Language Visual Basic - Computerprogramminglanguagethat runs in Microsoft Window End-effectors- The tool at the end of the Seiko RT3200robot usedto perform specific tasks. Seiko RT3200-Industrial robot usedin the productionindustryto perform assembly typejobs. Editable Image- This is the display of imageentire imageon the userinterface Train Image- The small region within the editableimageuseto selecta specific object out of the whole image - Chapter 2 Design and Technical Formulation 2.1 Introduction The designapproachesselectedfor this project makeuseof the work completed from last year's seniordesigngroup and improveon their work. The main part of the designdealswith controlling the SeikoD-TRAN robot in Visual Basic and incorporating a third party vision systemto be Usedby the Seiko robot. Section2.2 will containsthe ProblemStatementand section2.3 is the Design Specifications. In sections2.4 and 2.5, the focus is on the DesignApproachand the Alternative Approachesto the project. 2.2 Problem Statement The goal of this project is to upgradethe SeikoRT3200 so that it utilizes a third party vision system. The problem includescreatingvision softwarethat can incorpomte the alreadyexisting VisionBlox softwarewith the Seiko robot arm. In addition, the vision systemneedsto be ableto recognizesometrained objectsand perform particular task with the object. Moreover,the vision systemneedsto be able demonstratesome automationprocedurewith the robot arm. 2.3 Design Specifications The specificationfor our designrequiresthe vision systemto be ableto capture and analyzean imagein real time. The robot also needsto be ableto be controlled througha personalcomputer. Using the PC, a vision systemmust be incorporatedinto the SeikoRT3200 robot. The vision systemthat needsto be createdhaveto be ableto recognizean object, get the coordinatesof the found object, andthen sendthe coordinates of the object to the robot so it can interactwith it. Automationbetweenthe vision system and the Seikorobot arm is desirablefeatureof the designproject. 2 Fig. 2.2 Technical Design 2.4 Design Approach The approachtakento fulfill the specificationsof our seniordesignproject is to continuewith the developmentof last year's seniordesigngroup. In the precedingyear, a group of seniorsin the University of California, RiversideElectrical Programstarted the implementationof vision for the Seiko robot arm. They wereable to utilize Visual Basic 6.0 to incorporatethe vision softwareVisionBlox and the Seiko robot language Darl to work togetherasoneentity. With partsof the machinevision interfacealready developed,we neededonly to continuethe developmentby upgradingthe capabilitiesof the vision system,creatinga more userfriendly interface,and making the Seiko D-TRAN RT3200 Robot Arm havea totally automatedvision system. 2.5 Alternative Approaches Another possibleapproachcould havebeento start the project fresh and not use the codesprovidedby last year's group. The advantagewould be that we will havetotal control of the decisionsof the project and any errorsor issuesthat ariseswe would be ableto answer. The drawbackto this approachis that we would be reproducingmanyof the sameinformation that is alreadyavailableandthe differencefrom continuing from last year's end point versusstartinganewmight be minimal. Otherpossiblealternative approachescan be found in section3.3 of the report. 3 - Chapter 3 Design Evaluation 3.1 Introduction The most important measureof the effectivenessor how good the designof this project is dealswith the compatibility and accuracybetweenthe robot and the vision system. Therefore,most of the test were focusedon the vision systembeing able to identify anddifferentiateobjectsin an imageanddeterminewhetheror not the trained object is in the image. Next, how accurateis the robot in going to location of the desired object specifiedby the vision system. From the resultsof our tests,we concludethat are designhasachievedthe satisfactorylevel that we desire. Section3.2 is the Test Plan and Result,and section3.3 is the DesignComparisonI DesignTrade Off. 3.2 Test Plan and Result . . . . . . . . . . Delay neededwhenmoving robot with VB Sendingcommandsusing VB throughserialport Capturingand storing of live image Parametersfor comparingtrainedwith live image Pixel to world coordinatesystemcalculation Accuracyof the vision systemin real time The repeatabilityof the robot The capability of the vision system A compatiblespeedbetweenrobot and vision Ability to perform multiple task simultaneously (Vision) Using the FeatureFindToolin VisionBlox to comparean object Utilized the savecommandfrom the Controller form to storean imageand then wrote a load function in the Commandsform to load the saved imagessaved. Next, the FeatureFindTool.Found function wasusedto return the comparisonresult anddisplayedin a text box. The FeatureFindToolcompareseverythingwithin the trainedregion, so if the sameobject is placedon a different backgroundfrom the trainedimage, FeatureFindTool.Found will likely to return a False. Settingthe minimum % on the form will changethe FeatureFindTool.MinScore and this can makesomedIfference. Test showsthat 75% works well for objectswith the sameobject type. The test we usedis two washers. Testing for the MinScore Value: Comparingtwo washers.(WasherA is the washerin the trainedimage). 4 True (0 - 100) False none Washer B - True (0 - 89) False (90-100) WasherA True (0 - 87) False (88 - 100) WasherB - True (0 - 88) False True (0 - 84) False (85 - 100) WasherC True (smallerwasher) (0 - 34) False (35 - 100) Original image: WasherA Image2 Washer A - Image 3 (89- 100) Training an image The edshpTrain.LoadandedshpTrain.Save is usedto load and savean imagein the editableshaperegion of the editableimage. To usethe FeatureFindTool.Found function, the imagemust be first trained. The edshplnspection.save andFeatureFindTool.save shouldalwaysbe used wheneverthe edshpTrain.Save commandis used. The samefor the edshpTrain.Loadcommand. It appearsthat the CaliperTool commands works the sameway asthe FeatureFindTool,but therewereerrors when we try to incorporatethem into our program,mainly whentraining the CaliperT001. SavingandLoading an image. Mainly to !\toreand load the imagein the editableimageand the editablc train shaperegion. It is possibleto load an editableimageand a trained imagenot in the editableimage. Getting coordinateswhen a trainedimageis found in the editableimage. The commandsFeatureFindTooI.ResultX andFeatureFindTooI.ResultYis usedto get the centerposition of the trainedimagewith respectto the editableimagewhen FeatureFindTool.Found returnsa True. The top left comer of the editableimageis (0,0) andthe bottom right comer is (640,480). Theseare pixel coordinatesand a calculationwill be neededto convertthe coordinatesinto spatialcoordinatesso the Seiko Robot can utilize it. More detailson the conversionfrom pixel coordinatesto world -~ coordinatein the Robotic test section Displaying live imageson the editableimage The imagecapturedby the frame grabbermust be storedonto a temporary variableand then using the temporaryvariableto haveit display on the editableimage. Look at the PrivateSubRunProg() function to seehow this is done. I tried utilize the OCX file for the frame grabberto set asthe video card and referencethe imagefrom the frame grabberto the editable imagedirectly without first storing it in a temporaryimage. However,I wasunableto referenceframe grabbercard in my codeandhad usethe alternateoption. Automatingthe processof displayingthe live images . To automatethe process,I createda Do-While a loop to continue referencethe frame grabberimageto a temporaryimageand compareit with the storedtrainedimage. If a trainedimageis found, then the process stopsand the Pick( ) function is called. At first, I thoughtthe loop I createdwas causingthe computerto freeze,but after placing a variableto count the loops and settinga limit on how much the PrivateSub RunProg( ) loops, the freezeseemsto comefrom the infinite loop of the image alwaysreturningFalse. (Robotic) (R.O) 640 pixel x 512 pixel y (641,512) Fig. 3.1 Pixel Coordinate 6 Testingmovementlimitation of the robot arm Home position is 300. O.O.O. X is from 300 to 600 Y is from -277.615 to +277.615 Z is from -120 to 0 A is from -100degreeto 100 (for the end-effector) For all movement of the robot, we first programmed and tested it in DARL first and then after it works, the code is incorporated into the Visual Basic code. Testing for delay on the robot First we set the robot at speed 50, while teaching the robot to learn a new position a small delay is needed, and we set it to 5. When I try to move the robot ann from one position to another position, another delay is neededto allow the robot time to get to the new position. The delay was first set to 50, which is too short and the robot sometimes will skip commands. So the delay has been set to 100 now it works fine. Then we try to set the robot at full speed 300, between teaching the robot to learn a new position the delay was set to 5. When we try to move the robot arm from one position to another, the delay is set to 40 and it works fine. Shorter delay will work for shorter distance traveled by the robot, but delay 40 is a safe and reasonable delay time. Delay function used is actually a for-loop that just loops multiple times. Delay of 1 is equivalent to 1,000,000 loops. Converting pixel coordinate system to world coordinate system When camera to ground height is 45Omm, the screen is IIOmm X 9Ornand pixel to mm conversion is 1:5.8mm. When we try to use the conversion to get the robot to the converted location at this height, it is always off. We found out that the camera is not mounted at the center of the robot and is the cause of our conversion to be off. Later, we found at the 45Ornm height, the image is out of focus. So the new height that the image is in focus and the end-effector can still pick up object is at the height of 340mm. At this height, the screen is 95mm X 67mm and the pixel to mm conversion is 1:6.737. At each height, to test for screen size and unit conversion, four comers are drawn on a paper at the size of the screen. Displayed on the screen, and using image size on screen and the size of the four comers, the new unit conversion is determined. To test, object is set at different location and the robot will try going to the object. Many trials are taken to test for accuracy. 7 3.3 Design Comparison I Design Trade OfT Therearetwo major changesthat we madeto our original designplan, useof the CaliperToolfeaturein VisionBlox andthe workspaceusedfor our automationsystem. Originally, beforefully understandingthe capabilitiesand functionality of the FeatureFindToolof VisionBlox, we wereconsideringaddingthe CaliperToolcomponent to our vision system. We assumedthat without somesort of way to separatethe foregroundfrom the background,therewill be no way to detectan object. However, sincewe can control the background,we forced the backgroundof all imageswe work with to be alwayswhite or black. With the ability to control the background,thenjust by usingthe FeatureFindToolwe are ableto utilize the featuresof an object aloneto distinguishone object from another. Another major changewe madeto our original designwas the workspacefor the robot when we automateour vision system. Originally, we were planningto havea box shapedworkspacefor our vision systemandrobot would scanfor objectswithin that workspace.To do this would requiresomeextremelydifficult algorithmsto computethe translationfrom the pixel coordinatesystemto the world coordinatesystem,however,so we simplified the processby having the robotjust scanforward. To havethe workspace of a box would requirethe robot andcamerato move sideways,which can throw off the cameraorientationwith respectto the robot sincethe camerais mountedon the robot. For when the robot movesin the y direction,the whole camerais rotatedby some inconsistentdegree,which would be difficult to calculatethe relationshipbetweenthe robot movementswith respectto the anglechangeof the camera. By not having the robot being ableto move sidewayslimits the workspacein which our robot can work with in our automationmode,it simplified our calculationof translatingpixel locations into world locationsthat the Seiko robot can use. R - Chapter 4 Administration 4.1 Introduction Our project is a continuationof an existing project; thereforewe did not spend any moneyfor this project. The Budget/CostAnalysis of section4.2 containsprices of what it would havecost had we had to buy all the partsourselves.Section4.3 talks about the Marketability of the designwe help develop. 4.2 Budget/Cost Analysis Seiko D-TRAN RT3200 ... $ 10,000 Visionl Mono-kit: Hitachi KP-M2 Camera IrnagenationPX610 PCI Frame-grabberCard VisionBlox software . 12 volt DC PowerSupply& Cables Computar C-Mount, 25mm, fl.3 lens Visual Basic 6.0 Developmentcost: 200 hoursx $100per hour $1,975 $128 $99 . $20,000 Total: Purchasinl! newer model: Seiko RT 3300 $32,202 $60,000 4.3Marketability The newermodel RT3300,which is basicallythe samerobot asthe RT3200 modelbut with a vision system,is priced at $60,000. Evaluatingour budget/cost analysis,it showsthat we will be able to provide the vision systemwe developedand offer it at a much lower price. Being that the developmentof the vision systemwith the SeikoD-TRAN RT3200 is alreadycomplete,it is possibleto sell the vision systemat a much lower cost than the $32,202shown. Seikohassold many RT3200robots,which meansthat thereare manypotential RT3200ownersthat would needvision system update. With our ability to offer our vision systemat a much lower price than purchasing a RT3300for that includes,companiescan savea greatdealof money. Evaluatingthe existing optionsof currentRT3200model owners,it appearsthat thereis a possibility of a very profitable opportunityif our vision systemis marketedproperly. However,due to limited researchand knowledgeaboutthe numberof ownersof the Seiko RT3200robot, it is impossibleto predict the size of the marketfor our product. 9 - Chapter 5 Meeting Expectations 5.1 Introduction Our project hasmet all the specificationsin the problemstatementalongwith all of our primary objectives. The robot cannow be controlledthroughVisual Basic, and with the addition of the vision systemthe robot can also scanfor objectswithin the vision's workspaceand perform specifiedtask. The vision systemhasincreasedthe capabilitiesand valueto the Seikorobot arm. The DesignConstraintsare shownin section6.2 and the Elementsof Designare in section6.3. 5.2 Design Constraints Sinceour project is a continuationof last yearsdesign,we are limited to the approachesand direction in which we cantake our design. Due to last year's project, we were limited to using Visual Basic asour programminglanguage,which links the controller of the Seikorobot to the vision system. We were also constrainedto the VisionBlox softwareto perform our imageprocessing.The camera,frame grabbercard, andthe serialport were all hardwarepartsthat we were limited to usefor our project. Another constraintto our project is the end-effectorthat was providedby the Electrical EngineeringDepartmentof VCR. The end-effectorprovidedis very small and haveno real life applicability. We will not be able get a new end-effectorbeforethe end of the 2002 Springquarter,the demofor our project will be severelylimited 5.3 Elements of Design The usesof robotics in the industrial field havelong beenan acceptedand nonnal practiceof the industry. Thereare manybenefitsof usingroboticsfor production;such as safety,productive,reliable, and relatively cheapcomparedto humanlabor. For example,when working with dangerouschemicalsor in unsafeenvironments,robot can be usedto get thejob donewithout endangeringpeople'slives. Robotsare alsovery productivefor it canperfonn specifiedtask at a very high speedwithout ever havingto take a break. In most cases,machineswill outperformhumanlabor drasticallyin any massproduction. With the advancementof roboticsand technology,the robotsused today in industry are extremelyreliable and our experiencesworking with the Seiko RT3200 agreeswith that. Although purchasingan industrial robot might seemquite expensive,oncethe robot is purchasedthe costto maintainand reuseis relatively minimal. So in the long run, the useof robotsfor industrial applicationswill save companiestremendouslyin cost. Therewill alwaysbe critics that will opposethe useof robotsfor the fear of losing all jobs to machines. It is true that machineryand roboticshavetaking over many of the productionthat usedto be doneby people,but by using robotics it hasalso made many things much more cheaperand available. So until somethingmajor eventoccurs, machineryand robotswill continueto be integratedinto our everydaylives and continue to grow. 10 Chapter 6 - Conclusions 6.1 Introduction The problemstatementof this project is to upgradethe Seiko RT3200 so that it can utilize vision by incorporatinga Visual Basic interfaceusing the softwareVisionBlox to implementwith the Seiko robot arm. The robot will be ableto recognizetrained objectsand perfonn a particulartask with the object. We havesucceededin controlling the robot by using the Visual Basic userfront and the vision systemcan recognizea trainedimagewe specified. Using a trained image,we areable to get the Seiko robot to scana particular workspacefor the trainedobject. Then,oncethe trainedobject is found, we are able to allocateto the robot the location of the object and haveit pick it up, and all of this can automated.Therefore,we have accomplishedall the goalsthat we setout to accomplishandthe rest will be left to the future seniorsthat will be working on the improvementof this project. 6.2 Design Expansion I Improvement Suggestions Therearemany suggestionsthat we havefor the improvementand expansionof this project in the future. The first is to mount the camerain a higherposition so that the picturescapturedby the camerawill be in a betterfocus. As of now, the height of the object from the end-effectorwhen the imageis in focus is far too low, and whenthe endeffector tries to pick up a focusedobject, it cannotreachit. The alternativeto this approachmay be making a 10ngerend-effectorso that the end-effectorcan reachto a lower position, and thereforewill not needto changethe position of the camera. The secondapproachmay be betterbecausethe calculationof the pixel to world coordinate systemwou1dstayre1ativelythe same. Importantnote, if the cameraand the distance betweenthe platform is changed,then the areaof the camerarelative to the spatialarea will also change,causingthe pixel to world coordinatesystemcalculationto changeas well. Another suggestionwe havefor the improvementof this project is to changethe end-effectoron the Seiko RT3200robot arm to somethingmuchmoreuseful. The endeffector we havenow is ableto pick up 2-4 rom wide objectsonly. We suggestbuying a new end-effectorthat can actuallybe usedto do somethingmuch more useful so a more impressivedemonstrationcanuseto showcasethe usefulnessof the project. Other suggestionsthat future groupscan also considerare:working in C instead of Visual Basic,incorporationthe vision systemfor the Adaptecrobot, storing the commandsto readcodethroughthe serial port, and addingmore featuresto the existing vision system. The reasonfor working in the computerlanguageC is becausethe PX610 driver seemsto be morecompatiblewith C, and all its samplecodesare in C, thereforeit will be much easierto implementnew featuresin the future. Also, vision systemcreated for the Seiko robot shouldbe easily incorporatedinto the Adaptecrobot. Of coursethe commandsto control the robot andcameralocation will be different, the generalstructure shouldbe the same. One of the additionsthat we were meaningto addbut did not get to is getting rid 1 of the input commandsof DO COMM 1 78 DO OUNU 1 DO IUNff 1 When going from the control pendantto the Visual Basic program,thesethreecommands must be first typed on the control pendantto get the controller to respondto commands sentthroughthe serialport. This is a redundantprocedure,and getting rid of it will pleasefuture userswho want to sendcommandsto the robot via the serialport. Finally, this project canbe improvedalsojust by addingmore featuresand functionality to the existing vision system. The addition of edgedetection,caliper, and blob tools of VisionBlox would be greataddition to the existing vision system. 6.3User'sManual To startcontrolling the robot from the computer,first you haveto type three commandsfrom the teachpendant: DO COMM 1 78 DO OUNlT 1 DO IUNff 1 Theseinputs instructsthe controller to readcommandlines throughthe serialport insteadof the teachpendant. So all commandsforth is assumedto be typedusing the Visual Basic interfacecreated. Buttons: Calibrate- go to HOME position Load Image- Loadsa bitmap imageonto the editableimagescreen SaveTrainImage- Savesthe imagecurrentlyon the edshpTrainof the FeatureFindTooI Pick - Calls the function that movesthe robot to pick up an object Live Mode - Performsthe scanningand picking up the trainedobject Display Livelmage- Goesto the live imagescreenandcontroller display Move Ann - Moves the robot to a specifiedlocation TrainImage- Trains a specific region of an imageand the imageis usedfor recognition Use TrainImage- This checksif the train imageis currently on the editableimage display,andif so, the coordinatesof the object is displayed Exit - Quits the program Textbox: World Loc - Displaysthe location of the object with respectto the robot, theseare coordinatesthat the robot usesto pick up the object Pixel Loc - The location of the object with respectto the editableimage 12 Loop Counter- Use to displaythe numberof scanswhen in the live mode FoundObject - Returnstrue or false that the object is in the editableimage Minscore- Use to control how similar an object hasto be with respectto the train image before it is consideredthe sameobject Before perfonning any motion of the robot for the first time, the robot mustbe calibrated,and clicking on the "Calibrate" button on the user interfacedoesthis. Calibratingwill placethe robot to the HOME position. 13 ~~,. ~ bll1.-'11~ Q,! ~1 N~an ~ l.t~~m'i:ii:idt~'{H:} ~ -. I TQo1sA(kJ.lns ~ - ~f~S~Pf~t UAP~D n-AArn ~ L.~ t=:;:tLaSt~~ ~c~~ ~.'P'~1. ~'I;: ~ Mfr:O$dtVas... Appendix A: Parts List Software: Microsoft Visual Basic 6.0 VisionBlox Darl Hardware: Seiko D-TRAN RT3200 Camera:Hitachi KP-M2 PersonalComputer ImagenationPX610 frame grabber RS232serialport BNC video port 15 Appendix B: PX610 DLL Library Code 16 'Declarations for the PXDVNT.DLL 11b~ Global fgh As Long Global frh As Long Global counter As Long Sub displayit() r-'Pim y As Integer , bim xdx AsAs Integer, Integer, dy As Integer dx = (640& * Contro.1ler.HScroll1.Value) dy = (480& * Controller.HScrolll.Value) x = (640& dx) * LiveImage.HScroll1.Va.1ue y = (480& dy) * LiveImage.VScroll1;Value ~ - Call Sub pxPaintDisplay(Livelmage.hDC, frh, 1100&. 100& I 100& / 100& I x, y, dx, dy) I I I I I I I " I II'" I '" I I I I "8'" '8'.)""'" "1 WPX5.-NT.BAS I I I I , I , I . , , I I . , I I I , I . I I " . .~" , '. " i, Flags 1~1 J1Obal ;lobal ~lObal ;lobal ;lobal ;lobal ;lobal ;lobal Canst Canst Canst Canst Canst Canst Canst Canst Canst GRAB_OFF = &HO FIELDS = &H3 EITHER = &H3 GRAB_ON= &H3 FIELDO = &Hl FIELDl = &H2 rMMEDIATE = &H4 QUEUED= &H8 SINGLE_FLD = &H1O ;lobal Canst CACHE = &H20 Trigger Types = &H3 = &H2 ;lobal Const RISING ;lobal FALLING ;lobal ~lobal Canst Canst Canst Canst HIGH = &Hl LOW &HO DEBOUNCE = &H4 J10bal ;lobal ;lobal Jlobal Jlobal ;lobal ;lobal ;lobal Const Const Const Const Const Const Const Const Strobe Types STROBE_O = &Hl STROBE_l = &H2 STROBE_OFF = &H4 STROBING = &H8 STROBE_GAP = &H1O STROBE_STOP = &Hll STROBE_TRIG = &H12 STROBE_NORMAL &H13 ~!i;el Const Jlobal Const ;lobal = = SYNC~ORMAL = &H13 SYNC_OFF = &H4 Error Uobal Jlobal flobal Jlobal ~lobal ~lobal Ilobal Ilobal Const Const ERR~ONE Numbers = &HO ERR_NOT_VALID = &Hl Const E~CORRUPT = &H2 Const ERR_NO_PCI = &H4 Cons t E~BAD_IRQ = &H8 Const ~NO-.:ADDRESS = &H1O Const ~_DEVICES = &H20 Const ERR_GRAB_INVALID = &HBO File I/O = Return ~lobal Canst SUCCESS flobe1 Canst Canst FILE_EXISTS = 2 FILE_OPEN_ERROR= BAD_WRITE = 4 BAD_READ = 5 floba1 ~10ba1 11oba1 11oba1 11oba1 Ilobal n Const Canst Canst Canst Canst Values 0 WRONG_BITS = 8 BAD_FILE = 11 INVALID_FRAME = 12 lobal Const lobal Const Sync Types USER_SYNC = &HI INTERNAL_SYNC = &:H2 WEN_SYNC= &:H4 SINGLE_FIELD_SYNC = &:HIO AUTOMATIC_SYNC= &:HaO IQbal IQbal Const Const Configuration Values PXC_CACHE = &Hl PXC_NONINTERLACE = &H2 lobal ~ l Const Const I Const I' I , . , 310ba1 31oba1 31obal 31oba1 Canst Canst Canst Canst PXC_BUS = &HCO PXC_PCI = &HO PXC_1O4_PLUS = &H40 PXC_COMPACT_PCI= &H80 3~1 Canst PXC_VIDEO_DRlVE ~ = &H1OO .1 Canst PXC_H_CROP= &H1OO 31oba1 Canst 11oba1 Const PXC_V_SCALE = &H1OO PXC_V_CROP= &H800 llobal Const PXC_H_SCALE )loba1 Const 31abal Const = &H800 ~lobal Const PXC_STROBES = &H200 = &H400 PXC_WEN_SYNC PXC_CUSTOM_HW = &HFOOO Setup ~lare Function ~lare Sub ExitLibrary Functions Ini tLibrary Lib Lib "wpx5~t. dll" "wpx5~t.dl1" () As Long () Frame Data Functions )eclare Function AllocateBuffer As Long) As Long )eclare Function AllocateAddress l dy As Long, ByVal bits As Lib .wpxS~t.dll. Lib As Long) (ByVal .wpxS_nt. Long dll. dx (ByVal As Long, address As ByVal dy As Long, ByVal Long, ByVal bits dx Long, ByVa As )eclare Sub FreeFrame Lib .wpxS_nt.d11. (ByVal frh As Long) )eclare Function FrameWidth Lib .wpxS~t.dll. (ByVal frh As Long) As Long Jeclare Function FrameHeight Lib .wpxS_nt.dll. (ByVal frh As Long) As Long Jeclare Function FrameBits Lib .wpx5_nt.dll. (ByVal frh As Long) As Long Jeclare Function FrameBuffer Lib .wpx5~t.dll. (ByVal frh As Long) As Long 'FrameAddress NOT supported on NT Frame ~lare )eclare Allocation Grabber Function AllocateFG Lib .wpx5_nt.dll. Sub FreeFG Lib "wpx5_nt.dll. (ByVal ~clare J) As Function Long Grab Lib GrabTriggered ByVal flags Lib .wpxS_nt.dll. .wpxS~t. dll. )eclare :ime As Function Long, ~clare s Long) Function As Long ReadCache ~clare Function GrabToCache >eclare Function CacheTriggered L flags >eclare >eclare As Long) Function Function As Long Wait Lib .wpxS_nt.dll. WaitVB Lib .wpxS_nt.dll. ~clare Function IsFinished ~clare Sub KillQueue Frame ~clare Function Long) As Lib Lib .wpxS_nt. Lib Lib Function Function As Long, (ByVal dll. .wpxS~t. As Long Long, fgh (ByVal dll" fgh As Long, ByVal fgh As As Long, fgh (ByVal ByVal frh As Long, ByVal As Long, frh ByVal fgh As Long, (ByVal (ByVal fgh fgh As Long, frh As Long, Long, ByVal BYVal frh As As Long, flags ByVal (ByVal fgh As Long, ByVal flags (ByVal fgh As Long) As Long .wpxS_nt. dll- State As (ByVal dll- .wpxS~t. Lib Lib fgh .wpxS~t.dll. As Long .wpxS_nt.dll8 Grabber SetFineGain Lib Long) As (ByVal (ByVal ByVal flags Long, handle As As Long) As Lon ByVal ByVal del time As Long) ByVal ac del flags A As Long Long, ByVa As Long As Long) As Long As Long) Functions .wpxS_nt.dll. (ByVal fgh As Long, ByVal gain As Long, ByVal flag Long ), are Function SetGainRange Lib .wpxS_nt.dll. 19S As Long) As Long )eclare Function SetOffset Lib .wpxS_nt.dll. : As Long) As Long ~lare ~clare ength (ByVal n As Long) fgh As Long) Grab Functions >eclare Function GrabContinuous :ive As Long) As Long ~n Functions (ByVal (ByVal SetTriggerType Lib .wpx5~t.dll. SetLUT Lib nwpxS~t.dll. (ByVal lutarray As Long) As Long fgh fgh As As Long, Long, ByVal ByVal range offset As As Long, Long, ByVal ByVal fl flag (ByVal fgh As Long, ByVal mode As Long) As Long fgh As Long, ByVal first_address As Long, ByVal Declare Function SetCamera Lib .wpxS-.-nt.dll. (ByVal fgh As Long, ByVal camera As Long, ByVal flag I As Long) As Long Oeclare Sub ResetFG Lib "wpx5-.-nt. dll" (ByVal fgh As Long) Oeclare Function SetImageSize Lib "wpxS_nt. dll. (ByVal fgh As Long, ByVal resx As Long, ByVal res r~ Long, ByVal xO As Long, ByVal yO As Long, ByVal dx As Long, ByVal dy As Long, ByVal bits As to ) As Long Oeclare Function SetCompare Lib "wpxS_nt.dll" (ByVal fgh As Long, ByVal n As Long) As Long Declare Function SetFieldCount Lib "wpxS_nt.dll" (ByVal fgh As Long, ByVal x As Long) As Long , SetCurrentWindow NOT supported on NT Declare Function As Long) As Long Declare Function ( As Long, ByVal l.ong) As Long Declare Function ByVal blank_length SetStrobePolarity SetFieldSize xO As Long, Lib "wpxS_nt.dll" Lib .wpxS_nt.dll" ByVal yO As Long, As Long, ByVal s As Long, ByVal (ByVal fgh As Long As Long, ByVal field_length Function ReadRevision Lib .wpxS-pt.dll. )eclare )&clare >&clare Function Function Function ReadProtection HaveCache Lib VideoType Lib )eclare Function CheckGreater ~lare Function CheckEqual fgh As Long) As Long (ByVal Lib .wpxS-pt.dll. (ByVal fgh As Long) As Long .wpxS_nt.dll. (ByVal fgh As Long) As Long nwpxS-Pt.dll. (ByVal fgh As Long) As Long Lib .wpxS_nt. dll. (ByVal fgh As Long) As Long Lib .wpx5_nt.dll. (ByVal fgh As Long) As Long GetTriggerType Lib .wpxS-pt.dll. (ByVal fgh As Long) As Long GetFineGain Lib .wpxS_nt.dll. (ByVal fgh As Long) As Long GetGainRange Lib .wpx5_nt.dll. (ByVal fgh As Long) As Long GetOffset Lib .wpxS_nt.dll. (ByVal fgh As Long) As Long GetCamera Lib .wpx5_nt.dll. (ByVal fgh As Long) As Long GetLUT Lib .wpx5_nt.dll" (ByVal fgh As Long, ByVal first_address lutarray As Long) As Long CheckError Lib .wpx5-Pt.dll" (ByVal fgh As Long) As Long GetFieldCount Lib .wpxS-pt.dll. (ByVal fgh As Long) As Long GetFieldLength Lib .wpx5-pt. dll. (ByVal fgh As Long) As Long ReadConfiguration Lib .wpxS-pt.dll. (ByVal fgh As Long) As Long Data Manipulation As Function Long )eclare Function ;tring, ByVal ~lare :-ing) As ReadBin Lib WriteBin overwrite As Long ByVal Functions Function Long ReadBMP ~lare Function rtzing, ByVal ~lare Function ~lare Function ~wpx5J1t.dll~ Long) Lib WriteBMP overwrite ~wpx5_nt.dll~ Lib As Digital I/O FireStrobe As ~wpx5_nt.dll~ Long) As Alias Alias ~ReadBinA~ ~WriteBinA~ Alias Lib frh (ByVal Alias ~ReadBMPA~ As frh Long, As ByVal Long, fname ByVal ByV As fname St As ~WriteBMPA~ (ByVal frh (syval As frh Long, As ByVal Long, fname ByVal fname As St As Long functions -- strobes and Lib .wpxS_nt.dll. (ByVal GetStrobeState (ByVal ByV Long ~wpx5J1t.dll~ Lib As res As As Long. )eclare Sub GetRectangle Lib ~wpx5_nt.dll~ (ByVal frh As Long, but As Byte, ByVal xO As Long, U yO As Long, ByVal dx As Long, ByVal dy As Long) )eclare Sub PutRectangle Lib ~wpx5J1t.dll~ (buf As Byte, ByVal frh As Long, ByVal xO As Long, u yO As Long, ByVal dx As Long, ByVal dy As Long) )eclare Sub GetRow Lib ~wpx5_nt.dll~ (ByVal frh As Long, but As Byte, ByVal row As Long) ~clare Sub PutRow Lib ~wpx5_nt.dll~ (buf As Byte, ByVal frh As Long, ByVal row As Long) ~clare Sub GetColumn Lib ~wpx5J1t.dll~ (ByVal frh As Long, but As Byte, ByVal row As Long) ~clare Sub PutColumn Lib ~wpx5_nt.dll~ (buf As Byte, ByVal frh As Long, ByVal row As Long) )eclare :-ing) p Functions )eclare )eclare Function )eclare Function )eclare Function )eclare Function )eclare Function )eclare Function length As Long, ~re Function ), ,are Function )eclare Function )eclare Function fgh (ByVal fgh As Long, ByVal resx As Long, ByVal ByVal dx As Long, ByVal dy As Long, ByVal bi ts SetVideoFormat Lib "wpxS_nt.dll" As Long, ByVal flags As Long) Frame Grabber Info (ByVal .wpxSJlt.dll. syncs fgh As Long, (ByVal ByVal fgh As Long) command As As Long) As Long Long >eclare Function GetSyncType Lib .wpxS_nt.dll. (ByVal fgh As Long) As Long r-'ere Function SetDrivePolarity Lib .wpxS_nt.dll. (ByVal fgh As Long, ByVal vdrive As Long, ByV t. .(irive As Long) As Long ~clare Function SetDriveType Lib .wpxS_nt.dll. (ByVal fgh As Long, ByVal mode As Long) As Long )eclare Function SetStrobePeriods Lib .wpxS_nt.dll. (ByVal fgh As Long, ByVal tl As Long, ByVal t : As Long, ByVal t3 As Long) As Long ~clare Function SetStrobeType Lib .wpxSJlt.dl1.. (ByVal fgh As Long, ByVal mode As Long) As Long Ii veImage - 1 'ivate Sub FornLLoad( Dim x As Integer Dim y As Integer " **Fixed , This Window requires Size** moving the scrollbars Livelmage.ScaleMode = 3 VScrol11.Top = 0 VScrol11.Left = 640 VScrol11.Height = 512 HScrol11.Top = 512 HScrol11.Left = 0 HScrol11.Width = 640 Call pxSetWindowSize(O, 0, 640, 512) 'We calculate the new window size in twips because 'screen coordinates are in twips. Li veImage . ScaleMode 1 x = VScrol11.Left + VScrol11.Width y = HScrol11.Top + HScroll1.Height 'account for the window border size x = x + (Livelmage.Width - LiveImage.ScaleWidth) y = y + (Livelmage.Height - Livelmage.ScaleHeight) Livelmage.Width = x Livelmage.Height = y = Li velmage gndSub . Timer!. Int~l . 10 ?rivate Sub Fo~paint() Call displayit ~d Sub -ate Call Sub HScrolll_Change displayit () Sub ?rivate Sub Timerl_Timer() counter = counter + 1 tmp If = Grab(fgh, frh, (tmp = 0) Then Debug.print 8Grab End If Call Cnd Sub displayit ~rivate Sub VScrolll_Change( Call displayit Cnd Sub 0) failed8 :ontroller Tivate Call ~Sub - 1 Sub Commandl_Click Commands. GetImage 'rivate () Sub Form..-Load() If (InitLibrary() Debug.Print = 0) Then "init fail" End End If = fgh If (fgh AllocateFG(-l) = 0) Then ExitLibrary Debug.Print "frame grabber fail" End End If frh If = AllocateBuffer(640, (frh = 0) Then FreeFG (fgh) ExitLibrary Debug.Print End End If 480, "buffer 8} fail" tmp = SetImageSize(fgh, 640, If (tmp = 0) Then Debug.Print "SetImageSize 256, 0, . failed" End If LiveImage.Show d Sub - ate Sub Form_Unload(Cancel.As LiveImage.Timerl.Interval Unload Li veImage Integer) = 0 FreeFrame (frh) FreeFG (fgh) ExitLibrary ld Sub 'rivate tmp Sub grange_Click(Index As = SetGainRange(fgh, Integer) Index, 0) !'1d Sub rivate tmp Sub gslide_Change () = SetFineGain(fgh, gslide.Value, 0) nd Sub rivate Sub HScrolll_Change() Call displayit nd Sub rivate Sub Labe14 Click ndSub rivate tmp Sub offslide_Change() = SetOffset(fgh, offslide.Value ~ 'ivate Sub Open_Click() stop_click CMDialogl.FileName = .11 CMDialogl.Action = 1 If (CMDialogl.FileName <> .. Then ") V 640 .80, SI _troller - ~ Screen.MousePointer = 11 If ReadBMP(frh, CMDialog1.FileName) Screen.MousePointer = 0 MsgBox .Could Not Read File., End I f (-""-\ Screen.Mousepointer = 0 End If LiveImage.Refresh :nd Sub ~lic Sub play_Click() Li veImage . Timerl . Interval = 0 = Timer = 10 2 0 counter tl 'rivate Sub stop_click() ~ivelmage.Timerl.Interval iSub 'rivate Sub cmdQuit_Click() LiveImage.Timerl.Interval Unload Li veImage Unload Controller Load Commands Commands. Visible = True Commands. WindowState = 0 FreeFrame (frh) FreeFG (fgh) ExitLibrary :nd Sub = 0 Then 48, .Error " t >ption Explicit ~ining global variable of the form )rivate mintResultNumber As Integer )rivate counter_x As Integer >im loop_counter As Integer )rivate flag As Integer ~ivate Call Sub Commandl_Click() Get Image md Sub Sub cn¥iLoa~Click() 'rivate Loads a saved bi tmap image and sets to the edi table image screen When clicked, a file must be selected or an error occurs. A if statement but we consider this not the most important issue right now so disregard Commands.CommonDialogl.DialogTitle Commands .CommonDialogl.Filter Commands .CommonDialogl.FileName = "File = "* .bmp" = "* .bmp" can be used for now Open" Commands.CommonDialogl.ShoWOpen load the image information Commands.edshpTrain.Load Commands.edshpInspection.Load tapew ~ommands.FeatureFindTool.Load ~, from the FeatureFindSample. INI file "h:\SeniorProject\LastYear\FeatureFindSample.INI", "h:\SeniorProject\LastYear\FeatureFindSample.INIw, . " TrainingShape " wInspectionS "h:\SeniorProject\LastYear\FeatureFindSample.INI., "Featurefind Commands.FeatureFindTool.Refresh ~d Sub Irivate Sub cmdMOVE_Click() , Moves allow , user robot a list MSCoxmn1.OUtput Call Move1(380, to one location of coordinate right now for choices = -00 SPEED SO' + 170, -120, 0) or allow testing user purposes. to input Need to be incorporated later location ~Lf :nd Sub 'rivate ~til Sub cmdPICK_Click() pick(True) :nd Sub 'rivate Sub cBKiSave_ClickO 'Saves the current trained image ,to a file Filename Commands.CommonDialog2.DialogTitle = "File Save" Commands.CommonDialog2.Filter = "*.Dat" Commands. CommonDialog2. FileName = "image1. Dat" Commands. CommonDialog2 . Action = 2 If (Commands.CommonDialog2.FileName Screen.MousePointer = 11 <> "") Then "imagel.Dat" is used at the default name :ommands If WriteBMP(frh, Commands.CommonDialog2.FileNarne, Screen.MousePointer = 0 MsgBox 8Could Not Write File8, 48, 8Error8 End If \ Screen.MousePointer = 0 End If image and feature 'saves find information = Commands. CommonDialog2 . FileName .h: \SeniorProject\LastYear\FeatureFindSample. INI., .h:\SeniorProject\LastYear\FeatureFindSample.INI., Commands. FeatureFindTool. Commands .edshpTrain. save Commands.edshpInspection.save lape. 1) Then FeatureFileName Commands.FeatureFindTool.save .TrainingShape. .InspectionS .h:\SeniorProject\LastYear\FeatureFindSample.rNI., .Featurefind ~ool. 'ivate Sub coJmlandUse_Click , Compares the () features of Commands.FeatureFindTool.Use Commands. FeatureFindTool. Commands. CalXValue. Text !rivate ~' the trained image with the image being displayed Found Sub commandTrain_Click() Trains the image in the train Commands.FeatureFindTool.Train Commands.commandUse. Enabled shape box Rectangular blue shaped on the = True = True Commands. edshplnspection. Visible Commands.FeatureFindTool.Refresh 1d Sub 'rivate Sub disp_Click(Index the Displays live As Integer) image on the Li veimage Commands. WindowState Controller. Show Livelmage.Show = window. 1 nd Sub Sub EdibleImage_Paint 'Controls what to display () on the 'Commands.Ediblermage.picture If i = Commands. txtMinScore MinimumScore = Commands. FeatureFindTool. nd hold to drag shape rivate on the editable (flag = 1) image = -h: \SeniorProject\LastYear\abc.bmp- (Commands.CommonDialogl.FileName Commands. EdibleImage. picture ElseIf edible = "") Then = "h: \Seniorproj ect \LastYear\abc. Then Commands. EdibleImage. picture Commands.EdibleImage.Refreah flag = 0 = -h:\SeniorProject\LastYear\abc.bmp- bmp. editable image. Cli ~~nds - 3 Else = "h:\SeniorProject\LastYear\abc.bmp= Commands. CommonDialogl. FileName Commands.EdibleImage.Picture Commands. EdibleImage. ~d picture If Sub )rivate Sub FeatureFindTool_Use When features desired are found on the edible Xl Commands.FeatureFindTool.NwnberOfResults Else this controls what is displayed 0 Then =1 mintResultNumber image DisplayResultlnfo mintResultNwnber DisplayResultInfo End If = 0 Sub 'rivate Sub ForIrLLoad Loads the form, initializes Dim CommPort As String, Dim counter~ As Integer , intializes counter.-X counter ~lag these = = and sets Handshaking parameter As String, before Settings anything As String variables glObal 0 0 to be specified for featurefindtool to = Commands.FeatureFindTool.hInspectionShape Commands. FeatureFindTool. work = EdibleImage Commands.FeatureFindTool.hInspectionImage edshpInspection FeatureFindTool. = Commands. hTrainingImage = edshpTrain Commands.FeatureFindTool.hTrainingShape , image shown when program start at beginning Commands. EdibleImage. picture = Rh: \SeniorProj ect \LastYear\abc. Commands.edshpTrain.Load Rh:\SeniorProject\LastYear\abc.INI", Commands.edshpInspection.Load "h:\SeniorProject\LastYear\abc.INIw, Commands.FeatureFindTool.Load "h:\SeniorProject\LastYear\abc.INIw, Commands.FeatureFindTool.Refresh , to show when program is running Commands.edshpTrain.Visible = True Commands.edshplnspection.Visible = True Commands.commandUseEnabled True Commands. commandTrain. Enabled = True = . , initial value used, Commands.txtMinScore serial port settings can be changed = "75" I very ~hen program important =1 CoImnPort Settings = "9600--H,8,1" COM1. MSComml . CommPort = CommPort 9600 baud, no parity, 8 data, MSComml.Settings = Settings I done = 0 , need \ Use are Handshaking MSComml . Handshakinq = comRTS and 1 stop b~t is running hInspectionImage bmpR RTrainingShapeR wInspectionShape" RFeaturefindTool" :ommands- 4 , Open Port If = MSComml. PortOpen MSComml. PortOpen If ~d ~rivate False = True Then Sub DisplaYResult~nf~J) 'Displays the results of If mintResultNumber when using the "Use" button to the screen = 0 Then Commands.XValue.Text Commands. YValue. Text = "" = "" Resul tLabel. Enabled = False Commands. FrameCoordinates . Enabled = Commands. Else False Commands. Resul tLabel. Enabled = True Commands. FrameCoordinates . Enabled = True Commands.XValue. Commands. YValue. 'Point at the = Commands. FeatureFindTool. Text Text = origin Resul tX (mintResul tNumber) (mintResultNumber) Commands. FeatureFindTool.ResultY of the area where the feature was found when the invoked Commands.Textl = Commands .FeatureFindTool.ResultPoint If ~ub ?rivate Sub ~_Click(Index OUtput calibration MSComml.Output MSComml.Output Call delay(2) ?rivate As Integer) connnand HOME Calibrates robot. = "HOME" = vbCrLf Sub Exit_Click(Index Close the As Integer) Port If MSComml.Portapen <> False MSComm1. PortOpen = False End If , Exi t Program End ;ub Movel (x As Double, Then y As DOuble, z As DOuble bimbuffer As String Dim destination As String 'manually move arm for Dim T(l To 4) As String T(l) = CStr(x) T(2) = CStr(y) given destination R As Doubl.) (mintResultNumber) Use method was la8~ T()) T{.r a CStr(z) = CStr(R) 'Define point ~estination = T(l) buffer = "DO Tl MSCo~ .Output + - + T(2) - + - - ... ~()). + . . + T(4) = - + destination = buffer + vbCrLf Call delay(7) MSComml.Output = -DO MOVE Tl" + vbCrLf Sub ~ delay(c As Integer) 'Delay for specified = 1 Toc' For counter Next counter Used quite times often to make sure robot and vision can be worked tog. 1000000 md Sub SUb pick (y As To pick Boolean) object function Dim Dim ~im bim Dim Dim Dim Dim Dim if found, or increment to scan workspace screen_x screen-y darl~ = area if not found Loop is under the RunProg ( of robot. As Double As Double As Integer darl-y As Integer A As String move~ As Integer B As String move_x2 As Integer ndarl_x As Integer 'clear robot memory bank MSComml.Output = "DO CLEARCall delay(5) y to next " v~Lf Comrnands.FeatureFindTool.Found Jf Y = True Then 'get pixel screen_x = screen-y darl-y darl_x ndarl_x = location Commands.FeatureFindTool.ResultX(mintResultNumber) Commands. FeatureFindTool. = Clnt«64.516 - (screen_x = Clnt«scre~ / -6.124) = darl_x + counter-x Commands.txtWorldX.Text Commands. txtWor IdY Text . 'set Resul darl command into A = -DO Tl = " & ndarl_x / 6.124) + 387) tY (mintResul ) 'convert pixel location to real cooridate 'convert pixel location to real cooridate = ndarl_x = dar l-y string & -. . Ic darl~~ . , 4"'" ...~~~ Commands. cmdA. Text I set MSCo~ Call robot u A movement speed = .DO SPEED 300. .Output delay(l) COImnands. cmdA. Text = A tNumber) & vbCrLf 0 6 Call delay(l) MSComm1.0utput MSCoJXln1.0utput Call delay(S) 'open end-effector MSComm1.OUtput Call delay(40) 'move to found MSComml.OUtput = A = 8DO = vbCrLf OUTPUT + OG68 vbCrLf & object = 8DO MOVE T18 & vbCrLf Call delay(40) 'end-effector go down MSComm1Ou tpu t = 8DO OUTPUT + OG7 . 8 . vbCrLf Call delay(40) 'close end-effector MSCoJXlnl.Output = 8DOOUTPUT - OG68 & vbCrLf Call delay(40) 'end-effector go up MSComm1.OUtput = 8DO OUTPUT - OG78 & vbCrLf Call delay(40) 'set the destination that want to drop the object MSComm1.OUtput = 8DO T3 = -17. 473. -120. 0.8 & vbCrLf Call delay(S) 'go to the destination that want to drop the object MSComm1.OUtput = 8DO MOVE T38 & vbCrLf Call delay(40) 'drop object MSComm1.OUtput 8DO OUTPUT + 0068 & vbCrLf Call delay(40} = , example for last 'MSCoImnl.OUtput 'Call delay(S) 'MSCoImnl.OUtput 'Call delay(40) 'MSCoImnl.Output 'Call delay(S) 'MSCoImnl.Output 'Call delay(40) 'MSCoImnl.Output 'Call delay(40) counter_x = 0 demo = 800 = 800 MOVE T48 & vbCrLf T4 = 369. 34. = 800 TS = 369.34. -91. -96. 0.81& 0.- = 800 MOVE TS8 & vbCrLf = 800 OUTPUT + OG68 & v~Lf Else 'keep increment until find a object counter_x = counter_x + 10 MSCo~.OUtput = 8DO OUTPUT - OG78 & vbCrLf Call delay(40) Commands. Text 1 = move-x = 300 move-x2 = move_x B = 800 T10= 8 & MSCo~ . OUtput = MSCOImnl.OUtput = Call delay(5) = MSCOImnl.OUtput Call counter~ + counter-x move_x2 & 8. B vbCrLf 8DO MOVE T108 O. O. 0.8 & vbCrLf delay(5) End If Call delay(15) End Sub ~ic Sub Get Image ( ) Not used Dim tmp As In~er tmp Call = Grab(fgh, WriteBMP(frh, frh, 0) .c:\ee175AB\temp.bmp., 1 vbCrLf & vbCrLf :oIm1lands End Sub trivate SUb RunProg_Click(Index Automation Dim temp , loop of the As Integer) vision system, utilizes the pick function As Int898:r until object is found Do , setting live image to abc.bmp Call Controller.play_Click LiveImage.Timer1.Interval 0 temp = Grab(fgh, frh, 0) Call WriteBMP(frh, 8h:\SeniorProject\LastYear\abc.bmp8, 1) CoImlands.EdibleImage.Picture 8h:\SeniorProject\LastYear\abc.bmp" = = , saves abc.bmp info to abc.ini file Commands.FeatureFindTool.FeatureFileName = wh:\SeniorProject\LastYear\abc.DatW Commands.edshpTrain.save wh:\SeniorProject\LastYear\abc.INlw, wTrainingShapeW Commands.edshplnspection.save wh:\SeniorProject\LastYear\abc.INlw, wlnspectionShapew Commands.FeatureFindTool.save wh:\SeniorProject\LastYear\abc.INlw, wFeaturefindToolw 'load to be displayed and use Commands.edshpTrain.Load wh:\SeniorProject\LastYear\abc.INIw, Commands.edshpInspection.Load wh:\SeniorProject\LastYear\abc.INIw, Commands.FeatureFindTool.Load wh:\SeniorProject\LastYear\abc.INIw, wTrainingShapeW wInspectionShapew wFeaturefindToolw Commands.FeatureFindTool.Refresh Commands.EdibleImage.Refresh Controller.Refresh LiveImage.Refresh , check Call Call Call if trained image , setting flag = 1 Commands. the edible = = found by calling the use function Text to = after = = 0 loop counter + 1 loop_counter (Commands. FeatureFindTool. , reseting variable counter_x = 0 loop_counter 0 Commands. WindowState abc.bmp, 1 loop_counter Commands. Cal YValue. While image WindowState loop_counter Loop is coImnandUse_Click pick(Commands.FeatureFindTool.Found) delay(20) loop Found = False And loop_counter < 1~ Appendix D: Technical Specifications KP-M2U Svecification(EIA) . Sensorpick up device: 1/2" (KP-M2) Interline transferCCD 1/3" (KP-M3) interline transferCCD Sensingscanning area: 6.45 (H) x 4.84 (V) mm (KP-M2) 4.88 (H) x 3.09 (V) mm (KP-M3) Total number of pixels: 811 (H) x 508 (V) Number of effective pixels: 768 (H) x 494 (V) Pixel pitch: 8.4 (H) x 9.8 (V) ~m (KP-M2) 6.35 (H) x 7.4 (V) ~m (KP-M3) m . u' . ~,,-~--~'.'. M .~ . ~~ t, 0 Spectral sensitivity: J -~.. L - Scanning system: 2: I interlaced / 525 lines /60 fields per second / 30 frames per second or non-interlaced (only in external sync mode or with modification) Scanning frequency: 15.734kHz (H), 59.94Hz(V) Signal standard: EIA Monochrome Sync system: Internal or external (automatic switching) External sync input: HV ND 2 to 6 volts p-p input impedance1kohm, frequency deviation:t:l%, negativepolarity Resolution: 570 (H), 485 (V) TV lines Standard sensitivity: 400 lux @ f4 (3200K) Minimum sensitivity: 0.5 lux at fl.4 (with AGC on, gamma0.45, without IR cut filter) Electronic Shutter: off, 1/100th,1/125th,1/25Oth,1/500th,l/l,OOOth,1/2,OOOth, 1/4,OOOth, 1/10,OOOth (selectableby externalswitch) Gamma correction: 0.45 or 1.0 (selectableby internal switch) Signal to noise ratio: 56dB AGC: Normal or AGC (selectableby internal switch) 33 Video output: VS 1.0 volt p-p 75 ohms unbalanced. (0.7 volts p-p video and 0.3 volts p-p sync negative polarity) Integration mode: Field or frame integration (selectable by external switch) Field on demand function: Switchable on/off by internal switch Restart reset operation: On/Off selectable by component change . . Lens mount: C Flange focal distance: 7.526 mrn Ambient temperature and humidity: Operating:-100C to +60°C,RH 90% or less Storage:-200C to +6OoC,RH 70% or Jess Resistanceto vibration: 9G max (10 to 60Hz amplitudeconstantat 0.98mm) 7G constant(60 to 150Hzamplitudevariable), 10 to 150Hz(sweepingfor one minute, eachof X, Y andZ directionsfor 30 minutes) Dimensions: 44 (W) x 29 (H) x 72 (D) mm Weight: 120grams(approx) Supply voltage: 12 volts dc:tl volt Current consumption: 180mA (approx) Composition: Camera head (with IR cut filter), C mount cap, operation manual Seiko Robot RS-232serialcablepin-outs PC Seiko Controller 25 Pin (M) 9 Pin (F) 2 3~~ 3 2 5 ~-7 34 References [1] DARLfour ProgrammingGuide. Seiko Instruments,Torrance,CA 1987 [2] DARL Talk. Version 2.02A, Seiko Instruments,Torrance,CA 1995. [3] "Imaging Components:VisionBlox ImagingSoftware,"Vision 1, h~:llwww.visionl.com/software/vbloxdesc.shtml (currentJune7,2001). [4] "KPM-2 Camera,"PremierElectronics,httR://www.oremierelect.co.uk/kRm2.html (currentJune7,2001). [5] Seiko RT3200Installationand OperationManual. Torrance,CA 1987. ed., Seiko Instruments, [6] VisionBlox Training Manual.Version 3.0, IntegralVision Inc., FarmingtonHills, MI 1998. [7] VisionBlox ReferenceManual. Version 3.0, IntegralVision Inc., FarmingtonHills, MI 1998. [8] G. Perry,TeachYourself Visual Basic 5 in 24 Hours. 1sl ed., Indianapolis,Indiana SamsPublishing, 1997. Addison[9] J.J. Craig, Introduction to Robotics. 2nded., Reading,Massachusetts: Wesley Publishing Company, Inc., 1989. [10] H.M. Deitel, P.J.Deitel, andT.R. Nieto, Visual Basic6 How to Program.New Jersey:PrenticeHall, 1999. [11] C. Bertell, H. Nguyen,and K. Wassink,Final Reportof SeniorDesignProject Winter/Spring2001,2001. 36 Acknowledgement We would like to thank Dan Giles for the all the help and guidancehe hasassisted us with all throughout. We also like to thank Dr. GerardoBern for keepingus on track with our report by makingus sendhim weekly reports. Jojo, thanksfor helping us preparefor the presentation,it really helpedus from getting flusteredwhen we presented in front of everyone. Steve,thanksfor lending us the Visual Basic book. Also, thanksto Josephfor providing the us with the video cameraso we can tapeour demonstrationand being our cameramantoo. 37