v_langug users manual

v_langug users manual - V+ Language User's Guide Th is is a...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: V+ Language User's Guide Th is is a PDF/prin t version of th e V+ Lan gu age User's Gu ide on lin e docu men tation . A Table of Con ten ts is provided so th at you can locate th e desired topics. Becau se th e V+ Lan gu age User's Gu ide was design ed for on lin e viewin g, th ere may be sligh t formattin g an omalies in th e PDF/prin t version . Addition ally, lin ks to extern al docu men ts will n ot work in th e PDF file. For optimal viewin g an d n avigation , please u se th e HTML version of th is docu men t, wh ich can be accessed from th e Adept Docu men t Library. NOTE: Please see th e V+ Release Notes, wh ich are in clu ded with you r V+ software, for a description of an y recen t ch an ges. V+ Lan gu age User's Gu ide Page 1 Copyright Notice Th e in formation con tain ed h erein is th e property of Adept Tech n ology, In c., an d sh all n ot be reprodu ced in wh ole or in part with ou t prior written approval of Adept Tech n ology, In c. Th e in formation h erein is su bject to ch an ge with ou t n otice an d sh ou ld n ot be con stru ed as a commitmen t by Adept Tech n ology, In c. Th e docu men tation is periodically reviewed an d revised. Adept Tech n ology, In c., assu mes n o respon sibility for an y errors or omission s in th e docu men tation . Crit­ ical evalu ation of th e docu men tation by th e u ser is welcomed. You r commen ts assist u s in preparation of fu tu re docu men tation . Please su bmit you r commen ts to: tech pu bs@adept.com. Copyrigh t © 1 9 9 4 ­ 2 0 0 9 by Adept Tech n ology, In c. Adept, th e Adept logo, th e Adept Tech n ology logo, AdeptVision , AIM, Blox, Bloxview, FireBlox, Fireview, Meta Con trols, MetaCon trols, Metawire, Soft Mach in es, an d Visu al Mach in es are registered trademarks of Adept Tech n ology, In c. Brain on Board is a registered trademark of Adept Tech n ology, In c. in German y. Adept ACE , ACE PackXpert, Adept 1 0 6 0 / 1 0 6 0 +, Adept 1 8 5 0 / 1 8 5 0 XP, Adept 5 4 0 Adept 5 6 0 , Adept An y­ Feeder, Adept Award, Adept C4 0 , Adept C6 0 , Adept CC, Adept Cobra 3 5 0 , Adept Cobra 3 5 0 CR/E SD, Adept Cobra 5 5 0 , Adept 5 5 0 Clean Room, Adept Cobra 6 0 0 , Adept Cobra 8 0 0 , Adept Cobra i6 0 0 , Adept Cobra i8 0 0 , Adept Cobra PLC Server, Adept Cobra PLC8 0 0 , Adept Cobra s6 0 0 , Adept Cobra s8 0 0 , Adept Cobra s8 0 0 In verted, Adept Cobra Smart6 0 0 , Adept Cobra Smart8 0 0 , Adept DeskTop, Adept FFE , Adept Flex­ Feeder 2 5 0 , Adept IC, Adept iSigh t, Adept Impu lse Feeder, Adept Lin eVision , Adept MB­1 0 ServoKit, Adept MC, Adept Motion Blox­1 0 , Adept Motion Blox­4 0 L, Adept Motion Blox­4 0 R, Adept MV Adept MV­1 0 , Adept MV­1 9 , Adept MV4 , Adept MV­5 , Adept MV­8 , Adept OC, Adept Pyth on , Adept Qu attro s6 5 0 , Adept Qu attro s6 5 0 H, Adept sDIO, Adept SmartAmp, Adept SmartAxis, Adept SmartCon troller CS, Adept SmartCon troller CX, Adept SmartModu le, Adept SmartMotion , Adept SmartServo, Adept sMI6 , Adept sSigh t, Adept Viper s6 5 0 , Adept Viper s8 5 0 , Adept Viper s1 3 0 0 , Adept Viper s1 7 0 0 , AdeptCartesian , AdeptCast, AdeptForce, AdeptFTP, AdeptGE M, AdeptModu les, AdeptMotion , AdeptMotion Servo, AdeptMotion VME , AdeptNet, AdeptNFS, AdeptOn e, AdeptOn e­MV, AdeptOn e­XL, AdeptRAPID, AdeptSigh t, AdeptSix, AdeptSix 3 0 0 , AdeptSix 3 0 0 CL, AdeptSix 3 0 0 CR, AdeptSix 6 0 0 , AdeptTCP/IP, AdeptTh ree, AdeptTh ree­MV, AdeptTh ree­ XL, AdeptTwo, AdeptVision , AVI AdeptVision , AGS AdeptVision GV, AdeptVision I, AdeptVision II, Adept­ Vision VME , AdeptVision VXL, AdeptVision XGS, AdeptVision XGS II, AdeptWin dows, AdeptWin dows Con ­ troller, AdeptWin dows DDE , AdeptWin dows Offlin e E ditor, AdeptWin dows PC, AIM Comman d Server, AIM Dispen se, AIM PCB, AIM Vision Ware, A­Series, FlexFeedWare, HyperDrive, IO Blox, IO Blox 8 8 , MicroV+, Motion Blox, Motion Ware, ObjectFin der, ObjectFin der 2 0 0 0 , PackOn e, PalletWare, sAVI, S­Series, UltraOn e, V, V+ an d Vision Teach are trademarks of Adept Tech n ology, In c. An y trademarks from oth er compan ies u sed in th is pu blication are th e property of th ose respective compan ies. Created in th e Un ited States of America V+ Lan gu age User's Gu ide Page 3 Table Of Contents Introduction 9 Int roduct ion t o t he V + Language User's Guide Compat ibilit y Manual Overview V + Release Not es Relat ed Publicat ions Dangers, Warnings, Caut ions, and Not es S afet y Not at ions and Convent ions Out put Cont rol Commands H ow Can I Get H elp? Programming V+ 11 12 13 14 15 17 18 20 22 24 25 27 29 32 33 35 37 39 41 43 44 50 57 Creat ing a Program The S EE Edit or Environment s Ot her V + Programming Environment s Using t he S EE Edit or V + Program Types Format of Programs Execut ing Programs Program S t acks Flow of Program Execut ion S ubrout ines S cheduling of Program Execut ion Tasks Default Task Configurat ion The SEE Editor and Debugger 61 63 81 85 Basic S EE Edit or Operat ions S ample Edit ing S ession The Program Debugger Data Types and Operators 98 100 101 Int roduct ion S t ring Dat a Type V+ Lan gu age User's Gu ide Page 5 103 105 106 108 112 116 117 Real and Int eger Dat a Types Locat ion Dat a Types A rrays V ariable Classes Operat ors S t ring Operat or Order of Evaluat ion Program Control 118 Int roduct ion Uncondit ional Branch Inst ruct ions Program Int errupt Inst ruct ions Logical (Boolean) Expressions Condit ional Branching Inst ruct ions Looping S t ruct ures S ummary of Program Cont rol Keywords Cont rolling Programs in Mult iple CPU S yst ems Functions 120 121 123 129 130 133 137 140 141 Using Funct ions S t ring­Relat ed Funct ions Locat ion, Mot ion, and Ext ernal Encoder Funct ions Numeric V alue Funct ions Logical Funct ions S yst em Cont rol Funct ions Switches and Parameters 143 144 146 147 149 150 152 154 155 158 Int roduct ion Paramet ers S wit ches Motion Control Operations 162 Int roduct ion Locat ion V ariables Creat ing and A lt ering Locat ion V ariables Mot ion Cont rol Inst ruct ions V+ Lan gu age User's Gu ide Page 6 164 165 172 179 Tool Transformat ions S ummary of Mot ion Keywords 187 189 Input/Output Operations 196 198 201 203 204 206 210 215 219 223 227 233 234 Terminal I/O Digit al I/O Pendant I/O A nalog I/O S erial and Disk I/O Basics Disk I/O A dvanced Disk Operat ions S erial Line I/O DDCMP Communicat ion Prot ocol Kermit Communicat ion Prot ocol DeviceNet S ummary of I/O Operat ions Graphics Programming 237 Creat ing Windows Monit oring Event s Building a Menu S t ruct ure Creat ing But t ons Creat ing a S lide Bar Graphics Programming Considerat ions Communicat ing Wit h t he S yst em Windows A ddit ional Graphics Inst ruct ions Programming the MCP 239 242 244 247 249 251 253 255 257 259 260 261 267 271 272 Int roduct ion Writ ing t o t he Pendant Display Det ect ing User Input Cont rolling t he Pendant A ut o­S t art ing Programs Wit h t he MCP Programming Example: MCP Menu Programming the Adept T1/T2 Pendant V+ Lan gu age User's Gu ide Page 7 276 Int roduct ion Writ ing t o t he Pendant Display Det ect ing User Input Cont rolling t he Pendant A ut o­S t art ing Programs Wit h t he Pendant Programming Example: Pendant Menu Conveyor Tracking 278 279 280 288 292 293 297 299 300 301 302 309 311 Int roduct ion t o Conveyor Tracking Inst allat ion Calibrat ion Basic Programming Concept s Moving­Line Programming S ample Programs MultiProcessor Systems 313 Int roduct ion Requirement s for Mot ion S yst ems Inst alling Processor Boards Cust omizing Processor Workloads Using Mult iple V + S yst ems Rest rict ions Wit h Mult iprocessor S yst ems Example V+ Programs 315 316 318 319 320 325 326 328 329 333 335 337 Int roduct ion Pick and Place Menu Program Teaching Locat ions Wit h t he MCP Defining a Tool Transformat ion External Encoder Device 339 341 342 343 344 Int roduct ion Paramet ers Device S et up Reading Device Dat a Character Sets 346 V+ Lan gu age User's Gu ide Page 8 In trodu ction Introduction Introduction Compatibility Manual Overview V+ 14.0 R elease New Functionality R elated Publications Notes, Cautions, and Warnings Safety Reading and Training for System Users System Safeguards Computer­Controlled Robots Manually Controlled Robots O ther Computer­Controlled Devices Notations and Conventions Keyboard Keys Uppercase and Lowercase Letters Numeric Arguments Output Control Commands How Can I Get Help? V+ Lan gu age User's Gu ide Page 9 In trodu ction to th e V+ Lan gu age User's Gu ide Introduction to the V+ Language User's Guide V+ is a compu ter­based con trol system an d programmin g lan gu age design ed specifically for u se with Adept Tech n ology in du strial robots, vision systems, an d motion ­con trol systems. As a real­time system, con tin u ou s trajectory compu tation by V+ permits complex motion s to be execu ted qu ickly, with efficien t u se of system memory an d redu ction in overall system complexity. Th e V+ system con tin u ou sly gen erates robot­con trol comman ds an d can con ­ cu rren tly in teract with an operator, permittin g on ­lin e program gen eration an d modification . V+ provides all th e fu n ction ality of modern h igh ­level programmin g lan gu ages, in clu din g: l Callable su brou tin es l Con trol stru ctu res l Mu ltitaskin g en viron men t l Recu rsive, reen tran t program execu tion V+ Lan gu age User's Gu ide Page 1 1 Compatibility Compatibility Th is man u al is for u se with V+ version 1 4 .0 an d later. Th is man u al covers th e basic V+ sys­ tem. If you r system is equ ipped with option al AdeptVision , see th e AdeptVision Referen ce Gu ide an d th e AdeptVision User's Gu ide for details on th e vision en h an cemen ts to basic V+. V+ Lan gu age User's Gu ide Page 1 2 Man u al Overview Manual Overview Th is man u al details th e con cepts an d strategies of programmin g in V+. Material covered in clu des: l Fu n ction al overview of V+ l A description of th e data types u sed in V+ l A description of th e system parameters an d switch es l Basic programmin g of V+ systems l E ditin g an d debu ggin g V+ programs l Commu n ication with periph eral devices l Commu n ication with th e man u al con trol pen dan t l Con veyor trackin g featu re l E xample programs l Usin g tool tran sformation s l Requ iremen ts for th e system termin al l Accessin g extern al en coders Man y V+ keywords are sh own in abbreviated form in th is u ser gu ide. See th e V+ Lan gu age Referen ce Gu ide for complete details on all V+ keywords. V+ Lan gu age User's Gu ide Page 1 3 V+ Release Notes V+ R elease Notes For in formation on n ew featu res or en h an ced keywords listed by V+ software release, select a lin k below: V+ 1 4 .x Release Notes V+ 1 5 .x Release Notes V+ 1 6 .x Release Notes V+ 1 7 .x Release Notes V+ Lan gu age User's Gu ide Page 1 4 Related Pu blication s R elated Publications In addition to th is man u al, h ave th e followin g pu blication s h an dy as you set u p an d program you r Adept au tomation system. Related Pu blication s Man u al Material Covered V+ Lan gu age Referen ce Gu ide Th is man u al provides a complete description of th e keywords u sed in th e basic V+ system. V+ Operatin g System User's Gu ide Th is man u al provides a description of th e V+ operatin g system. Loadin g, storin g, an d execu t­ in g programs are covered in th is man u al. V+ Operatin g System Referen ce Gu ide Th is man u al provides description s of th e V+ oper­ atin g system comman ds (kn own as mon itor comman ds). AdeptVision User's Gu ide Th is man u al describes con cepts an d strategies for programmin g th e AdeptVision system. AdeptVision Referen ce Gu ide Th is man u al provides description s of th e key­ words available with systems th at in clu de th e option al AdeptVision system. In stru ction s for Adept Utility Programs Adept provides a series of programs for con ­ figu rin g an d calibratin g variou s featu res of you r Adept system. Th e u se of th ese u tility programs is described in th is man u al. Adept SmartCon troller User's Gu ide Th ese man u als detail th e in stallation , con ­ figu ration , an d main ten an ce of you r Adept con ­ troller. Th e con troller mu st be set u p an d con figu red before con trol programs will execu te properly. Adept MV Con troller User's Gu ide Adept SmartMotion Developer's Gu ide Th ese man u als describe th e in stallation , con ­ figu ration , an d tu n in g of an Adept motion sys­ tem. Adept SmartMotion In stallation Gu ide AdeptMotion VME Developer's Gu ide V+ Lan gu age User's Gu ide Page 1 5 Related Pu blication s Adept T1 Pen dan t User's Gu ide Adept T2 Pen dan t User’s Gu ide Th is man u al describes th e basic u se of th e T1 /T2 man u al con trol pen dan t. NOTE: Th e MCP is described in th e Adept SmartCon troller User's Gu ide or Adept MV Con troller User's Gu ide. V+ Lan gu age User's Gu ide Page 1 6 Dan gers, Warn in gs, Cau tion s, an d Notes Dangers, Warnings, Cautions, and Notes Th ere are six levels of special alert n otation th at may be u sed in th is man u al. In descen din g order of importan ce, th ey are: DANGER: Th is in dicates an immin en tly h azardou s electrical situ ation wh ich , if n ot avoided, will resu lt in death or seriou s in ju ry. DANGER: Th is in dicates an immin en tly h azardou s situ ation wh ich , if n ot avoided, will resu lt in death or seriou s in ju ry. W ARNI NG: Th is in dicates a poten tially h azardou s electrical situ ation wh ich , if n ot avoided, cou ld resu lt in seriou s in ju ry or major damage to th e equ ipmen t. W ARNI NG: Th is in dicates a poten tially h azardou s situ ation wh ich , if n ot avoided, cou ld resu lt in seriou s in ju ry or major damage to th e equ ip­ men t. CAUTI ON: Th is in dicates a situ ation wh ich , if n ot avoided, cou ld resu lt in min or in ju ry or damage to th e equ ipmen t. NOTE: Th is provides su pplemen tary in formation , emph asizes a poin t or procedu re, or gives a tip for easier operation . V+ Lan gu age User's Gu ide Page 1 7 Safety Safety Th e followin g section s discu ss th e safety measu res you mu st take wh ile operatin g an Adept robot. Reading and T raining for System Users Adept robot systems in clu de compu ter­con trolled mech an isms th at are capable of movin g at h igh speeds an d exertin g con siderable force. Like all robot systems an d in du strial equ ipmen t, th ey mu st be treated with respect by th e system u ser. Impacts an d Trappin g Poin ts Adept recommen ds th at you read th e American Nation al Stan dard for In du strial Robot Systems­Safety Requ iremen ts, pu blish ed by th e Robotic In du stries Association in con ju n ction with th e American Nation al Stan dards In stitu te. Th e pu blication , ANSI/RIA R1 5 .0 6 ­1 9 8 6 , con tain s gu idelin es for robot system in stallation , safegu ardin g, main ten an ce, testin g, startu p, an d operator train in g. Th e docu men t is available from th e American Nation al Stan d­ ards In stitu te, 1 4 3 0 Broadway, New York, NY 1 0 0 1 8 . System Safeguards Safegu ards sh ou ld be an in tegral part of robot workcell design , in stallation , operator train in g, an d operatin g procedu res. Adept robot systems h ave variou s commu n ication featu res to aid you in con stru ctin g system safegu ards. Th ese in clu de remote emergen cy stop circu itry an d digital in pu t an d ou tpu t lin es. Computer-Controlled Robots Adept robots are compu ter con trolled, an d th e program th at is ru n n in g th e robot may cau se it to move at times or alon g path s you may n ot an ticipate. You r system sh ou ld be equ ipped with in dicator ligh ts th at tell operators wh en th e system is active. Th e con troller in terface pan el (CIP) provides th ese ligh ts. Wh en th e Wh ite HIGH POWE R en able ligh t on th e CIP is illu ­ min ated, do n ot en ter th e workcell becau se th e robot may move u n expectedly. V+ Lan gu age User's Gu ide Page 1 8 Safety High Power E n able Ligh t Manually Controlled Robots Adept robots can also be con trolled man u ally wh en th e wh ite HIGH POWE R en able ligh t on th e fron t of th e con troller is illu min ated. Wh en th is ligh t is lit, robot motion can be in itiated from th e termin al or th e man u al con trol pen dan t (see rogrammin g th e MCP on page 2 5 7 or P Programmin g th e Adept T1 Pen dan t for more in formation ). Before you en ter th e workspace, tu rn th e keyswitch to man u al mode an d take th e key with you . Th is will preven t an yon e else from in itiatin g u n expected robot motion s from th e termin al keyboard. Other Computer-Controlled Devices In addition , th ese systems can be programmed to con trol equ ipmen t or devices oth er th an th e robot. As with th e robot, th e program con trollin g th ese devices may cau se th em to oper­ ate at times n ot an ticipated by person n el. Make su re th at safegu ards are in place to preven t person n el from en terin g th e workcell. W ARNI NG: E n terin g th e robot workcell wh en th e wh ite HIGH POWE R en able ligh t is illu min ated can resu lt in severe in ju ry. Adept Tech n ology recommen ds th e u se of addition al safety featu res su ch as ligh t cu rtain s, safety gates, or safety floor mats to preven t en try to th e workcell wh ile HIGH POWE R is en a­ bled. Th ese devices may be con n ected u sin g th e robot's remote emergen cy stop circu itry (see th e Adept MV Con troller User's Gu ide or Adept SmartCon troller User's Gu ide). V+ Lan gu age User's Gu ide Page 1 9 Notation s an d Con ven tion s Notations and Conventions Th is section describes variou s n otation s u sed th rou gh ou t th is man u al an d con ven tion s observed by th e V+ system. Keyboard Keys Th e system keyboard is th e primary in pu t device for con trollin g th e V+ system. Graph ics­ based systems u se a PC­style keyboard an d h igh ­resolu tion graph ics mon itor. NOTE: Th e word termin al is u sed th rou gh ou t th is man u al to refer eith er to a compu ter termin al or to th e combin ation of a graph ics mon itor an d a PC­style keyboard. In pu t typed at th e termin al mu st gen erally be termin ated by pressin g th e En ter or Retu rn key. (Th ese keys are fu n ction ally iden tical an d are often abbreviated with th e symbol ↵.) S+F9 mean s to h old down th e S h ift key wh ile pressin g th e F9 key. Ctrl+R mean s to h old down th e Ctrl key wh ile pressin g th e R key. Th e keys in th e row across th e top of th e keyboard are referred to as fu n ction keys. Th e V+ SE E program editor an d th e V+ program debu gger u se some of th em for special fu n ction s. NOTE: Th e Delete an d Backspace keys can always be u sed to erase th e last ch aracter typed. Th e Delete option s associated with th e F1 4 key on a Wyse termin al are u sed on ly by th e SE E editor an d th e program debu gger. Uppercase and Lowercase Letters You will n otice th at a mixtu re of u ppercase (capital) an d lowercase letters is u sed th rou gh ou t th is man u al wh en V+ operation s are presen ted. V+ keywords are sh own in u ppercase letters. Parameters to keywords are sh own in lowercase. Man y V+ keywords h ave option al parameters an d/or elemen ts. Requ ired keyword elemen ts an d parameters are sh own in bold­ face type. Option al keyword elemen ts an d parameters are sh own in n ormal type. If th ere is a comma followin g an option al parameter, th e comma mu st be retain ed if th e parameter is omitted, u n less n oth in g follows. For example, th e BASE operation (comman d or in stru ction ) h as th e form BASE dx, dy, dz, rotation wh ere all of th e parameters are option al. To specify on ly a 3 0 0 ­millimeter ch an ge in th e Z direction , th e operation can be en tered in an y of th e followin g ways: BASE 0,0,300,0 BASE,,300, BASE,,300 V+ Lan gu age User's Gu ide Page 2 0 Notation s an d Con ven tion s Note th at th e commas precedin g th e n u mber 3 0 0 mu st be presen t to correctly relate th e n u mber with a Z­direction ch an ge. Numeric Arguments All n u mbers in th is man u al are decimal u n less oth erwise n oted. Bin ary n u mbers are sh own as ^B, octal n u mbers as ^, an d h exadecimal n u mbers as ^H. Several types of n u meric argu men ts can appear in comman ds an d in stru ction s. For each type of argu men t, th e valu e can gen erally be specified by a n u meric con stan t, a variable n ame, or a math ematical expression . Th ere are some restriction s on th e n u meric valu es th at are accepted by V+. Th e followin g ru les determin e h ow a valu e will be in terpreted in th e variou s situ ation s described. 1 . Distan ces are u sed to defin e location s to wh ich th e robot is to move. Th e u n it of meas­ u re for distan ces is th e millimeter, alth ou gh u n its are n ever explicitly en tered for an y valu e. Valu es en tered for distan ces can be positive or n egative.1 2 . An gles in degrees are en tered to defin e an d modify orien tation s th e robot is to assu me at n amed location s, an d to describe an gu lar position s of robot join ts. An gle valu es can be positive or n egative, with th eir magn itu des limited by 1 8 0 degrees or 3 6 0 degrees depen din g on th e u sage. 3 . Join t n u mbers are in tegers from on e u p to th e n u mber of join ts in th e robot, in clu d­ in g th e h an d if a servo­con trolled h an d is operation al. For Adept SCARA robots, join t n u mberin g starts with th e rotation abou t th e base, referred to as join t 1 . For mech ­ an isms con trolled by AdeptMotion , see th e device modu le docu men tation for join t n u mberin g. 4 . S ign al n u mbers are u sed to iden tify digital (on /off) sign als. Th ey are always con ­ sidered as in teger valu es with magn itu des in th e ran ges 1 to 8 , 3 3 to 5 1 2 , 1 0 0 1 to 1 0 1 2 , 1 0 3 2 to 1 5 1 2 , 2 0 0 1 to 2 5 1 2 , or 3 0 0 1 to 3 0 0 4 . A n egative sign al n u mber in di­ cates an off state. 5 . I n teger argu men ts can be satisfied with real valu es (th at is, valu es with in teger an d fraction al parts). Wh en an in teger is requ ired, th e valu e is rou n ded an d th e resu ltin g in teger is u sed. 6 . Argu men ts in dicated as bein g scalar variables can be satisfied with a real valu e (th at is, on e with in teger an d fraction al parts) except wh ere n oted. Scalars can ran ge from ­9 .2 2 * 1 0 18 to 9 .2 2 * 1 0 18 in valu e (displayed as ­9 .2 2 E 1 8 an d 9 .2 2 E 1 8 ).2 1See th e IPS in stru ction for a special case of specifyin g robot speed in in ch es per secon d. 2Nu m bers specifically declared to be dou ble­precision 1 .8 * 1 0 ­ 307. valu es can ran ge from ­1 .8 * 1 0 ­ 307 to V+ Lan gu age User's Gu ide Page 2 1 Ou tpu t Con trol Comman ds Output Control Commands Th e followin g special comman ds con trol ou tpu t to th e system termin al. For all th ese com­ man ds, wh ich are called con trol ch aracters, th e con trol (Ctrl) key on th e termin al is h eld down wh ile a letter key is pressed. Th e letter key can be typed with or with ou t th e S h ift key. Un like oth er V+ comman ds, con trol ch aracters do n ot n eed to be completed by pressin g th e En ter or Retu rn key. Ctrl+C Aborts some comman ds (for example, DIRE CTORY, LISTP, I/O). If an y in pu t h as been en tered at th e keyboard sin ce th e cu rren t com­ man d was in itiated, th en th e first Ctrl+C can cels th at pen din g in pu t an d th e secon d Ctrl+C aborts th e cu rren t comman d. Ctrl+C can n ot be u sed to abort program execu tion . E n ter th e ABORT or PANIC comman d at th e keyboard to stop th e robot program or press on e of th e pan ic bu tton s to tu rn off Robot Power. Ctrl+S Stops ou tpu t to th e mon itor or termin al so it can be reviewed. Th e oper­ ation produ cin g th e ou tpu t is stopped u n til ou tpu t is resu med by Ctrl+Q. Ctrl+Q Resu mes ou tpu t to th e mon itor or termin al after it h as been stopped with a Ctrl+S. Ctrl+O Su spen ds ou tpu t to th e ASCII termin al even th ou gh th e cu rren t oper­ ation con tin u es (th at is, th e ou tpu t is lost). Th is is u sefu l for disregardin g a portion of a len gth y ou tpu t. An oth er Ctrl+O will cau se th e ou tpu t to be displayed again . NOTE: Th is ou tpu t con trol comman d works on ly with th e ASCII ter­ min al. Th e Ctrl+O con dition is can celed au tomatically wh en th e cu rren t oper­ ation completes, or if th ere is an in pu t requ est from an execu tin g pro­ gram. Ctrl+W Slows ou tpu t to th e mon itor or termin al so it can be read more easily. A secon d Ctrl+W will termin ate th is mode an d restore n ormal display speed. Th e Ctrl+W con dition is can celed au tomatically wh en th e cu rren t oper­ ation completes or if th ere is an in pu t requ est from an execu tin g pro­ gram. Ctrl+Z If typed in respon se to a program prompt, termin ates program execu tion with th e message * Un expected en d of file* . Th is is sometimes u sefu l for abortin g a program. Ctrl+U Can cels th e cu rren t in pu t lin e. Usefu l if you n otice an error earlier in th e lin e or you wan t to ign ore th e cu rren t in pu t lin e for some oth er reason . V+ Lan gu age User's Gu ide Page 2 2 Ou tpu t Con trol Comman ds V+ Lan gu age User's Gu ide Page 2 3 How Can I Get Help? How Can I Get Help? For details on gettin g assistan ce with you r Adept software or h ardware, you can access th e followin g in for­ mation sou rces on th e Adept corporate website: l For Con tact in formation : ttp://www.adept.com/con tact/americas h l For Produ ct Su pport in formation : ttp://www.adept.com/su pport/service­an d­su pport/main h l For fu rth er in formation abou t Adept Tech n ology, In c.: h ttp://www.adept.com V+ Lan gu age User's Gu ide Page 2 4 Programmin g V+ Programming V+ Creating a Program Program and Variable Name Requirements The Editing W indow Editing Modes Ch an gin g E ditin g Modes The SEE Editor Environments Using Text Editors O ther Than the SEE Editor Th e SE E E ditor Win dow Other V+ Programming Environments Using the SEE Editor Entering New Lines of Code Exiting the Editor Savin g a Program V+ Program Types Executable Programs Robot Con trol Programs E xclu sive Con trol of a Robot General Programs Format of Programs Program Lines Program O rganization Program Variables Executing Programs Selecting a Program Task Program Stacks Stack Requirements Flow of Program Execution V+ Lan gu age User's Gu ide Page 2 5 Programmin g V+ RUN/HO LD Button Subroutines Argument Passing Mappin g th e Argu men t List Argu men t Passin g by Valu e or Referen ce Un defin ed Argu men ts Program Files Reentrant Programs Recu rsive Programs Asynchronous Processing Error Trapping Scheduling of Program Execution Tasks System Timing and Time Slices Specifying Tasks, Time Slices, and Priorities Task Scheduling Execution Priority Example Default Task Configuration System Task Configuration Description of System Tasks User Task Configuration V+ Lan gu age User's Gu ide Page 2 6 Creatin g a Program Creating a Program Th is section provides a brief overview of creatin g programs with th e SE E editor. or complete F details on th e SE E editor an d program debu gger, see Th e SE E E ditor an d Debu gger on page 6 1 . NOTE: See th e AdeptWin dows User's Gu ide for in stru ction s on u sin g AdeptWin dows PC. Th e editor is accessed from th e system prompt with th e comman d: SEE p r o g _ n a m e If prog_ n ame is already residen t in system memory, it is open ed for editin g. If prog_ n ame is n ot cu rren tly residen t in system memory, th e SE E editor open s an d th e bottom lin e asks: " prog_ n ame" doesn 't exist. Create it? Y/N. If you an swer Y, th e program is created, th e SE E editor cu rsor moves to th e top of th e editin g win dow, an d you can begin editin g th e program. If you an swer N, you are retu rn ed to th e sys­ tem prompt. If prog_ n ame is omitted, th e last program edited is open ed for editin g.1 Program and Variable Name Requirements Program an d variable n ames can h ave u p to 1 5 ch aracters. Names mu st begin with a letter an d can be followed by an y sequ en ce of letters, n u mbers, periods, an d u n derlin e ch aracters. Letters u sed in program n ames can be en tered in eith er lowercase or u ppercase. V+ always displays program an d variable n ames in lowercase. T he E diting Window Wh en th e SE E editor is open , it occu pies th e Mon itor win dow on th e mon itor. If th e Mon itor win dow is n ot open , click on th e adept logo in th e u pper left corn er of th e mon itor an d select Mon itor from th e displayed list. On ce th e SE E editor is open , it fu n ction s n early u n iformly regardless of th e type of Adept sys­ tem on wh ich it is u sed. For graph ics­based systems, see th e V+ Operatin g System User's Gu idean d see th e AdeptWin dows User's Gu ide for in formation on u sin g AdeptWin dows PC. E diting Modes Th e SE E editor h as th ree editin g modes: comman d, in sert, an d replace. Th e statu s lin e sh ows th e mode th e editor is cu rren tly in (see Th e SE E E ditor Win dow n page 3 0 ). o Th e editor begin s in comman d mode. In comman d mode, you do n ot en ter actu al program code bu t en ter th e special editor comman ds listed in Table 3 ­6 , " Cu rsor Movemen t in Com­ man d ode" n d Table 3 ­7 , " SE E E ditor Comman d Mode peration s." ou en ter actu al lin es M a O Y V+ Lan gu age User's Gu ide Page 2 7 Creatin g a Program of code in in sert or replace mode. In in sert mode, th e ch aracters you type are placed to th e left of th e cu rsor, an d existin g code is pu sh ed to th e righ t. In replace mode, th e ch aracters you en ter replace th e ch aracter th at is u n der th e cu rsor. Ch an gin g Editin g Modes To en ter comman d mode press th e E dit (F1 1 ) key or E sc key. To en ter in sert mode: l Press th e In sert key (th e key's LE D mu st be off) l Press th e 0 /In s key (th e Nu m Lock LE D mu st be off) l Press th e i key (th e editor mu st be in Comman d mode) To en ter replace mode: l Press th e Replace (F1 2 ) key l Press th e r key (th e editor mu st be in Comman d mode) 1Un less an execu tin g program h as failed to complete n ormally, in wh ich case th e failed pro­ gram will be open ed. V+ Lan gu age User's Gu ide Page 2 8 Th e SE E E ditor E n viron men ts The SEE Editor Environments Th e SE E editor displays on th e mon itor of older termin al­based systems, or in a " mon itor" win dow with in a PC graph ics­based system (su ch as AdeptWin dows). Th e majority of th e fu n ction s are iden tical, regardless of th e en viron men t in wh ich th e SE E editor ru n s. Note th at Adept DeskTop an d Adept ACE provide en h an ced program editors th at in clu de color­cod­ in g, syn tax h elp, an d oth er featu res th at are n ot available in th e SE E editor. For details, see th e Adept DeskTop User's Gu ide an d th e Adept ACE User's Gu ide. Using T ext E ditors Other T han the SE E E ditor Programs can be written u sin g an y editor th at creates a DOS ASCII text file. Th ese programs can th en be stored on a V+ compatible disk (see th e FORMAT comman d in th e V+ Lan gu age Referen ce Gu ide), LOADed in to system memory, an d open ed by th e SE E editor. Wh en th e program is loaded, a syn tax ch eck is made. Programs th at fail th e syn tax ch eck will be marked as n on execu table. Th ese programs can be open ed in th e SE E editor an d an y n on ­ con formin g lin es are marked with a qu estion mark. On ce th ese lin es h ave been corrected, th e program can be execu ted. In order for program files created ou tside of th e SE E editor to LOAD correctly, th e followin g requ iremen ts mu st be met: l l l l l l E ach program mu st begin with a .PROGRAM() lin e. E ach program mu st en d with an .E ND lin e (th is lin e is au tomatically added by th e SE E editor bu t mu st be explicitly added by oth er editors). E ach program lin e mu st be termin ated with a carriage­retu rn /lin e­feed (ASCII 1 3 /ASCII 1 0 ). Th e en d of th e file (n ot th e en d of each program) mu st be marked with a Con trol­Z ch aracter (ASCII 2 7 ). Lin es th at con tain on ly a lin e­feed (ASCII 1 0 ) are ign ored. Alth ou gh fon ts an d spacin g with in files are n ot sign ifican t to th e Adept system, in order to h ave th e text look th e same as it wou ld in on e of th e Adept en viron men ts, a fixed­space fon t (e.g., Cou rier) an d 8 ­space tab settin gs sh ou ld be u sed. Th e featu res of th e SE E editor win dow are sh own in th e figu re below. V+ Lan gu age User's Gu ide Page 2 9 Th e SE E E ditor E n viron men ts Th e SE E E ditor Win dow Th e S EE Editor W in dow Th e items in th e followin g n u mbered list refer to th e n u mbers in h e SE E E ditor Win dow. T 1 . On ASCII termin als, th is area sh ows th e row an d colu mn of th e cu rsor location . 2 . Th is lin e displays th e program n ame an d th e program's parameter list. Th e program n ame can n ot be edited, bu t program parameters can be added between th e paren ­ th eses (see Special E ditin g Situ ation s n page 6 9 for a description of a special case o wh ere you can n ot edit th is list). 3 . Th e typin g cu rsor. l l l In in sert mode, ch aracters en tered at th e keyboard are en tered at th e cu rsor position . E xistin g ch aracters to th e righ t of th e cu rsor are pu sh ed righ t. In replace mode, th e ch aracter u n der th e cu rsor is replaced. In comman d mode, Copy, Paste, an d similar comman ds take place at th e cu rsor location . V+ Lan gu age User's Gu ide Page 3 0 Th e SE E E ditor E n viron men ts With a graph ics­based system, clickin g with th e poin ter device sets th e typin g cu rsor at th e poin ter location . (Th e cu rsor can n ot be set lower th an th e last lin e in a program.) Also, th e scroll bars on th e mon itor win dow can be u sed to scroll th rou gh th e program. 4 . Sh ows th e n ame of th e program cu rren tly bein g edited. If th e program is open in read­on ly mode, /R is appen ded to th e n ame.1 5 . Sh ows th e program step at wh ich th e cu rsor is position ed an d th e total n u mber of lin es in th e program. 6 . Sh ows th e cu rren t editor mode. 7 . Sh ows th e n u mber of lin es in th e copy (attach ) bu ffer. Wh en ever a program lin e is Cu t or Copied, it is placed in th e copy bu ffer. Wh en lin es are pasted, th ey are removed from th e copy bu ffer an d pasted in th e reverse order in wh ich th ey were copied. Th e F9 an d F1 0 keys are u sed for copyin g an d pastin g program lin es. 8 . Th is is th e message lin e. It displays variou s messages an d prompts. 1Program s are open in read­on ly mode wh en /R is appen ded to th e SE E comman d wh en th e program is open ed or wh en a cu rren tly execu tin g program is open . V+ Lan gu age User's Gu ide Page 3 1 Oth er V+ Programmin g E n viron men ts Other V+ Programming Environments In addition to th e SE E editor, wh ich was in trodu ced in th e previou s section , th is section describes oth er programmin g en viron men ts th at can be u sed to create V+ programs. AdeptWindows Th e SE E editor displays on a " mon itor" win dow with in th e AdeptWin dows PC application pro­ gram. For details, see th e AdeptWin dows User's Gu ide. Adept ACE Th e Adept ACE Program E ditor is an on lin e, in teractive editor for V+ an d MicroV+ programs. Th e Program E ditor performs syn tax ch eckin g an d formattin g wh ile you are programmin g. It also provides debu ggin g fu n ction ality. For details on u sin g th e Adept ACE in terface, see th e Adept ACE User's Gu ide. Adept DeskT op Th e Adept DeskTop Program E ditor is an on lin e, in teractive editor for V+ an d MicroV+ pro­ grams. Th e Program E ditor performs syn tax ch eckin g an d formattin g wh ile you are pro­ grammin g. It also provides debu ggin g fu n ction ality. For details on u sin g th e Adept DeskTop in terface, see th e Adept DeskTop User's Gu ide. T ext E ditor V+ programs can be written an d modified offlin e u sin g an y text­editin g program (e.g., Note­ pad, WordPad, E macs, UltraE dit) th at creates an ASCII text file. However, n o syn tax ch eck­ in g is don e u n til th e program is loaded in to th e Adept system. For more in formation on creatin g V+ programs u sin g a text editor, see Creatin g a Program on page 2 7 an d Th e SE E E ditor E n viron men ts on page 2 9 . V+ Lan gu age User's Gu ide Page 3 2 Usin g th e SE E E ditor Using the SEE Editor Th e followin g section s give a brief overview on u sin g th e SE E editor. For more details, see Th e SE E E ditor an d Debu gger on page 6 1 . E ntering New Lines of Code On ce you h ave open ed th e editor an d moved to in sert or replace mode, you can begin en ter­ in g lin es of code. E ach complete lin e of code n eeds to be termin ated with a carriage retu rn . If a lin e of code exceeds th e mon itor lin e width , th e editor wraps th e code to th e n ext lin e an d temporarily overwrites th e n ext lin e. Do n ot en ter a carriage retu rn u n til you h ave typed th e complete lin e of code. Wh en you press th e retu rn key after completin g a lin e of code, th e SE E editor au tomatically ch ecks th e syn tax of th e lin e. Keywords are ch ecked for proper spellin g, in stru ction s are ch ecked for requ ired argu men ts, paren th eses are ch ecked for proper closin g, an d th e lin e is ch ecked to make su re th e V+ system is able to execu te th e lin e of code. (Remember, th is ch eck is solely for syn tax, n ot for program logic.) If th e program lin e fails th e syn tax ch eck, th e system places a qu estion mark (? ) at th e begin ­ n in g of th e lin e (an d u su ally displays a message in dicatin g th e problem). You do n ot h ave to correct th e lin e immediately, an d you can exit th e editor with u n corrected program lin es. You will n ot, h owever, be able to execu te th e program. E xiting the E ditor To complete an editin g session an d exit th e editor, press th e E xit (F4 ) key on a graph ics­ based system. If you r program is execu table, you are retu rn ed to th e system prompt with ou t an y fu rth er messages. If an y lin es of code in th e program h ave failed th e syn tax ch eck, th e statu s lin e displays th e message: *Program not executable* Press RETURN to continue. Pressin g ↵ retu rn s you to th e system prompt. You may also get th e message: *Control structure error at step xx* Th is in dicates th at a con trol stru ctu re (described in Program Con trol on page 1 1 8 ) h as n ot been properly en ded. Pressin g ↵retu rn s you to th e system prompt, bu t th e program you h ave been editin g will n ot be execu table. You can n ot exit th e editor with lin es in th e copy bu ffer. To discard u n wan ted lin es: V+ Lan gu age User's Gu ide Page 3 3 Usin g th e SE E E ditor 1 . Pu t th e editor in comman d mode. 2 . E n ter th e n u mber of lin es to discard an d press E sc an d th en k. S avin g a Program Wh en you exit th e SE E editor, ch an ges to th e program you were workin g on are saved on ly in system memory. To perman en tly save a program to disk, u se on e of th e STORE comman ds described in th e V+Operatin g System Referen ce Gu ide. V+ Lan gu age User's Gu ide Page 3 4 V+ Program Types V+ Program Types Th ere are two types of V+ programs: l E xecu table Programs l Comman d Programs E xecu table programs are described in th is section . Comman d programs are similar to MS­ DOS batch programs or UNIX scripts, an d th ey are described in th e V+Operatin g System User's Gu ide. E xecutable Programs Th ere are two classes of execu table programs: robot con trol programs an d gen eral pro­ grams. Robot Con trol Programs A robot con trol program is a V+ program th at directly con trols a robot or motion device. It can con tain an y of th e V+ program in stru ction s. Robot con trol programs are u su ally execu ted by program task #0 , bu t th ey can be execu ted by an y of th e program tasks available in th e V+ system. Task #0 au tomatically attach es th e robot wh en program execu tion begin s. If a robot con trol program is execu ted by a task oth er th an #0 , h owever, th e program mu st explicitly attach th e robot (program tasks are described in detail later in th is ch apter). For n ormal execu tion of a robot con trol program, th e system switch DRY.RUN mu st be dis­ abled an d th e robot mu st be attach ed by th e robot con trol program. Th en , an y robot­related error will stop execu tion of th e program (u n less an error­recovery program h as been estab­ lish ed [see" RE ACTE " in th e V+Lan gu age Referen ce Gu ide]).1 Exclu sive Con trol of a Robot l l l l Wh en ever a robot is attach ed by an active task, n o oth er task can attach th at robot or execu te in stru ction s th at affect it, except for th e E ACTI an d BRAKE in stru ction s. R Wh en th e robot con trol task stops execu tion for an y reason , th e robot is detach ed u n til th e task resu mes, at wh ich time th e task au tomatically attempts to reattach th e robot. If an oth er task h as attach ed th e robot in th e mean time, th e first task can n ot be resu med. Task #0 always attempts to attach robot #1 wh en program execu tion begin s. No oth er tasks can su ccessfu lly attach an y robot u n less an explicit ATTACH in stru ction is execu ted. Sin ce task #0 attempts to attach robot #1 , th at task can n ot be execu ted after an oth er task h as attach ed th at robot. If you wan t an oth er task to con trol th e robot an d you wan t to execu te task #0 , you mu st follow th is sequ en ce of even ts: V+ Lan gu age User's Gu ide Page 3 5 V+ Program Types l Start task #0 . l Have task #0 DE TACH th e robot. l l Start th e task th at will con trol th e robot. (Th e program execu tin g as task #0 can start u p an oth er task.) Have th at task ATTACH th e robot. See Creatin g Win dows for more in formation on th e ATTACH an d DE TACH in stru ction s. l Note th at robots are attach ed even in DRY.RUN mode. In th is case, motion comman ds issu ed by th e task are ign ored, an d n o oth er task can access th e robot. General Programs A gen eral program is an y program th at does n ot con trol a robot. With a robot system, th ere can be on e or more programs execu tin g con cu rren tly with th e robot con trol program. For example, an addition al program migh t mon itor an d con trol extern al processes via th e exter­ n al digital sign al lin es an d an alog sign al lin es. Gen eral programs can also commu n icate with th e robot con trol program (an d each oth er) th rou gh global variables an d software sign als. (Gen eral programs can also h ave a direct effect on th e robot motion with th e BRAKE in stru ction , alth ou gh th at practice is n ot rec­ ommen ded.) With th e exception of th e BRAKE in stru ction , a gen eral program can n ot execu te an y in stru c­ tion th at affects th e robot motion . Also, th e BASE or TOOL settin gs can n ot be ch an ged by gen ­ eral programs. E xcept for th e robot, gen eral­pu rpose con trol programs can access all th e oth er featu res of th e Adept system, in clu din g th e AdeptVision option (if it is presen t in th e system), th e (in ter­ n al an d extern al) digital sign al lin es, th e USE R serial lin es, th e system termin al, th e disk drives, an d th e man u al con trol pen dan t. Note th at except for th e exclu sion of certain in stru ction s, gen eral­pu rpose con trol programs are ju st like robot con trol programs. Th u s, th e term program is u sed in th e remain der of th is ch apter wh en th e material applies to eith er type of con trol program. 1If th e system is in DRY.RUN mode wh ile a robot con trol program is execu tin g, robot motion in stru ction s are ign ored. Also, if th e robot is detach ed from th e program, robot­related errors do n ot affect program execu tion . V+ Lan gu age User's Gu ide Page 3 6 Format of Programs Format of Programs Th is section presen ts th e format th at V+ programs mu st follow. Th e format of th e in dividu al lin es is described, followed by th e overall organ ization of programs. Th is in formation applies to all programs regardless of th eir type or in ten ded u se. Program Lines E ach lin e or step of a program is in terpreted by th e V+ system as a program in stru ction . Th e gen eral format of a V+ program step is: step_number step_label operation ;Comment E ach item is option al an d is described in detail below. Step Nu mber E ach step with in a program is au tomatically assign ed a step n u mber. Steps are n u mbered con secu tively, an d th e n u mbers are au tomatically adju sted wh en ever steps are in serted or deleted. Alth ou gh you will n ever en ter step n u mbers in to programs, you will see th em displayed by th e V+ system in several situ ation s. Step Label Becau se step n u mbers ch an ge as a program evolves, th ey are n ot u sefu l for iden tifyin g steps for program­con trolled bran ch in g. Th erefore, pro­ gram steps can con tain a step label. A step label is a programmer­spec­ ified in teger (0 to 6 5 5 3 5 ) th at is placed at th e start of a program lin e to be referen ced elsewh ere in th e program (u sed with GOTO statemen ts). Operation Th e operation portion of each step mu st be a valid V+ lan gu age keyword an d may con tain parameters an d addition al keywords. Th e V+ Lan gu age Referen ce Gu ide gives detailed description s of all th e keywords rec­ ogn ized by V+. Oth er in stru ction s may be recogn ized if you r system in clu des option al featu res su ch as AdeptVision . Commen t Th e semicolon ch aracter is u sed to in dicate th at th e remain der of a pro­ gram lin e is commen t in formation to be ign ored by V+. Wh en all th e elemen ts of a program step are omitted, a blan k lin e resu lts. Blan k program lin es are acceptable in V+ programs. Blan k lin es are often u sefu l to space ou t program steps to make th em easier to read. Wh en on ly th e commen t elemen t of a program step is presen t, th e step is called a commen t lin e. Commen ts are u sefu l to describe wh at th e program does an d h ow it in teracts with oth er programs. Use commen ts to describe an d explain th e in ten t of th e section s of th e programs. Su ch in tern al docu men tation will make it easier to modify an d debu g pro­ grams. V+ Lan gu age User's Gu ide Page 3 7 Format of Programs Th e example programs in th is man u al, an d th e u tility programs provided by Adept with you r system, provide examples of programmin g format an d style. Notice th at Adept programs con ­ tain n u merou s commen ts an d blan k lin es. Wh en program lin es are en tered, extra spaces can be en tered between an y elemen ts in th e lin e. Th e V+ editors add or delete spaces in program lin es to make th em con form with th e stan dard spacin g. Th e editors also au tomatically format th e lin es to u ppercase for all key­ words an d lowercase for all u ser­defin ed n ames. Wh en you complete a program lin e (by en terin g a carriage retu rn , movin g off a lin e, or exitin g th e editor), th e editor ch ecks th e syn tax of th e lin e. If th e lin e can n ot be execu ted, an error message is ou tpu t. Certain con trol stru ctu re errors are n ot ch ecked u n til you exit from th e editor (or ch an ge to editin g a differen t program). If an error is detected at th at time, an error message is displayed an d th e program is marked as n ot execu table. (E rror ch eckin g stops at th at poin t in th e pro­ gram. Th u s, on ly on e con trol stru ctu re error at a time can be detected.) Program Organization Th e first step of every V+ program mu st be a .PROGRAM in stru ction . Th is in stru ction n ames th e program, defin es an y argu men ts it receives or retu rn s, an d h as th e format: .PROGRAM program_name(parameter_list) ;Comment Th e program n ame is requ ired, bu t th e parameter list an d commen t are option al. After th e .PROGRAM lin e, th ere are on ly two restriction s on th e order of oth er in stru ction s in a program. l l AUTO, LOCAL, or GLOBAL in stru ction s mu st precede an y execu table program in stru c­ tion s. On ly commen t lin es, blan k lin es, an d oth er AUTO, LOCAL, or GLOBAL in stru c­ tion s are permitted between th e .PROGRAM step an d an AUTO, LOCAL, or GLOBAL in stru ction . Th e en d of a program is marked by a lin e begin n in g with .E ND. Th e V+ editors au to­ matically add (bu t do n ot display) th is lin e at th e en d of a program.1 Program Variables V+ u ses th ree classes of variables: GLOBAL, LOCAL, an d AUTO. Th ese are described in detail in Variable lasses. C 1Th e .PROGRAM an d .E ND lin es are au tom atically en tered by th e V+ editors. If you u se an oth er text editor for tran sfer to a V+ system, you MUST en ter th ese two lin es. In gen eral, an y editor th at produ ces u n formatted ASCII files can be u sed for programmin g. See th e FOR­ MAT comman d for details on creatin g floppy disks compatible with oth er operatin g systems. V+ Lan gu age User's Gu ide Page 3 8 E xecu tin g Programs Executing Programs Wh en V+ is actively followin g th e in stru ction s in a program, it is said to be execu tin g th at pro­ gram. Th e stan dard V+ system provides for simu ltan eou s execu tion of u p to seven differen t pro­ grams­for example, a robot con trol program an d u p to six addition al programs. Th e option al V+ exten sion s software provides for simu ltan eou s execu tion of u p to 2 8 programs. E xecu tion of each program is admin istered as a separate program task by th e system. Th e way program execu tion is started depen ds u pon th e program task to be u sed an d th e type of program to be execu ted. Th e followin g section s describe program execu tion in detail. Selecting a Program T ask Task # 0 h as th e h igh est priority in th e (stan dard) task con figu ration . Th u s, th is task is n or­ mally u sed for th e primary application program. For example, with a robot system, task #0 is n ormally u sed to execu te th e robot con trol program. NOTE:As a con ven ien ce, wh en execu tion of task #0 begin s, th e task always au to­ matically selects robot #1 an d attach es th e robot. E xecu tion of task #0 is n ormally started by u sin g th e E XE CUTE mon itor comman d, or by startin g th e program from th e man u al con trol pen dan t. Wh ile task #0 is execu tin g, th e V+ mon itor does n ot display its n ormal dot prompt. An aster­ isk (* ) prompt is u sed in stead to remin d th e u ser th at task #0 is execu tin g. Th e asterisk prompt does n ot appear au tomatically, h owever. Th e prompt is displayed wh en ever th ere is in pu t to th e V+ system mon itor from th e system termin al. NOTE:E ven th ou gh th e system prompt is n ot displayed wh ile program task #0 is execu t­ in g, V+ mon itor comman ds can be en tered at an y time th at a program is n ot waitin g for in pu t from th e termin al. Th e ABORT mon itor comman d or program in stru ction stops task #0 after th e cu rren t robot motion completes. Th e CYCLE .E ND mon itor comman d or program in stru ction can be u sed to stop th e program at th e en d of its cu rren t execu tion cycle. If program execu tion stops becau se of an error, a PAUSE in stru ction , an ABORT comman d or in stru ction , or th e mon itor comman ds PROCE E D or RE TRY can be u sed to resu me execu tion (see th e + Operatin g System Referen ce Gu ide for in formation on mon itor comman ds). V Wh ile execu tion is stopped, th e DO mon itor comman d can be u sed to execu te a sin gle pro­ gram in stru ction (en tered from th e keyboard) as th ou gh it were th e n ext in stru ction in th e program th at is stopped. For debu ggin g pu rposes, th e SSTE P or XSTE P mon itor comman ds can be u sed to execu te a program on e step at a time. Also, th e TRACE featu re can be u sed to follow th e flow of pro­ gram execu tion . (Th e program debu gger can also be u sed to execu te a program on e V+ Lan gu age User's Gu ide Page 3 9 E xecu tin g Programs in stru ction at a time. See Th e Program Debu gger on page 8 5 for in formation on th e V+ pro­ gram debu gger.) E xecu tion of program tasks oth er th an #0 is gen erally th e same as for task #0 . Th e followin g poin ts h igh ligh t th e differen ces: l l l Th e task n u mber mu st be explicitly in clu ded in all th e mon itor comman ds an d program in stru ction s th at affect program execu tion , in clu din g E XE CUTE , BORT, PROCE E D, A RE TRY, SSTE P, an d XSTE P. (However, wh en th e V+ program debu gger is bein g u sed, th e task bein g accessed by th e debu gger becomes th e defau lt task for all th ese com­ man ds.) If th e program is goin g to con trol th e robot, it mu st explicitly ATTACH th e robot before execu tin g an y in stru ction s th at con trol th e robot. If task 0 is n ot execu tin g con cu rren tly, th e V+ mon itor prompt con tin u es to be a dot (.). Also, th e prompt is displayed after th e task­in itiatin g E XE CUTE comman d is proc­ essed. NOTE: If you wan t program execu tion to be delayed briefly to allow time for th e dot prompt to be ou tpu t (for example, to preven t it from occu rrin g du rin g ou tpu t from th e pro­ gram), h ave you r program execu te two WAIT in stru ction s with n o parameter. l Th e TRACE featu re does n ot apply to tasks oth er th an #0 . NOTE: To u se TRACE with a program th at is in ten ded to execu te in a task oth er th an #0 , execu te th e program as task #0 . (Th is con sideration does n ot apply wh en u sin g th e V+ program debu gger, wh ich can access an y program task.) See section Sch edu lin g of Program E xecu tion Tasks on page 5 0 for details on task sch ed­ u lin g. V+ Lan gu age User's Gu ide Page 4 0 Program Stacks Program Stacks Wh en su brou tin e calls are made, V+ u ses an in tern al storage area called a stack to save in for­ mation requ ired by th e execu tin g program. Th is in formation in clu des: l Th e n ame an d step n u mber of th e callin g program. l Data n ecessary to access su brou tin e argu men ts. l Th e valu es of an y au tomatic variables specified in th e called program. Th e V+ system allows you to explicitly allocate storage to th e stack for each program task. Th u s, th e amou n t of stack space can be tu n ed for a particu lar application to optimize th e u se of system memory. Stacks can be made arbitrarily large, limited on ly by th e amou n t of mem­ ory available on you r system. Stack Requirements Wh en a V+ program is execu ted in a given task, each program stack is allocated six kilobytes of memory. Th is valu e can be adju sted, on ce th e desired stack requ iremen ts are determin ed, by u sin g th e STACK mon itor comman d (for example, in a start­u p mon itor comman d pro­ gram). See th e + Operatin g System Referen ce Gu ide for in formation on mon itor com­ V man ds. On e meth od of determin in g th e stack requ iremen ts of a program task is simply to execu te its program. If th e program ru n s ou t of stack space, it stops with th e error message: *Too many subroutine calls* or *Not enough stack space* If th is h appen s, u se th e STACK mon itor comman d to in crease th e stack size an d th en issu e th e RE TRY mon itor comman d to con tin u e program execu tion . In th is case, you do n ot n eed to restart th e program from th e begin n in g. (Th e STATUS comman d will tell you h ow mu ch stack space a failed task requ ested.) Altern atively, you can start by settin g a large stack size before ru n n in g you r program. After th e program h as been ru n , an d all th e execu tion path s h ave been followed, u se th e STATUS mon itor comman d to look at th e stack statistics for th e program task. Th e stack MAX valu e sh ows h ow mu ch stack space you r program task n eeds in order to execu te. Th e stack size can th en be set to th e maximu m sh own , with a little extra for safety. If it is impossible to in voke all th e possible execu tion path s, th e th eoretical stack limits can be calcu lated from th e figu res provided in th e followin g table. You can calcu late th e worst­case stack size by addin g u p th e overh ead for all th e program calls th at can be active at on e time. Divide th e total by 1 0 2 4 to get th e size in kilobytes. Use th is n u mber in th e STACK mon itor comman d to set th e size. V+ Lan gu age User's Gu ide Page 4 1 Program Stacks S tack S pace Requ ired by a S u brou tin e Bytes Requ ired For Notes 20 Th e actu al su brou tin e call 32 E ach su brou tin e argu men t (plu s on e of th e followin g): 4 E ach real su brou tin e argu men t or au tomatic variable 1 8 E ach dou ble­precision real su b­ rou tin e argu men t or au tomatic variable 1 48 E ach tran sformation su brou tin e argu men t or au tomatic variable 1, 2 varies E ach precision ­poin t su brou tin e argu men t or au tomatic variable 1, 2, 3 84 E ach belt variable argu men t or au tomatic variable 1, 2 132 E ach strin g variable argu men t or au tomatic variable 1, 2 NOTES : l l l If an y su brou tin e argu men t or au tomatic variable is an array, th e size sh own mu st be mu ltiplied by th e size of th e array. (Remember th at array in dexes start at zero.) If a su brou tin e argu men t is always called by referen ce, th is valu e can be omitted for th at argu men t. Requ ires fou r bytes for each join t of th e robot (on mu ltiple robot systems, u se th e robot with th e most join ts). V+ Lan gu age User's Gu ide Page 4 2 Flow of Program E xecu tion Flow of Program Execution Program in stru ction s are n ormally execu ted sequ en tially from th e begin n in g of a program to its en d. Th is sequ en tial flow may be ch an ged wh en a GOTO or IF...GOTO in stru ction , or a con ­ trol stru ctu re, is en cou n tered. Th e CALLin stru ction cau ses an oth er program to be execu ted, bu t it does n ot ch an ge th e sequ en tial flow th rou gh th e callin g program becau se execu tion of th e callin g program resu mes wh ere it left off wh en a RE TURN in stru ction is execu ted by th e CALLed program. Th e WAIT in stru ction su spen ds execu tion of th e cu rren t program u n til a con dition is sat­ isfied. Th e WAIT.E VE NT in stru ction su spen ds execu tion of th e cu rren t program u n til a spec­ ified even t occu rs or u n til a specified time elapses. Th e PAUSE an d HALT in stru ction s both termin ate execu tion of th e cu rren t program. After a PAUSE , program execu tion can be resu med with a PROCE E D mon itor comman d (see th e + V Operatin g System Referen ce Gu ide for in formation on mon itor comman ds). E xecu tion can ­ n ot be resu med after a HALT. Th e STOP in stru ction may or may n ot termin ate program execu tion . If th ere are more pro­ gram execu tion cycles to perform, th e STOP in stru ction cau ses th e main program to be restarted at its first step (even if th e STOP in stru ction occu rs in a su brou tin e). If n o execu tion loops remain , STOP termin ates th e cu rren t program. RUN/HOLD Button E xecu tion of program task #0 can also be stopped with th e RUN/HOLD bu tton on th e man ­ u al con trol pen dan t (MCP). Wh en a program is execu tin g an d th e RUN/HOLD bu tton on th e pen dan t is pressed, program execu tion is su spen ded. If th e keyswitch on th e CIP or on a remote fron t pan el is set to man u al mode, program execu tion will resu me if th e RUN/HOLD bu tton is h eld down ­bu t execu tion will stop again wh en th e bu tton is released. If th e keyswitch on th e CIP or on a remote fron t pan el is set to au tomatic mode, program execu tion can be resu med by en terin g a PROCE E D or RE TRY mon ­ itor comman d at th e system termin al. With Category 1 or 3 systems, th ere are addition al restriction s wh en u sin g th e MCP. See th e robot in stru ction h an dbook for you r Category 1 or 3 system for details. Also see Usin g th e STE P Bu tton n page 2 6 5 . o Occasion ally, you may wan t to disable th e HOLD bu tton on th e MCP. For example, th e RE ACTE in stru ction will n ot react wh en th e MCP HOLD bu tton is pressed u n less you disable th e HOLD bu tton . You can disable th e HOLD bu tton u sin g th e KE YMODE in stru ction . See th e V+ Lan gu age Referen ce Gu ide for details on th e KE YMODE in stru ction . V+ Lan gu age User's Gu ide Page 4 3 Su brou tin es Subroutines Th ere are th ree meth ods of exch an gin g in formation between programs: l global variables l soft­sign als l program argu men t list Wh en u sin g global variables, simply u se th e same variable n ames in th e differen t programs. Un less u sed carefu lly, th is meth od can make program execu tion u n predictable an d h ard to debu g. It also makes it difficu lt to write gen eralized su brou tin es becau se th e variable n ames in th e main program an d su brou tin e mu st always be th e same. Soft­sign als are in tern al program sign als. Th ese are digital software switch es wh ose state can be read an d set by all tasks an d programs (in clu din g across CPUs in mu ltiple CPU sys­ tems). See " Soft ign als" for details. S E xch an gin g in formation th rou gh th e program argu men t list gives you better con trol over ch an ges made to variables. It also elimin ates th e requ iremen t th at th e variable n ames in th e callin g program be th e same as th e n ames in th e su brou tin e. Th e followin g section s describe exch an gin g data th rou gh th e program parameter list. Argument Passing Th ere are two importan t con sideration s wh en passin g an argu men t list from a callin g pro­ gram to a su brou tin e. Th e first is makin g su re th e callin g program passes argu men ts in th e way th e su brou tin e expects to receive th em (mappin g). Th e secon d is determin in g h ow you wan t th e su brou tin e to be able to alter th e variables (passin g by valu e or referen ce). Mappin g th e Argu men t List An argu men t list is a list of variables or valu es separated by commas. Th e argu men t list passed to a callin g program mu st match th e su brou tin e's argu men t list in n u mber of argu ­ men ts an d data type of each argu men t (see Un defin ed Argu men ts n page 4 7 ). Th e variable o n ames do n ot h ave to match . Wh en a callin g program passes an argu men t list to a su brou tin e, th e su brou tin e does n ot look at th e variable n ames in th e list bu t th e position of th e argu men ts in th e list. Th e argu ­ men t list in th e CALL statemen t is mapped item for item to th e argu men t list of th e su b­ rou tin e. It is th is mappin g featu re th at allows you to write gen eralized su brou tin es th at can be called by an y n u mber of differen t programs, regardless of th e actu al valu es or variable n ames th e callin g program u ses. Th e followin g figu re sh ows th e mappin g of an argu men t list in a CALL statemen t to th e argu ­ men t list in a su brou tin e. Th e arrows in dicate th at each item in th e list mu st match in posi­ tion an d data type bu t n ot n ecessarily in n ame. (Th e CALL statemen t argu men t list can in clu de valu es an d expression s as well as variable n ames.) V+ Lan gu age User's Gu ide Page 4 4 Su brou tin es Argu men t Mappin g Wh en th e main program reach es th e CALL in stru ction sh own at th e top of th e figu re, th e su b­ rou tin e a_ rou tin e is called an d th e argu men t list is passed as sh own . See th e description of th e CALL in stru ction in th e V+ Lan gu age Referen ce Gu ide for addition al details on passin g arrays. Argu men t Passin g by Valu e or Referen ce An importan t prin ciple to grasp in u sin g su brou tin e calls is th e way th at th e passed variables are affected. Variables can be ch an ged by a su brou tin e, an d th e ch an ged valu e can be passed back to th e callin g program. If a callin g program passes a variable to a su brou tin e, an d th e su b­ rou tin e can ch an ge th e variable an d pass th e ch an ged variable back to th e callin g program, th e variable is said to be passed by referen ce. If a callin g program passes a variable to a su b­ rou tin e bu t th e su brou tin e can n ot pass th e variable back in an altered form, th e variable is said to be passed by valu e. Variables you wan t ch an ged by a su brou tin e sh ou ld be passed by referen ce. All th e variables passed in th e CALL statemen t in Argu men t Mappin g are bein g passed by referen ce. Ch an ges made by th e su brou tin e are reflected in th e state of th e variables in th e callin g program. An y V+ Lan gu age User's Gu ide Page 4 5 Su brou tin es argu men t th at is to be ch an ged by a su brou tin e an d passed back to th e callin g rou tin e mu st be specified as a variable (n ot an expression or valu e). In addition to passin g variables wh ose valu e you wan t ch an ged, you will also pass variables th at are requ ired for th e su brou tin e to perform its task bu t wh ose valu e you do n ot wan t ch an ged after th e su brou tin e completes execu tion . Pass th ese variables by valu e. Wh en a variable is passed by valu e, a copy of th e variable, rath er th an th e actu al variable, is passed to th e su brou tin e. Th e su brou tin e can make ch an ges to th e variable, bu t th e ch an ges are n ot retu rn ed to th e callin g program (th e variable in th e callin g program h as th e same valu e it h ad wh en th e su brou tin e was called). Th e followin g figu re sh ows h ow to pass th e differen t types of variables by valu e. Real n u mbers an d in tegers are su rrou n ded by paren th eses, :NULL is appen ded to location var­ iables, an d +" " is appen ded to strin g variables. In th e followin g figu re, real_ var_ b is still bein g passed by referen ce, an d an y ch an ges made in th e su brou tin e will be reflected in th e callin g program. Th e su brou tin e can n ot ch an ge an y of th e oth er variables: it can make ch an ges on ly to th e copies of th ose variables th at h ave been passed to it. (It is con sidered poor programmin g practice for a su brou tin e to ch an ge an y argu men ts except th ose th at are bein g passed back to th e callin g rou tin e. If an in pu t argu ­ men t mu st be ch an ged, Adept su ggests you make an AUTOmatic copy of th e argu men t an d work with th e copy.) V+ Lan gu age User's Gu ide Page 4 6 Su brou tin es Call by Valu e Valu es, as well as variables, can be passed by a CALL statemen t. Th e in stru ction : CALL a_routine(loc_1, 17.5, 121, "some string") is an acceptable call to a_ rou tin e. Un defin ed Argu men ts If th e callin g program omits an argu men t, eith er by leavin g a blan k in th e argu men t list (e.g., arg_ 1 , , arg_ 3 ) or by omittin g argu men ts at th e en d of a list (e.g., arg_ 1 , arg_ 2 ), th e argu ­ men t are passed as u n defin ed. Th e su brou tin e receivin g th e argu men t list can test for th is valu e u sin g th e DE FINE D fu n ction an d take appropriate action . Program Files Sin ce lin kin g an d compilin g are n ot requ ired by V+, main programs an d su brou tin es always exist as separate programs. Th e V+ file stru ctu re allows you to keep a main program an d all th e su brou tin es it CALLs or E XE CUTE s togeth er in a sin gle file so th at wh en a main program is loaded, all th e su brou tin es it calls are also loaded. (If a program calls a su brou tin e th at is n ot residen t in system memory, th e error * Un defin ed program or variable n ame* will resu lt.) See th e description s of th e STORE _ comman ds an d th e MODULE comman d in th e V+ Oper­ atin g System User's Gu ide for details. For an example of creatin g a program file, see " Sample E ditin g Session " on page 8 5 . Reentrant Programs Th e V+ system allows th e same program to be execu ted con cu rren tly by mu ltiple program tasks. Th at is, th e program can be reen tered wh ile it is already execu tin g. Th is allows differen t tasks th at are ru n n in g con cu rren tly to u se th e same gen eral­pu rpose su brou tin e. To make a program reen tran t, you mu st observe a few gen eral gu idelin es wh en writin g th e program: l Global variables can be read bu t mu st n ot be modified. l Local variables sh ou ld n ot be u sed. l On ly au tomatic variables an d su brou tin e argu men ts can be modified. In special situ ation s, local variables can be u sed, an d global variables can be modified, bu t th en th e program mu st explicitly provide program logic to in terlock access to th ese variables. Th e TAS real­valu ed fu n ction (defin ed in Table 6 ­4 , " System Con trol Fu n ction s" ) may be h elp­ fu l in th ese situ ation s. (See th e V+ Lan gu age Referen ce Gu ide for details.) V+ Lan gu age User's Gu ide Page 4 7 Su brou tin es Recu rsive Programs Recu rsive programs are su brou tin es th at call th emselves, eith er directly or in directly. A direct call occu rs wh en a program actu ally calls itself, wh ich is u sefu l for some special pro­ grammin g situ ation s. In direct calls are more common . Th ey occu r wh en program A calls pro­ gram B, wh ich even tu ally leads to an oth er call to program A before program B retu rn s. For example, an ou tpu t rou tin e may detect an error an d call an error­h an dlin g rou tin e, wh ich in tu rn calls th e origin al ou tpu t rou tin e to report th e error. If recu rsive su brou tin e calls are u sed, th e program mu st observe th e same gu idelin es as for reen tran t programs (see Reen tran t Programs on page 4 7 ). In addition , you mu st gu aran tee th at th e recu rsive calls do n ot con tin u e in defin itely. Oth erwise, th e program task will ru n ou t of stack space. Asynchronous Processing A particu larly powerfu l featu re of V+ is th e ability to respon d to an even t (su ch as an extern al sign al or error con dition ) wh en it occu rs, with ou t th e programmer's h avin g to in clu de in stru c­ tion s to test repeatedly for th e even t. If even t h an dlin g is properly en abled, V+ will react to an even t by in vokin g a specified program ju st as if a CALL in stru ction h ad been execu ted. Su ch a program is said to be called asyn ch ron ou sly, sin ce its execu tion is n ot syn ch ron ized with th e n ormal program flow. Asyn ch ron ou s processin g is en abled by th e RE ACT, RE ACTE , an d RE ACTI program in stru c­ tion s. E ach program task can u se th ese in stru ction s to prepare for in depen den t processin g of even ts. In addition , th e option al V+ E xten sion s software u ses th e WINDOW in stru ction to en able asyn ch ron ou s processin g of win dow violation s wh en th e robot is trackin g a con veyor belt. Sometimes a reaction mu st be delayed u n til a critical program section h as completed. Also, sin ce some even ts are more importan t th an oth ers, a program sh ou ld be able to react to some even ts bu t n ot oth ers. V+ allows th e relative importan ce of a reaction to be specified by a program priority valu e from 1 to 1 2 7 . Th e h igh er th e program priority settin g, th e more importan t is th e reaction . A reaction su brou tin e is called on ly if th e main program priority is less th an th at of th e reac­ tion program priority. If th e main program priority is greater th an or equ al to th e reaction pro­ gram priority, execu tion of th e reaction su brou tin e is deferred u n til th e main program priority drops. Sin ce th e main program (for example, th e robot con trol program) n ormally ru n s at program priority zero an d th e min imu m reaction program priority is on e, an y reac­ tion can n ormally in terru pt th e main program. Th e main program priority can be raised or lowered with th e LOCK program in stru ction , an d its cu rren t valu e can be determin ed with th e PRIORITY real­valu ed fu n ction . Wh en th e main program priority is raised to a certain valu e, all reaction s of equ al or lower priority are locked ou t. Wh en a reaction su brou tin e is called, th e main program priority is au tomatically set to th e reaction program priority, th u s preven tin g an y reaction s of equ al or lower program priority V+ Lan gu age User's Gu ide Page 4 8 Su brou tin es from in terru ptin g it. Wh en a RE TURN in stru ction is execu ted in th e reaction program, th e main program priority is au tomatically reset to th e level it h ad before th e reaction su brou tin e was called. For fu rth er in formation on reaction s an d program priority, see th e followin g keywords: LOCK, PRIORITY, RE ACT, an d RE ACTI in th e + Lan gu age Referen ce Gu ide. V E rror T rapping Normally, wh en an error occu rs du rin g execu tion of a program, th e program is termin ated an d an error message is displayed on th e system termin al. However, if th e RE ACTE in stru c­ tion h as been u sed to en able an error­trappin g program, th e V+ system in vokes th at pro­ gram as a su brou tin e in stead of termin atin g th e program th at en cou n tered th e error. (E ach program task can h ave its own error trap en abled.) Before in vokin g th e error­trappin g su brou tin e, V+ locks ou t all oth er reaction s by raisin g th e main program priority to 2 5 4 (see Asyn ch ron ou s Processin g on page 4 8 ). See th e description of th e RE ACTE in stru ction in th e + Lan gu age Referen ce Gu ide for fu rth er in formation on V error trappin g. V+ Lan gu age User's Gu ide Page 4 9 Sch edu lin g of Program E xecu tion Tasks Scheduling of Program Execution Tasks Th e V+ system appears to execu te all th e program tasks at th e same time. However, th is is actu ally ach ieved by rapidly switch in g between th e tasks man y times each secon d, with each task receivin g a fraction of th e total time available. Th is is referred to as con cu rren t execu tion . Th e followin g section s describe h ow execu tion time is divided amon g th e differen t tasks. NOTE:Th e defau lt task con figu ration will work for most application s: You will n ot h ave to alter task execu tion priorities. Th e defau lt con figu ration is optimized for Adept's AIM soft­ ware. System T iming and T ime Slices Th e amou n t of time a particu lar program task receives is determin ed by two parameters: its assign men t to th e variou s time slices an d its priority with in th e time slice. A brief description of th e system timin g will h elp you to u n derstan d wh at a time slice is an d h ow on e can be selected. NOTE:Do n ot con fu se task priority (described h ere) with program priority (described in Asyn ch ron ou s Processin g). Task priority govern s th e processin g of th e variou s system tasks with in a time slice. Program priority govern s th e execu tion of programs with in a task. E ach system cycle is divided in to 1 6 time slices of on e millisecon d each . Th e time slices are n u mbered 0 th rou gh 1 5 . A sin gle occu rren ce of all 1 6 time slices is referred to as a major cycle. For a robot or motion system, each of th ese cycles correspon ds to on e ou tpu t from th e V+ trajectory gen erator to th e digital servos. Specifying T asks, T ime Slices, and Priorities Tasks 0 th rou gh 6 (0 th rou gh 2 7 with option al V+ E xten sion s software) can be u sed, an d th eir con figu ration can be tailored to su it th e n eeds of specific application s. E ach program task con figu red for u se requ ires dedicated system memory, wh ich is u n avail­ able to u ser programs. Th erefore, th e n u mber of tasks available sh ou ld be made n o larger th an n ecessary, especially if memory space for u ser programs is critical. Wh en application programs are execu ted, th eir program tasks are n ormally assign ed defau lt time slices an d priorities accordin g to th e cu rren t system con figu ration . Th ese defau lts can be overridden temporarily for an y u ser program task. Th is is don e by specifyin g th e desired time­slice an d priority parameters in th e E XE CUTE , PRIME , or XSTE P comman d u sed to in i­ tiate execu tion . Th e temporary valu es remain in effect u n til th e program task is started again , by a n ew E XE CUTE , PRIME , or XSTE P comman d. (See th e + Lan gu age Referen ce V Gu ide for details on th ese in stru ction s.) V+ Lan gu age User's Gu ide Page 5 0 Sch edu lin g of Program E xecu tion Tasks T ask Scheduling Tasks are sch edu led to ru n with a specified priority in on e or more time slices. Tasks may h ave priorities from ­1 to 6 4 , an d th e priorities may be differen t in each time slice. Th e priority mean in gs are: ­1 Do n ot ru n in th is slice even if n o oth er task is ready to ru n . 0 Do n ot ru n in th is slice u n less n o oth er task from th is slice is ready to ru n . 1 ­ 64 Ru n in th is slice accordin g to specified priority. High er priority tasks may lock ou t lower on es. Priorities are broken in to th e followin g ran ges: 1 ­ 31 Normal u ser task priorities. 32 ­ 62 Used by V+ device drivers an d system tasks. 63 Used by th e trajectory gen erator. Do n ot u se 6 3 u n less you h ave very sh ort task execu tion times. Use of th ese priorities may cau se jerks in th e robot tra­ jectories. 64 Used by th e servo. Do n ot u se 6 4 u n less you h ave very sh ort task execu tion times. Use of th ese priorities may cau se jerks in th e robot trajectories. Wh en ever th e cu rren t task becomes in active (e.g., du e to an I/O operation , a WAIT in stru c­ tion , or completion of th e task programs), V+ search es for a n ew task to ru n . Th e search begin s with th e h igh est priority task in th e cu rren t time slice an d proceeds th rou gh th at slice in order of descen din g priority. If mu ltiple programs are waitin g to ru n in th e task, th ey are ru n accordin g to th e relative program priorities. If a ru n n able task is n ot fou n d, th e n ext h igh er slice is ch ecked. All time slices are ch ecked, wrappin g arou n d from slice 1 5 to slice 0 u n til th e origin al slice is reach ed. If n o ru n n able tasks are en cou n tered, th e V+ n u ll task execu tes. Wh en ever a 1 ms in terval expires, V+ performs a similar search of th e n ext time slice. If th e n ext time slice does n ot con tain a ru n n able task, th e cu rren tly execu tin g task con tin u es. If more th an on e task in th e same time slice h ave th e same priority, th ey become part of a rou n d­robin sch edu lin g grou p. Wh en ever a member of a rou n d­robin grou p is selected by th e n ormal slice search in g, th e grou p is scan n ed to fin d th e member of th e grou p th at ran most recen tly. Th e member th at follows th e most recen t is ru n in stead of th e on e th at was orig­ in ally selected. If a task is in more th an on e rou n d­robin grou p in differen t slices, th en all su ch tasks in both slices appear to be in on e big grou p. Th is property can cau se a task to be ru n in a slice you did n ot expect. For example: Slice 1 : Task A priority 1 0 , Task B priority 1 0 V+ Lan gu age User's Gu ide Page 5 1 Sch edu lin g of Program E xecu tion Tasks Slice 5 : Task B priority 1 5 , Task C priority 1 5 All th ree tasks, A, B, an d C, are in th e same rou n d­robin grou p becau se task B appears in both . Th erefore, task C may ru n in slice 1 at priority 1 0 , or task A may ru n in slice 5 at prior­ ity 1 5 , depen din g on wh ich member of th e grou p ran most recen tly. Th e RE LE ASE program in stru ction may be u sed to bypass th e n ormal sch edu lin g process by explicitly passin g con trol to an oth er task. Th at task th en gets to ru n in th e cu rren t time slice u n til it is resch edu led by th e 1 ms clock. A task may also RE LE ASE to an yon e, wh ich mean s th at a n ormal scan is made of all oth er tasks to fin d on e th at is ready to ru n . Du rin g th is scan , members of th e origin al task's rou n d­robin grou p (if an y) are ign ored. Th erefore, RE LE ASE to an yon e can n ot be u sed to pass con trol to a differen t member of th e cu rren t grou p. AWAIT program in stru ction with n o argu men t su spen ds a task u n til th e start of th e n ext major cycle (slice 0 ). At th at time, th e task becomes ru n n able an d will execu te if selected by th e n ormal sch edu lin g process. A WAIT with an expression performs a release to an yon e if th e expression is FALSE . On systems th at in clu de th e V+ exten sion s, th e V+ task profiler can be u sed to determin e h ow th e variou s tasks are in teractin g. It provides a mean s of determin in g h ow mu ch time is bein g u sed by each task, eith er on an average basis or as a sn apsh ot of several con secu tive cycles. With in each time slice, th e task with h igh est priority can be locked ou t on ly by a servo in ter­ ru pt. Tasks with lower priority can ru n on ly if th e h igh er­priority task is in active or waitin g. A u ser task waits wh en ever an y of th e followin g occu rs: l l l Th e program issu es an in pu t or ou tpu t requ est th at cau ses a wait. Th e program execu tes a robot motion in stru ction wh ile th e robot is still movin g in respon se to a previou s motion in stru ction . Th e program execu tes a WAIT or WAIT.E VE NT program in stru ction . If a program is execu tin g con tin u ou sly with ou t performin g an y of th e above operation s, it locks ou t an y lower­priority tasks in its time slice. Th u s, programs th at execu te in a con ­ tin u ou s loop sh ou ld gen erally execu te a WAIT (or WAIT.E VE NT) in stru ction occasion ally (for example, on ce each time th rou gh th e loop). Th is sh ou ld n ot be don e, of cou rse, if timin g con ­ sideration s for th e application preclu de su ch execu tion delays. If a program poten tially h as a lot of critical processin g to perform, its task sh ou ld be in mu l­ tiple slices, an d th e task sh ou ld h ave th e h igh est priority in th ese slices. Th is will gu aran tee th e task's gettin g all th e time n eeded in th e mu ltiple slices, plu s (if n eeded) addition al u n u sed time in th e major cycle. Th e followin g figu re sh ows th e task sch edu ler algorith m. Th is flow ch art assu mes th at th e servo task is con figu red to ru n every 1 ms an d n o task issu es a RE LE ASE in stru ction . (Actu ­ ally, at th e poin t marked ru n servos?, an y system level in terru pts are processed­in motion V+ Lan gu age User's Gu ide Page 5 2 Sch edu lin g of Program E xecu tion Tasks systems th e servo task is gen erally th e most likely to in terru pt an d is th e most time con ­ su min g system task.) V+ Lan gu age User's Gu ide Page 5 3 Sch edu lin g of Program E xecu tion Tasks V+ Lan gu age User's Gu ide Page 5 4 Sch edu lin g of Program E xecu tion Tasks Task Sch edu ler E xecution Priority E xample Th e followin g example sh ows h ow th e task priority sch eme works. Th e example makes th e fol­ lowin g assu mption s: l Task 0 ru n s in all time slices at priority 2 0 l Task 1 ru n s in all time slices at priority 1 0 l Task 2 ru n s in all time slices at priority 2 0 l All system tasks are ign ored (systems tasks are described in th e n ext section ) l All system in terru pts are ign ored Th e followin g figu re sh ows th ree tasks execu tin g con cu rren tly. Note th at sin ce n o LOCK or RE ACT_ in stru ction s are issu ed, th e program priority remain s 0 for th e en tire segmen t. (See " Program In terru pt In stru ction s" for description s of th e RE ACT rou tin es, th e LOCK in stru c­ tion , an d an oth er program execu tion example.) Th e illu stration sh ows th e timelin es of execu tin g programs. A solid lin e in dicates a program is ru n n in g; a dotted lin e in dicates a program is waitin g. Th e Y axis sh ows th e program priority. Th e X axis is divided in to 1 ­millisecon d time slices. Th e sequ en ce of even ts for Priority E xample 1 is: 1 . prog_ a issu es a WAIT.E VE NT. Th is su spen ds prog_ a an d passes execu tion to th e n ext h igh est task wh ich is task 2 ru n n in g prog_ c. 2 . prog_ c ru n s u n til it issu es a RE LE ASE in stru ction . Sin ce th e RE LE ASE h as n o argu ­ men ts, execu tion is passed to th e n ext h igh est task with a program to ru n . Sin ce task 0 is waitin g on a SE T.E VE NT, th e n ext task is task 1 . 3 . Task 2 issu es a SE T.E VE NT to task 0 an d ru n s u n til th e en d of a time slice at wh ich time task 0 ru n s. Tasks 0 an d 2 h ave th e same priority so th ey swap execu tion . (If two tasks with equ al priority are ready to ru n , th e least recen tly ru n task ru n s.) 4 . prog_ a waits for a disk I/O operation to complete. Th e n ext h igh est priority task is 2 wh ich ru n s u n til th e I/O operation completes an d task 0 becomes th e least recen tly ru n task. 5 . prog_ a completes, passin g con trol to task 2 . 6 . prog_ c completes, passin g con trol to task 1 . Notice th at u n less both task 0 an d task 2 are waitin g or do n ot h ave a program to ru n , or task 0 or task 2 RE LE ASE s to task 1 , task 1 is effectively blocked from execu tion . V+ Lan gu age User's Gu ide Page 5 5 Sch edu lin g of Program E xecu tion Tasks Priority E xample 1 Th e n u mbers in th is example are referen ced in th e text in E xecu tion Priority E xample n o page 5 5 . V+ Lan gu age User's Gu ide Page 5 6 Defau lt Task Con figu ration Default Task Configuration System T ask Configuration Th e Adept V+ system h as a n u mber of in tern al tasks th at compete with application (u ser) program tasks for time with in each time slice: l l l On motion systems, th e V+ trajectory gen erator ru n s (as th e h igh est priority task) in slice # 0 an d con tin u es th rou gh as man y time slices as n ecessary to compu te th e n ext motion device set poin t. On motion systems, th e CPU ru n n in g servo code ru n s th e servo task (at in terru pt level) every 1 or 2 millisecon ds.1 Th e V+ system tasks ru n accordin g to th e priorities sh own in System Task Priorities. Description of S ystem Tasks Th e system tasks an d th eir fu n ction s are sh own in th e followin g table. Description of S ystem Tasks Task Fu n ction Trajectory Gen erator Compu te th e series of set poin ts th at make u p a robot motion Termin al/Graph ics Refresh th e termin al or graph ics mon itor display Mon itor Service u ser requ ests en tered at th e mon itor win dow (mon itor comman ds an d respon ses to system prompts) DDCMP Han dle implemen tation of DDCMP protocols for serial lin es con figu red as DDCMP lin es Kermit Han dle implemen tation of Kermit protocols for serial lin es con figu red as Kermit lin es Pen dan t Han dle man u al con trol pen dan t I/O Disk Driver Han dle requ ests for I/O to th e h ard an d floppy disk drives an d th e Compact Flash Serial I/O Service serial I/O ports Pipes Driver Allow a V+ task to service I/O requ ests like a stan dard I/O driver V+ Lan gu age User's Gu ide Page 5 7 Defau lt Task Con figu ration NFS Driver Allow access of remote files on n etwork file servers u sin g th e Network File Services protocol TCP Driver Han dle th e TCP n etwork commu n ication s pro­ tocol on E th ern et Vision Commu n ication s Commu n icate between V+ an d vision software Vision An alysis E valu ate vision comman ds Vision An alysis #2 Vision tool an alysis Servo Commu n ication s Commu n icate with th e servo in terru pt rou tin es or th e motion ­con trol h ardware Cat 3 Timer Han dle timin g an d sequ en cin g wh en robot power is en abled in systems with th e Cat 3 option en abled S ystem Task Priorities S ystem Task Time S lice 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Trajectory Gen erator 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 Termin al/ Graph ics 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 58 Mon itor 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 56 DDCMP 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42 Kermit 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52 Pen dan t 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 0 Disk Driver 0 0 0 0 0 0 0 0 0 0 0 0 0 0 39 48 V+ Lan gu age User's Gu ide Page 5 8 Defau lt Task Con figu ration Serial I/O 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 44 Pipes Driver 0 0 0 0 0 0 0 0 0 0 0 0 0 0 43 0 NF S Driver 0 0 0 0 0 0 0 0 0 0 0 0 0 0 40 40 TCP Driver 0 0 0 0 0 0 0 0 0 0 0 0 0 0 38 54 Vision Comm 14 14 14 14 14 14 14 14 14 14 14 14 14 0 0 0 Vision An alysis 12 12 12 12 12 12 12 12 12 12 12 12 12 0 0 0 Vision An alysis #2 13 13 13 13 13 13 13 13 13 13 13 13 13 0 0 0 Servo Comm 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41 0 Cat 3 Timer 0 45 0 45 0 45 0 45 0 45 0 45 0 45 0 0 User T ask Configuration Th e remain in g time is allocated to th e u ser tasks u sin g th e con troller con figu ration u tility. (See th e description of CONFIG_ C in th e In stru ction s for Adept Utility Programs for details.) For each time slice, you specify wh ich tasks may ru n in th e slice an d wh at priority each task h as in th at slice. Th e defau lt priority con figu ration is sh own in th e followin g table. Defau lt Task Prioritiesi User Task 0 S lice 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 20 20 20 20 20 20 20 20 20 10 10 10 10 0 0 0 V+ Lan gu age User's Gu ide Page 5 9 Defau lt Task Con figu ration 1 19 19 21 21 19 19 21 21 19 9 11 11 9 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 20 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 4 15 15 15 15 15 15 15 15 15 5 5 5 5 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 7 ­ 27 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 1Th e frequ en cy at wh ich th e servo tasks in terru pts th e major cycle is set with th e con troller con figu ration u tility, CONFIG_ C. V+ Lan gu age User's Gu ide Page 6 0 Th e SE E E ditor an d Debu gger The SEE Editor and Debugger Basic SEE Editor Operations Cursor Movement Deleting, Copying, and Moving Lines Text Search in g an d Replacin g Switching Programs in the Editor Th e In tern al Program List Special Editing Situations The SEE Editor in Command Mode Comman d Mode Copy Bu ffer SE E E ditor E xten ded Comman ds E dit Macros Sample Editing Session The Program Debugger Entering and Exiting the Debugger Th e DE BUG Mon itor Comman d Usin g th e Debu g Key or th e DE BUG E xten ded Comman d E xitin g th e Debu gger The Debugger Display Debugger O peration Modes Debugging Programs Position in g th e Typin g Cu rsor Debugger Key Commands Debug Monitor­Mode Keyboard Commands Using a Pointing Device W ith the Debugger Control of Program Execution Sin gle­Step E xecu tion PAUSE In stru ction s Program Breakpoin ts Program Watch poin ts V+ Lan gu age User's Gu ide Page 6 1 Basic SE E E ditor Operation s Basic SEE Editor Operations Th e SE E editor was in trodu ced in th e previou s ch apter. It is described in more detail in th is ch apter. Th e followin g n otation is u sed in th e tables in th is section : l Th e con trol key is in dicated by Ctrl+, th e altern ate key is in dicated by Alt+, an d th e Sh ift key is in dicated by S+. Wh en u sin g th e sh ift, altern ate, an d con trol keys, th ey sh ou ld be pressed at th e same time as th e followin g key. NOTE: For ASCII termin al an d AdeptWin dows based systems, u se th e sh ift key to get th e secon dary fu n ction of th e cu rsors an d keypad keys. Use th e con trol key in stead of th e sh ift in VGB­based systems. l l l <n > in dicates a n u mber is to be en tered as a comman d prefix (with ou t th e an gle brackets). For example, en ter 1 0 L to move th e cu rsor to lin e 1 0 . <ch ar> in dicates a ch aracter is to be en tered (with ou t th e an gle brackets). For exam­ ple, en ter Sa to skip to th e n ext a on th e lin e. Keys u sed on ly with graph ics­based systems are marked with an { A} . Cursor Movement Th e followin g tables list th e keys u sed for movin g arou n d th e editor in all modes. Th e cu rsor keys can be eith er th e cu rsor movemen t keys above th e trackball or th e keys on th e n u meric keypad wh en Nu m lock is n ot en gaged. Cu rsor Movemen t Keys with a VGB Keyboard Cu rsor Key W ith ou t Ctrl Key W ith Ctrl Key Up Arrow Up 1 lin e Up 1 /4 page Down Arrow Down 1 lin e Down 1 /4 page Righ t Arrow Righ t 1 ch ar­ acter Righ t 1 item Left Arrow Left 1 ch ar­ acter Left 1 item V+ Lan gu age User's Gu ide Page 6 3 Basic SE E E ditor Operation s Home Top of program Page Up Up 1 screen Page Down Down 1 screen End E n d of program Cu rsor Movemen t Keys with an AdeptW in dows Keyboard Cu rsor Key W ith ou t Ctrl Key Up Arrow Up 1 lin e Up 1 /4 page Down Arrow Down 1 lin e Down 1 /4 page Righ t Arrow Righ t 1 ch aracter Righ t 1 item Left Arrow Left 1 ch aracter Left 1 item Home Top of program Page Up Up 1 screen Page Down Down 1 screen End E n d of program W ith Ctrl Key Th e scroll bars will also move th rou gh a SE E editor program. (Th e bottom scroll bar h as an effect on ly if th e editor win dow h as been sized down .) Clickin g on th e u p/down arrows moves th e program u p or down a few lin es. Clickin g th e left/righ t arrows moves th e program left or righ t. Clickin g in a scroll bar displays th e correspon din g section of th e program (e.g., clickin g in th e middle of th e scroll bar displays th e middle section of th e program). Draggin g a scroll h an ­ dle moves th e program u p or down , or left or righ t. V+ Lan gu age User's Gu ide Page 6 4 Basic SE E E ditor Operation s Cu rsor Movemen t Keys with an AS CI I Termin al Key Fu n ction W ith ou t S h ift Key Up Arrow Up 1 lin e Down Arrow Down 1 lin e Righ t Arrow Righ t 1 ch aracter Left Arrow Left 1 ch aracter Lin e Feed Up 1 screen Home Down 1 screen Start (PF1 ) Go to start of lin e <­­ (PF2 ) Move left 1 item ­­> (PF3 ) Move righ t 1 item End (PF4 ) Go to en d of lin e Top (F1 5 ) Go to top of program Bottom (F1 6 ) Go to en d of program V+ Lan gu age User's Gu ide Page 6 5 Basic SE E E ditor Operation s Deleting, Copying, and Moving Lines Copy (F9 ) Copy th e cu rren t lin e in to th e editor's copy bu ffer (kn own as th e attach bu ffer). Paste (F1 0 ) Paste th e most recen tly copied lin e above th e cu rren t lin e. You can n ot exit SE E with lin es in th e attach bu ffer. (Ctrl+K will remove lin es from th e copy bu ffer with ou t pastin g th em in to a program.)Lin es can n ot be pasted in read­on ly mode. Paste All (S+F1 0 ) Paste th e en tire copy bu ffer above th e cu rren t lin e. Cu t (S+F9 ) Cu t th e cu rren t lin e an d place it in th e copy bu ffer. Ctrl+Delete Delete th e cu rren t program lin e an d do n ot place it in th e copy bu ffer. (Press Un do (F6 ) immediately after deletin g to restore th e lin e(s) ju st deleted.) Text S earch in g an d Replacin g Th e SE E editor can search for specific text strin gs or ch an ge a specified strin g to an oth er strin g. Th e followin g keys perform strin g search es an d replacemen ts. To search for a text strin g: 1 . Press th e Fin d (F7 ) key (or press F in comman d mode). 2 . E n ter a search strin g an d press ↵. 3 . Th e text is search ed for from th e cu rsor location to th e bottom of th e program (bu t n ot from th e top of th e program to th e cu rsor location ). 4 . To repeat th e search , press th e Repeat (↵) key (or ' in comman d mode). To fin d an d replace a lin e of text: 1 . Press th e Ch an ge (S+F7 ) key (or press C in comman d mode). 2 . E n ter a search strin g an d press ↵. 3 . E n ter th e replace strin g an d press ↵. 4 . Th e text is search ed for from th e cu rsor location to th e bottom of th e program. On ly on e search an d replace operation will take place at a time. Global search es an d replaces are n ot performed. 5 . To repeat th e ch an ge, press th e Repeat (↵) key (or ' in comman d mode). 6 . To can cel th e ch an ge, press th e Un do (F6 ) key (before closin g th e lin e). V+ Lan gu age User's Gu ide Page 6 6 Basic SE E E ditor Operation s Normally, text search es are n ot case­sen sitive. Th e E XACT editor comman d toggles th e case sen sitivity of th e search operation (see SE E E ditor E xten ded Comman ds on page 7 8 ). NOTE:Press th e space bar to abort a search . Th e latest search an d replacemen t strin gs are retain ed between edit session s. Switching Programs in the E ditor Th e followin g fu n ction keys switch from editin g on e program to editin g an oth er program. (Th e in tern al program list men tion ed below is described in th e n ext section .) Th e S EE Editor Fu n ction Key Description Key( s) Action New (F2 ) Th e editor prompts for th e n ame of th e n ew pro­ gram to edit. Th e n ew program is accessed in read­write mode u n less /R is specified after th e program n ame or th e program is cu rren tly execu tin g. Th e h ome poin ter for th e in tern al pro­ gram list is set to th e old program. Go To (F3 ) If th e cu rsor is on a lin e con tain in g a CALL in stru ction , th e program referen ced by th e CALL is open ed in th e SE E editor. If th e program is presen t on th e in tern al program list, th e pre­ viou s access mode is u sed. If th e program is n ot on th e program list, th e editor remain s in its cu r­ ren t access mode. Retrieve (S+F3 ) Th is comman d cau ses th e editor to cycle th rou gh th e in tern al program list, brin gin g th e n ext program in th e list in to th e editor. Th e access mode for th e n ew program is th e same as th e previou s time th e program was edited. Prog_ Up { S} Ctrl+Home { A} (Home key on n u meric keypad) Ch an ges to editin g a program con tain ed on th e task execu tion stack bein g accessed by th e editor. Wh en th e n ew program is open ed, its n ame is added to th e in tern al program list main ­ tain ed by th e editor.If th e execu tion stack is bein g accessed for th e first time du rin g th e edit session , th e editor accesses th e stack for th e task th at most recen tly stopped execu tin g (if V+ Lan gu age User's Gu ide Page 6 7 Basic SE E E ditor Operation s th e program debu gger is n ot in u se), or th e stack for th e task bein g debu gged. Th e last pro­ gram on th e execu tion stack is open ed for edit­ in g.If th e execu tion stack h as already been accessed, th e program open ed is th e on e th at called th e previou s program accessed from th e stack. Prog_ Down { S} Ctrl+E n d { A} Ch an ges to editin g a program con tain ed on th e task execu tion stack bein g accessed by th e editor. Wh en th e n ew program is open ed, its n ame is added to th e in tern al program list main ­ tain ed by th e editor.If th e execu tion stack is bein g accessed for th e first time du rin g th e edit session , th is comman d acts exactly like Prog_ Up { S} or S +Home { A} (see above).If th e execu tion stack h as already been accessed, th e program open ed is th e on e th at was called by th e previou s program accessed from th e stack. Th e I n tern al Program List To simplify movin g from on e program to an oth er du rin g an editin g session , th e SE E editor main tain s an in tern al list of programs. Th e program list con tain s th e followin g in formation (for u p to 2 0 programs): l Program n ame l E ditor access mode last u sed l Nu mber of th e step last accessed l Memorized cu rsor position (see th e M comman d) Th e program list is accessed with th e SE E mon itor comman d an d program in stru ction an d with editor comman ds described in th is ch apter.1 Th e editor main tain s two poin ters in to th e program list: 1 . Th e top poin ter always refers to th e program cu rren tly displayed in th e edit win dow. 2 . Th e h ome poin ter refers to th e program th at was edited most recen tly. Th e followin g ru les govern th e program list an d its poin ters. l Wh en a SE E mon itor comman d is en tered, on e of th e followin g occu rs: l If a program n ame is specified, th e n ew program n ame is added at th e top of th e program list. V+ Lan gu age User's Gu ide Page 6 8 Basic SE E E ditor Operation s l l l l l l l If n o program n ame is specified an d n o program task h as stopped execu tin g sin ce th e last edit session , th e program list is n ot ch an ged an d th e program at th e top of th e list (th e last program edited) is open ed. If n o program n ame is specified an d a program task h as stopped execu tin g sin ce th e last edit session , th at program is added to th e top of th e program list an d is displayed for editin g. Wh en a SE E program in stru ction is execu ted, a temporary program list is created for th at editin g session . Th e list in itially in clu des on ly th e cu rren t program n ame. Th e list is deleted at th e en d of th e editin g session . Wh en ever a program n ot already on th e list is edited du rin g an editin g session (for example, pressin g th e New (F2 ) or Go To (F3 ) key), th e n ew n ame is added at th e top of th e program list an d th e h ome poin ter is moved to th e en try for th e previou s pro­ gram edited. Retrieve (S+F3 ) rotates th e program list so th e top en try moves to th e bottom, an d all th e oth er en tries move u p on e position . Th e top program is th en displayed for edit­ in g, an d th e h ome poin ter is position ed at th e first en try below th e top of th e list. Th e H comman d advan ces th e h ome poin ter down th e list an d displays th e n ame of th e program at th e n ew position . Th e Alt+H comman d switch es to editin g th e program marked by th e h ome poin ter. Th at program is th en moved to th e top of th e list, an d th e h ome poin ter is moved to th e en try for th e previou s program edited. If th e h ome poin ter h as n ot been explicitly moved, Alt+H open s th e previou sly edited pro­ gram. Special E diting Situations l l You can n ot modify th e .PROGRAM argu men t list or an AUTO in stru ction wh ile th e pro­ gram is presen t on a task execu tion stack. (A program is on th e execu tion stack if it h as been execu ted in th at task sin ce th e last KILL or ZE RO in stru ction .) Th e error mes­ sage * In valid wh en program on stack* is displayed. To edit th e lin e, exit th e editor an d remove th e program from (all) th e execu tion stack(s) in wh ich it appears. (See th e STATUS mon itor comman d in th e + Operatin g System Referen ce Gu ide for in for­ V mation abou t h ow to examin e th e execu tion stacks. See th e KILL mon itor comman d in th e + Operatin g System Referen ce Gu ide for in formation abou t h ow to clear a V stack.) If you en ter a lin e of code th at is lon ger th an 8 0 ch aracters, th e portion of th e lin e lon ger th an 8 0 ch aracters is n ot displayed u n til you move th e cu rsor alon g th e lin e (or make a ch an ge to th e lin e). Th en th e editor temporarily wraps th e lin e an d over­ writes th e n ext lin e on th e screen . Th e temporarily overwritten lin e is redisplayed as soon as you move off th e lin e th at is wrappin g on top of it. V+ Lan gu age User's Gu ide Page 6 9 Basic SE E E ditor Operation s NOTE: You may occasion ally en cou n ter lin es th at are too lon g for SE E to process. (Su ch lin es can be created with an editor on an oth er compu ter, or th ey may resu lt from a lin e becomin g fu rth er in den ted becau se of n ew su rrou n din g con trol stru ctu res.) An y attempt to move th e cu rsor to su ch a lin e will resu lt in th e message * Lin e too lon g* , an d th e cu rsor will au tomatically move to th e n ext lin e. (Th e { comman d [an d oth ers] can be u sed to move th e cu rsor above a lon g lin e.) Th e best way to u se th e SE E editor to ch an ge su ch a lin e is to: 1. Move th e cu rsor to th e en d of th e lin e ju st above th e lon g lin e. 2 . Use I n sert mode to in sert two or more program lin es th at will h ave th e same effect as th e lon g lin e, plu s a blan k lin e. 3 . With th e cu rsor at th e blan k lin e, issu e on e comman d to delete th e blan k lin e an d th e lon g lin e (for example, S +Delete in Comman d mode). l Wh en ever th e cu rsor is moved off a program lin e (an d wh en certain comman ds are in voked), th e editor closes th e cu rren t lin e. As part of th at process, th e lin e (an d th ose followin g it) are displayed in stan dard V+ format (for example, abbreviation expan sion , letter case, spacin g, an d lin e in den ts). Wh en a lon g lin e is closed, th e en d of th e lin e is erased from th e screen an d th e n ext lin e is au tomatically redrawn . Un do (F6 ) will n ot u n do ch an ges to a closed lin e. Un til a lin e is closed, its effect on th e in den tin g of su bsequ en t lin es is n ot con sidered. Th u s, for example, Redraw (S+F6 ) ign ores an u n closed lin e wh en redrawin g th e dis­ play. l l In some cases, closin g a lin e will cau se its len gth to be in creased becau se of abbre­ viation expan sion an d lin e in den ts. If th e expan ded lin e is lon ger th at th e maximu m lin e len gth allowed, an error message is displayed an d you can n ot move off of th e lon g lin e. You mu st th en sh orten th e lin e, break it in to two or more pieces, or press Un do (F6 ) to restore th e previou s version of th e lin e. Syn tax is also ch ecked wh en a lin e is closin g. If an error is detected, th e editor n or­ mally marks th e lin e as a bad lin e by placin g a ? in colu mn 1 . Programs con tain in g bad lin es can n ot be execu ted. Th u s, you mu st elimin ate all th e bad lin es in a program before you can execu te it. (You can u se th e editor's strin g search featu re to search th rou gh a program for qu estion marks in dicatin g bad lin es.) NOTE:Th e editor provides a comman d (AUTO.BAD, see SE E E ditor E xten ded Comman ds for more in formation ) th at can be u sed to tell th e editor you wan t to be forced to correct bad lin es as soon as th ey are detected. V+ Lan gu age User's Gu ide Page 7 0 Basic SE E E ditor Operation s T he SE E E ditor in Command Mode In addition to th e key lists in th e precedin g tables, th e key strokes listed in th e followin g table moves th e cu rsor wh en th e editor is in comman d mode. Cu rsor Movemen t in Comman d Mode Key Action B Bu mp win ­ dow down a few lin es E sc B Ctrl+B Go to bot­ tom of program T Bu mp win ­ dow u p a few lin es E sc T Ctrl+T Go to top of pro­ gram [ Up a lin e Down a lin e Alt+[ (graph ics­based system){ Up a few lin es Alt+] (graph ics­based system) } Down a few lin es ( Up to top of win dow ) Down to bottom of win dow <n >L Move to lin e <n > V+ Lan gu age User's Gu ide Page 7 1 Basic SE E E ditor Operation s Space Righ t on e ch aracter E sc Space Tab Righ t to n ext item Back Space Left on e ch aracter E sc Back Space E sc Tab Left to previou s item Retu rn Go to start of n ext lin e E sc Retu rn Close lin e an d go to colu mn 1 , (comma) Go to begin n in g of lin e . (period) Go to en d of lin e <n >J Ju mp to colu mn <n > S<ch ar> Skip to ch aracter <ch ar> ; Skip to semicolon Th e followin g table lists th e action s th at keystrokes perform wh en th e editor is in Comman d mode. Th e ch aracters in th e colu mn labeled Ch ar. Codes are defin ed as follows: M Th e comman d ch an ges edit mode from Comman d mode to eith er In sert mode or Replace mode as in dicated in th e table. V+ Lan gu age User's Gu ide Page 7 2 Basic SE E E ditor Operation s (M) Th e comman d ch an ges th e mode as in dicated on ly u n til th e n ext ch ar­ acter is typed, an d th en th e editor retu rn s to Comman d mode. R Th e comman d can be execu ted wh en th e program is bein g viewed in read-on ly mode. S EE Editor Comman d Mode Operation s Keystroke( s) Fu n ction Ch ar. Codes Editin g a Lin e of Text D Delete a ch aracter I Start ch ar­ acter In sert mode M E sc I Break lin e an d en ter In sert mode M R Start ch ar­ acter Replace mode M E sc Retu rn to Comman d mode W Delete u p to th e n ext item E sc W Delete item an d start In sert mode M V+ Lan gu age User's Gu ide Page 7 3 Basic SE E E ditor Operation s K<ch ar> Delete (kill) u p to ch aracter <ch ar> / Replace a sin gle ch ar­ acter (M) \ In sert a sin ­ gle ch ar­ acter (M) Ctrl+L Con vert to lowercase to en d of lin e Ctrl+U Con vert to u ppercase to en d of lin e E sc Ctrl+B Con vert tabs to blan ks (spaces) E sc Ctrl+T Con vert spaces to tabs Deletin g/Copyin g/Movin g Lin es E sc D Ctrl+D Delete a lin e ­E sc D ­Ctrl+D Un delete last lin e deleted A Copy lin e to attach bu ffer R V+ Lan gu age User's Gu ide Page 7 4 Basic SE E E ditor Operation s ­A Copy lin e from attach bu ffer E sc A Ctrl+A Move lin e to attach bu ffer ­E sc A ­Ctrl+A Move lin e from attach bu ffer E Du mp attach bu ffer to program E sc K Ctrl+K Delete (kill) lin e in attach bu ffer R Text S earch in g an d Replacemen t F Fin d a strin g in th e pro­ gram R C Su bstitu te a strin g in th e pro­ gram ' Repeat last Fin d or Ch an ge R 0' Display strin g bein g R V+ Lan gu age User's Gu ide Page 7 5 Basic SE E E ditor Operation s search ed for Program Operation s N Ch an ge to editin g n ew pro­ gram R H Rotate h ome list an d sh ow top n ame R E sc H Ch an ge to top pro­ gram on h ome list R Ctrl+R Ch an ge to editin g pro­ gram CALLed on th e cu r­ ren t lin e R E sc Ctrl+R Ch an ge to n ext pro­ gram on h ome list R E sc S Ch an ge to previou s program on stack R ­E sc S Ch an ge to n ext pro­ gram on stack R Miscellan eou s Operation s V+ Lan gu age User's Gu ide Page 7 6 Basic SE E E ditor Operation s E sc Ctrl+C Can cel ch an ges to cu rren t lin e R E sc E E xit th e editor (or th e debu gger) R Ctrl+E E xit th e editor (or th e debu gger) R G Repeat th e last S, K, Ctrl+L, or Ctrl+U comman d (wh ich ever was last) R M Memorize cu rren t lin e an d col­ umn R ­M Retu rn to memorized position R V Refresh th e fu ll dis­ play R X In itiate exten ded comman d (see below) R XDE BUG Ch an ge to debu gger R V+ Lan gu age User's Gu ide Page 7 7 Basic SE E E ditor Operation s mon itor mode Comman d Mode Copy Bu ffer In comman d mode, a special 2 5 ­lin e copy bu ffer is main tain ed. Th is bu ffer is completely sep­ arate from th e copy bu ffer described in Deletin g, Copyin g, an d Movin g Lin es n page 6 6 , an d o works on ly wh en th e editor is in comman d mode. S +Delete { A} removes lin es from th e pro­ gram an d places th em in th e special bu ffer. Precedin g S +Delete { A} by a min u s sign (­) copies th e lin e most recen tly deleted (an d removes it from th e bu ffer). S +Delete { A} can be prefaced with a min u s sign an d a n u mber to u n delete a n u mber of lin es. Th ese keystrokes work as described on ly in Comman d mode. Th e copy bu ffer is discarded wh en you exit th e SE E editor (bu t is main tain ed as you edit differen t programs with ou t leav­ in g th e editor). S EE Editor Exten ded Comman ds E ditor exten ded comman ds are u sed for in frequ en t operation s th at do n ot warran t allocation to a dedicated keyboard key. Th e exten ded comman ds are in voked with th e X comman d (in Comman d mode), wh ich prompts for th e n ame of th e actu al comman d to be performed. Th e comman d n ame can be abbreviated to th e sh ortest len gth th at u n iqu ely iden tifies th e comman d. After th e comman d n ame (or abbreviation ) is en tered, press ↵ to in dicate th e en d of th e n ame. As in dicated below, some comman ds display a message on th e editor comman d lin e. Some of th e comman ds prompt for addition al in pu t. All of th e followin g comman ds can be u sed wh en viewin g a program in read­on ly mode. Most of th e comman ds close th e cu rren t lin e. AUTO.BAD Toggles between th e meth ods th e editor u ses to respon d to in valid lin es detected wh ile editin g. In th e first mode, su ch lin es are flagged as bad lin es with a qu estion mark in colu mn on e. E ditin g of th e program can con tin u e n ormally, bu t th e program is n ot execu table u n til all th e bad lin es are eith er cor­ rected, deleted, or made in to commen t lin es. In th e secon d mode, in valid lin es mu st be corrected, deleted, or com­ men ted ou t before th e lin e can be closed. DE BUG Switch es from n ormal program editin g to u se of th e program debu gger in its mon itor mode. (Th e debu gger is described in Th e Program Debu gger on page 8 5 .) DSIZE Sets th e size of th e debu g win dow u sed by th e program debu gger (described in Th e Debu gger Display on page 8 8 ). V+ Lan gu age User's Gu ide Page 7 8 Basic SE E E ditor Operation s E XACT Toggles th e case­sen sitivity of text search es. In th e first mode, case is ign ored wh en makin g text search es. In th e secon d mode, text search es mu st match u pper­ an d lowercase letters exactly for a search to be su ccessfu l RE ADONLY Ch an ges th e access mode for th e cu rren t program to read­on ly mode. (May be abbreviated RO.) RE ADWRITE Ch an ges th e access mode for th e cu rren t program to read­write mode. (May be abbreviated RW) SE E Switch es from debu g editor mode to n ormal (fu ll­screen ) program edit­ in g. (Also see th e E dit [F7 ] key.) TSIZE In respon se to th is comman d, you are sh own th e cu rren t size of th e dis­ play, an d asked h ow man y lin es h igh you wan t th e display to be. You mu st specify at least seven lin es. (Press ↵to retain th e cu rren t settin g.) See DSIZE above for an explan ation of h ow th e TSIZE settin g affects th e size of th e edit an d debu g win dows displayed by th e program debu gger. WHE RE Displays th e cu rren t cu rsor colu mn n u mber. (Th e cu rren t cu rsor lin e n u mber is always displayed on th e in formation lin e at th e bottom of th e edit win dow.) NOTE: Th e settin gs con trolled by th e exten ded comman ds are all retain ed between edit­ in g session s in itiated with th e SE E mon itor comman d. Wh en th e SE E program in stru ction is u sed to in itiate program editin g, all th e settin gs con ­ trolled by th e exten ded comman ds are set to th e in itial settin gs described below. Settin gs ch an ged du rin g th e edit session are n ot retain ed after th e editor is exited. Edit Macros E dit macros allow you to perform th e same sequ en ce of editor comman ds or en ter th e same sequ en ce of text ch aracters several times du rin g an editin g session . Two edit macros can be defin ed at th e same time. E ith er macro can be in voked from an y poin t in th e defin ition of th e oth er macro, except th at su ch lin kin g is n ot permitted to be recu rsive. (Th at is, a macro can n ot call itself, an d a called macro can n ot call th e oth er macro.) Th e followin g table sh ows th e keys u sed to defin e an d apply th e macros. All th ese comman ds can be u sed wh en viewin g a program in read­on ly mode bu t can n ot perform an y action s dis­ allowed in read­on ly mode. Press th e space bar to abort an execu tin g macro. V+ Lan gu age User's Gu ide Page 7 9 Basic SE E E ditor Operation s Fu n ction Keys Associated W ith Macros Key( s) E sc U Action Defin e th e U macro. Th e prompt Macro (Ctrl+Z en ds): is displayed on th e editor comman d lin e. Press th e keys you wish to h ave recorded in exactly th e sequ en ce th ey are to be processed to per­ form th e desired operation s. Wh en you h ave fin ish ed en terin g th e macro defin ition , en ter Ctrl+Z. NOTE:It may be easier to man u ally perform th e sequ en ce to be recorded, writin g down th e keys as you press th em. Th en you can read from you r n otes as you defin e th e equ ivalen t macro. U Process th e U macro. 0U Display th e cu rren t defin ition of th e U macro. E sc Y Defin e th e Y macro. Y Process th e Y macro. 0Y Display th e cu rren t defin ition of th e Y macro. NOTE:Macro defin ition s are retain ed between editor session s in itiated with th e SE E mon ­ itor comman d (bu t n ot between session s in itiated with th e SE E program in stru ction ). 1Th e program list is cleared wh en th e ZE RO mon itor comman d is processed. V+ Lan gu age User's Gu ide Page 8 0 Sample E ditin g Session Sample Editing Session Th e followin g steps will create a sample V+ program an d su brou tin e, give an example of parameter passin g, an d create a disk file of th e sample programs. See Programmin g Flow Ch art for a correct programmin g flow ch art. 1 . With th e con troller ru n n in g, make su re th ere are n o oth er programs in memory by en terin g th e comman d:1 ZERO 2 . Th e system asks for verification th at you wan t to delete all programs from memory. Th is deletes th e programs an d data from system memory bu t does n ot delete th e disk files. 3 . E n ter th e comman d: SEE sample 4 . Th e system advises you th at th is program does n ot exist an d asks if you wan t to create it. Respon d Y ↵. 5 . Th e SE E editor win dow sh ou ld n ow be displayed. E n ter in sert mode by pressin g th e In sert key (E dit [F1 1 ] on a Wyse termin al). 6 . E n ter th e followin g lin es exactly as sh own : AUTO TYPE CALL TYPE $ans "Welcome." get_response($ans) $ans, " is now at the keyboard." 7 . Create th e su brou tin e get_ respon se:2 a. Move th e cu rsor to th e CALL lin e an d press th e Goto (F3 ) key. b. Th e message lin e in dicates th at get_ respon se does n ot exist an d asks if you wan t to create it. Respon d Y ↵. 8 . A n ew program is open ed in th e SE E editor win dow. E n ter th e parameter for th is su b­ rou tin e by u sin g th e cu rsor keys to place th e typin g cu rsor between th e paren th eses on th e program lin e an d type $ text_ param. 9 . Move th e cu rsor off th e program lin e an d en ter th e lin es: PROMPT "May I have your name please? ", $text_param RETURN 1 0 . Review you r programs. Th e Retrieve (S+F3 ) key toggles th rou gh all th e programs you h ave edited in th e cu rren t session . 1 1 . Wh en you are satisfied you r programs are correct, exit th e SE E editor by pressin g th e E xit (F4 ) key. 1 2 . You are n ow at th e system prompt. Test you r program by en terin g th e comman d: V+ Lan gu age User's Gu ide Page 8 1 Sample E ditin g Session EXECUTE/c sample 1 3 . Th e program greets you , asks for you r n ame, an d prin ts th e respon se on th e screen . A message is th en displayed in dicatin g th at th e program is completed. 1 4 . If all works correctly, create a program library u sin g th e MODULE comman d. MODULE sampfile = sample, get_response 1 5 . Save you r programs to a disk file by en terin g th e comman ds: STOREM sampfile.v2 = sample A program library (modu le) file is created (u sin g th e defau lt path specification ) th at con ­ tain s th e two programs, sample an d get_ respon se. 1 6 . To verify th at th e programs were stored su ccessfu lly, en ter th e comman ds: ZERO LOAD sampfile.v2 EXECUTE/C sample Th e program execu tes as before. See th e V+ Operatin g System User's Gu ide for details on th e defau lt path an d option s to th e STORE comman ds. Wh en you are creatin g an d modifyin g programs, keep in min d: l l If you load a file con tain in g programs with th e same n ames as programs residen t in memory, th e residen t programs will NOT be replaced. You mu st delete (from memory) a program before you can load a program with th e same n ame. You can n ot overwrite existin g disk files. A file mu st be deleted from disk (with th e FDE ­ LE TE in stru ction ) before a file of th e same n ame can be written to th e same su b­direc­ tory. If you are makin g ch an ges to existin g files, we recommen d th e followin g procedu re: 1 . Ren ame th e existin g file for backu p: FRENAME filename.bak = filename.v2 2 . Store th e modified files: STOREM filename.v2 3 . Wh en you are satisfied with th e modified files, delete th e backu p: FDELETE filename.bak l If you h ave programs from mu ltiple disk files residen t in memory, th e modu le com­ man ds will h elp keep th e variou s files straigh t. See th e description s of MODULE , STO­ RE M, MIDRE CTORY, LOAD, MDIR an d DE LE TE M in th e + Lan gu age Referen ce Gu ide. V V+ Lan gu age User's Gu ide Page 8 2 Sample E ditin g Session Programmin g Flow Ch art 1Mem ory does n ot h ave to be cleared. However, it will make th is example simpler. V+ Lan gu age User's Gu ide Page 8 3 Sample E ditin g Session 2Th ere is n o differen ce between a su brou tin e an d a program. V+ Lan gu age User's Gu ide Page 8 4 Th e Program Debu gger The Program Debugger V+ systems in clu de a program debu gger for in teractively execu tin g an d modifyin g appli­ cation programs. With th e debu gger, a program can be execu ted on e step at a time (or in larger, u ser­con trolled segmen ts) wh ile th e program in stru ction s an d th e program ou tpu t are simu ltan eou sly displayed in two separate section s of th e mon itor win dow. NOTE:Th e program debu gger can n ot access protected programs. Th e debu gger h as an editor mode th at allows editin g of programs du rin g th e debu ggin g ses­ sion . Ch an ges made to th e program can be execu ted immediately to verify th eir cor­ rectn ess. Wh ile th e program is execu tin g, th e valu es of program variables can easily be displayed or ch an ged. Th e followin g section s describe th e u se of th e program debu gger in detail. E n terin g an d E xitin g th e Debu gger Th e Debu g Mon itor comman d Usin g th e Debu g Key or th e DE BUG E xten ded Comman d Th e Debu gger Display Debu gger Operation Modes Debu ggin g Programs Position in g th e Typin g Cu rsor Debu gger Key Comman ds Debu g Mon itor­Mode Keyboard Comman ds Usin g a Poin tin g Device With th e Debu gger Con trol of Program E xecu tion Sin gle­Step E xecu tion PAUSE In stru ction s Program Breakpoin ts Program Watch poin ts E ntering and E xiting the Debugger Th e program debu gger can be in voked in two ways: V+ Lan gu age User's Gu ide Page 8 5 Th e Program Debu gger l l From th e comman d lin e with th e DE BUG mon itor comman d (see th e + Operatin g V System Referen ce Gu ide for in formation on mon itor comman ds). From th e SE E editor with th e Debu g (S+F1 1 ) key or th e DE BUG exten ded comman d. (Th e fu n ction keys an d th e SE E editor exten ded comman ds are described in Th e SE E E ditor in Comman d Mode.) NOTE:Th e program debu gger can n ot be in voked from th e SE E editor wh en th e editor h as been in itiated with th e SE E program in stru ction . Wh en a debu ggin g session is in itiated, two aspects of th e debu ggin g session n eed to be estab­ lish ed: th e program task th at is accessed for program execu tion an d th e program th at is dis­ played in th e debu gger edit win dow. Th e meth ods for providin g th is in formation depen d on h ow you in voke th e program debu gger, as described below. Exitin g th e Debu gger Press E xit (F4 ) to exit th e program debu gger an d retu rn to th e V+ system prompt. Th is com­ man d is accepted in eith er debu g mode. In addition , in debu g editor mode (in Comman d mode) you can u se Alt+E to exit to th e V+ system prompt (or E sc an d E if you r keyboard does n ot h ave an Alt key). T he DE BUG Monitor Command Th e DE BUG mon itor comman d allows you to in voke th e debu gger from th e system prompt. S yn tax DEBUG t prog, step V+ Lan gu age User's Gu ide Page 8 6 Th e Program Debu gger Parameter Description s t In itiates debu ggin g in task n u mber t. If th e task n u mber is n ot specified, th e task n u mber is determin ed as follows: If an y execu tion task h as termin ated execu tion sin ce th e start of th e last debu ggin g session , th at task is assu med. If n o task h as termin ated sin ce th e previou s debu ggin g session , th e pre­ viou s task is accessed again . If n eith er of th e above situ ation s apply, th e main con trol task (n u mber 0 ) is accessed. (Comman ds affectin g oth er tasks can still be en tered, bu t th eir task n u mber mu st be specified explicitly.) prog Th e n amed program is displayed in th e debu gger edit win dow in read­ on ly editor access mode. If th e n ame is omitted, th e program primed for th e task or th e last pro­ gram execu ted by th e task is selected. An error resu lts if th e n amed program does n ot exist, an d th e DE BUG requ est is aborted. Wh en th e specified program is open ed for (read­on ly) editin g, its n ame is added at th e top of th e SE E editor in tern al program list. step An option al parameter th at allows you to open a program at th e step n u mber specified. DE BUG with ou t an y parameters is u sefu l wh en : 1 . You wan t to resu me th e latest debu ggin g session . In th is case, th e edit win dow an d th e execu tion poin ter (see E xample Program Debu gger Display) are restored as th ey were wh en th e previou s debu ggin g ses­ sion was en ded. Th at is, debu ggin g can con tin u e as th ou gh it h ad n ot been in terru pted. 2 . A program h as termin ated execu tion with an error, an d you wan t to u se th e debu gger to in vestigate th e cau se. In th is case, th e program th at failed is displayed in th e edit win dow, with th e execu tion poin ter position ed at th e step after th e failed step. V+ Lan gu age User's Gu ide Page 8 7 Th e Program Debu gger Using the Debug Key or the DE BUG E xtended Command Wh ile editin g a program with th e SE E editor, ch an ge to th e program debu gger by pressin g th e Debu g (S+F1 1 ) key or by en terin g th e DE BUG exten ded comman d. Wh en th e debu gger is in voked from th e SE E editor, you are asked wh ich execu tion task you wan t to u se. Th en th e debu gger display replaces th e n ormal SE E editor display, with th e same program visible in th e edit win dow an d th e specified task selected. Wh ile u sin g th e program debu gger you may decide you wan t to ch an ge th e defau lt task n u mber. You can u se th e followin g steps to make th at ch an ge: 1 . If you are in debu g mon itor mode, press E dit (F1 1 ) to select debu g editor mode. (Th e debu g modes are described later in th is ch apter.) 2 . E n ter th e SE E editor DE BUG exten ded comman d. 3 . In respon se to th e prompt, en ter th e desired n ew task n u mber. T he Debugger Display On ce th e program debu gger h as been in voked, th e display looks similar to th at sh own in th e followin g figu re. NOTE:Th e sample sh own below represen ts th e display th at appears on graph ics­based mon itor. V+ Lan gu age User's Gu ide Page 8 8 Th e Program Debu gger E xample Program Debu gger Display Th e followin g n u mbers referes to th e precedin g figu r. 1 Th e execu tion poin ter­in dicates th e n ext step in th e program th at is execu ted. 2 Th e editor in formation lin e, Th is lin e provides th e same in for­ mation as th at provided du rin g a n ormal editin g session (see Fig­ u re 2 ­1 on page 3 6 ). Notice th at wh ile th e debu gger is in mon itor mode, th e program is in read­on ly mode. Th e debu g win dow occu ­ pies th e screen below th is lin e. 3 Th e typin g cu rsor. In mon itor mode, th e cu rsor appears in th e debu g win dow, an d debu g an d mon itor comman ds can be en tered. Respon ses to program prompts appear h ere. Com­ man ds appear below th e debu g in formation lin e. 4 Sh ows wh ich task th e debu g session is ru n n in g in . 5 Sh ows th e debu g mode. In mon itor mode, debu g an d oth er mon ­ itor comman ds can be en tered, an d th e program can be execu ted. In editor mode, th e typin g cu rsor appears in th e editor win dow, an d th e program can be edited. V+ Lan gu age User's Gu ide Page 8 9 Th e Program Debu gger 6 Displays en tered comman ds an d th e resu lts of variou s debu g operation s. Th e > ch aracter serves as a prompt for u ser in pu t wh en you are en terin g comman ds to th e debu gger. After proc­ essin g a comman d, th e debu gger displays OK on th e comman d lin e after th e comman d. Th at ackn owledges completion of th e comman d, regardless of wh eth er or n ot th e comman d was su c­ cessfu l. For example, th e comman d lin e sh own in E xample Pro­ gram Debu gger Display in dicates th at th e debu gger h as ju st processed th e comman d XSTE P place. NOTE:Un der some circu mstan ces th e display in th e edit win dow can be overwritten by program or system ou tpu t. Press Redraw (S+F6 ) to restore th e en tire debu gger screen . Sin ce th e edit win dow can be moved to an ywh ere in th e cu rren t program (or even to an oth er program), th is poin ter may n ot be visible in th e edit win dow. Th e edit win dow will move to th e section of program con tain in g th is poin ter wh en ever program execu tion stops for an y reason . Debugger Operation Modes Th e program debu gger h as two modes of operation : l Mon itor mode In th is mode th e program in th e edit win dow is accessed in read­on ly mode, an d all key­ strokes are in terpreted as system mon itor comman ds. System an d program ou tpu t is displayed in th e debu g win dow. Wh ile in mon itor mode, th e program displayed in th e edit win dow is accessed in read­ on ly mode. As described in a later section , most of th e keyboard fu n ction keys perform th e same fu n ction s as with th e SE E editor. Th is is th e in itial mode wh en th e debu gger is in voked. See th e section Debu g Mon itor­ Mode Keyboard Comman ds for a description of h ow mon itor mode is u sed. l E ditor mode As its n ame in dicates, th is mode en ables fu ll editin g access to th e program in th e editor win dow. All th e featu res of th e SE E editor can be u sed in th is mode. NOTE:Programs th at h ave been loaded from disk files with th e read­on ly attribu te can n ot be accessed in editor read­write mode. Use th e E dit (F1 1 )an d Debu g (S+F1 1 ) keys (or Ctrl+E ) to ch an ge modes. Debugging Programs Th e basic strategy for debu ggin g a program is: V+ Lan gu age User's Gu ide Page 9 0 Th e Program Debu gger 1 . In voke th e program debu gger with th e DE BUG mon itor comman d, th e DE BUG editor exten ded comman d, or th e Debu g (S+F1 2 ) key. 2 . In itiate execu tion of th e program (u su ally with th e PRIME or XSTE P mon itor com­ man ds). (Th is step can be performed before or after th e debu gger is in itiated.) 3 . Step th rou gh th e program (execu tin g in dividu al steps, section s of th e program, or complete su brou tin es) to trace th e flow of program execu tion . (A later section of th is ch apter describes con trol of program execu tion wh ile debu ggin g.) 4 . Use th e Display (F5 )an d Teach (S+F5 ) keys to display an d redefin e th e valu es of var­ iables. 5 . Use edit mode to perform an y desired editin g operation s on th e program. 6 . Repeat steps 2 th rou gh 5 as requ ired. 7 . E xit from th e debu gger. Th e followin g section s describe th e debu gger comman ds an d oth er featu res of th e V+ sys­ tem th at aid program debu ggin g. Wh en u sin g th e debu gger, keep in min d: l l l l Some system mon itor comman ds are n ot accepted in debu g mon itor mode. (For example, th e COMMANDS comman d is n ot accepted.) In some situ ation s th e termin al cu rsor is in th e edit win dow wh en you wan t it to be in th e debu g win dow. In debu g mon itor mode, th e Redraw (S+F6 ) or Un do (F6 ) keys forces th e cu rsor to th e bottom lin e of th e debu g win dow. Ou tpu t to th e screen from th e program is gen erally directed to th e debu g win dow. However, if th e ou tpu t in clu des con trol strin gs to position th e cu rsor (for example, clear th e screen ), th e program ou tpu t may appear in th e edit win dow. Th e Redraw (S+F6 ) key restores th e n ormal debu gger display (except in th e situ ation described by th e n ext item). Wh en th e program displays a prompt for in pu t in th e debu g win dow an d execu tes a PROMPT in stru ction , everyth in g you type before pressin g ↵is received by th e program. Th u s, you can n ot issu e an y debu gger comman ds at su ch times. Positioning the T yping Cursor Th e typin g cu rsor is position ed in th e debu g win dow wh en : l l Th e program debu gger is in itiated. Task execu tion is in itiated or termin ated (in th e latter case, th e edit win dow will be moved as requ ired to in clu de th e execu tion poin ter). l Th e Redraw (S+F6 ) or Un do (F6 ) key is pressed in debu g mon itor mode. l Th e debu gger is switch ed from editor mode to mon itor mode. V+ Lan gu age User's Gu ide Page 9 1 Th e Program Debu gger Th e typin g cu rsor is position ed in th e edit win dow wh en : l An y fu n ction key operation ­oth er th an Redraw (S+F6 ) or Un do (F6 )­is performed du r­ in g debu g mon itor mode. (Note th at th is in clu des all th e keys n ormally u sed to move th e cu rsor in th e edit win dow, su ch as th e arrow keys.) l l Th e debu gger is switch ed from mon itor mode to edit mode. With graph ics­based systems, th e typin g cu rsor is position ed in th e edit win dow if you click th e poin ter device an ywh ere in th at win dow. Debugger Key Commands Cu rsor Movemen t in Comman d Mode an d SE E E ditor Comman d Mode Operation s list all th e keys in terpreted as comman ds by th e V+ SE E editor. E xcept for th e differen ces described below, all th e keys listed in th ose tables h ave exactly th e same effect with th e debu gger (in eith er of its modes) as th ey do wh en u sed with th e SE E editor (detailed earlier in th is ch ap­ ter). NOTE:Wh ile u sin g th e debu gger, th e followin g keys are particu larly u sefu l for movin g to differen t programs on th e execu tion stack for th e task bein g debu gged: Prog Up an d Prog Down { S} , an d Ctrl+Home an d Ctrl+E n d { A} . Th e followin g fu n ction keys are in terpreted differen tly by th e program debu gger an d th e SE E editor. E dit (F1 1 ) Wh en th e debu gger is in mon itor mode, th is key cau ses editor mode to be selected. Th is key h as its n ormal editor fu n ction (selection of editor Com­ man d mode) wh en in editor mode. Un do(F6 ) Wh en th e debu gger is in mon itor mode, th is key simply moves th e typin g cu rsor to th e bottom of th e debu g win dow. Teach (S+F5 ) In itiates ch an gin g th e valu e of th e variable at th e cu rsor position . NOTE:Th is comman d can n ot be u sed wh ile th e editor is in read­write access mode. You can u se th e RE ADONLY or RO exten ded comman d to select read­on ly mode (see SE E E ditor E xten ded Comman ds for details). As with Display (F5 ), th e typin g cu rsor is u sed to poin t to th e variable of in terest. Pressin g Teach (S+F5 ) cau ses th e cu rren t valu e of th e variable to be displayed in th e debu g win dow an d a prompt for a n ew valu e to be assign ed to th e variable. For real­valu ed variables, th e n ew valu e can be in pu t as a con stan t, a variable n ame, or an expression . V+ Lan gu age User's Gu ide Page 9 2 Th e Program Debu gger For location variables, th e n ew valu e can be in pu t as a location fu n ction (for example, HE RE or TRANS) or a variable n ame. Also, a compou n d tran sformation can be specified wh en accessin g a tran sformation variable. For strin g variables, th e n ew valu e can be in pu t as a strin g con stan t, variable n ame, or expression . Debug Monitor-Mode Keyboard Commands Th e V+ program debu gger allows you to in teractively execu te an d edit th e program bein g debu gged. Th e comman ds described in Debu gger Comman ds can be u sed to con trol execu tion of th e program you are debu ggin g (see Con trol of Program E xecu tion for more in formation ). Th e terms defin ed in th e followin g table are u sed in Debu gger Comman ds wh en sh owin g equ ivalen t mon itor comman ds: Defin ition of Terms Term Used Defin ition cu rren t_ program Refers to th e program displayed in th e edit win dow. cu rren t_ step Refers to th e program step at wh ich th e movable cu rsor is position ed. (Note th at even wh en th e termin al cu rsor is visible in th e debu g win ­ dow or on th e comman d lin e, th e position of th e movable cu rsor is still retain ed by th e debu gger.) debu g_ task Refers to th e task n u mber sh own on th e in formation lin e of th e debu g win dow. NOTE: All th e comman ds described below (except Ctrl+E ) requ ire debu g mon itor mode for th eir u se. Be carefu l n ot to en ter Ctrl+O or Ctrl+S wh ile u sin g th e debu gger. Th ese con trol ch ar­ acters disable ou tpu t to th e termin al u n til a secon d Ctrl+O or a Ctrl+Q is in pu t. Debu gger Comman ds Key( s) Ctrl+B Action Set a breakpoin t at th e step in dicated by th e typin g cu rsor (also see Ctrl+N below). (Th e u se of breakpoin ts is described in Program Break­ V+ Lan gu age User's Gu ide Page 9 3 Th e Program Debu gger poin ts.) Th is comman d is equ ivalen t to th e followin g system mon itor com­ man d: BPT @current_program current_step Ctrl+E Altern ate between debu g modes. Th is comman d is equ ivalen t to th e E dit (F1 2 ) an d Debu g (S+F1 2 ) fu n ction keys, depen din g on th e cu rren t debu gger mode. (Use Ctrl+E with termin als th at do n ot h ave th e equ iv­ alen t fu n ction keys. Use E sc an d th en E to exit from th e editor to th e V+ system prompt.) Ctrl+G Perform an XSTE P comman d for th e in stru ction step in dicated by th e typin g cu rsor. Th is comman d is equ ivalen t to th e followin g system mon itor com­ man d: XSTEP debug_task,,current_step Ctrl+N Can cel th e breakpoin t at th e step in dicated by th e typin g cu rsor (see Ctrl+B above). Th is comman d is equ ivalen t to th e followin g system mon itor com­ man d: BPT @current_program - current_step Ctrl+P PROCE E D execu tion of th e cu rren t task from th e cu rren t position of th e execu tion poin ter. Th is comman d is equ ivalen t to th e followin g system mon itor com­ man d: PROCEED debug_task Ctrl+X Perform an XSTE P comman d for th e cu rren t task from th e cu rren t posi­ tion of th e execu tion poin ter. Th is comman d is equ ivalen t to th e followin g system mon itor com­ man d: XSTEP debug_task Ctrl+Z Perform an SSTE P comman d for th e cu rren t task from th e cu rren t posi­ tion of th e execu tion poin ter. Th is comman d is equ ivalen t to th e followin g system mon itor com­ man d: V+ Lan gu age User's Gu ide Page 9 4 Th e Program Debu gger SSTEP debug_task Using a Pointing Device With the Debugger On graph ics­based systems, dou ble­clickin g on a variable or expression displays th e valu e of th e variable or expression . (If program execu tion h as n ot progressed to th e poin t wh ere a var­ iable h as been assign ed a valu e, dou ble clickin g on th e variable may retu rn an u n defin ed valu e message.) Control of Program E xecution Wh ile debu ggin g programs, you will wan t to pau se execu tion at variou s poin ts to examin e th e statu s of th e system (e.g., to display th e valu es of program variables). Th e followin g paragraph s describe h ow to con trol execu tion of th e program bein g debu gged. NOTE: E xcept for th e special debu gger comman ds men tion ed below, all th e followin g tech n iqu es can be u sed even wh en th e program debu gger is n ot in u se. Single-Step E xecution Th e debu gger Ctrl+X comman d provides a con ven ien t mean s for h avin g program execu tion stop after each in stru ction is processed. E ach time Ctrl+X is en tered, a V+ XSTE P comman d is processed for th e program bein g debu gged. Th e debu gger Ctrl+Z comman d is provided to allow you to step across su brou tin e calls. E ach time Ctrl+Z is en tered, an SSTE P comman d is processed for th e program bein g debu gged. Th u s, wh en th e execu tion poin ter is position ed at a CALL or CALLS in stru ction , typin g Ctrl+Z will cau se th e en tire su brou tin e to be execu ted, an d execu tion pau ses at th e step followin g th e su brou tin e call. (Ctrl+Z beh aves exactly as Ctrl+X does wh en th e cu rren t in stru ction is n ot a su brou tin e call.) NOTE: You can n ot sin gle­step in to a su brou tin e th at was loaded from a protected disk file. Th u s, you mu st u se Ctrl+Z to step across an y CALL of su ch a rou tin e. NOTE: Th e execu tion poin ter (­>) is n ot displayed wh ile th e system is execu tin g an in stru ction . Do n ot type a Ctrl+X or Ctrl+Z u n til th e execu tion poin ter reappears. PAUSE Instructions Debu g editor mode can be u sed to in sert PAUSE in stru ction s in th e program at strategic poin ts. E xecu tion pau ses wh en th ose poin ts are reach ed. After th e pau se h as occu rred, an d you are ready to h ave execu tion resu me, you can u se th e PROCE E D comman d. V+ Lan gu age User's Gu ide Page 9 5 Th e Program Debu gger Th e debu gger Ctrl+P comman d provides a con ven ien t mean s of issu in g a PROCE E D com­ man d for th e program bein g debu gged. Th e disadvan tage of u sin g PAUSE in stru ction s, h owever, is th at th ey mu st be explicitly edited in to th e program an d removed wh en debu ggin g is completed. Th e followin g section describes a more con ven ien t way to ach ieve th e same effect as is ach ieved wh en a PAUSE in stru ction is u sed.. Program Breakpoints Th e V+ BPT comman d can be u sed to attach a breakpoin t to an in stru ction . Th e BPT allows eith er or both of th e followin g respon ses to occu r wh en th e breakpoin t is en cou n tered du rin g execu tion : l l E xecu tion stops at th e flagged in stru ction (before it is execu ted). Valu es are displayed on th e system termin al, sh owin g th e cu rren t statu s of u ser­spec­ ified expression s. To set breakpoin ts at variou s poin ts in th e program, en ter th e appropriate BPT comman ds on th e debu gger comman d lin e to place th e breakpoin ts an d to specify expression s to be eval­ u ated wh en th e breakpoin ts are en cou n tered. If you do n ot n eed to h ave an expression evalu ated at a breakpoin t, you can u se th e debu gger Ctrl+B comman d to set a pau sin g breakpoin t­th at is, on e th at will cau se execu tion to stop. To u se th e Ctrl+B comman d you mu st position th e typin g cu rsor in th e edit win dow so it is on th e in stru ction of in terest. On ce th e cu rsor is position ed, you can type Ctrl+B to h ave a breakpoin t placed at th at in stru ction . NOTE:You can u se Go To (F3 ) (an d oth er editor comman ds) to ch an ge th e program in th e edit win dow. Th u s, you can move to an y program you wan t before typin g Ctrl+B to set a breakpoin t. (You do n ot h ave to explicitly switch to h avin g th e edit win dow sh ow th e pro­ gram cu rren tly stopped. Th e debu gger will au tomatically display th e appropriate program th e n ext time execu tion stops for an y reason .) Wh en program execu tion stops at a breakpoin t, you can u se th e debu gger Ctrl+N comman d to can cel th e breakpoin t at th e in stru ction , or you can leave th e breakpoin t set. In eith er case, you can type Ctrl+P wh en you are ready to h ave program execu tion resu me. NOTE: A BPT comman d with n o parameters clears th e breakpoin ts in all th e programs in th e system memory (except th ose programs th at are execu tin g). E n terin g a BPT com­ man d with n o parameters in debu g mon itor mode clears breakpoin ts in th e cu rren t pro­ gram. Program Watchpoints Th e V+ WATCH comman d attach es a watch poin t to a variable or u ser­specified expression . Wh en a watch poin t h as been set, th e specified variable or expression is examin ed before each V+ Lan gu age User's Gu ide Page 9 6 Th e Program Debu gger program in stru ction is execu ted by th e task associated with th e watch poin t. Th e valu e deter­ min ed is compared with th e valu e recorded wh en th e watch poin t was origin ally defin ed. If th e valu e h as ch an ged, th e task is stopped an d th e old an d n ew valu es are displayed. NOTE: Processin g watch poin ts con su mes a lot of execu tion time an d can sign ifican tly slow down program execu tion . Be su re to can cel all th e watch poin ts for an execu tion task wh en you are fin ish ed u sin g th e task for debu ggin g. Th ere is n o sh orth an d debu gger comman d for settin g watch poin ts, bu t WATCH comman ds can be en tered on th e debu gger comman d lin e. V+ Lan gu age User's Gu ide Page 9 7 Data Types an d Operators Data Types and Operators Introduction Dynamic Data Typing and Allocation Variable Name Requirements String Data Type ASCII Values Functions That O perate on String Data R eal and Integer Data Types Numeric Representation Numeric Expressions Logical Expressions Logical Con stan ts Functions That O perate on Numeric Data Location Data Types Transformations Precision Points Arrays Variable Classes Global Variables Local Variables Automatic Variables Scope of Variables Variable Initialization Operators Assignment O perator Mathematical O perators Relational O perators Logical O perators Bitwise Logical O perators V+ Lan gu age User's Gu ide Page 9 8 Data Types an d Operators String Operator Order of Evaluation V+ Lan gu age User's Gu ide Page 9 9 In trodu ction Introduction Th is ch apter describes th e data types u sed by V+. Dynamic Data T yping and Allocation V+ does n ot requ ire you to declare variables or th eir data types. Th e first u se of a variable determin es its data type an d allocate space for th at variable. You can create variables an d assign th em a type as n eeded. Th e program in stru ction : real_var = 13.65 creates th e variable real_ var as a real variable an d assign s it th e valu e 1 3 .6 5 (if th e real_ var h ad already been created, th e in stru ction will merely ch an ge its valu e). Nu meric, strin g, an d tran sformation arrays u p to th ree dimen sion s can be declared dyn am­ ically. Variable Name Requirements Th e requ iremen ts for a valid variable n ame are: 1 . Keywords reserved by Adept can n ot be u sed. Th e V+ Lan gu age Referen ce Gu ide lists th e basic keywords reserved by Adept. If you h ave AdeptVision , Th e AdeptVision Referen ce Gu ide lists th e addition al reserved words u sed by th e vision system. 2 . Th e first ch aracter of a variable n ame mu st be a letter. 3 . Allowable ch aracters after th e first ch aracter are letters, n u mbers, periods, an d th e u n derlin e ch aracter. 4 . On ly th e first 1 5 ch aracters in a variable n ame are sign ifican t. Th e followin g are all valid variable n ames: x count dist.to.part.33 ref_frame Th e followin g n ames are in valid for th e reason s in dicated: 3x one&two pi this_is_a_long_name (first character not a letter) (& is an invalid name character) (reserved word) (too many characters) All bu t th e last of th ese in valid n ames are rejected by V+ with an error message. Th e extra­ lon g n ame is tru n cated (with ou t warn in g) to: this_is_a_long_. V+ Lan gu age User's Gu ide Page 1 0 0 Strin g Data Type String Data Type Variable n ames are preceded with a dollar ($ ) sign to in dicate th at th ey con tain strin g data.1 Th e program in stru ction : $string_name = "Adept V+" allocates th e strin g variable strin g_ n ame (if it h ad n ot previou sly been allocated) an d assign s it th e valu e Adept V+. Nu mbers can be u sed as strin gs with a program in stru ction su ch as: $numeric_string = "13.5" wh ere n u meric _ strin g is assign ed th e valu e 1 3 .5 . Th e program in stru ction : $numeric_string = 13.5 resu lts in an error sin ce you are attemptin g to assign a real valu e to a strin g variable. Th e followin g restriction s apply to strin g con stan ts (e.g., " a strin g" ): l l ASCII valu es 3 2 (space) to 1 2 6 (7 e) are acceptable ASCII 3 4 (" ) can n ot be u sed in a strin g Strin gs can con tain from 0 to 1 2 8 ch aracters. Strin g variables can con tain valu es from 0 to 2 5 5 see Ch aracter Sets on page 3 4 6 for th e in terpretation of th e fu ll ch aracter set). ( Th e followin g are all valid n ames for strin g variables: $x $process $prototype.names $part_1 Th e followin g n ames are in valid for strin gs for th e reason s in dicated: $3x $one-two factor $this_is_a_long_name (first character not a letter) (- is an invalid name character) ($ prefix missing) (too many characters) All bu t th e last of th ese in valid n ames are rejected by V+ with an error message. Th e extra lon g n ame is tru n cated (with ou t warn in g) to $ th is_ is_ a_ lon g_ . ASCII Values An ASCII valu e is th e n u meric represen tation of a sin gle ASCII ch aracter. (See Ch aracter Sets on page 3 4 6 for a complete list of th e ASCII ch aracter set.) An ASCII valu e is specified by prefixin g a ch aracter with an apostroph e ('). An y ASCII ch aracter from th e space ch ar­ acter (decimal valu e 3 2 ) to th e tilde ch aracter (7 e, decimal valu e 1 2 6 ) can be u sed as an ASCII con stan t. Th u s, th e followin g are valid ASCII con stan ts: 'A '1 'v '% Note th at th e ASCII valu e '1 (decimal valu e 4 9 ) is n ot th e same as th e in teger valu e 1 (dec­ imal valu e 1 .0 ). Also, it is n ot th e same as th e strin g valu e " 1 " . V+ Lan gu age User's Gu ide Page 1 0 1 Strin g Data Type Functions T hat Operate on String Data Strin g­Related u n ction s, u mmarizes th e V+ fu n ction s th at operate on strin g data. F s 1Th e dollar sign is n ot con sidered in th e ch aracter cou n t of th e variable n ame. V+ Lan gu age User's Gu ide Page 1 0 2 Real an d In teger Data Types R eal and Integer Data Types Nu mbers th at h ave a wh ole n u mber an d a fraction al part (or man tissa an d expon en t if th e valu e is expressed in scien tific n otation ) belon g to th e data type real. Nu meric valu es h avin g on ly a wh ole n u mber belon g to th e data type in teger. In gen eral, V+ does n ot requ ire you to differen tiate between th ese two data types. If an in teger is requ ired an d you su pply a real, V+ promotes th e real to an in teger by rou n din g (n ot tru n cation ). Wh ere real valu es are requ ired, V+ con siders an in teger a special case of a real th at does n ot h ave a fraction al part. Th e defau lt real type is a sign ed, 3 2 ­bit IE E E sin gle­precision n u mber. Real valu es can also be stored as 6 4 ­bit IE E E dou ble­precision n u mbers if th ey are specifically typed u sin g th e DOU­ BLE keyword (see Variable Classes for details). Th e ran ge of in teger valu es is: ­1 6 ,7 7 7 ,2 1 6 to 1 6 ,7 7 7 ,2 1 5 Sin gle­precision real valu es h ave 2 4 bits of precision , an d h ave th e approximate ran ge: ­1 E +3 8 to 1 E +3 8 Dou ble­precision real valu es h ave 5 2 bits of precision , an d h ave th e approximate ran ge: ­1 E +3 0 7 to 1 E +3 0 7 Numeric Representation Nu meric valu es can be represen ted in th e stan dard decimal n otation or in scien tific n otation . See eal an d In teger Data Types n page 1 0 3 . R o Nu meric valu es can also be represen ted in octal, bin ary, an d h exadecimal form. Th e followin g table sh ows th e requ ired form for each in teger represen tation . I n teger Valu e Represen tation Prefix Example Represen tation n on e ­1 9 3 decimal ^B ^B1 0 0 1 bin ary (max­ imu m of 8 bits) ^ ^3 4 6 octal ^H ^H2 3 FF h exadecimal ^D ^D2 0 0 0 0 0 0 0 dou ble­precision V+ Lan gu age User's Gu ide Page 1 0 3 Real an d In teger Data Types Numeric E xpressions In almost all situ ation s wh ere a n u meric valu e of a variable can be u sed, a n u meric expres­ sion can also be u sed. Th e followin g examples all resu lt in x h avin g th e same valu e. x x x x x = = = = = 3 6/2 SQRT(9) SQR(2) - 1 9 MOD 6 Logical E xpressions V+ does n ot h ave a specific logical (Boolean ) data type. An y n u meric valu e, variable, or expres­ sion can be u sed as a logical data type. V+ con siders 0 to be false an d an y oth er valu e to be tru e. Logical Con stan ts Th ere are fou r logical con stan ts, TRUE an d ON th at will resolve to ­1 , an d FALSE an d OFF th at will resolve to 0 . Th ese con stan ts can be u sed an ywh ere th at a Boolean expression is expect­ ed. A logical valu e, variable, or expression can be u sed an ywh ere th at a decision is requ ired. In th is example, an in pu t sign al is tested. If th e sign al is on (h igh ) th e variable dio.sample is given th e valu e tru e, an d th e IF clau se execu tes. Oth erwise, th e E LSE clau se execu tes: dio.sample = SIG(1001) IF dio.sample THEN ; Steps to take when signal is on (high) ELSE ; Steps to take when signal is off (low) END Sin ce a logical expression can be u sed in place of a logical variable, th e first two lin es of th is example cou ld be combin ed to IF SIG(1001) THEN Functions T hat Operate on Numeric Data Nu meric Valu e Fu n ction s on page 1 4 7 , u mmarizes th e V+ fu n ction s th at operate on s n u meric data. V+ Lan gu age User's Gu ide Page 1 0 4 Location Data Types Location Data Types Th is section gives a brief explan ation of location data. Motion Con trol Operation s on page 1 6 2 covers location s an d th eir u se in detail. T ransformations A data type particu lar to V+ is th e tran sformation data type. Th is data type is a collection of several valu es th at u n iqu ely iden tify a location in Cartesian space. Th e creation an d modification of location variables are discu ssed in Motion Con trol Operation s on page 1 6 2 . Precision Points Precision poin ts are a secon d data type particu lar to V+. A precision poin t is a collection of join t an gles an d tran slation al valu es th at u n iqu ely iden tify th e position an d orien tation of a robot. Th e differen ce between tran sformation variables an d precision ­poin t variables will become more apparen t wh en robot motion in stru ction s are discu ssed in Motion Con trol Oper­ ation s on page 1 6 2 . V+ Lan gu age User's Gu ide Page 1 0 5 Arrays Arrays V+ su pports arrays of u p to th ree dimen sion s. An y V+ data type can be stored in an array. Like simple variables, array allocation (an d typin g) is dyn amic. Un less th ey are declared to be AUTOmatic, array sizes do n ot h ave to be declared. For example: array.one[2] = 36 allocates space for a on e­dimen sion al array n amed array.on e an d places th e valu e 3 6 in ele­ men t two of th e array. (Th e n u mbers in side th e brackets ([ ]) are referred to as in dices. An array in dex can also be a variable or an expression .) $array.two[4,5] = "row 4, col 5" allocates space for a two­dimen sion al array n amed array.two an d places row 4 , col 5 in row fou r, colu mn five of th e array. array.three[2,2,4] = 10.5 allocates space for a th ree­dimen sion al array n amed array.th ree an d places th e valu e 1 0 .5 in row two, colu mn two, ran ge fou r. If an y of th e above in stru ction s were execu ted an d th e array h ad already been declared, th e in stru ction wou ld merely place th e valu e in th e appropriate location . If a data type differen t from th e on e th e array was origin ally created with is specified, an error will resu lt. Arrays are allocated in blocks of 1 6 . Th u s, th e in stru ction : any_array[2] = 50 resu lts in allocation of array elemen ts 0 ­ 1 5 . Th e in stru ction s: any_array[2] = 50 any_array[20] = 75 resu lts in th e allocation of array elemen ts 0 ­ 3 1 . Array allocation is most efficien t wh en th e h igh est ran ge in dex exceeds th e h igh est colu mn in dex, an d th e h igh est colu mn in dex exceeds th e h igh est row in dex. (Row is th e first ele­ men t, colu mn is th e secon d elemen t, an d ran ge is th e th ird elemen t.) Global Array Access Restriction V+ h as a featu re wh ere global an d LOCAL arrays are au tomatically exten ded as th ey are u sed. For efficien cy, th ere is n o in terlockin g of th e array exten sion process between mu ltiple tasks. A crash to DDT can occu r if on e task is exten din g or deletin g an array wh ile an oth er is tryin g to access it. Th e AIM software application h as bu ilt­in protection to preven t th is prob­ lem an d th e resu ltin g crash . However, cu stom V+ programs mu st be coded to avoid th is prob­ lem u sin g on e of th e followin g meth ods: V+ Lan gu age User's Gu ide Page 1 0 6 Arrays Meth od 1 If th ere is a kn own reason able u pper­bou n d on th e array dimen sion s, defin e (by assign in g an arbitrary valu e to it) th e h igh est elemen t of th e array. For mu lti­dimen sion al arrays, assign th e h igh est elemen t of each possible su b­array. Th is assign men t preven ts th e arrays from exten din g. Meth od 2 Use th e TAS fu n ction to in terlock access to th e array. In th is case, access to th e array is h an ­ dled exclu sively from on e or two su brou tin es th at in clu de th e TAS to con trol access to th e array. For details, see th e AS program in stru ction docu men tation . T V+ Lan gu age User's Gu ide Page 1 0 7 Variable Classes Variable Classes In addition to h avin g a data type, variables belon g to on e of th ree classes, GLOBAL, LOCAL, or AUTOMATIC. Th ese classes determin e h ow a variable can be altered by differen t callin g in stan ces of a program. Global Variables Th is is th e defau lt class. Un less a variable h as been specifically declared to be LOCAL or AUTO, a n ewly created variable is con sidered global. On ce a global variable h as been in itialized, it is available to an y execu tin g program1 u n til th e variable is deleted or all programs th at ref­ eren ce it are removed from system memory (with a DE LE TE or ZE RO in stru ction ). Global var­ iables can be explicitly declared with th e GLOBAL program in stru ction . GLOBAL DOUBLE dbl_real_var Global variables are very powerfu l an d sh ou ld be u sed carefu lly an d con sciou sly. If you can ­ n ot th in k of a good reason to make a variable global, good programmin g practice dictates th at you declare it to be LOCAL or AUTO. Local Variables Local variables are created by a program in stru ction similar to: LOCAL the_local_var wh ere th e variable th e_ local_ var is created as a local variable. Local variables can be ch an ged on ly by th e program in wh ich th ey are declared. An importan t differen ce between local variables in V+ an d local variables in most oth er h igh ­ level lan gu ages is th at V+ local variables are local to all copies (callin g in stan ces) of a pro­ gram, n ot ju st a particu lar callin g in stan ce of th at program. Th is distin ction is critical if you write recu rsive programs. In recu rsive programs you will gen erally wan t to u se th e n ext var­ iable class, AUTO. Automatic Variables Au tomatic variables are created by a program in stru ction similar to: AUTO the_auto_var wh ere th e_ au to_ var is created as an au tomatic variable. Au tomatic variables can be ch an ged on ly by a particu lar callin g in stan ce of a program. AUTO statemen ts can n ot be added or deleted wh en th e program is on th e stack. See " Special E ditin g Situ ation s." AUTO DOUBLE dbl_auto_var V+ Lan gu age User's Gu ide Page 1 0 8 Variable Classes Au tomatic variables are more like th e local variables of oth er h igh ­level lan gu ages. If you are writin g programs u sin g a recu rsive algorith m, you will most likely wan t to u se variables in th e au tomatic class. Scope of Variables Th e scope of a variable refers to th e ran ge of programs th at can see th at variable. Th e fol­ lowin g figu resh ows th e scope of th e differen t variable classes. A variable can be altered by th e program(s) in dicated in th e sh aded area of th e box it is in plu s an y programs th at are in smaller boxes. Wh en a program declares an AUTO or LOCAL variable, an y GLOBAL variables of th e same n ame created in oth er programs are n ot accessible. Variable Scopin g Variable Scope E xample sh ows an example of u sin g th e variou s variable classes. Notice th at: l l prog_ 1 declares a to be GLOBAL. Th u s, it is available to all programs n ot h avin g an AUTO or LOCAL a. prog_ 2 creates an u n declared variable b. By defau lt, b is GLOBAL an d available to oth er V+ Lan gu age User's Gu ide Page 1 0 9 Variable Classes programs n ot h avin g a LOCAL or AUTO b. l l prog_ 3 declares an AUTO a an d can n ot u se GLOBAL a. After prog_ 3 completes, th e valu e of AUTO a is deleted. prog_ 4 declares a LOCAL a an d, th erefore, can n ot u se GLOBAL a. Un like th e AUTO a in prog_ 3 , h owever, th e valu e of LOCAL a is stored an d is available for an y fu tu re CALLs to prog_ 4 . Variable Scope E xample V+ Lan gu age User's Gu ide Page 1 1 0 Variable Classes Variable Initialization Before a variable can be u sed it mu st be in itialized. Strin g an d n u meric variables can be in itial­ ized by placin g th em on th e left side of an assign men t statemen t. Th e statemen ts: var_one = 36 $var_two = "two" in itializes th e variables var_ on e an d $ var_ two. var_one = var_two in itializes var_ on e if var_ two h as already been in itialized. Oth erwise, an u n defin ed valu e error is retu rn ed. A variable can n ever be in itialized on th e righ t side of an assign men t state­ men t (var_ two cou ld n ever be in itialized by th e above statemen t). Th e statemen t: var_one = var_one + 10 is valid on ly if var_ on e h as been in itialized in a previou s statemen t. Strin gs, n u meric variables, an d location variables can be in itialized by bein g loaded from a disk file. Strin gs an d n u meric variables can be in itialized with th e PROMPT in stru ction . Tran sformation s an d precision poin ts can be in itialized with th e SE T or HE RE program in stru c­ tion s. Th ey can also be in itialized with th e HE RE an d POINT mon itor comman ds or with th e TE ACH mon itor comman d an d th e man u al con trol pen dan t. See th e + Operatin g System V Referen ce Gu ide for in formation on mon itor comman ds. 1Un less th e program h as declared a LOCAL or AUTO variable with th e same n ame. V+ Lan gu age User's Gu ide Page 1 1 1 Operators Operators Th e followin g section s discu ss th e valid operators. Assignment Operator Th e equ al sign (=) is u sed to assign a valu e to a n u meric or strin g variable. Th e variable bein g assign ed a valu e mu st appear by itself on th e left side of th e equ al sign . Th e righ t side of th e equ al sign can con tain an y variable or valu e of th e same data type as th e left side, or an y expression th at resolves to th e same data type as th e left side. An y variables u sed on th e righ t side of an assign men t operator mu st h ave been previou sly in itialized. Location variables requ ire th e u se of th e SE T in stru ction for a valid assign men t statemen t. Th e in stru ction : loc_var1 = loc_var2 is u n acceptable for location an d precision ­poin t variables. Mathematical Operators V+ u ses th e stan dard math ematical operators sh own in th e followin g table. Math ematical Operators S ymbol Fu n ction + addition ­ su btraction or u n ary min u s * mu ltiplication / division MOD modu lar (remain der) division Relational Operators Relation al operators are u sed in expression s th at yield a Boolean valu e. Th e resolu tion of an expression con tain in g a relation al operator is always ­1 (tru e) or 0 (false) an d tells you if th e specific relation stated in th e expression is tru e or false. Th e most common u se of relation al expression s is with th e con trol stru ctu res. V+ u ses th e stan dard relation al operators sh own in th e followin g table. V+ Lan gu age User's Gu ide Page 1 1 2 Operators Relation al Operators S ymbol Fu n ction == equ al to < less th an > greater th an <= or =< less th an or equ al to >= or => greater th an or equ al to <> n ot equ al to If x h as a valu e of 6 an d y h as a valu e of 1 0 , th e followin g Boolean expression s resolve to ­1 (tru e): x<y y >= x y <> x an d th ese expression s resolve to 0 (false): x>y x <> 6 x == y Note th e differen ce between th e assign men t operator = an d th e relation al operator ==: z = x == y In th is example, z is assign ed a valu e of 0 sin ce th e Boolean expression x == y is false an d wou ld th erefore resolve to 0 . A relation al operator n ever ch an ges th e valu e of th e variables on eith er side of th e relation al operator. Logical Operators Logical operators affect th e resolu tion of a Boolean variable or expression , an d combin e sev­ eral Boolean expression s so th ey resolve to a sin gle Boolean valu e. V+ u ses th e stan dard logical operators sh own in th e followin g table. Logical Operators S ymbol Effect V+ Lan gu age User's Gu ide Page 1 1 3 Operators NOT Complemen t th e expression or valu e; makes a tru e expres­ sion or valu e false an d vice versa. AND Both expression s mu st be tru e before th e en tire expres­ sion is tru e. OR E ith er expression mu st be tru e before th e en tire expres­ sion is tru e. XOR On e expression mu st be tru e an d on e mu st be false before th e en tire expression is tru e. If x = 6 an d y = 1 0 , th e followin g expression s resolves to ­1 (tru e): NOT(x == 7) (x > 2) AND (y =< 10) An d th ese expression s resolves to 0 (false): NOT(x == 6) (x < 2) OR (y > 10) Bitwise Logical Operators Bitwise logical operators operate on pairs of in tegers. Th e correspon din g bits of each in teger are compared an d th e resu lt is stored in th e same bit position in a th ird bin ary n u mber.Th e followin g table lists th e V+ bitwise logical operators. Bitwise Logical Operators Operator Effect BAND E ach bit is compared u sin g an d logic. If both bits are 1 , th en th e cor­ respon din g bit is set to 1 . Oth erwise, th e bit is set to 0 . BOR E ach bit is compared u sin g or logic. If eith er bit is 1 , th en th e cor­ respon din g bit is set to 1 . If both bits are 0 , th e correspon din g bit is set to 0 . BXOR E ach bit is compared u sin g exclu sive or logic. If both bits are 1 or both bits are 0 , th e correspon din g bit is set to 0 . Wh en on e bit is 1 an d th e oth er is 0 , th e correspon din g bit is set to 1 . V+ Lan gu age User's Gu ide Page 1 1 4 Operators COM Th is operator works on on ly on e n u mber. E ach bit is complemen ted: 1 s become 0 s an d 0 s become 1 s. E xamples: x = ^B1001001 BAND ^B1110011 resu lts in x h avin g a valu e of ^B1 0 0 0 0 0 1 . x = COM ^B100001 resu lts in x h avin g a valu e of ^B1 1 1 1 0 . V+ Lan gu age User's Gu ide Page 1 1 5 Strin g Operator String Operator Strin gs can be con caten ated (join ed) u sin g th e plu s sign . For example: $name = "Adept " $incorp = ", Inc." $coname = $name + "Technology" + $incorp resu lts in th e variable $ con ame h avin g th e valu e " Adept Tech n ology, In c" . V+ Lan gu age User's Gu ide Page 1 1 6 Order of E valu ation Order of Evaluation E xpression s con tain in g more th an on e operator are n ot evalu ated in a simple left to righ t man n er. Th e followin g lists th e order in wh ich operators are evalu ated. With in an expression , fu n ction s are evalu ated first, with expression s with in th e fu n ction evalu ated accordin g to th e table. Th e order of evalu ation can be ch an ged u sin g paren th eses. Operators with in each pair of paren th eses, startin g with th e most deeply n ested pair, are completely evalu ated accordin g to th e ru les in th e followin g table before an y operators ou tside th e paren th eses are eval­ u ated. Operators on th e same level in th e table are evalu ated strictly left to righ t. Order of Operator Evalu ation Operator NOT, COM ­ (Un ary min u s) * , /, MOD, AND, BAND +, ­, OR, BOR, XOR, BXOR ==, <=, >=, <, >, <> V+ Lan gu age User's Gu ide Page 1 1 7 Program Con trol Program Control Introduction Unconditional Branch Instructions GO TO CALL CALLS Program Interrupt Instructions W AIT W AIT.EVENT REACT and REACTI REACTE HALT, STO P, and PAUSE BRAKE, BREAK, and DELAY Additional Program Interrupt Instructions Program Interrupt Example Logical (Boolean) Expressions Conditional Branching Instructions IF...GO TO IF...THEN...ELSE CASE value O F E xample Looping Structures FO R E xamples DO ...UNTIL W HILE...DO Summary of Program Control Keywords Controlling Programs in Multiple CPU Systems V+ Lan gu age User's Gu ide Page 1 1 8 In trodu ction Introduction Th is ch apter in trodu ces th e stru ctu res available in V+ to con trol program execu tion . Th ese stru ctu res in clu de th e loopin g an d bran ch in g in stru ction s common to most h igh ­level lan ­ gu ages as well as some in stru ction s specific to V+. V+ Lan gu age User's Gu ide Page 1 2 0 Un con dition al Bran ch In stru ction s Unconditional Branch Instructions Th ere are th ree u n con dition al bran ch in g in stru ction s in V+: l GOTO l CALL l CALLS GOT O Th e GOTO in stru ction cau ses program execu tion to bran ch immediately to a program label in stru ction somewh ere else in th e program. Th e syn tax for GOTO is: GOTO label label 61 62 63 64 65 100 66 is an in teger en tered at th e begin n in g of a lin e of program code. label is n ot th e same as th e program step n u mbers: Step n u mbers are assign ed by th e system; labels are en tered by th e programmer as th e open in g to a lin e of code. In th e n ext code example, th e n u mbers in th e first colu mn are program step n u mbers (th ese n u mbers are n ot displayed in th e SE E editor). Th e n u mbers in th e secon d colu mn are program labels. . GOTO 100 . . TYPE "The instruction GOTO 100 got me he re." . A GOTO in stru ction can bran ch to a label before or after th e GOTO in stru ction . GOTO in stru ction s can make program logic difficu lt to follow an d debu g, especially in a lon g, complicated program with man y su brou tin e calls. Use GOTO in stru ction s with care. A com­ mon u se of GOTO is as an exit rou tin e or exit on error in stru ction . CALL Th e CALL an d CALLS in stru ction s are u sed in V+ to implemen t su brou tin e calls. Th e CALL in stru ction cau ses program execu tion to be su spen ded an d execu tion of a n ew program to begin . Wh en th e n ew program h as completed execu tion , execu tion of th e origin al program resu mes at th e in stru ction after th e CALL in stru ction . Th e details of su brou tin e creation , execu tion , an d parameter passin g are covered in Su brou tin es on page 4 4 . Th e simplified syn ­ tax for a CALL in stru ction is: CALL program(arg_list) program is th e n ame of th e program to be called. Th e program n ame mu st be spec­ ified exactly, an d th e program bein g CALLed mu st be residen t in system memory. V+ Lan gu age User's Gu ide Page 1 2 1 Un con dition al Bran ch In stru ction s arg_ list is th e list of argu men ts bein g passed to th e su brou tin e. Th ese argu ­ men ts can be passed eith er by valu e or by referen ce an d mu st agree with th e argu men ts expected by th e program bein g called. Su brou tin es an d argu men t lists are described in " Su brou tin es." Th e code: 48 49 50 . CALL check_data(locx, locy, length) . su spen ds execu tion of th e callin g program, passes th e argu men ts locx, locy, an d len gth to pro­ gram ch eck_ data, execu tes ch eck_ data, an d (after ch eck_ data h as completed execu tion ) resu mes execu tion of th e callin g program at step 5 0 . CALLS Th e CALLS in stru ction is iden tical to th e CALL in stru ction except for th e specification of program. For a CALLS in stru ction , program is a strin g valu e, variable, or expression . Th is allows you to call differen t su brou tin es u n der differen t con dition s u sin g th e same lin e of code. (Th ese differen t su brou tin es mu st h ave th e same arg_ list.) Th e code: 47 48 49 50 . $program_name = $program_list[program_select] CALLS $program_name(length, width) . su spen ds execu tion of th e callin g program, passes th e parameters len gth an d width to th e program specified by array in dex program_ select from th e array $ program_ list, execu tes th e specified program, an d resu me execu tion of th e callin g program at step 5 0 . V+ Lan gu age User's Gu ide Page 1 2 2 Program In terru pt In stru ction s Program Interrupt Instructions V+ provides several ways of su spen din g or termin atin g program execu tion . A program can be pu t on h old u n til a specific con dition becomes TRUE u sin g th e WAIT in stru ction . A pro­ gram can be pu t on h old for a specified time period or u n til an even t is gen erated in an oth er task by th e WAIT.E VE NT in stru ction . A program can be in terru pted based on a state tran ­ sition of a digital in pu t sign al with th e RE ACT an d RE ACTI in stru ction s. Program errors can be in tercepted an d h an dled with a RE ACTE in stru ction . Program execu tion can be termin ated with th e HALT, STOP, an d PAUSE comman ds. Th ese in stru ction s in terru pt th e program in wh ich th ey are con tain ed. An y programs ru n n in g as oth er tasks are n ot affected. Robot motion can be con trolled with th e BRAKE , BRE AK, an d DE LAY in stru ction s. (Th e ABORT an d PROCE E D mon itor comman ds can also be u sed to su spen d an d proceed programs, see th e V+ Operatin g System Referen ce Gu ide for details.) W AI T WAIT su spen ds program execu tion u n til a con dition (or con dition s) becomes tru e. WAIT SIG(1032, -1028) delays execu tion u n til digital in pu t sign al 1 0 3 2 is on an d 1 0 2 8 is off. WAIT TIMER(1) > 10 su spen ds execu tion u n til timer 1 retu rn s a valu e greater th an 1 0 . WAIT .E VE NT Th e in stru ction : WAIT.EVENT , 3.7 su spen ds execu tion for 3 .7 secon ds. Th is wait is more efficien t th an waitin g for a timer (as in th e previou s example) becau se th e task does n ot h ave to loop con tin u ally to ch eck th e timer valu e. Th e in stru ction : WAIT.EVENT su spen ds execu tion u n til an oth er task issu es a SE T.E VE NT in stru ction to th e waitin g task. If th e SE T.E VE NT does n ot occu r, th e task waits in defin itely. RE ACT and RE ACT I Wh en a RE ACT or RE ACTI in stru ction is en cou n tered, th e program begin s mon itorin g a dig­ ital in pu t sign al specified in th e RE ACT in stru ction . Th is sign al is mon itored in th e backgrou n d with program execu tion con tin u in g n ormally u n til th e specified sign al tran sition s. Wh en (an d if) a tran sition is detected, th e program su spen ds execu tion at th e cu rren tly execu tin g step. V+ Lan gu age User's Gu ide Page 1 2 3 Program In terru pt In stru ction s RE ACT an d RE ACTI su spen d execu tion of th e cu rren t program an d call a specified su brou tin e. Addition ally, RE ACTI issu es a BRAKE in stru ction to immediately stop th e cu rren t robot motion . Both in stru ction s specify a su brou tin e to be ru n wh en th e digital tran sition is detected. After th e specified su brou tin e h as completed, program execu tion resu mes at th e step execu tin g wh en th e digital tran sition was detected. Digital sign als 1 0 0 1 ­ 1 0 1 2 an d 2 0 0 1 ­ 2 0 0 8 can be u sed for RE ACT in stru ction s. Th e sign al mon itorin g in itiated by RE ACT/RE ACTI is in effect u n til an oth er RE ACT/RE ACTI or IGNORE in stru ction is en cou n tered. If th e specified sign al tran sition is n ot detected before an IGNORE or secon d RE ACT/RE ACTI in stru ction is en cou n tered, th e RE ACT/RE ACTI in stru ction h as n o effect on program execu tion . Th e syn tax for a RE ACT or RE ACTI in stru ction is: REACT signal_number, program, priority sign al_ n u mber digital in pu t sign al in th e ran ge 1 0 0 1 to 1 0 1 2 or 2 0 0 1 to 2 0 0 8 . program th e su brou tin e (an d its argu men t list) th at is to be execu ted wh en a react is in itiated. priority n u mber from 1 to 1 2 7 th at in dicates th e relative importan ce of th e reac­ tion . Th e followin g code implemen ts a RE ACT rou tin e: 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 . ; ; ; ; Look for a change in signal 1001 from "on" to "off". Call subroutine "alarm if a change is detected. Set priority of "alarm" to 10 (default would be 1). The main program has default priority of 0. REACT -1001, alarm, 10 ; REACT will be in effect for the following code MOVE MOVE LOCK MOVE MOVE LOCK MOVE a b 20 c d 0 e ;Defer any REACTions to "alarm" ;Allow REACTions ; Disable monitoring of signal 1001 IGNORE -1001 V+ Lan gu age User's Gu ide Page 1 2 4 Program In terru pt In stru ction s If sign al 1 0 0 1 tran sition s du rin g execu tion of step 4 3 , step 4 3 completes, th e su brou tin e alarm is called, an d execu tion resu mes at step 4 4 . If sign al 1 0 0 1 tran sition s du rin g execu tion of step 4 7 , steps 4 7 , 4 8 , an d 4 9 completes (sin ce th e program h ad been given a h igh er priority th an RE ACT), th e su brou tin e alarm is called, an d execu tion resu mes at step 5 0 .1 RE ACT E RE ACTE en ables a reaction program th at is ru n wh en ever a system error th at cau ses pro­ gram execu tion to termin ate is en cou n tered. Th is in clu des all robot errors, h ardware errors, an d most system errors (it does NOT in clu de I/O errors). Un like RE ACT an d RE ACTI, RE ACTE can n ot be deferred based on priority con sideration s. Th e in stru ction : REACTE trouble en ables mon itorin g of system errors an d execu te th e program trou ble wh en ever a system error is gen erated. HALT , ST OP, and PAUSE Wh en a HALT in stru ction is en cou n tered, program execu tion is termin ated, an d an y open serial or disk u n its are DE TACHE D an d FCLOSE d. PROCE E D or RE TRY will n ot resu me execu tion . Wh en a STOP in stru ction is en cou n tered, execu tion of th e cu rren t program cycle is ter­ min ated an d th e n ext execu tion cycle resu mes at th e first step of th e program. If th e STOP in stru ction is en cou n tered on th e last execu tion cycle, program execu tion is termin ated, an d an y open serial or disk u n its are DE TACHE D an d FCLOSE d. PROCE E D or RE TRY will n ot resu me execu tion . (See E XE CUTE for details on execu tion cycles.) Wh en a PAUSE in stru c­ tion is en cou n tered, execu tion is su spen ded. After a PAUSE , th e system prompt appears an d Mon itor Comman ds can be execu ted. Th is allows you to verify th e valu es of program var­ iables an d set system parameters. Th is is u sefu l du rin g program debu ggin g. Th e mon itor comman d PROCE E D resu mes execu tion of a program in terru pted with th e PAUSE com­ man d. BRAKE , BRE AK, and DE LAY BRAKE aborts th e cu rren t robot motion . Th is in stru ction can be issu ed from an y task. Pro­ gram execu tion is n ot su spen ded an d th e program (execu tin g as task 0 ) con tin u es to execu te at th e n ext in stru ction . BRE AK su spen ds program execu tion (defeats forward proc­ essin g) u n til th e cu rren t robot motion is completed. Th is in stru ction can be execu ted on ly from a robot con trol program an d is u sed wh en completion of th e cu rren t robot motion mu st occu r before execu tion of th e n ext in stru ction . A DE LAY in stru ction specifies th e min imu m delay between robot motion s (n ot program in stru ction s). V+ Lan gu age User's Gu ide Page 1 2 5 Program In terru pt In stru ction s Additional Program Interrupt Instructions You can specify a parameter in th e in stru ction lin e for th e I/O in stru ction s ATTACH, RE AD, GE TC, an d WRITE th at cau ses th e program to su spen d u n til th e I/O requ est h as been su c­ cessfu lly completed. Th ird­party boards may also gen erate system level in terru pts. For details, see th e descrip­ tion s of INT.E VE NT, CLE AR.E VE NT an d WAIT.E VE NT in Su mmary of Program Con trol Key­ words on page 1 3 7 . Program Interrupt E xample Th e followin g figu re sh ows h ow th e task an d program priority sch eme works. It also sh ows h ow th e asyn ch ron ou s an d program in terru pt in stru ction s work with in th e priority sch eme. Th e example makes th e followin g assu mption s: l Task 1 ru n s in all time slices at priority 3 0 l Task 2 ru n s in all time slices at priority 2 0 l All system tasks are ign ored l All system in terru pts are ign ored Th e illu stration sh ows th e time lin es of execu tin g programs. A solid lin e in dicates a program is ru n n in g, an d a dotted lin e in dicates a program is waitin g. Th e Y axis sh ows th e program prior­ ity. Th e X axis is divided in to 1 6 ­millisecon d major cycles. Th e example sh ows two tasks execu tin g con cu rren tly with RE ACT rou tin es en abled for each task. Note h ow th e LOCK in stru ction s an d triggerin g of th e RE ACT rou tin es ch an ge th e program priority. Th e sequ en ce of even ts for th e example is: 1 . Task 1 is ru n n in g program prog_ a at program priority 0 . A reaction program based on sign al 1 0 0 3 is en abled at priority 5 . 2 . Sign al 1 0 0 3 is asserted extern ally. Th e sign al tran sition is n ot detected u n til th e n ext major cycle. 3 . Th e sign al 1 0 0 3 tran sition is detected. Th e task 1 reaction program begin s execu tion , in terru ptin g prog_ a. 4 . Th e task 1 reaction program reen ables itself an d completes by issu in g a RE TURN in stru ction . prog_ a resu mes execu tion in task 1 . 5 . Task 1 prog_ a issu es a CLE AR.E VE NT in stru ction followed by a WAIT.E VE NT in stru c­ tion to wait for its even t flag to be set. Task 1 is su spen ded, an d task 2 resu mes execu tion of prog_ b. Task 2 h as a reaction program based on sign al 1 0 1 0 en abled at priority 5 . 6 . Task 2 prog_ b issu es a LOCK 1 0 in stru ction to raise its program priority to level 1 0 . 7 . Sign al 1 0 1 0 is asserted extern ally. Th e sign al tran sition is n ot detected u n til th e n ext V+ Lan gu age User's Gu ide Page 1 2 6 Program In terru pt In stru ction s major cycle. 8 . Th e sign al 1 0 1 0 tran sition is detected, an d th e task 2 reaction is triggered. However, sin ce th e reaction is at level 5 an d th e cu rren t program priority is 1 0 , th e reaction execu tion is deferred. 9 . Task 2 prog_ b issu es a LOCK 0 in stru ction to lower its program priority to level 0 . Sin ce a level 5 reaction program is pen din g, it begin s execu tion immediately an d sets th e program priority to 5 . 1 0 . Sign al 1 0 0 3 is asserted extern ally. Th e sign al tran sition is n ot detected u n til th e n ext major cycle. 1 1 . Th e sign al 1 0 0 3 tran sition is detected wh ich triggers th e task 1 reaction rou tin e an d also sets th e task 1 even t flag. Sin ce task 1 h as a h igh er priority (3 0 ) th an task 2 (2 0 ), task 1 begin s execu tin g its reaction rou tin e an d task 2 is su spen ded. 1 2 . Th e task 1 reaction rou tin e completes by issu in g a RE TURN in stru ction . Con trol retu rn s to prog_ a in task 1 . 1 3 . Task 1 prog_ a issu es a CLE AR.E VE NT in stru ction followed by a WAIT.E VE NT in stru c­ tion to wait for its even t flag to be set. Task 1 is su spen ded an d task 2 resu mes execu tion of its reaction rou tin e. Th e task 2 reaction rou tin e completes by issu in g a RE TURN in stru ction . Con trol retu rn s to prog_ b in task 2 . 1 4 . Task 2 prog_ b issu es a SE T.E VE NT 1 in stru ction , settin g th e even t flag for task 1 . Task 2 n ow issu es a RE LE ASE program in stru ction to yield con trol of th e CPU. 1 5 . Sin ce th e task 1 even t flag is n ow set, an d its priority is h igh er th an task 2 , task 1 resu mes execu tion , an d task 2 is su spen ded. V+ Lan gu age User's Gu ide Page 1 2 7 Program In terru pt In stru ction s Priority E xample 2 1Th e L OCK in stru ction can be u sed to con trol execu tion of a program after a RE ACT or RE ACTI su brou tin e h as completed. V+ Lan gu age User's Gu ide Page 1 2 8 Logical (Boolean ) E xpression s Logical (Boolean) Expressions Th e n ext two section s discu ss program con trol stru ctu res wh ose execu tion depen ds on an expression or variable th at takes on a Boolean valu e (a variable th at is eith er tru e or false, or an expression th at resolves to tru e or false). An expression can take in to accou n t an y n u mber of variables or digital in pu t sign als as lon g as th e fin al resolu tion of th e expression is a Boolean valu e. In V+, an y n u mber (real or in teger) can satisfy th is requ iremen t. Zero is con sidered false; an y n on zero n u mber is con sidered tru e. Th ere are fou r system con stan ts, TRUE an d ON th at resolve to ­1 , an d FALSE an d OFF, th at resolve to 0 . E xamples of valid Boolean expression s: y > 32 NOT(y > 32) x == 56 x AND y (x AND y) OR (var1 < var2) -1 For details on V+ relation al operators, see Relation al Operators n page 1 1 2 . o V+ Lan gu age User's Gu ide Page 1 2 9 Con dition al Bran ch in g In stru ction s Conditional Branching Instructions Con dition al bran ch in g in stru ction s allow you to execu te blocks of code based on th e cu rren t valu es of program variables or expression s. V+ h as th ree con dition al bran ch in stru ction s: l l l IF...GOTO IF...THE N...E LSE CASE valu e OF IF...GOT O IF...GOTO beh aves similarly to GOTO, bu t a con dition can be attach ed to th e bran ch . If th e in stru ction : IF logical_expression GOTO 100 is en cou n tered, th e bran ch to label 1 0 0 occu rs on ly if logical_ expression h as a valu e of tru e. IF...T HE N...E LSE Th e basic con dition al in stru ction is th e IF...THE N...E LSE clau se. Th is in stru ction h as two forms: IF expression THEN code block ( e x e c u t e d w h e n e x p r e s s i o n i s t r u e ) END IF expression THEN code block ( e x e c u t e d w h e n e x p r e s s i o n i s t r u e ) ELSE code block ( e x e c u t e d w h e n e x p r e s s i o n i s f a l s e ) END expression is an y well­formed Boolean expression (described above). In th e followin g example, if program execu tion reach es step 5 9 an d n u m_ parts is greater th an 7 5 , step 6 0 is execu ted. Oth erwise, execu tion resu mes at step 6 2 . 56 57 58 59 60 61 62 . ;CALL "check_num" if "num_parts" is greater than 75 IF num_parts > 75 THEN CALL check_num(num_parts) END . In th e followin g example, if program execu tion reach es step 3 7 with in pu t sign al 1 0 3 3 on an d n eed_ part tru e, th e program execu tes steps 3 8 to 4 0 an d resu mes at step 4 4 . Oth er­ wise, it execu tes step 4 2 an d resu mes at step 4 4 . 32 33 34 . ; If I/O signal 1033 is on and Boolean "need_part" is ; true, then pick up the part V+ Lan gu age User's Gu ide Page 1 3 0 Con dition al Bran ch in g In stru ction s 35 36 37 38 39 40 41 42 43 44 ; else alert the operator. IF SIG(1033) AND need_part THEN MOVE loc1 CLOSEI DEPART 50 ELSE TYPE "Part not picked up." END . CASE value OF Th e IF...THE N...E LSE stru ctu re allows a program to take on e of two differen t action s. Th e CASE stru ctu re will allow a program to take on e of man y differen t action s based on th e valu e of a variable. Th e variable u sed mu st be a real or an in teger. Th e form of th e CASE stru ctu re is: CASE target OF VALUE list_of_values: code block ( e x e c u t e d w h e n target i s i n list_of_values) VALUE list_of_values: code block ( e x e c u t e d w h e n target i s i n list_of_values) ... ANY code block ( e x e c u t e d w h e n target n o t i n a n y list_of_values) END real valu e to match . list_ of_ valu eslist (separated by commas) of real valu es. If on e of th e valu es in th e list equ als target, th e code followin g th at valu e statemen t is execu ted. Example 5 66 67 50 68 69 70 71 72 73 74 75 76 77 78 79 80 81 ; Create a menu structure using a CASE statement TYPE "1. Execute the program." TYPE "2. Execute the programmer." TYPE "3. Execute the computer." PROMPT "Enter menu selection.", select CASE select OF VALUE 1: CALL exec_program() VALUE 2: CALL exec_programmer() VALUE 3: CALL exec_computer() ANY PROMPT "Entry must be from 1 to 3", select GOTO 50 V+ Lan gu age User's Gu ide Page 1 3 1 Con dition al Bran ch in g In stru ction s 82 83 END . If th e above code is rewritten with ou t an ANY statemen t, an d a valu e oth er th an 1 , 2 , or 3 is en tered, th e program con tin u es to execu te at step 8 3 with ou t execu tin g an y program. V+ Lan gu age User's Gu ide Page 1 3 2 Loopin g Stru ctu res Looping Structures In man y cases, you will wan t th e program to execu te a block of code more th an on ce. V+ h as th ree loopin g stru ctu res th at allow you to execu te blocks of code a variable n u mber of times. Th e th ree in stru ction s are: l l l FOR DO...UNTIL WHILE ...DO FOR A FOR in stru ction creates an execu tion loop th at will execu te a given block of code a specified n u mber of times. Th e basic form of a FOR loop is: FOR index = start_val TO end_val STEP incr . code block . END in dex is a real variable th at keeps track of th e n u mber of times th e FOR loop h as been execu ted. Th is variable is available for u se with in th e loop. start_ val is a real expression for th e startin g valu e of th e in dex. en d_ val is a real expression for th e en din g valu e of th e in dex. E xecu tion of th e loop termin ates wh en in dex reach es th is valu e. in cr is a real expression in dicatin g th e amou n t in dex is to be in cremen ted after each execu tion of th e loop. Th e defau lt valu e is 1 . Examples 88 89 90 91 92 93 94 102 103 104 105 106 107 108 109 110 . ; Output even elements of array "$names" (up to index 32) FOR i = 2 TO 32 STEP 2 TYPE $names[i] END . . . ; Output the values of the 2 dimensional array "values" in ; column and row form (10 rows by 10 columns) . FOR i = 1 TO 10 FOR j = 1 to 10 TYPE values[i,j], /S END TYPE " ", /C1 V+ Lan gu age User's Gu ide Page 1 3 3 Loopin g Stru ctu res 111 112 END . A FOR loop can be made to cou n t backward by en terin g a n egative valu e for th e step in cre­ men t. 13 14 15 16 17 18 19 . ; Count backward from 10 to 1 FOR i = 10 TO 1 STEP -1 TYPE i END . Ch an gin g th e valu e of in dex in side a FOR loop will cau se th e loop to beh ave improperly. To avoid problems with th e in dex, make th e in dex variable an au to variable an d do n ot ch an ge th e in dex from in side th e FOR loop. Ch an ges to th e startin g an d en din g variables do n ot affect th e FOR loop on ce it is execu tin g. DO...UNT IL DO...UNTIL is a loopin g stru ctu re th at execu tes a given block of code an in determin ate n u mber of times. Termin ation of th e loop occu rs wh en th e Boolean expression or variable th at con trols th e loop becomes tru e. Th e Boolean is tested after each execu tion of th e code block­if th e expression evalu ates to tru e, th e loop is n ot execu ted again . Sin ce th e expression is n ot evalu ated u n til after th e code block h as been execu ted, th e code block will always execu te at least on ce. Th e form for th is loopin g stru ctu re is: DO . code block . UNTIL expression expression is an y well­formed Boolean expression . Th is expression mu st even tu ally eval­ u ate to tru e, or th e loop execu tes in defin itely. 20 21 22 23 24 25 26 27 28 . ; Output the numbers 1 to 100 to the screen x=1 DO TYPE x x=x+1 UNTIL x > 100 . Step 2 6 en su res th at x will reach a h igh en ou gh valu e so th at th e expression x > 1 0 0 becomes tru e. 43 44 45 46 . ; Echo up to 15 characters to the screen. Stop when 15 ; characters or the character "#" have been entered. V+ Lan gu age User's Gu ide Page 1 3 4 Loopin g Stru ctu res 47 48 49 50 51 52 53 x=1 DO PROMPT "Enter a character: ", $ans TYPE $ans x=x+1 UNTIL (x > 15) OR ($ans == "#") . In th is code, eith er x reach in g 1 5 or # bein g en tered at th e PROMPT in stru ction termin ates th e loop. As lon g as th e operator en ters en ou gh ch aracters, th e loop termin ates. WHILE ...DO WHILE ...DO is a loopin g stru ctu re similar to DO...UNTIL except th e Boolean expression is evalu ated at th e begin n in g of th e loop in stead of at th e en d. Th is mean s th at if th e con dition in dicated by th e expression is tru e wh en th e WHILE ...DO in stru ction is en cou n tered, th e code with in th e loop will be execu ted. WHILE ...DO loops are su sceptible to in fin ite loopin g ju st as DO...UNTIL loops are. Th e expres­ sion con trollin g th e loop mu st even tu ally evalu ate to tru e for th e loop to termin ate. Th e form of th e WHILE ...DO loopin g stru ctu re is: WHILE expression DO code block END expression is an y well­formed Boolean expression as described at th e begin n in g of th is sec­ tion . Th e followin g code sh ows a WHILE ...DO loop bein g u sed to validate in pu t. Sin ce th e Boolean expression is tested before th e loop is execu ted, th e code with in th e loop will be execu ted on ly wh en th e operator in pu ts an u n acceptable valu e at step 2 3 . 20 21 22 23 24 25 26 27 . ; Loop until operator inputs value in the range 32-64 PROMPT "Enter a number in the range 32 to 64.", ans WHILE (ans < 32) OR (ans > 64) DO PROMPT "Number must be in the range 32-64.", ans END . In th e above code, an operator cou ld en ter a n on n u meric valu e, in wh ich case th e program execu tion wou ld stop. A more robu st strategy wou ld be to u se a strin g variable in th e PROMPT in stru ction an d th en u se th e $ DE CODE an d VAL fu n ction s to evalu ate th e in pu t. In th e followin g code, if digital sign al 1 0 3 3 is on wh en step 6 9 is reach ed, th e loop does n ot execu te, an d th e program con tin u es at step 7 3 . If digital sign al 1 0 3 3 is off, th e loop execu tes con tin u ally u n til th e sign al comes on . 65 66 67 . ; Create a busy loop waiting for signal ; 1033 to turn "on" V+ Lan gu age User's Gu ide Page 1 3 5 Loopin g Stru ctu res 68 69 70 71 72 73 WHILE NOT SIG(1033) DO ;Wait for signal END . V+ Lan gu age User's Gu ide Page 1 3 6 Su mmary of Program Con trol Keywords Summary of Program Control Keywords Th e followin g table su mmarizes th e program con trol in stru ction s. See th e V+Lan gu age Referen ce Gu ide for details on th ese comman ds. Program Con trol Operation s Keyword Type Fu n ction ABORT Program In stru ction Termin ate execu tion of a con trol program. CALL Program In stru ction Su spen d execu tion of th e cu rren t program an d con ­ tin u e execu tion with a n ew program (th at is, a su b­ rou tin e). CALLS Program In stru ction Su spen d execu tion of th e cu rren t program an d con ­ tin u e execu tion with a n ew program (th at is, a su b­ rou tin e) specified with a strin g valu e. CASE Program In stru ction In itiate processin g of a CASE stru ctu re by defin in g th e valu e of in terest. CLE AR.E VE NT Program In stru ction Clear an even t associated with th e specified task. CYCLE .E ND Program In stru ction Termin ate th e specified con trol program th e n ext time it execu tes a STOP program in stru ction (or its equ ivalen t). Su spen d processin g of an application program or comman d program u n til a program com­ pletes execu tion . DO Program In stru ction In trodu ce a DO program stru ctu re. E XE CUTE Program In stru ction Begin execu tion of a con trol program. E XIT Program In stru ction E xit a FOR, DO, or WHILE con trol stru ctu re. FOR Program In stru ction E xecu te a grou p of program in stru ction s a certain n u mber of times. GE T.E VE NT Real­ Retu rn even ts th at are set for th e specified task. V+ Lan gu age User's Gu ide Page 1 3 7 Su mmary of Program Con trol Keywords Valu ed Fu n ction GOTO Program In stru ction Perform an u n con dition al bran ch to th e program step iden tified by th e given label. HALT Program In stru ction Stop program execu tion an d do n ot allow th e pro­ gram to be resu med. IF...GOTO Program In stru ction Bran ch to th e specified label if th e valu e of a logical expression is RUE (n on zero). T IF...THE N Program In stru ction Con dition ally execu te a grou p of in stru ction s (or on e of two grou ps) depen din g on th e resu lt of a logical expression . INT.E VE NT Program In stru ction Sen d a SE T.E VE NT in stru ction to th e cu rren t task if an in terru pt occu rs on a specified VME bu s vector. LOCK Program In stru ction Set th e program reaction lock­ou t priority to th e valu e given . MCS Program In stru ction In voke a mon itor comman d from a con trol program. NE XT Program In stru ction Break a FOR, DO, or WHILE stru ctu re an d start th e n ext iteration of th e con trol stru ctu re. PAUSE Program In stru ction Stop program execu tion bu t allow th e program to be resu med. PRIORITY Real­ Valu ed Fu n ction Retu rn th e cu rren t reaction lock­ou t priority for th e program. RE ACT RE ACTI Program In stru ction In itiate con tin u ou s mon itorin g of a specified digital sign al an d au tomatically trigger a su brou tin e call if th e sign al tran sition s properly. RE ACTE Program In stru ction In itiate th e mon itorin g of errors th at occu r du rin g execu tion of th e cu rren t program task. RE LE ASE Program In stru ction Allow th e n ext available program task to ru n . V+ Lan gu age User's Gu ide Page 1 3 8 Su mmary of Program Con trol Keywords RE TURN Program In stru ction Termin ate execu tion of th e cu rren t su brou tin e an d resu me execu tion of th e last­su spen ded program at th e step followin g th e CALL or CALLS in stru ction th at cau sed th e su brou tin e to be in voked. RE TURNE Program In stru ction Termin ate execu tion of an error reaction su brou tin e an d resu me execu tion of th e last­su spen ded pro­ gram at th e step followin g th e in stru ction th at cau sed th e su brou tin e to be in voked. RUNSIG Program In stru ction Tu rn on (or off) th e specified digital sign al as lon g as execu tion of th e in vokin g program task con tin u es. SE T.E VE NT Program In stru ction Set an even t associated with th e specified task. STOP Program In stru ction Termin ate execu tion of th e cu rren t program cycle. WAIT Program In stru ction Pu t th e program in to a wait loop u n til th e con dition is RUE . T WAIT.E VE NT Program In stru ction Su spen d program execu tion u n til a specified even t h as occu rred, or u n til a specified amou n t of time h as elapsed. WHILE Program In stru ction In itiate processin g of a WHILE stru ctu re if th e con ­ dition is RUE or skippin g of th e WHILE stru ctu re if T th e con dition is in itially ALSE . F V+ Lan gu age User's Gu ide Page 1 3 9 Con trollin g Programs in Mu ltiple CPU Systems Controlling Programs in Multiple CPU Systems V+ systems equ ipped with mu ltiple CPUs an d option al V+ E xten sion s can ru n mu ltiple copies of V+. Keep th e followin g con sideration s in min d wh en ru n n in g mu ltiple V+ systems: l l l l l l l A graph ics­based system is requ ired. Th e secon d, th ird, etc., V+ copies are displayed in separate win dows on th e mon itor. Th ese win dows are labeled Mon itor_ 2 , Mon itor_ 3 , etc. Th e system switch MONITORS mu st be en abled before th ese win dows can be displayed. Th e CPU n u mber is deter­ min ed by th e board address switch (see th e Adept MV Con troller User's Gu ide). ALL V+ copies sh are th e same digital in pu t, ou tpu t, an d soft sign als. Global variables are n ot sh ared. Th e IOGE T_ an d IOPUT_ in stru ction s can be u sed to sh are data between V+ copies via an 8 KB reserved section of sh ared memory on each board. Acceptable address valu es are 0 to h exadecimal valu e 1 FFF (decimal valu e 0 to 8 1 9 1 ). Th is memory area is u sed on ly for commu n ication between V+ application programs an d is n ot u sed for an y oth er pu rpose. (It is n ot possible to access th e rest of th e processor memory map.) Th e IOTAS() fu n ction can be u sed to in terlock access to u ser data stru ctu res. Th e addresses are based on sin gle­byte (8 ­bit) valu es. For example, if you write a 3 2 ­ bit valu e to an address, it occu pies fou r address spaces (th e address th at you specify an d th e n ext th ree addresses). If you read a valu e from a location u sin g a format differen t from th e format th at was u sed to write to th at location , you get an in valid valu e, bu t you will n ot get an error message. (For example, if you write u sin g IOPUTF an d read u sin g IOPUTL, you r data is in valid.) NOTE: V+ does n ot en force an y memory protection sch emes for u se of th e application sh ared­memory area. It is th e u ser's respon sibility to keep track of memory u sage. If you are u sin g application or u tility programs written by someon e else, you sh ou ld read th e docu men tation provided with th at soft­ ware to en su re th at it does n ot con flict with you r u sage of th e sh ared area. l l In gen eral, robot con trol an d system con figu ration ch an ges mu st be performed from CPU #1 . CPUs oth er th an #1 always start u p with th e stan d­alon e con trol modu le. No belts or kin ematic modu les are loaded. E ach mu ltiple CPU can execu te its own au tostart rou tin e. CPU #1 loads th e n ormal AUTO file an d execu te th e program au to, CPU #2 loads th e file AUTO0 2 .V2 an d execu te th e program au to0 2 . V+ Lan gu age User's Gu ide Page 1 4 0 Fu n ction s Functions Using Functions Variable Assignment Using Functions Functions Used in Expressions Functions as Arguments to a Function String-R elated Functions Examples of String Functions Location, Motion, and External Encoder Functions Examples of Location Functions Numeric Value Functions Examples of Arithmetic Functions Logical Functions System Control Functions Example of System Control Functions V+ Lan gu age User's Gu ide Page 1 4 1 Usin g Fu n ction s Using Functions V+ provides you with a wide variety of predefin ed fu n ction s for performin g strin g, math ­ ematical, an d gen eral system parameter man ipu lation . In most cases, you mu st provide th e data th at is in pu t to a fu n ction . Th e fu n ction th en retu rn s a valu e based on a specific oper­ ation on th at data. Fu n ction s can be u sed an ywh ere a valu e or expression wou ld be u sed. Variable Assignment Using Functions Th e in stru ction : $curr_time = $TIME() pu ts th e cu rren t system time in to th e variable $ cu rr_ time. Th is is an example of a fu n ction th at does n ot requ ire an y in pu t data. Th e in stru ction : var_root = SQRT(x) pu ts th e squ are root of th e valu e x in to var_ root. X is n ot ch an ged by th e fu n ction . Functions Used in E xpressions A fu n ction can be u sed wh erever an expression can be u sed (as lon g as th e data type retu rn ed by th e fu n ction is th e correct type). Th e in stru ction : IF LEN($some_string) > 12 THEN resu lts in th e Boolean expression bein g tru e if th e strin g $ some_ strin g h as more th an 1 2 ch aracters. Th e in stru ction : array_var = some_array[VAL($x)] resu lts in array_ var h avin g th e same valu e as th e array cell $ x. (VAL con verts a strin g to a real.) Functions as Arguments to a Function In most cases, th e valu es passed to a fu n ction are n ot ch an ged. Th is n ot on ly protects th e variables you u se as argu men ts to a fu n ction , bu t also allows you to u se a fu n ction as an argu men t to a fu n ction (so lon g as th e data type retu rn ed is th e type expected by th e fu n c­ tion ). Th e followin g example resu lts in i h avin g th e absolu te valu e of x. (i = D(­2 2 ) = 2 ). i = SQRT(SQR(x)) V+ Lan gu age User's Gu ide Page 1 4 3 Strin g­Related Fu n ction s String-R elated Functions Th e valu e retu rn ed from a strin g fu n ction may be an oth er strin g or a n u meric valu e. S trin g-Related Fu n ction s Keyword Fu n ction ASC Retu rn a sin gle ch aracter valu e from with in a strin g. $ CHR Retu rn a on e­ch aracter strin g h avin g a given valu e. DBLB Retu rn th e valu e of eigh t bytes of a strin g in terpreted as an IE E E dou ­ ble­precision floatin g­poin t n u mber. $ DBLB Retu rn an 8 ­byte strin g con tain in g th e bin ary represen tation of a real valu e in dou ble­precision IE E E floatin g­poin t format. $ DE CODE E xtract part of a strin g as delimited by given break ch aracters. $ E NCODE Retu rn a strin g created from ou tpu t specification s. Th e strin g produ ced is similar to th e ou tpu t of a TYPE in stru ction . FLTB Retu rn th e valu e of fou r bytes of a strin g in terpreted as an IE E E sin ­ gle­precision floatin g­poin t n u mber. $ FLTB Retu rn a 4 ­byte strin g con tain in g th e bin ary represen tation of a real valu e in sin gle­precision IE E E floatin g­poin t format. $ INTB Retu rn a 2 ­byte strin g con tain in g th e bin ary represen tation of a 1 6 ­ bit in teger. LEN Retu rn th e n u mber of ch aracters in th e given strin g. LNGB Retu rn th e valu e of fou r bytes of a strin g in terpreted as a sign ed 3 2 ­ bit bin ary in teger. $ LNGB Retu rn a 4 ­byte strin g con tain in g th e bin ary represen tation of a 3 2 ­ bit in teger. $ MID Retu rn a su bstrin g of th e specified strin g. PACK Replace a su bstrin g with in an array of (1 2 8 ­ch aracter) strin g var­ iables or with in a (n on array) strin g variable. V+ Lan gu age User's Gu ide Page 1 4 4 Strin g­Related Fu n ction s POS Retu rn th e startin g ch aracter position of a su bstrin g in a strin g. $ TRANSB Retu rn a 4 8 ­byte strin g con tain in g th e bin ary represen tation of a tran sformation valu e. $ TRUNCATE Retu rn all ch aracters in th e in pu t strin g u n til an ASCII NUL (or th e en d of th e strin g) is en cou n tered. $ UNPACK Retu rn a su bstrin g from an array of 1 2 8 ­ch aracter strin g variables. VAL Retu rn th e real valu e represen ted by th e ch aracters in th e in pu t strin g. E xamples of String Functions Th e in stru ction : TYPE $ERROR(-504) ou tpu ts th e text * Un expected en d of file* to th e screen . Th e in stru ction s: $message = "The length of this line is: " TYPE $ENCODE($message, /I0, LEN($message)+14), " characters." ou tpu ts th e message Th e len gth of th is lin e is: 4 2 ch aracters. V+ Lan gu age User's Gu ide Page 1 4 5 Location , Motion , an d E xtern al E n coder Fu n ction s Location, Motion, and External Encoder Functions V+ provides n u merou s fu n ction s for man ipu latin g an d con vertin g location variables. See Motion Con trol Operation s for details on motion processin g an d a table th at in clu des all loca­ tion ­related fu n ction s. See Readin g Device Data on page 3 4 4 for details on th e extern al en coders. E xamples of Location Functions Th e in stru ction : rotation = RZ(HERE) places th e valu e of th e cu rren t rotation abou t th e Z axis in th e variable rotation . Th e in stru ction : dist = DISTANCE(HERE, DEST) places th e distan ce between th e motion device's cu rren t location an d its destin ation (th e valu e of th e n ext motion in stru ction ) in th e variable dist. Th e in stru ction s: IF INRANGE(loc_1) == 0 THEN IF SPEED(2) > 50 THEN SPEED 50 END MOVE(loc_1) END en su res th at loc_ 1 is reach able an d moves th e motion device to th at location at a program speed n ot exceedin g 5 0 . V+ Lan gu age User's Gu ide Page 1 4 6 Nu meric Valu e Fu n ction s Numeric Value Functions Th e fu n ction s listed in th e followin g table provide trigon ometric, statistical, an d data type con ­ version operation s. See Data Types an d Operators n page 9 8 for addition al details on arith ­ o metic processin g. Nu meric Valu e Fu n ction s Keyword Fu n ction ABS Retu rn absolu te valu e. ATAN2 Retu rn th e size of th e an gle (in degrees) th at h as its trigon ometric tan ­ gen t equ al to valu e_ 1 /valu e_ 2 . BCD Con vert a real valu e to Bin ary Coded Decimal (BCD) format. COS Retu rn th e trigon ometric cosin e of a given an gle. CUBRT Retu rn s th e cu be root of a parameter. DCB Con vert BCD digits in to an equ ivalen t in teger valu e. FRACT Retu rn th e fraction al part of th e argu men t. INT Retu rn th e in teger part of th e valu e. MAX Retu rn th e maximu m valu e con tain ed in th e list of valu es. MIN Retu rn th e min imu m valu e con tain ed in th e list of valu es. OUTSIDE Test a valu e to see if it is ou tside a specified ran ge. PI Retu rn th e valu e of th e math ematical con stan t pi (3 .1 4 1 5 9 3 ). RANDOM Retu rn a pseu doran dom n u mber. SIGN Retu rn th e valu e 1 with th e sign of th e valu e parameter. SIN Retu rn th e trigon ometric sin e of a given an gle. SQR Retu rn th e squ are of th e parameter. SQRT Retu rn th e squ are root of th e parameter. V+ Lan gu age User's Gu ide Page 1 4 7 Nu meric Valu e Fu n ction s E xamples of Arithmetic Functions Th e in stru ction s: $a = "16" x = SQRT(VAL($a)) resu lts in x h avin g a valu e of 4 . Th e in stru ction : x = INT(RANDOM*10) creates a pseu doran dom n u mber between 0 an d 1 0 . V+ Lan gu age User's Gu ide Page 1 4 8 Logical Fu n ction s Logical Functions Th e followin g table lists th e fu n ction s th at retu rn Boolean valu es. Th ese fu n ction s requ ire n o argu men ts an d essen tially operate as system con stan ts. Logical Fu n ction s Keyword Fu n ction FALSE Retu rn th e valu e u sed by V+ to represen t a logical false resu lt. OFF Retu rn th e valu e u sed by V+ to represen t a logical false resu lt. ON Retu rn th e valu e u sed by V+ to represen t a logical tru e resu lt. TRUE Retu rn th e valu e u sed by V+ to represen t a logical tru e resu lt. V+ Lan gu age User's Gu ide Page 1 4 9 System Con trol Fu n ction s System Control Functions Th e fu n ction s listed in th e followin g table retu rn in formation abou t th e system an d system parameters. S ystem Con trol Fu n ction s Keyword Fu n ction CAS Th is fu n ction compares a real variable to a test valu e, an d con ­ dition ally sets a n ew valu e as on e in divisible operation . DE FINE D Determin e wh eth er a variable h as been defin ed. E RROR Retu rn th e error n u mber of a recen t error th at cau sed program execu tion to stop or cau sed a RE ACTE reaction . $ E RROR Retu rn th e error message associated with th e given error code. FRE E Retu rn th e amou n t of u n u sed free memory storage space. GE T.E VE NT Retu rn even ts th at are set for th e specified task. ID Retu rn valu es th at iden tify th e con figu ration of th e cu rren t system. $ ID Retu rn th e system creation date an d edit/revision in formation . INTB Retu rn th e valu e of two bytes of a strin g in terpreted as a sign ed 1 6 ­ bit bin ary in teger. LAST Retu rn th e h igh est in dex u sed for an array (dimen sion ). PARAME TE R Retu rn th e cu rren t settin g of th e n amed system parameter. PRIORITY Retu rn th e cu rren t reaction lock­ou t priority for th e program. SE LE CT Retu rn th e u n it n u mber th at is cu rren tly selected by th e cu rren t task for th e device n amed. STATUS Retu rn statu s in formation for an application program. SWITCH Retu rn an in dication of th e settin g of a system switch . TAS Retu rn th e cu rren t valu e of a real­valu ed variable an d assign it a n ew valu e. Th e two action s are don e in divisibly so n o oth er program task V+ Lan gu age User's Gu ide Page 1 5 0 System Con trol Fu n ction s can modify th e variable at th e same time. TASK Retu rn in formation abou t a program execu tion task. TIME Retu rn an in teger valu e represen tin g eith er th e date or th e time spec­ ified in th e given strin g parameter. $ TIME Retu rn a strin g valu e con tain in g eith er th e cu rren t system date an d time or th e specified date an d time. TIME R Retu rn th e cu rren t time valu e of th e specified system timer. TPS Retu rn th e n u mber of ticks of th e system clock th at occu r per secon d (Ticks Per Secon d). E xample of System Control Functions Th e in stru ction : IF (TIMER(2) > 100) AND (DEFINED(loc_1)) THEN MOVE loc_1 END execu tes th e MOVE in stru ction on ly if timer (2 ) h ad a valu e greater th an 1 0 0 an d th e variable loc_ 1 h ad been defin ed. V+ Lan gu age User's Gu ide Page 1 5 1 Switch es an d Parameters Switches and Parameters Introduction Parameters Viewing Parameters Setting Parameters Summary of Basic System Parameters Graph ics­Based System Termin al Settin gs Graph ics­Based System Termin al Settin gs Switches Viewing Switch Settings Setting Switches Summary of Basic System Switches V+ Lan gu age User's Gu ide Page 1 5 2 In trodu ction Introduction System parameters determin e certain operatin g ch aracteristics of th e V+ system. Th ese parameters h ave n u meric valu es th at can be ch an ged from th e comman d lin e or from with in a program to su it particu lar system con figu ration s an d n eeds. Th e variou s parameters are described in th is ch apter alon g with th e operation s for displayin g an d ch an gin g th eir valu es. System switch es are similar to system parameters in th at th ey con trol th e operatin g beh av­ ior of th e V+ system. Switch es differ from parameters, h owever, in th at th ey do n ot h ave n u meric valu es. Switch es can be set to eith er en abled or disabled, wh ich can be th ou gh t of as on an d off, respectively. All th e basic system switch es are described in th is ch apter. Th e mon itor comman ds an d pro­ gram in stru ction s th at can be u sed to display an d ch an ge th eir settin gs are also presen ted. V+ Lan gu age User's Gu ide Page 1 5 4 Parameters Parameters See th e V+Lan gu age Referen ce Gu ide for more detailed description s of th e keywords dis­ cu ssed h ere. Wh en ever a system parameter n ame is u sed, it can be abbreviated to th e min imu m len gth requ ired to iden tify th e parameter. For example, th e HAND.TIME parameter can be abbre­ viated to H, sin ce n o oth er parameter n ame begin s with H. Viewing Parameters To see th e state of a sin gle parameter, u se th e PARAME TE R mon itor comman d: PARAMETER parameter_name If parameter_ n ame is omitted, th e valu e of all parameters is displayed. To retrieve th e valu e of a parameter from with in a program, u se th e PARAME TE R fu n ction . Th e in stru ction : TYPE "HAND.TIME parameter =", PARAMETER(HAND.TIME) will display th e cu rren t settin g of th e h an d­delay parameter in th e mon itor win dow. Th e PARAME TE R fu n ction can be u sed in an y expression to in clu de th e valu e of a parameter. For example, th e followin g program statemen t in creases th e delay for h an d actu ation : PARAMETER HAND.TIME = PARAMETER(HAND.TIME) + 0.15 Note th at th e left­h an d occu rren ce of PARAME TE R is th e in stru ction n ame an d th e righ t­ h an d occu rren ce is th e fu n ction n ame. Setting Parameters To set a parameter from th e comman d lin e, u se th e PARAME TE R mon itor comman d. Th e in stru ction : PARAMETER SCREEN.TIMEOUT = 10 sets th e screen blan kin g time to 1 0 secon ds. To set a parameter in a program, u se th e PARAME TE R program in stru ction . Th e in stru ction : PARAMETER NOT.CALIBRATED = 1 asserts th e n ot calibrated state for robot 1 . Some parameters are organ ized as arrays an d mu st be accessed by specifyin g an array in dex. V+ Lan gu age User's Gu ide Page 1 5 5 Parameters Summary of Basic System Parameters System parameters are set to defau lts wh en th e V+ system is in itialized. Th e defau lt valu es are in dicated with each parameter description below. Th e settin gs of th e parameter valu es are n ot affected by th e ZE RO comman d. If you r robot system in clu des option al en h an cemen ts (su ch as vision ), you will h ave oth er sys­ tem parameters available. Con su lt th e docu men tation for th e option s for details. Th e basic system parameters are sh own in th e followin g table. Basic S ystem Parameters Parameter Defau lt Use Min Max BE LT.MODE Con trols th e operation of th e con ­ veyor trackin g featu re of th e V+ sys­ tem. 0 0 14 HAND.TIME Determin es th e du ration of th e motion delay th at occu rs du rin g proc­ essin g of OPE NI, CLOSE I, an d RE LAXI in stru ction s. Th e valu e for th is param­ eter is in terpreted as th e n u mber of secon ds to delay. Du e to th e way in wh ich V+ gen erates its time delays, th e HAND.TIME parameter is in ter­ n ally rou n ded to th e n earest mu ltiple of 0 .0 1 6 secon ds. 0 .0 5 0 1E18 KE RMIT.RE TRY Sets th e n u mber of times Kermit will attempt to tran sfer a data packet before qu ittin g with an error. 15 1 1000 KE RMIT.TIME OUT Time, in secon ds, th at Kermit will wait before retryin g th e tran sfer of a data packet. 8 1 95 NOT.CALIBRATE D Represen ts th e calibration statu s of th e robot(s) con trolled by th e V+ sys­ tem. 7 0 7 SCRE E N.TIME OUT Con trols au tomatic blan kin g of th e graph ics mon itor on graph ics­based systems. 0 0 16383 V+ Lan gu age User's Gu ide Page 1 5 6 Parameters TE RMINAL Th is parameter determin es h ow th e V+ will in teract with an ASCII system termin al. Th e acceptable valu es are 0 th rou gh 4 , an d th ey h ave th e in ter­ pretation s sh own in th e followin g table. 41 0 4 NOTE S: 1Th e defau lt valu e for TE RMINAL is ch an ged with th e u tility CONFIG_ C.V2 on th e Adept Utility Disk. See th e In stru ction s for Adept Utility Programs. Graph ics-Based S ystem Termin al S ettin gs Parameter Valu e Termin al Type Treatmen t of DEL & BS Cu rsor-u p Comman d 0 TTY \<ech o>\ Non e 1 CRT E rase <VT> 2 CRT E rase <SUB> 3 CRT E rase < FF> 4 CRT E rase <E SC>M V+ Lan gu age User's Gu ide Page 1 5 7 Switch es Switches System switch es govern variou s featu res of th e V+ system. Th e switch es are described below. See th e V+Lan gu age Referen ce Gu ide an d th e V+Operatin g System Referen ce Gu ide for more detailed description s of th e keywords discu ssed h ere. As with system parameters, th e n ames of system switch es can be abbreviated to th e min i­ mu m len gth requ ired to iden tify th e switch . Viewing Switch Settings Th e SWITCH mon itor comman d displays th e settin g of on e or more system switch es: SWITCH switch_name, ..., switch_name If n o switch es are specified, th e settin gs of all switch es are displayed. With in programs, th e SWITCH real­valu ed fu n ction retu rn s th e statu s of a switch . Th e in stru ction : SWITCH(switch_name) retu rn s TRUE (­1 .0 ) if th e switch is en abled, FALSE (0 .0 ) if th e switch is disabled. Some switch es are organ ized as arrays an d may be accessed by specifyin g th e array in dex. Setting Switches Th e E NABLE an d DISABLE mon itor comman ds/program in stru ction s con trol th e settin g of system switch es. Th e in stru ction : ENABLE BELT en ables th e BE LT switch . Th e in stru ction : DISABLE BELT, CP disables th e CP an d BE LT switch es. Mu ltiple switch es can be specified for eith er in stru ction . Switch es can also be set with th e SWITCH program in stru ction . Its syn tax is: SWITCH switch_name = value Th is in stru ction differs from th e E NABLE an d DISABLE in stru ction s in th at th e SWITCH in stru ction en ables or disables a switch depen din g on th e valu e on th e righ t­h an d side of th e equ al sign . Th is allows you to set switch es based on a variable or expression . Th e switch is en abled if th e valu e is TRUE (n on zero) an d disabled if th e valu e is FALSE (zero). Th e in stru c­ tion : SWITCH CP = SIG(1001) en ables th e con tin u ou s path (CP) switch if in pu t sign al 1 0 0 1 is on . V+ Lan gu age User's Gu ide Page 1 5 8 Switch es Summary of Basic System Switches Th e defau lt switch settin gs at system power­u p are given in th e followin g table. (Th e switch settin gs are n ot affected by th e ZE RO comman d.) Option al en h an cemen ts to you r V+ system may in clu de addition al system switch es. If so, th ey are described in th e docu men tation for th e option s. Basic S ystem S witch es S witch Use AUTO.POWE R.OFF Wh en th is switch is en abled V+ will treat software errors as h ard errors an d disable HIGH POWE R. Normally th ese errors stop th e robot an d sign al th e V+ program, bu t DO NOT cau se HIGH POWE R to be tu rn ed off. Th e soft errors are:(­6 2 4 ) * force protect limit exceeded (­1 0 0 3 ) * Time­ou t n u llin g errors* Mtr (­1 0 0 6 ) * Soft en velope error* Mtr BE LT Used to tu rn on th e con veyor trackin g featu res of V+ (if th e option is in stalled).Th is switch mu st be en abled before an y of th e special con veyor trackin g in stru ction s can be execu ted. Wh en BE LT is disabled, th e con veyor trackin g software h as a min imal impact on th e overall performan ce of th e system. Defau lt is disabled. CP E n able/disable con tin u ou s­path motion processin g (see " Con ­ tin u ou s­Path Trajectories" ). Defau lt is en abled. DE CE L.1 0 0 Wh en DE CE L.1 0 0 is en abled for a robot, th e maximu m decel­ eration percen tage defin ed by SPE C is ign ored an d a maximu m deceleration of 1 0 0 % is u sed in stead. Th is maximu m decel­ eration valu e is u sed to limit th e valu e specified by th e ACCE L program in stru ction . For backwards compatibility, by defau lt, DE CE L.1 0 0 is disabled for all robots. DRY.RUN E n able/disable sen din g of motion comman ds to th e robot. E n a­ ble th is switch to test programs for proper logical flow an d cor­ rect extern al commu n ication with ou t h avin g to worry abou t th e robot ru n n in g in to someth in g. (Also see th e TRACE switch , wh ich is u sefu l du rin g program ch eckou t.) Th e man u al con trol pen dan t can still be u sed to move th e robot wh en DRY.RUN is en abled. Defau lt is disabled. V+ Lan gu age User's Gu ide Page 1 5 9 Switch es FORCE Con trols wh eth er th e (option al) stop­on ­force featu re of th e V+ system is active. Defau lt is disabled. INTE RACTIVE Su ppresses display of variou s messages on th e system ter­ min al. In particu lar, wh en th e INTE RACTIVE switch is disabled, V+ does n ot ask for con firmation before performin g certain oper­ ation s an d does n ot ou tpu t th e text of error messages. Th is switch is u su ally disabled wh en th e system is bein g con trolled by a su pervisory compu ter to relieve th e compu ter from h avin g to process th e text of messages.Defau lt is en abled. MCP.ME SSAGE S Con trols h ow system error messages are h an dled wh en th e con ­ troller keyswitch is n ot in th e MANUAL mode position . Defau lt is disabled. MCS.ME SSAGE S Con trols wh eth er mon itor comman ds execu ted with th e MCS in stru ction will h ave th eir ou tpu t displayed on th e termin al. Defau lt is disabled. ME SSAGE S Con trols wh eth er ou tpu t from TYPE in stru ction s will be dis­ played on th e termin al. Defau lt is en abled. MONITORS Th is switch is u sed with systems con figu red for mu ltiple V+ sys­ tem processors (requ ires th e option al V+ E xten sion s software) an d E n able or disable selectin g of mu ltiple mon itor win dows. POWE R Tracks th e statu s of Robot Power. Th is switch is au tomatically en abled wh en ever Robot Power is tu rn ed on . Th is switch can be u sed to tu rn Robot Power on or off­en ablin g th e switch tu rn s on Robot Power an d disablin g th e switch tu rn s off Robot Power. Defau lt is disabled. ROBOT Th is is an array of switch es th at con trol wh eth er or n ot th e sys­ tem sh ou ld access robots n ormally con trolled by th e sys­ tem.Defau lt is disabled. SUPE RVISOR Not u sed in n ormal operation . SE T.SPE E D E n able/disable th e ability to set th e mon itor speed from th e man u al con trol pen dan t. Defau lt is en abled. TRACE E n able/disable a special mode of program execu tion in wh ich each program step is displayed on th e system termin al before it is execu ted. Th is is u sefu l du rin g program developmen t for V+ Lan gu age User's Gu ide Page 1 6 0 Switch es ch eckin g th e logical flow of execu tion (also see th e DRY.RUN switch ). Defau lt is disabled. UPPE R Determin es wh eth er comparison s of strin g valu es will con sider lowercase letters th e same as u ppercase letters. Wh en th is switch is en abled, all lowercase letters are con sidered as th ou gh th ey are u ppercase. Defau lt is en abled. V+ Lan gu age User's Gu ide Page 1 6 1 Motion Con trol Operation s Motion Control Operations Introduction Location Variables Coordinate Systems Transformations Yaw Pitch Roll Special Situ ation s Creating and Altering Location Variables Creating Location Variables Tran sformation s vs. Precision Poin ts Modifying Location Variables Relative Tran sformation s E xamples of Modifyin g Location Variables Defining a Reference Frame Miscellaneous Location O perations Motion Control Instructions Basic Motion O perations Join t­In terpolated Motion vs. Straigh t­Lin e Motion Safe Approach es an d Departu res Movin g an In dividu al Join t End­Effector O peration Instructions Continuous­Path Trajectories Breaking Continuous­Path O peration Procedural Motion Procedu ral Motion E xamples Timin g Con sideration s Robot Speed Motion Modifiers Customizing the Calibration Routine Tool Transformations Defining a Tool Transformation Summary of Motion Keywords V+ Lan gu age User's Gu ide Page 1 6 2 In trodu ction Introduction A primary focu s of th e V+ lan gu age is to drive motion devices. Th is ch apter discu sses th e lan ­ gu age elemen ts th at gen erate con troller ou tpu t to move a motion device from on e location to an oth er. Before we in trodu ce th e V+ motion in stru ction s, we sh ou ld examin e th e V+ loca­ tion variables an d see h ow th ey relate to th e space in wh ich th e motion device operates. V+ Lan gu age User's Gu ide Page 1 6 4 Location Variables Location Variables Location s can be specified in two ways in V+: tran sformation s an d precision poin ts. A tran sformation is a set of six compon en ts th at u n iqu ely iden tifies a location in Cartesian space an d th e orien tation of th e motion device en d­of­arm toolin g at th at location . A tran s­ formation can also represen t th e location of an arbitrary local referen ce frame. A precision poin t in clu des an elemen t for each join t in th e motion device. Rotation al join t valu es are measu red in degrees; tran slation al join t valu es are measu red in millimeters. Th ese valu es are absolu te with respect to th e motion device's h ome sen sors an d can n ot be made relative to oth er location s or coordin ate frames. Coordinate Systems Th e followin g figu re sh ows th e world coordin ate system for an Adept SCARA robot an d an Adept Cartesian robot. Ultimately, all tran sformation s are based on a world coordin ate sys­ tem. Th e V+ lan gu age con tain s several in stru ction s for creatin g local referen ce frames, bu ild­ in g relative tran sformation s, an d ch an gin g th e origin of th e base (world) coordin ate frame. Th erefore, an in dividu al tran sformation may be relative to an oth er tran sformation , a local ref­ eren ce frame, or an altered base referen ce frame. Differen t robots an d motion devices design ates differen t location s as th e origin of th e world coordin ate system. See th e u ser's gu ide for Adept robots or th e device modu le doc­ u men tation for AdeptMotion VME systems to determin e th e origin an d orien tation of th e world coordin ate frame. V+ Lan gu age User's Gu ide Page 1 6 5 Location Variables Adept Robot Cartesian Space T ransformations Th e first th ree compon en ts of a tran sformation variable are th e valu es for th e poin ts on th e X, Y, an d Z axes. In an Adept SCARA robot, th e origin of th is Cartesian space is th e base of th e robot. Th e Z axis poin ts straigh t u p th rou gh th e middle of th e robot colu mn . Th e X axis poin ts straigh t ou t, an d th e Y axis ru n s left to righ t as you face th e robot. Th e first robot in Adept Robot Cartesian Space sh ows th e orien tation of th e Cartesian space for an Adept SCARA robot. Th e location of th e world coordin ate system for oth er robots an d motion devices depen ds on th e kin ematic model of th e motion device. For example, th e secon d robot in Adept Robot Cartesian Space sh ows th e world coordin ate frame for a robot bu ilt on th e Car­ tesian coordin ate model. See th e kin ematic device modu le docu men ts for you r particu lar motion device. Wh en a tran sformation is defin ed, a local referen ce frame is created at th e X, Y, Z location with all th ree local frame axes parallel to th e world coordin ate frame. XYZ E lemen ts of a Tran s­ formation sh ows th e first part of a tran sformation . Th is tran sformation h as th e valu e X = 3 0 , Y = 1 0 0 , Z = 1 2 5 , yaw = 0 , pitch = 0 , an d roll = 0 . V+ Lan gu age User's Gu ide Page 1 6 6 Location Variables XYZ E lemen ts of a Tran sformation Th e secon d th ree compon en ts of a tran sformation variable specify th e orien tation of th e en d­of­arm toolin g. Th ese th ree compon en ts are yaw, pitch , an d roll. Th ese elemen ts are fig­ u red as ZYZ' E u ler valu es. Figu res 8 ­3 th rou gh 8 ­5 demon strate h ow th ese valu es are in ter­ preted. Yaw Yaw is a rotation abou t th e local referen ce frame Z axis. Th is rotation is n ot abou t th e pri­ mary referen ce frame Z axis, bu t is cen tered at th e origin of th e local frame of referen ce. Yaw sh ows th e yaw axis with a rotation of 3 0 to th e primary referen ce frame Z axis bu t may be cen tered at an y poin t in th at space. In th is example, th e yaw valu e is 3 0 valu e (X = 3 0 , Y = 1 0 0 , Z = 1 2 5 , yaw = 3 0 , pitch = 0 , an d roll = 0 ). V+ Lan gu age User's Gu ide Page 1 6 7 Location Variables Wh en you are u sin g a robot, th e local frame of referen ce defin ed by th e XYZ compon en ts is located at th e en d of th e robot tool flan ge. (Th is local referen ce frame is referred to as th e tool coordin ate system.) In Yaw, th e large Cartesian space represen ts a world coordin ate system. Th e small Cartesian space represen ts a local tool coordin ate system (wh ich is cen tered at th e motion device toolin g flan ge). Yaw V+ Lan gu age User's Gu ide Page 1 6 8 Location Variables Pitch Pitch is defin ed as a rotation abou t th e local referen ce frame Y axis, after yaw h as been applied. Pitch sh ows th e local referen ce frame with a yaw of 3 0 of 4 0 For example, deflection of a wrist join t is reflected in th e pitch compon en t. Th e movemen t of a fifth axis on a SCARA robot is reflected in th e pitch compon en t. In th is example, th e motion device en d­of­arm toolin g h as a pitch of 4 0 a tran sformation with th e valu e (X = 3 0 , Y = 1 0 0 , Z = 1 2 5 , yaw = 3 0 , pitch = 4 0 , an d roll = 0 ). Th is location can be reach ed on ly by a mech ­ an ism with a fifth axis. Pitch is represen ted as sh own as ­1 7 0 Pitch V+ Lan gu age User's Gu ide Page 1 6 9 Location Variables Roll Roll is defin ed as a rotation abou t th e Z axis of th e local referen ce frame after yaw an d pitch h ave been applied. Roll sh ows a local referen ce frame in th e primary robot Cartesian space an d th e direction roll wou ld take with in th at space. In th is example th e tran sformation h as a valu e of X = 3 0 , Y = 1 0 0 , Z = 1 2 5 , yaw = 3 0 , pitch = 4 0 , an d roll = 2 0 . Th is location can be reach ed on ly by a mech an ism with fifth an d sixth axes. Roll S pecial S itu ation s Wh en th e Z axes of th e local an d primary referen ce frames are parallel, roll an d yaw produ ce th e same motion in th e same plan e, alth ou gh th e two motion s may be in differen t direction s. Th is is always th e case with a fou r­axis SCARA robot. Th e system au tomatically reflects V+ Lan gu age User's Gu ide Page 1 7 0 Location Variables rotation of th e qu ill in th e roll compon en t of a tran sformation variable, an d th e yaw com­ pon en t is forced to 0 robot equ ipped with a fifth axis, rotation of th e qu ill is reflected in th e yaw compon en t an d motion of a rotatin g en d­effector (sixth axis) is reflected in th e roll com­ pon en t. Notice in XYZ E lemen ts of a Tran sformation th at th e local referen ce frame poin ts straigh t u p. Th is correspon ds to a situ ation wh ere th e en d of arm toolin g poin ts straigh t back alon g th e th ird axis. In a mech an ism n ot equ ipped with a 3 6 0 th is is an impossible position . For a fou r­ axis SCARA, th is compon en t mu st poin t straigh t down (pitch = 1 8 0 mu st be with in th e ran ge of motion of th e fifth axis. V+ Lan gu age User's Gu ide Page 1 7 1 Creatin g an d Alterin g Location Variables Creating and Altering Location Variables Creating Location Variables Th e most straigh tforward meth od of creatin g a location variable is to place th e robot or motion device at a location an d en ter th e mon itor comman d: HERE loc_name Tran sformation s vs. Precision Poin ts A location can be specified u sin g eith er th e six compon en ts described in th e previou s section , or by specifyin g th e state th e robot join ts wou ld be in wh en a location is reach ed. Th e former meth od resu lts in a tran sformation variable. Tran sformation s are th e most flexible an d effi­ cien t location variables. Precision poin ts record th e join t valu es of each join t in th e motion device. Precision poin ts may be more accu rate, an d th ey are th e on ly way of extractin g join t in formation th at will allow you to move an in dividu al join t. Precision poin ts are iden tified by a leadin g pou n d sign (#). Th e comman d: HERE #pick will create th e precision poin t #pick equ al to th e cu rren t robot join t valu es. Modifying Location Variables Th e in dividu al compon en ts of an existin g tran sformation or precision poin t can be edited with th e POINT mon itor comman d: POINT loc_name displays th e tran sformation compon en ts of loc_ n ame an d allows you to edit th em. If loc_ n ame is n ot defin ed, a n u ll tran sformation is displayed for editin g. A location variable can be du plicated u sin g th e POINT mon itor comman d or SE T program in stru ction . Th e mon itor comman d: POINT loc_name = loc_value an d th e program in stru ction : SET loc_name = loc_value both resu lt in th e variable loc_ n ame bein g given th e valu e of loc_ valu e. Th e POINT mon itor comman d also allows you to edit loc_ n ame after it h as been assign ed th e valu e of loc_ valu e. Th e followin g fu n ction s retu rn tran sformation valu es: TRANS Create a location by specifyin g in dividu al compon en ts of a tran sformation . A valu e can be specified for each compon en t. V+ Lan gu age User's Gu ide Page 1 7 2 Creatin g an d Alterin g Location Variables SHIFT Alter th e Cartesian compon en ts of an existin g tran sformation . Th e POINT an d SE T operation s can be u sed in con ju n ction with th e tran sformation fu n ction s SHIFT an d TRANS to create location variables based on specific modification s of existin g var­ iables. SET loc_name = SHIFT(loc_value BY 5, 5, 5) will create th e location variable loc_ n ame. Th e location of loc_ n ame are sh ifted 5 mm in th e positive X, Y, an d Z direction s from loc_ valu e. Relative Tran sformation s Relative tran sformation s allow you to make on e location relative to an oth er an d to bu ild local referen ce frames to wh ich th at tran sformation s can be relative. For example, you may be bu ildin g an assembly wh ose location in th e workcell ch an ges periodically. If all th e location s on th e assembly are tau gh t relative to th e world coordin ate frame, each time th e assembly is located differen tly in th e workcell, all th e location s mu st be retau gh t. If, h owever, you create a frame based on iden tifiable featu res of th e assembly, you will h ave to reteach on ly th e poin ts th at defin e th e frame. Examples of Modifyin g Location Variables Relative Tran sformation sh ows h ow relative tran sformation s work. Th e magn itu de an d direc­ tion elemen ts (x, y, z), bu t n ot th e orien tation elemen ts (y, p, r), of an Adept tran sformation can be represen ted as a 3 ­D vector, as sh own by th e dash ed lin es an d arrows in Relative Tran sformation . Th e followin g code gen erates th e location s sh own in th at figu re. ; Define a simple transformation SET loc_a = TRANS(300,50,350,0,180,0) ; Move to the location MOVE loc_a BREAK ; Move to a location offset -50mm in X, 20mm in Y, ; and 30mm in Z relative to "loc_a" MOVE loc_a:TRANS(-50, 20, 30) BREAK ; Define "loc_b" to be the current location relative ; to "loc_a" HERE loc_a:loc_b ;loc_b = -50, 20, 30, 0, 0, 0 BREAK ; Define "loc_c" as the vector sum of "loc_a" and "loc_b" SET loc_c = loc_a:loc_b ;loc_c = 350, 70, 320, 0, 180, 0 On ce th is code h as ru n , loc_ b exists as a tran sformation th at is completely in depen den t of loc_ a. Th e followin g in stru ction moves th e robot an oth er ­5 0 mm in th e x, 2 0 mm in th e y, an d 3 0 mm in th e z direction (relative to loc_ c): MOVE loc_c:loc_b V+ Lan gu age User's Gu ide Page 1 7 3 Creatin g an d Alterin g Location Variables Mu ltiple relative tran sformation s can be ch ain ed togeth er. If we defin e loc_ d to h ave th e valu e 0 , 5 0 , 0 , 0 , 0 , 0 : SET loc_d = TRANS(0,50) an d th en issu e th e followin g MOVE in stru ction : MOVE loc_a:loc_b:loc_d th e robot moves to a position x = ­5 0 mm, y =7 0 mm, an d z = 3 0 mm relative to loc_ a. In Relative Tran sformation , th e tran sformation loc_ b defin es th e tran sformation n eeded to get from th e local referen ce frame defin ed by loc_ a to th e local referen ce frame defin ed by loc_ c. Th e tran sformation n eeded to go in th e opposite direction (from loc_ c to loc_ a) can be cal­ cu lated by: INVERSE(loc_b) Th u s, th e in stru ction : MOVE loc_c:INVERSE(loc_b) effectively moves th e robot back to loc_ a. V+ Lan gu age User's Gu ide Page 1 7 4 Creatin g an d Alterin g Location Variables Relative Tran sformation Th is figu re sh ows th e first th ree location s from th e previou s code examples. Defining a Reference Frame In th e example sh own in Relative Location s, a pallet is brou gh t in to th e workcell on a con ­ veyor. Th e program th at follows teach es th ree location s th at defin e th e pallet referen ce frame (pallet.frame) an d th en removes th e parts from th e pallet. Th e program th at follows V+ Lan gu age User's Gu ide Page 1 7 5 Creatin g an d Alterin g Location Variables ru n s regardless of wh ere th e pallet is placed in th e workcell as lon g as it is with in th e robot's workin g en velope. Relative Location s ; Get the locations to define the pallet DETACH () ;Release robot for use by the MCP PROMPT "Place robot at pallet origin. ", $ans HERE loc.origin ;Record the frame origin PROMPT "Place robot at point on the pallet x-axis. ", $ans HERE loc.x.axis ;Record point on x-axis PROMPT "Place robot at point in positive y direction. ", $ans HERE loc.pos.y ;Record positive y direction ATTACH () ;Reattach the robot V+ Lan gu age User's Gu ide Page 1 7 6 Creatin g an d Alterin g Location Variables ; Create the local reference frame "pallet.frame" SET pallet.frame = FRAME(loc.origin, loc.x.axis,loc.pos.y, loc.origin) cell.space = 50 ;Spacing of cells on pallet ; Remove the palletized items FOR i = 0 TO 3 FOR J = 0 TO 2 APPRO pallet.frame:TRANS(i*cell.space, j*cell.space), 25 MOVE pallet.frame:TRANS(i*cell.space, j*cell.space) BREAK ;Settle robot CLOSEI ;Grab the part DEPART 25 ;MOVE to the drop off location END END In th e above example, th e code th at teach es th e pallet frame mu st ru n on ly wh en th e pallet location ch an ges. If you are bu ildin g an assembly th at does n ot h ave regu larly spaced location s like th e above example, th e followin g code teach es in dividu al location s relative to th e frame: ; Get the locations to define the pallet frame DETACH () ;Release robot for use by the MCP PROMPT "Place robot at assembly origin. ", $ans HERE loc.origin ;Record the frame origin PROMPT "Place robot at point on the assm. x-axis. ", $ans HERE loc.x.axis ;Record point on x-axis PROMPT "Place robot at point in positive y direction. ", $ans HERE loc.pos.y ;Record positive y direction ; Create the local reference frame "assm.frame" SET assm.frame = FRAME(loc.origin, loc.x.axis, loc.pos.y, loc.origin) ; Teach the locations on the assembly PROMPT "Place the robot in the first location. ", $ans HERE assm.frame:loc.1 ;Record the first location PROMPT "Place the robot in the second location. ", $ans HERE assm.frame:loc.2 ;Record the second location ; etc. ; Move to the locations on the assembly ATTACH () ;Reattach the robot V+ Lan gu age User's Gu ide Page 1 7 7 Creatin g an d Alterin g Location Variables APPRO assm.frame:loc.1, 25 MOVE assm.frame:loc.1 ;Activate gripper DEPART 25 APPRO assm.frame:loc.1, 25 MOVE assm.frame:loc.2 ;Activate gripper DEPART 25 ; etc. In th e above example, th e frame mu st be tau gh t each time th e assembly moves­th e loca­ tion s on th e assembly mu st be tau gh t on ly on ce. Th e in stru ction HE RE assm.frame:loc.1 tells th e system to record th e location loc.1 relative to assm.frame rath er th an relative to th e world coordin ate frame. If a su bassembly is bein g bu ilt relative to loc.1 , th e in stru ction : HERE assm.frame:loc.1:sub.loc.1 creates a compou n d tran sformation wh ere su b.loc.1 is relative to th e tran sformation assm.frame:loc.1 . Miscellaneous Location Operations Th e in stru ction : DECOMPOSE array_name = #loc_name places th e join t valu es of #loc_ n ame in th e array array_ n ame. DE COMPOSE works with tran sformation s an d precision poin ts. Th e comman d: WHERE displays th e cu rren t robot location . Th e BASE operation can be u sed to realign th e world referen ce frame relative to th e robot. V+ Lan gu age User's Gu ide Page 1 7 8 Motion Con trol In stru ction s Motion Control Instructions V+ processes robot motion in stru ction s differen tly from th e way you migh t expect. With V+, a motion in stru ction su ch as MOVE part is in terpreted to mean start movin g th e robot to loca­ tion 'part'. As soon as th e robot starts movin g to th e specified destin ation , th e V+ program con tin u es with ou t waitin g for th e robot motion to complete. Th e in stru ction sequ en ce: MOVE part.1 SIGNAL 1 MOVE part.2 SIGNAL 2 cau ses extern al ou tpu t sign al #1 to be tu rn ed on immediately after th e robot begin s movin g to part.1 , rath er th an waitin g for it to arrive at th e location . Wh en th e secon d MOVE in stru c­ tion is en cou n tered, V+ waits u n til th e motion to part.1 is completed. E xtern al ou tpu t sign al #2 is tu rn ed on ju st after th e motion to part.2 begin s. Th is is kn own as forward processin g. See Breakin g Con tin u ou s­Path Operation for details on h ow to defeat forward processin g. Th is parallel operation of program execu tion an d robot motion makes possible th e procedu ral motion s described later in th is ch apter. Basic Motion Operations Join t-I n terpolated Motion vs. S traigh t-Lin e Motion Th e path a motion device takes wh en movin g from on e location to an oth er can be eith er a join t­in terpolated motion or a straigh t­lin e motion . Join t­in terpolated motion s move each join t at a con stan t velocity (except du rin g th e acceleration /deceleration ph ases­see Robot Speed). Typically, th e robot tool tip moves in a series of arcs th at represen ts th e least proc­ essin g­in ten sive path th e trajectory gen erator can formu late. Straigh t­lin e motion s en su re th at th e robot tool tip traces a straigh t lin e, u sefu l for cu ttin g a straigh t lin e or layin g a bead of sealan t. Th e in stru ction : MOVE pick cau ses th e robot to move to th e location pick u sin g join t­in terpolated motion . Th e in stru c­ tion : MOVES pick cau ses th e robot to move th e pick u sin g a straigh t­lin e motion . S afe Approach es an d Departu res In man y cases you will wan t to approach a location from a distan ce offset alon g th e tool Z axis or depart from a location alon g th e tool Z axis before movin g to th e n ext location . For example, if you were in sertin g compon en ts in to a crowded circu it board, you wou ld wan t th e robot arm to approach a location from directly above th e board so n earby parts are n ot dis­ tu rbed. Assu min g you were u sin g a fou r­axis Adept robot, th e in stru ction s: V+ Lan gu age User's Gu ide Page 1 7 9 Motion Con trol In stru ction s APPRO place, 50 MOVE place DEPART 50 cau ses join t­in terpolated motion to a poin t 5 0 mm above place, movemen t down to place, an d movemen t straigh t u p to 5 0 mm above place. If th e in stru ction s APPROS, DE PARTS, an d MOVE S h ad been u sed, th e motion s wou ld h ave been straigh t lin e in stead of join t in terpolated. NOTE:Approach es an d departs are based on th e tool coordin ate system, n ot th e world coordin ate system. Th u s, if th e location specifies a pitch of 1 3 5 relative to th e world coor­ din ate system. See Yaw n page 1 6 7 for a description of th e tool coordin ate system. o Movin g an I n dividu al Join t You can move an in dividu al join t of a robot u sin g th e in stru ction DRIVE . Th e in stru ction s: DRIVE 2,50.0, 100 DRIVE 3,25, 100 moves join t 2 th rou gh 5 0 SPE E D 1 0 0 %. E nd-E ffector Operation Instructions Th e in stru ction s described in th is section depen d on th e u se of two digital sign als. Th ey are u sed to open , close, or relax a gripper. Th e u tility program SPE C specifies wh ich sign als con trol th e en d effector. See th e In stru ction s for Adept Utility Programs. Th e in stru ction OPE N open s th e gripper du rin g th e en su in g motion in stru ction . Th e in stru c­ tion OPE NI open s th e gripper before an y addition al motion in stru ction s are execu ted. CLOSE an d CLOSE I are th e complemen tary in stru ction s. Wh en an OPE N(I) or CLOSE (I) in stru ction is issu ed, on e solen oid is activated an d th e oth er is released. To completely relax both solen oids, u se th e in stru ction RE LAX or RE LAXI. Use th e system parameter HAND.TIME to set th e du ration of th e motion delay th at occu rs du rin g an OPE NI, CLOSE I, or RE LAXI in stru ction . Use th e fu n ction HAND to retu rn th e cu rren t state of th e gripper. Continuous-Path T rajectories Wh en a sin gle motion in stru ction is processed, su ch as th e in stru ction : MOVE pick th e robot begin s movin g toward th e location by acceleratin g smooth ly to th e comman ded speed. Sometime later, wh en th e robot is close to th e destin ation location pick, th e robot V+ Lan gu age User's Gu ide Page 1 8 0 Motion Con trol In stru ction s decelerates smooth ly to a stop at location pick. Th is motion is referred to as a sin gle motion segmen t, sin ce it is produ ced by a sin gle motion in stru ction . Wh en a sequ en ce of motion in stru ction s is execu ted, su ch as: MOVE loc.1 MOVE loc.2 th e robot begin s movin g toward loc.1 by acceleratin g smooth ly to th e comman ded speed1 ju st as before. However, th e robot does n ot decelerate to a stop wh en it gets close to loc.1 . In stead, it smooth ly ch an ges its direction an d begin s movin g toward loc.2 . Fin ally, wh en th e robot is close to loc.2 , it decelerates smooth ly to a stop at loc.2 . Th is motion con sists of two motion segmen ts sin ce it is gen erated by two motion in stru ction s. Makin g smooth tran sition s between motion segmen ts with ou t stoppin g th e robot motion is called con tin u ou s­path operation . Th at is th e n ormal meth od V+ u ses to perform robot motion s. If desired, con tin u ou s­path operation can be disabled with th e CP switch . Wh en th e CP switch is disabled, th e robot decelerates an d stops at th e en d of each motion segmen t before begin n in g to move to th e n ext location . NOTE: Disablin g con tin u ou s­path operation does n ot affect forward processin g (th e par­ allel operation of robot motion an d program execu tion ). Con tin u ou s­path tran sition s can occu r between an y combin ation of straigh t­lin e an d join t­ in terpolated motion s. For example, a con tin u ou s motion cou ld con sist of a straigh t­lin e motion (for example, DE PARTS) followed by a join t­in terpolated motion (for example, APPRO) an d a fin al straigh t­lin e motion (for example, MOVE S). An y n u mber of motion seg­ men ts can be combin ed th is way. Breaking Continuous-Path Operation Certain V+ program in stru ction s cau se program execu tion to be su spen ded u n til th e cu rren t robot motion reach es its destin ation location an d comes to a stop. Th is is called breakin g con ­ tin u ou s path . Su ch in stru ction s are u sefu l wh en th e robot mu st be stopped wh ile some oper­ ation is performed (for example, closin g th e h an d). Con sider th e in stru ction sequ en ce: MOVE loc.1 BREAK SIGNAL 1 Th e MOVE in stru ction starts th e robot movin g to loc.1 . Program execu tion th en con tin u es an d th e BRE AK in stru ction is processed. BRE AK cau ses th e V+ program to wait u n til th e motion to loc.1 completes. Th e extern al sign al is n ot tu rn ed on u n til th e robot stops. (Recall th at with ou t th e BRE AK in stru ction th e sign al wou ld be tu rn ed on immediately after th e motion to loc.1 starts.) Th e followin g in stru ction s always cau se V+ to su spen d program execu tion u n til th e robot stops (see th e V+Lan gu age Referen ce Gu ide for detailed in formation on th ese in stru ction s): V+ Lan gu age User's Gu ide Page 1 8 1 Motion Con trol In stru ction s BASE BRE AK CLOSE I CPOFF DE TACH (0 ) HALT OPE NI PAUSE RE LAXI TOOL Also, th e robot decelerates to a stop wh en th e BRAKE (n ot to be con fu sed with BRE AK) in stru ction is execu ted (by an y program task), an d wh en th e reaction associated with a RE ACTI in stru ction is triggered. Th ese even ts cou ld h appen at an y poin t with in a motion seg­ men t. (Note th at th ese even ts can be in itiated from a differen t program task.) Th e robot also decelerates an d comes to a stop if n o n ew motion in stru ction is en cou n tered before th e cu rren t motion completes. Th is situ ation can occu r for a variety of reason s: l l l A WAIT or WAIT.E VE NT in stru ction is execu ted an d th e wait con dition is n ot satisfied before th e robot motion completes. A PROMPT in stru ction is execu ted an d n o respon se is en tered before th e robot motion completes. Th e V+ program in stru ction s between motion in stru ction s take lon ger to execu te th an th e robot takes to perform its motion . Procedural Motion Th e ability to move in straigh t lin es an d join t­in terpolated arcs is bu ilt in to th e basic operation of V+. Th e robot tool can also move alon g a path th at is prerecorded, or described by a math ­ ematical formu la. Su ch motion s are performed by programmin g th e robot trajectory as th e robot is movin g. Su ch a program is said to perform a procedu ral motion . A procedu ral motion is a program loop th at compu tes man y sh ort motion s an d issu es th e appropriate motion requ ests. Th e parallel execu tion of robot motion s an d n on ­motion in stru c­ tion s allows each su ccessive motion to be defin ed with ou t stoppin g th e robot. Th e con ­ tin u ou s­path featu re of V+ au tomatically smooth es th e tran sition s between th e compu ted motion segmen ts. Procedu ral Motion Examples Two simple examples of procedu ral motion s are described below. In th e first example, th e robot tool is moved alon g a trajectory described by location s stored in th e array path . (Th e LAST fu n ction is u sed to determin e th e size of th e array.) SPEED 0.75 IPS ALWAYS FOR index = 0 TO LAST(path) MOVES path[index] END Th e robot tool moves at th e con stan t speed of 0 .7 5 in ch per secon d th rou gh each location defin ed in th e array path . (On e way to create th e path array is to u se th e V+ TE ACH com­ man d to move th e robot alon g th e desired path an d to press repeatedly th e RE CORD bu tton on th e man u al con trol pen dan t.) V+ Lan gu age User's Gu ide Page 1 8 2 Motion Con trol In stru ction s In th e n ext example, th e robot tool is to be moved alon g a circu lar arc. However, th e path is n ot prerecorded­it is described math ematically, based on th e radiu s an d cen ter of th e arc to be followed. Th e program segmen t below assu mes th at a real variable radiu s h as already been assign ed th e radiu s of th e desired arc, an d x.cen ter an d y.cen ter h ave been assign ed th e respective coordin ates of th e cen ter of cu rvatu re. Th e variables start an d last are assu med to h ave been defin ed to describe th e portion of th e circle to be traced. Fin ally, th e variable an gle.step is assu med to h ave been defin ed to specify th e (an gu lar) in cremen t to be traversed in each in cremen tal motion . (Becau se th e DURATION in stru ction is u sed, th e program moves th e robot tool an gle.step degrees arou n d th e arc every 0 .5 secon d.) Wh en th is program segmen t is execu ted, th e X an d Y coordin ates of poin ts on th e arc are repeatedly compu ted. Th ey are th en u sed to create a tran sformation th at defin es th e des­ tin ation for th e n ext robot motion segmen t. DURATION 0.5 ALWAYS FOR angle = start TO last STEP angle.step x = radius*COS(angle)+x.center y = radius*SIN(angle)+y.center MOVE TRANS(x, y, 0, 0, 180, 0) END T iming Considerations Becau se of th e compu tation time requ ired by V+ to perform th e tran sition s between motion segmen ts, th ere is a limit on h ow closely spaced comman ded location s can be. Wh en loca­ tion s are too close togeth er, th ere is n ot en ou gh time for V+ to compu te an d perform th e tran sition from on e motion to th e n ext, an d th ere will be a break in th e con tin u ou s­path motion . Th is mean s th at th e robot stops momen tarily at in termediate location s. Th e min imu m spacin g th at can be u sed between location s before th is effect occu rs is deter­ min ed by th e time requ ired to complete th e motion from on e location to th e n ext. Straigh t­ lin e motion s can be u sed if th e motion segmen ts take more th an abou t 3 2 millisecon ds each . Join t­in terpolated motion s can be u sed with motion segmen ts as sh ort as abou t 1 6 mil­ lisecon ds each . NOTE:Th e stan dard trajectory gen eration frequ en cy is 6 2 .5 Hz. With an option al soft­ ware licen se, trajectory frequ en cies of 1 2 5 Hz, 2 5 0 Hz, an d 5 0 0 Hz are possible. Th e min imu m motion times for join t an d straigh t­lin e motion s mu st be greater th an or equ al to th e con figu red trajectory cycle time. As a con ven ien ce, if th ey are set to be less th an th e con figu red trajectory cycle time (for example 0 ), th e trajectory cycle time is u sed as th e min imu m motion time. V+ Lan gu age User's Gu ide Page 1 8 3 Motion Con trol In stru ction s Robot Speed A robot move h as th ree ph ases: an acceleration ph ase wh ere th e robot accelerates to th e maximu m speed specified for th e move, a velocity ph ase wh ere th e robot moves at a rate n ot exceedin g th e specified maximu m speed, an d a deceleration ph ase wh ere th e robot decel­ erates to a stop (or tran sition s to th e n ext motion ). Robot speed can mean two th in gs: h ow fast th e robot moves between th e acceleration an d deceleration ph ases of a motion (referred to in th is man u al as robot speed), or h ow fast th e robot gets from on e place to an oth er (referred to in th is man u al as robot performan ce). Th e robot speed between th e acceleration an d deceleration ph ases is specified as eith er a per­ cen tage of n ormal speed or an absolu te rate of travel of th e robot tool tip. Speed set as a per­ cen tage of n ormal speed is th e defau lt. Th e speed of a robot move based on n ormal speed is determin ed by th e followin g factors: l l Th e program speed (set with th e SPE E D program in stru ction ). Th is speed is set to 1 0 0 wh en program execu tion begin s. Th e mon itor speed (set with th e SPE E D mon itor comman d or a SPE E D program in stru ction th at specifies MONITOR). Th is speed is n ormally set to 5 0 at system startu p (start­u p SPE E D can be set with th e CONFIG_ C u tility). (Th e effects of th e two SPE E D operation s are sligh tly differen t. See th e SPE E D program in stru ction for fu rth er details.) Robot speed is th e produ ct of th ese two speeds. With mon itor speed an d program speed set to 1 0 0 , th e robot moves at its n ormal speed. With mon itor speed set to 5 0 an d program speed set to 5 0 , th e robot moves at 2 5 % of its n ormal speed. To move th e robot tool tip at an absolu te rate of speed, a speed rate in in ch es per secon d or millimeters per secon d is specified in th e SPE E D program in stru ction . Th e in stru ction : SPEED 25 MMPS ALWAYS specifies an absolu te tool tip speed of 2 5 millimeters per secon d for all robot motion s u n til th e n ext SPE E D in stru ction . In order for th e tool tip to actu ally move at th e specified speed: l l Th e mon itor speed mu st be 1 0 0 . Th e location s mu st be far en ou gh apart so th at th e robot can accelerate to th e desired speed an d decelerate to a stop at th e en d of th e motion . Robot performan ce is a fu n ction of th e SPE E D settin gs an d th e followin g factors: l Th e robot acceleration profile an d ACCE L settin gs. Th e defau lt acceleration profile is based on a n ormal maximu m rate of acceleration an d deceleration . Th e ACCE L com­ man d can scale down th ese maximu m rates so th at th e robot acceleration an d/or deceleration takes more time. You can also defin e option al acceleration profiles th at alter th e maximu m rate of ch an ge for acceleration an d deceleration (u sin g th e SPE C u tility) V+ Lan gu age User's Gu ide Page 1 8 4 Motion Con trol In stru ction s l l l l l Th e location toleran ce settin gs (COARSE /FINE , NULL/NONULL) for th e move. Th e more accu rately a robot mu st get to th e actu al location , th e more time th e move will take. (For AdeptMotion VME devices, th e mean in g of COARSE /FINE is set with th e SPE C u tility.) An y DURATION settin g. DURATION forces a robot move to take a min imu m time to complete regardless of th e SPE E D settin gs. Th e maximu m allowable velocity. For Adept robots, maximu m velocity is factory set. For AdeptMotion VME devices, th is is set with th e SPE C u tility. Th e in ertial loadin g of th e robot an d th e tu n in g of th e robot. Straigh t­lin e vs. join t­in terpolated motion s­for complex geometries, straigh t­lin e an d join t­in terpolated path s produ ce differen t dyn amic respon ses an d, th erefore, differen t motion times. Robot performan ce for a given application can be greatly en h an ced or severely degraded by th ese settin gs. For example: l l A h eavily loaded robot may actu ally sh ow better performan ce with slower SPE E D an d ACCE L settin gs, wh ich lessen s oversh oot at th e en d of a move an d allows th e robot to settle more qu ickly. Application s su ch as pickin g u p bags of produ ct with a vacu u m gripper do n ot requ ire h igh accu racy an d can gen erally ru n faster with a COARSE toleran ce. Motion Modifiers Th e followin g in stru ction s modify th e ch aracteristics of in dividu al motion s. Th ese in stru c­ tion s are su mmarized in Motion Con trol Operation s. NOTE:Th e in stru ction s listed below with an asterisk (* ) can take ALWAYS as an argu ­ men t. l l l l l l l l l l l l ABOVE /BE LOW ACCE L BRE AK COARSE /FINE * CPON/CPOFF DURATION* FLIP/NOFLIP LE FTY/RIGHTY NOOVE RLAP/OVE RLAP* NULL/NONULL* BRAKE SINGLE /MULTIPLE * SPE E D* V+ Lan gu age User's Gu ide Page 1 8 5 Motion Con trol In stru ction s Customizing the Calibration Routine Th e followin g in formation is requ ired on ly if you n eed to cu stomize th e calibration sequ en ce. Most AdeptMotion u sers do n ot n eed to do th is. Wh en a CALIBRATE comman d or in stru ction is processed, th e V+ system loads th e file CAL_ UTIL.V2 (see th e diction ary page for th e CALIBRATE comman d for details) an d execu tes a pro­ gram con tain ed in th at file. Th e main calibration program th en examin es th e SPE C data for th e robot to determin e th e n ame of th e disk file th at con tain s th e specific calibration program for th e cu rren t robot, an d th e n ame of th at program. Th e stan dard rou tin e u sed for AdeptMotion devices is stored on th e system disk in \CALIB\STANDARD.CAL (an d th e rou tin e is n amed .stan dard.cal). Th at file is protected an d th u s can n ot be viewed. However, a read­on ly copy of th e file is provided, in \CALIB\STA­ NDARD.V2 , as a basis for developin g a cu stom calibration rou tin e th at can th en be su b­ stitu ted for th e stan dard file. (Th e n ame of th e robot­specific calibration file an d program can be ch an ged u sin g th e SPE C u tility program.) 1See th e SPE E D m on itor com m an d an d SPE E D program in stru ction s. V+ Lan gu age User's Gu ide Page 1 8 6 Tool Tran sformation s Tool Transformations A tool tran sformation is a special tran sformation th at is u sed to accou n t for robot grippers (or parts h eld in grippers) th at are offset from th e cen ter of th e robot tool flan ge. If a location is tau gh t u sin g a part secu red by an offset gripper, th e actu al location recorded is n ot th e part location , bu t th e cen ter of th e tool flan ge to wh ich th e offset gripper is attach ed, as sh own in th e followin g figu re. If th e same location is tau gh t with a tool tran sformation in place, th e location recorded is th e cen ter of th e gripper, n ot th e cen ter of th e tool flan ge. Th is allows you to ch an ge grippers an d still h ave th e robot reach th e correct location . Th e followin g fig­ u re sh ows th e location of th e robot wh en a location is tau gh t an d th e actu al location th at is recorded wh en n o tool tran sformation is in effect. If th e proper tool tran sformation is in effect wh en th e location is tau gh t, th e location recorded will be th e part location an d n ot th e cen ter of th e tool flan ge. Recordin g Location s Defining a T ool T ransformation If th e dimen sion s of a robot tool are kn own , th e POINT comman d can be u sed to defin e a tool tran sformation to describe th e tool. Th e n u ll tool h as its cen ter at th e su rface of th e tool mou n tin g flan ge an d its coordin ate axes parallel to th at of th e last join t of th e robot. Th e n u ll tool tran sformation is equ al to [0 ,0 ,0 ,0 ,0 ,0 ]. V+ Lan gu age User's Gu ide Page 1 8 7 Tool Tran sformation s For example, if you r tool h as fin gers th at exten d 5 0 mm below th e tool flan ge an d 1 0 0 mm in th e tool x direction , an d you wan t to ch an ge th e tool settin g to compen sate for th e offset, en ter th e followin g lin es at th e system prompt (bold ch aracters in dicate th ose actu ally en tered): . POINT hand.tool X 0.00 Y 0.00 C h a n g e ? ,100,-50↵ 0.00 100.00 Change? ↵ . TOOL hand.tool↵ . LISTL hand.tool↵ X.jt1 0.00 ↵ Z 0.00 (create a new transformation) y p r 0.000 0.000 0.000 (alter it by the grip offset) -50.00 0.000 0.000 y/jt2 100.00 z/jt3 -50.00 y/jt4 0.000 p/jt5 0.000 0.000 r/jt6 0.000 Th e followin g image sh ows th e TOOL th at wou ld resu lt from th e above operation . Tool Tran sformation Tool tran sformation s are most importan t wh en : l Grippers are ch an ged frequ en tly l Th e robot is vision gu ided l Robot location s are loaded directly from CAD data V+ Lan gu age User's Gu ide Page 1 8 8 Su mmary of Motion Keywords Summary of Motion Keywords Th e followin g table su mmarizes th e keywords associated with motion in V+. For complete details on an y keyword, click on th e keyword n ame in th e table, or refer to th e keyword doc­ u men tation available in th e V+ Lan gu age Referen ce Gu ide. Motion Con trol Operation s Keyword Type Fu n ction ABOVE PI Requ est a ch an ge in th e robot con figu ration du rin g th e n ext motion so th at th e elbow is above th e lin e from th e sh ou lder to th e wrist. ACCE L PI Set acceleration an d deceleration for robot motion s. ACCE L RF Retu rn th e cu rren t robot acceleration or deceleration settin g. ALIGN PI Align th e robot tool Z axis with th e n earest world axis. ALTE R PI Specify th e magn itu de of th e real­time path mod­ ification th at is to be applied to th e robot path du rin g th e n ext trajectory compu tation . ALTOFF PI Termin ate real­time path ­modification mode (alter mode). ALTON PI E n able real­time path ­modification mode (alter mode), an d specify th e way in wh ich ALTE R coordin ate in for­ mation will be in terpreted. AMOVE PI Position an extra robot axis du rin g th e n ext join t­in ter­ polated or straigh t­lin e motion . APPRO PI Start join t­in terpolated robot motion toward a location defin ed relative to specified location . APPROS PI Start straigh t­lin e robot motion toward a location defin ed relative to specified location . BASE PI Tran slate an d rotate th e world referen ce frame rel­ ative to th e robot. BASE TF Retu rn th e tran sformation valu e th at represen ts th e tran slation an d rotation set by th e last BASE com­ man d or in stru ction . BE LOW PI Requ est a ch an ge in th e robot con figu ration du rin g th e n ext motion so th at th e elbow is below th e lin e from th e sh ou lder to th e wrist. BRAKE PI Abort th e cu rren t robot motion . V+ Lan gu age User's Gu ide Page 1 8 9 Su mmary of Motion Keywords BRE AK PI Su spen d program execu tion u n til th e cu rren t motion completes. CALIBRATE PI In itialize th e robot position in g system. CLOSE PI Close th e robot gripper immediately. CLOSE I PI Close th e robot gripper. COARSE PI E n able a low­precision featu re of th e robot h ardware servo (see FINE ). CONFIG RF Retu rn a valu e th at provides in formation abou t th e robot's geometric con figu ration , or th e statu s of th e motion servo­con trol featu res. CP S Con trol th e con tin u ou s­path featu re. CPOFF PI In stru ct th e V+ system to stop th e robot at th e com­ pletion of th e n ext motion in stru ction (for all su b­ sequ en t motion in stru ction s) an d n u ll position errors. CPON PI In stru ct th e V+ system to execu te th e n ext motion in stru ction (or all su bsequ en t motion in stru ction s) as part of a con tin u ou s path . DE COMPOSE PI E xtract th e (real) valu es of in dividu al compon en ts of a location valu e. DE LAY PI Cau se robot motion to stop for th e specified period of time. DE PART PI Start a join t­in terpolated robot motion away from th e cu rren t location . DE PARTS PI Start a straigh t­lin e robot motion away from th e cu r­ ren t location . DE ST TF Retu rn a tran sformation valu e represen tin g th e plan n ed destin ation location for th e cu rren t robot motion . DISTANCE RF Determin e th e distan ce between th e poin ts defin ed by two location valu es. DRIVE PI Move an in dividu al join t of th e robot. DRY.RUN S Con trol wh eth er or n ot V+ commu n icates with th e robot. DURATION PI Set th e min imu m execu tion time for su bsequ en t robot motion s. DURATION RF Retu rn th e cu rren t settin g of on e of th e motion DURA­ V+ Lan gu age User's Gu ide Page 1 9 0 Su mmary of Motion Keywords TION specification s. DX RF Retu rn th e X displacemen t compon en t of a given tran s­ formation valu e. DY RF Retu rn th e Y displacemen t compon en t of a given tran s­ formation valu e. DZ RF Retu rn th e Z displacemen t compon en t of a given tran s­ formation valu e. FINE PI E n able a h igh ­precision featu re of th e robot h ardware servo (see COARSE ). FLIP PI Requ est a ch an ge in th e robot con figu ration du rin g th e n ext motion so th at th e pitch an gle of th e robot wrist h as a n egative valu e (see NOFLIP). FORCE S Con trol wh eth er or n ot th e (option al) stop­on ­force fea­ tu re of th e V+ system is active. FRAME TF Retu rn a tran sformation valu e defin ed by fou r posi­ tion s. HAND RF Retu rn th e cu rren t h an d open in g. HAND.TIME P E stablish th e du ration of th e motion delay th at occu rs du rin g OPE NI, CLOSE I, an d RE LAXI in stru ction s. HE RE PI Set th e valu e of a tran sformation or precision ­poin t variable equ al to th e cu rren t robot location . HE RE TF Retu rn a tran sformation valu e th at represen ts th e cu r­ ren t location of th e robot tool poin t. HOUR.ME TE R RF Retu rn th e cu rren t valu e of th e robot h ou r meter. IDE NTICAL RF Determin e if two location valu es are exactly th e same. INRANGE RF Retu rn a valu e th at in dicates if a location can be reach ed by th e robot, an d if n ot, wh y n ot. INVE RSE TF Retu rn th e tran sformation valu e th at is th e math ­ ematical in verse of th e given tran sformation valu e. IPS CF Specify th e u n its for a SPE E D in stru ction as in ch es per secon d. LATCH TF Retu rn a tran sformation valu e represen tin g th e loca­ tion of th e robot at th e occu rren ce of th e last extern al trigger. LATCHE D RF Retu rn th e statu s of th e extern al trigger an d of th e in formation it cau ses to be latch ed. V+ Lan gu age User's Gu ide Page 1 9 1 Su mmary of Motion Keywords LE FTY PI Requ est a ch an ge in th e robot con figu ration du rin g th e n ext motion so th at th e first two lin ks of a SCARA robot resemble a h u man 's left arm (see RIGHTY). MMPS CF Specify th e u n its for a SPE E D in stru ction as mil­ limeters per secon d. MOVE PI In itiate a join t­in terpolated robot motion to th e posi­ tion an d orien tation described by th e given location . MOVE S PI In itiate a straigh t­lin e robot motion to th e position an d orien tation described by th e given location . MOVE F PI In itiate a th ree­segmen t pick­an d­place join t­in ter­ polated robot motion to th e specified destin ation , mov­ in g th e robot at th e fastest allowable speed. MOVE SF PI In itiate a th ree­segmen t pick­an d­place straigh t­lin e robot motion to th e specified destin ation , movin g th e robot at th e fastest allowable speed. MOVE T PI In itiate a join t­in terpolated robot motion to th e posi­ tion an d orien tation described by th e given location an d simu ltan eou sly operate th e h an d. MOVE ST PI In itiate a straigh t­lin e robot motion to th e position an d orien tation described by th e given location an d simu l­ tan eou sly operate th e h an d. MULTIPLE PI Allow fu ll rotation s of th e robot wrist join ts (see SIN­ GLE ). NOFLIP PI Requ est a ch an ge in th e robot con figu ration du rin g th e n ext motion so th at th e pitch an gle of th e robot wrist h as a positive valu e (see FLIP). NONULL PI In stru ct th e V+ system n ot to wait for position errors to be n u lled at th e en d of con tin u ou s­path motion s (see NULL). NOOVE RLAP PI Disable th e NOOVE RLAP limit­error ch eckin g (see OVE RLAP.) NORMAL TF Correct a tran sformation for an y math ematical rou n d­ off errors. NOT.CALIBRATE D P In dicate (or assert) th e calibration statu s of th e robots con n ected to th e system. NU L L TF Retu rn a n u ll tran sformation valu e­on e with all zero compon en ts. V+ Lan gu age User's Gu ide Page 1 9 2 Su mmary of Motion Keywords NU L L PI E n able n u llin g of join t position errors. OPE N PI Open th e robot gripper. OPE NI PI Open th e robot gripper immediately. OVE RLAP PI Gen erate a program error if a su bsequ en t motion s i plan n ed th at cau ses a selected mu lti­tu rn xis to a move more th an ±1 8 0 degrees to avoid a imit stop l (see NOOVE RLAP). PAYLOAD PI Set an in dication of th e cu rren t robot payload. #PDE ST PF Retu rn a precision ­poin t valu e represen tin g th e plan n ed destin ation location for th e cu rren t robot motion . #PHE RE PF Retu rn a precision ­poin t valu e represen tin g th e cu r­ ren t location of th e cu rren tly selected robot. #PLATCH PF Retu rn a precision ­poin t valu e represen tin g th e loca­ tion of th e robot at th e occu rren ce of th e last extern al trigger. POWE R S Con trol or mon itor th e statu s of Robot Power. #PPOINT PF Retu rn a precision ­poin t valu e composed from th e given compon en ts. RE ACTI PI In itiate con tin u ou s mon itorin g of a specified digital sig­ n al. Au tomatically stop th e cu rren t robot motion if th e sign al properly tran sition s an d option ally trigger a su b­ rou tin e call. RE ADY PI Move th e robot to th e RE ADY location above th e work­ space, wh ich forces th e robot in to a stan dard con ­ figu ration . RE LAX PI Limp th e pn eu matic h an d. RE LAXI PI Limp th e pn eu matic h an d immediately. RIGHTY PI Requ est a ch an ge in th e robot con figu ration du rin g th e n ext motion so th at th e first two lin ks of th e robot resemble a h u man 's righ t arm (see LE FTY). ROBOT S E n able or disable on e robot or all robots. RX TF Retu rn a tran sformation describin g a rotation abou t th e x axis. RY TF Retu rn a tran sformation describin g a rotation abou t th e y axis. V+ Lan gu age User's Gu ide Page 1 9 3 Su mmary of Motion Keywords RZ TF Retu rn a tran sformation describin g a rotation abou t th e z axis. SCALE TF Retu rn a tran sformation valu e equ al to th e tran s­ formation parameter with th e position scaled by th e scale factor. SCALE .ACCE L S E n able or disable th e scalin g of acceleration an d decel­ eration as a fu n ction of program speed. SCALE .ACCE L.ROT S Specify wh eth er or n ot th e SCALE .ACCE L switch takes in to accou n t th e Cartesian rotation al speed du rin g straigh t­lin e motion s. SE LE CT PI Select th e u n it of th e n amed device for access by th e cu rren t task. SE LE CT RF Retu rn th e n u mber of th e cu rren tly selected u n it of th e n amed device type. SE T PI Set th e valu e of th e location variable on th e left equ al to th e location valu e on th e righ t of th e equ al sign . SE T.SPE E D S Con trol wh eth er or n ot th e mon itor speed can be ch an ged from th e man u al con trol pen dan t. Th e mon ­ itor speed can n ot be ch an ged wh en th e switch is dis­ abled. SHIFT TF Retu rn a tran sformation valu e resu ltin g from sh iftin g th e position of th e tran sformation parameter by th e given sh ift amou n ts. SINGLE PI Limit rotation s of th e robot wrist join t to th e ran ge ­ 1 8 0 degrees to +1 8 0 degrees (see MULTIPLE ). SOLVE .ANGLE S PI Compu te th e robot join t position s (for th e cu rren t robot) th at are equ ivalen t to a specified tran s­ formation . SOLVE .FLAGS RF Retu rn bit flags represen tin g th e robot con figu ration specified by an array of join t position s. SOLVE .TRANS PI Compu te th e tran sformation equ ivalen t to a given set of join t position s for th e cu rren t robot. SPE E D PI Set th e n omin al speed for su bsequ en t robot motion s. SPE E D RF Retu rn on e of th e system motion speed factors. STATE RF Retu rn a valu e th at provides in formation abou t th e robot system state. TOOL PI Set th e in tern al tran sformation u sed to represen t th e V+ Lan gu age User's Gu ide Page 1 9 4 Su mmary of Motion Keywords location an d orien tation of th e tool tip relative to th e tool mou n tin g flan ge of th e robot. TOOL TF Retu rn th e valu e of th e tran sformation specified in th e last TOOL comman d or in stru ction . TRANS TF Retu rn a tran sformation valu e compu ted from th e given X, Y, Z position displacemen ts an d y, p, r orien ­ tation rotation s. PI: Program In stru ction , RF: Real­Valu ed Fu n ction , TF: Tran sformation Fu n ction , S: Switch , P: Parameter, PF: Precision ­Poin t Fu n ction , CF: Con version Factor V+ Lan gu age User's Gu ide Page 1 9 5 In pu t/Ou tpu t Operation s Input/Output Operations Terminal I/O Terminal TypesTerminal Types Input Processing O utput Processing Digital I/O High­Speed Interrupts Soft Signals Digital I/O and Third Party Boards Digital I/O and DeviceNet Pendant I/O Analog I/O Serial and Disk I/O Basics Logical Units Error Status Attaching/Detaching Logical Units Reading W riting Input W ait Modes O utput W ait Modes Disk I/O Attaching Disk Devices Disk I/O and the Network File System (NFS) Disk Directories Disk File O perations Open in g a Disk File Writin g to a Disk Readin g From a Disk Detach in g Disk I/O E xample Advanced Disk Operations V+ Lan gu age User's Gu ide Page 1 9 6 In pu t/Ou tpu t Operation s Variable­Length Records Fixed­Length Records Sequential­Access Files Random­Access Files Buffering and I/O O verlapping Disk Commands Accessing the Disk Directories AdeptNET Serial Line I/O I/O Configuration Attaching/Detaching Serial I/O Lines Input Processing O utput Processing Serial I/O E xamples DDCMP Communication Protocol General O peration Attaching/Detaching DDCMP Devices Input Processing O utput Processing Protocol Parameters Kermit Communication Protocol Starting a Kermit Session File Access Using Kermit Bin ary Files Kermit Line Errors System Parameters for KermitSystem Parameters for Kermit DeviceNet Summary of I/O Operations V+ Lan gu age User's Gu ide Page 1 9 7 Termin al I/O Terminal I/O Th e program in stru ction u sed to ou tpu t text to th e mon itor screen is TYPE . Th e program lin e: TYPE "This is a terminal output instruction." ou tpu ts th e text between th e qu otation marks to th e cu rren t cu rsor location . If a variable x h as a valu e of 2 7 , th e in stru ction : TYPE "The value of x is ", x, "." ou tpu ts The value of x is 27. to th e mon itor. Th e TYPE in stru ction h as qu alifiers for en terin g blan k spaces an d movin g th e cu rsor. Th e in stru ction : TYPE /C34, /U17, "This is the screen center." en ters 3 4 carriage retu rn s (clear th e screen ), move u p 1 7 lin es from th e bottom of th e screen , an d ou tpu t th e text message. Addition al qu alifiers are available to format th e ou tpu t of variables an d con trol termin al beh avior. Th e program in stru ction u sed to retrieve data in pu t from th e keyboard is PROMPT. Th e pro­ gram lin e: PROMPT "Enter a value for x: ", x h alts program execu tion an d wait for th e operator to en ter a valu e from th e keyboard (in th is case a real or in teger valu e). If a valu e of th e proper data type is en tered, th e valu e is assign ed to th e n amed variable (if th e variable does n ot exist, it is created an d assign ed th e valu e en tered) an d program execu tion proceeds. If an improper data type is en tered, th e sys­ tem gen erates an error message an d h alts execu tion . Strin g data is expected if a strin g var­ iable ($ x, for example) is specified. All termin al in pu t sh ou ld be verified for proper data type. Th e followin g code segmen t en su res th at a positive in teger is in pu t. (Usin g th e VAL() fu n ction also gu aran tees th at in ad­ verten tly en tered n on n u meric ch aracters do n ot cau se a system error.) DO PROMPT "Enter a value greater than 0: ", $x x = VAL($x) UNTIL x > 0 V+ Lan gu age User's Gu ide Page 1 9 8 Termin al I/O T erminal T ypes In order for V+ to ech o in pu t ch aracters properly an d to gen erate certain displays on ch ar­ acter­based termin als, th e type of termin al bein g u sed mu st be specified to th e system. Th e defau lt termin al type (wh ich is recorded on th e V+ system disk) is assu med each time th e V+ system is booted from disk.1 After th e system is booted, th e TE RMINAL system parameter can be set to specify a differen t termin al type. Input Processing Termin al in pu t is bu ffered by th e system bu t is n ot ech oed u n til it is actu ally read by th e V+ mon itor or by a program. A maximu m of 8 0 ch aracters can be received before V+ begin s to reject in pu t. Wh en in pu t is bein g rejected, V+ beeps th e termin al for each ch aracter reject­ ed. On in pu t, V+ may in tercept special ch aracters Ctrl+O, Ctrl+Q, an d Ctrl+S, an d u se th em to con trol termin al ou tpu t.2 Th ey can n ot be in pu t even by th e GE TC fu n ction . Th eir fu n ction s are sh own in th e followin g table. S pecial Ch aracter Codes Ch ar. Decimal Fu n ction Ctrl+O 15 Su ppress or stop su ppressin g ou tpu t Ctrl+Q 17 Resu me ou tpu t su spen ded by Ctrl+S Ctrl+S 19 Immediately su spen d termin al ou tpu t Wh en Ctrl+O is u sed to su ppress ou tpu t, all ou tpu t in stru ction s beh ave n ormally, except th at n o ou tpu t is sen t to th e termin al. Ou tpu t su ppression is can celed by typin g a secon d Ctrl+O, by V+ writin g a system error message, or by a termin al read requ est. Oth er special ch aracters are recogn ized by th e termin al in pu t h an dler wh en processin g a PROMPT or RE AD in stru ction , or wh en readin g a mon itor comman d. However, th ese ch ar­ acters can be read by th e GE TC fu n ction , in wh ich case th eir n ormal action is su ppressed. S pecial Ch aracter Codes Read by GETC Ch ar. Decimal Name Action Ctrl+C 03 Abort th e cu rren t mon itor comman d Ctrl+H 08 Backspace Delete th e previou s in pu t ch aracter Ctrl+I 09 Tab Move to th e n ext tab stop Ctrl+M 13 Retu rn Complete th is in pu t lin e V+ Lan gu age User's Gu ide Page 1 9 9 Termin al I/O Ctrl+R 18 Retype th e cu rren t in pu t lin e Ctrl+U 21 Delete th e en tire cu rren t lin e Ctrl+W 23 Start/stop slow ou tpu t mode Ctrl+Z 26 Complete th is in pu t with an en d of file error DE L 1207 Delete Delete th e previou s in pu t ch aracter Du rin g a PROMPT or RE AD in stru ction , all con trol ch aracters are ign ored except th ose listed above. Tab ch aracters are au tomatically con verted to th e appropriate n u mber of space ch ar­ acters wh en th ey are received. (Tab stops are assu med to be set every eigh t spaces [at col­ u mn s 9 , 1 7 , 2 5 ,...] an d can n ot be ch an ged.) Un like PROMPT, both RE AD an d GE TC requ ire th at th e termin al be ATTACHed. Normally, RE AD an d GE TC ech o in pu t ch aracters as th ey are processed. An option al mode argu men t for each of th ese operation s allows ech o to be su ppressed. Output Processing Ou tpu t to th e system termin al can be performed u sin g PROMPT, TYPE , or WRITE in stru c­ tion s. All eigh t­bit, bin ary, byte data is ou tpu t to th e termin al with ou t an y modification . TYPE an d WRITE au tomatically appen d a Retu rn ch aracter (1 3 decimal) an d Lin e Feed ch ar­ acter (1 0 decimal) to each data record, u n less th e /S format con trol is specified. PROMPT does n ot appen d an y ch aracters. Un like all th e oth er I/O devices, th e termin al does n ot h ave to be attach ed prior to ou tpu t requ ests. If a differen t task is attach ed to th e termin al, h owever, an y ou tpu t requ ests are qu eu ed u n til th e oth er task detach es. V+ system error messages are always displayed imme­ diately, regardless of th e statu s of termin al attach men t. 1Th e defau lt termin al type an d commu n ication ch aracteristics of th e serial lin e are set with th e con figu ration program in th e file CONFIG_ C.V2 on th e Adept Utility Disk. 2Term in al beh avior is con figu rable u sin g th e /FL USH an d /FL OW in stru ction . See th e V+Lan gu age Referen ce Gu ide. V+ Lan gu age User's Gu ide Page 2 0 0 argu men ts to th e FSE T Digital I/O Digital I/O Adept con trollers can commu n icate in a digital fash ion with extern al devices u sin g th e Digital I/O capability. Digital in pu t reads th e statu s of a sign al con trolled by u ser­in stalled equ ip­ men t. A typical digital in pu t operation is to wait for a microswitch on a workcell con veyor to close, in dicatin g th at an assembly is in th e proper place. Th e WAIT in stru ction an d SIG fu n c­ tion are u sed to h alt program execu tion u n til a digital in pu t ch an n el sign al ach ieves a spec­ ified state. Th e program lin e: WAIT SIG(1001) h alts program execu tion u n til a switch in g device attach ed to digital in pu t ch an n el 1 0 0 1 is closed. If sign al 1 0 0 2 is a sen sor in dicatin g a part feeder is empty, th e code: IF SIG(1002) THEN CALL service.feeder() END ch ecks th e sen sor state an d calls a rou tin e to service th e feeder if th e sen sor is on . Th e SIGNAL in stru ction is u sed for digital ou tpu t. In th e above example, th e con veyor belt may n eed to be stopped after digital in pu t sign al 1 0 0 1 sign als th at a part is in place. Th e in stru ction : SIGNAL(-33) tu rn s off digital ou tpu t sign al 3 3 , cau sin g th e con veyor belt con n ected to sign al 3 3 to stop. Wh en processin g on th e part is fin ish ed an d th e part n eeds to be moved ou t of th e work area, th e in stru ction : SIGNAL(33) tu rn s th e con veyor belt back on . Th e digital I/O ch an n els mu st be in stalled before th ey can be accessed by th e SIG fu n ction or SIGNAL in stru ction . Th e SIG.INS fu n ction retu rn s an in di­ cation of wh eth er a given sign al n u mber is available. Th e code lin e: IF SIG.INS(33) THEN can be u sed to en su re th at a digital sign al is available before you attempt to access it. Th e mon itor comman d IO displays th e statu s of all digital I/O ch an n els. For details on in stallin g digital I/O h ardware, see th e Adept SmartCon troller User's Gu ide or th e dept MV Con troller A User's Gu ide. Digital ou tpu t ch an n els are n u mbered from 1 to 5 1 2 . In pu t ch an n els are in th e ran ge 1 0 0 1 to 1 5 1 2 . Mu ltiple sign als can be tu rn ed ON or OFF with a sin gle in stru ction . SIGNAL(33),(-34),(35) or SIGNAL(-33),(34),(-35) V+ Lan gu age User's Gu ide Page 2 0 1 Digital I/O High-Speed Interrupts Normally, th e digital I/O system is ch ecked on ce every V+ major cycle (every 1 6 ms). In some cases, th e delay or u n certain ty resu ltin g may be u n acceptable. Digital sign als 1 0 0 1 ­ 1 0 0 4 can be con figu red as h igh ­speed in terru pts. Wh en a sign al con figu red as a h igh ­speed in ter­ ru pt tran sition s, its state is read at system in terru pt level, resu ltin g in a maximu m delay of 1 ms. Th e con troller con figu ration u tility CONFIG_ C is u sed to con figu re h igh ­speed in ter­ ru pts. See th e INT.E VE NT in stru ction in th e V+ Lan gu age Referen ce Gu ide for more in for­ mation Soft Signals Soft sign als are u sed primarily as global flags. Th e soft sign als are in th e ran ge 2 0 0 1 ­ 2 5 1 2 an d can be u sed with SIG an d SIGNAL. A typical u se of soft sign als is for in tertask com­ mu n ication . See " RE ACT an d E ACTI" an d th e RE ACT_ in stru ction s in th e V+ Lan gu age RefR eren ce Gu ide. Soft sign als may be u sed to commu n icate between differen t V+ systems ru n n in g on mu ltiple system processors.1 Digital I/O and T hird Party Boards Wh en V+ starts, defau lt blocks of system memory are assign ed to th e digital I/O system. V+ expects to fin d th e digital I/O image at th ese location s. If you are u sin g a th ird party digital I/O board, you mu st remap th ese memory location s to correspon d to th e actu al memory location of th e digital I/O image on you r board. See th e description of DE F.DIO in th e V+ Lan gu age Referen ce Gu ide for details. Digital I/O and DeviceNet Wh en V+ starts, defau lt blocks of system memory are assign ed to th e DeviceNet system. V+ expects to fin d th e DeviceNet image at th ese location s. For addition al in formation , see Device­ Net on page 2 3 3 . 1If you r system is equ ipped with mu ltiple system processors an d th e option al V+ E xten sion s software, you can ru n differen t copies of V+ on each processor. Use th e CONFIG_ C u tility to set u p mu ltiple V+ systems. V+ Lan gu age User's Gu ide Page 2 0 2 Pen dan t I/O Pendant I/O Most of th e stan dard V+ I/O operation s can be u sed to read data from th e man u al con trol pen dan t keypad an d to write data to th e pen dan t display. For in formation on accessin g th e man u al con trol pen dan t, see rogrammin g th e MCP on page 2 5 7 . P V+ Lan gu age User's Gu ide Page 2 0 3 An alog I/O Analog I/O Up to eigh t an alog I/O modu les for a total of 3 2 ou tpu t an d 2 5 6 in pu t ch an n els1 can be in stalled in an Adept MV con troller. Th e followin g figu re sh ows th e I/O ch an n el n u mbers for each in stalled modu le. An alog I/O modu les can be con figu red for differen t in pu t/ou tpu t ran ges. Th e actu al in pu t an d ou tpu t voltages are determin ed by settin g on th e AIO modu le. Regardless of th e in pu t/ou tpu t ran ge selected, th e AIO.IN fu n ction retu rn s a valu e in th e ­ 1 .0 to 1 .0 ran ge an d th e AIO.OUT in stru ction expects a valu e in th e ran ge ­1 .0 to 1 .0 . Addi­ tion ally, modu les can be con figu red for differen tial in pu t (wh ich redu ces th e maximu m n u mber of in pu t ch an n els to 1 2 8 ). Con tact Adept Application s for details on in stallin g an d con figu rin g an alog I/O boards2. See How Can I Get Help? on page 2 4 for con tact in formation . Th e in stru ction : analog.value = AIO.IN(1004) reads th e cu rren t state of an alog in pu t ch an n el 4 . Th e in stru ction : AIO.OUT 2 = 0.9 writes th e valu e 0 .9 to an alog ou tpu t ch an n el 2 . Th e in stru ction : IF AIO.INS (4) THEN AIO.OUT 4 = 0.56 END writes to ou tpu t ch an n el 4 on ly if ou tpu t ch an n el 4 is in stalled. An alog I/O Board Ch an n els V+ Lan gu age User's Gu ide Page 2 0 4 An alog I/O 1An alog I/O boards can be con figu red for differen tial in pu t rath er th an sin gle­en ded in pu t. Dif­ feren tial in pu t redu ces th e n u mber of ch an n els on a sin gle board from 3 2 to 1 6 . 2Th e an alog I/O board u sed by th e Adept MV con troller is su pplied by Xycom, In c. Th e model n u mber is XVME ­5 4 0 . Th e ph on e n u mber for Xycom is (8 0 0 ) 2 8 9 ­9 2 6 6 . V+ Lan gu age User's Gu ide Page 2 0 5 Serial an d Disk I/O Basics Serial and Disk I/O Basics Th e followin g section s describe th e basic procedu res th at are common to both serial an d disk I/O operation s. Disk I/O on page 2 1 0 covers disk I/O in detail. Serial Lin e I/O on page 2 1 9 cov­ ers serial I/O in detail. Logical Units All V+ serial an d disk I/O operation s referen ce an in teger valu e called a Logical Un it Nu mber or LUN. Th e LUN provides a sh orth an d meth od of iden tifyin g wh ich device or file is bein g ref­ eren ced by an I/O operation . See th e ATTACH comman d in th e V+Lan gu age Referen ce Gu ide for th e defau lt device LUN n u mbers. Disk devices are differen t from all th e oth er devices in th at th ey allow files to be open ed. E ach program task can h ave on e file open on each disk LUN. Th at is, each program task can h ave mu ltiple files open simu ltan eou sly (on th e same or differen t disk u n its). NOTE:No more th an 6 0 disk files can be open by th e en tire system at an y time. Th at in clu des files open ed by programs an d by th e system mon itor (for example, for th e FCOPY comman d). Th e error * Device n ot ready* resu lts if an attempt is made to open a 6 1 st file. For details on accessin g th e graph ics win dow LUNs, see Graph ics Programmin g n page 2 3 7 . o E rror Status Un like most oth er V+ in stru ction s, I/O operation s are expected to fail u n der certain cir­ cu mstan ces. For example, wh en readin g a file, an error statu s is retu rn ed to th e program to in dicate wh en th e en d of th e file is reach ed. Th e program is expected to h an dle th is error an d con tin u e execu tion . Similarly, a serial lin e may retu rn an in dication of a parity error, wh ich sh ou ld cau se th e program to retry a data tran smission sequ en ce. For th ese reason s, V+ I/O in stru ction s n ormally do n ot stop program execu tion wh en an error occu rs. In stead, th e su ccess or failu re of th e operation is saved in tern ally for access by th e IOSTAT real­valu ed fu n ction . For example, a referen ce to IOSTAT(5 ) retu rn s a valu e in di­ catin g th e statu s of th e last I/O operation performed on LUN 5 . Th e valu es retu rn ed by IOS­ TAT fall in to on e of followin g th ree categories: I OS TAT Retu rn Valu es Valu e Explan ation 1 Th e I/O operation completed su ccessfu lly. 0 Th e I/O operation h as n ot yet completed. Th is valu e appears on ly if a pre­read or n o­wait I/O is bein g performed. V+ Lan gu age User's Gu ide Page 2 0 6 Serial an d Disk I/O Basics <0 Th e I/O operation completed with an error. Th e error code in dicates wh at type of error occu rred. Th e error message associated with a n egative valu e from IOSTAT can be fou n d in th e V+Lan gu age Referen ce Gu ide. Th e $ E RROR strin g fu n ction can be u sed in a program (or with th e LISTS mon itor comman d) to gen erate th e text associated with most I/O errors. It is good practice to u se IOSTAT to ch eck each I/O operation performed, even if you th in k it can n ot fail (h ardware problems can cau se u n expected errors). NOTE:It is n ot n ecessary to u se IOSTAT after u se of a GE TC fu n ction , sin ce errors are retu rn ed directly by th e GE TC fu n ction . Attaching/Detaching Logical Units In gen eral, an I/O device mu st be attach ed u sin g th e ATTACH in stru ction before it can be accessed by a program. On ce a specific device (su ch as th e man u al con trol pen dan t) is attach ed by on e program task, it can n ot be u sed by an oth er program task. Most I/O requ ests fail if th e device associated with th e referen ced LUN is n ot attach ed. E ach program task h as its own sets of disk an d graph ics logical u n its. Th u s, more th an on e program task can attach th e same logical u n it n u mber in th ose grou ps at th e same time with ­ ou t in terferen ce. A ph ysical device type can be specified wh en th e logical u n it is attach ed. If a device type is specified, it su persedes th e defau lt, bu t on ly for th e logical u n it attach ed. Th e specified device type remain s selected u n til th e logical u n it is detach ed. An attach requ est can option ally specify immediate mode. Normally, an attach requ est is qu eu ed, an d th e callin g program is su spen ded if an oth er con trol program task is attach ed to th e device. Wh en th e device is detach ed, th e n ext attach men t in th e qu eu e will be processed. In immediate mode, th e ATTACH in stru ction completes immediately­with an error if th e requ ested device is already attach ed by an oth er con trol program task. With V+ systems, attach requ ests can also specify n o­wait mode. Th is mode allows an attach requ est to be qu eu ed with ou t forcin g th e program to wait for it to complete. Th e IOSTAT fu n c­ tion mu st th en be u sed to determin e wh en th e attach h as completed. If a task is already attach ed to a logical u n it, it will get an error immediately if it attempts to attach again with ou t detach in g, regardless of th e type of wait mode specified. Wh en a program is fin ish ed with a device, it detach es th e device with th e DE TACH program in stru ction . Th is allows oth er programs to process an y pen din g I/O operation s. Wh en a con trol program completes execu tion n ormally, all I/O devices attach ed by it are au to­ matically detach ed. If a program stops abn ormally, h owever, most device attach men ts are preserved. If th e con trol program task is resu med an d attempts to reattach th ese logical V+ Lan gu age User's Gu ide Page 2 0 7 Serial an d Disk I/O Basics u n its, it may fail becau se of th e attach men ts still in effect. Th e KILL mon itor comman d forces a program to detach all th e devices it h as attach ed. If attach ed by a program, th e termin al an d man u al con trol pen dan t are detach ed wh en ever th e program h alts or pau ses for an y reason , in clu din g error con dition s an d sin gle­step mode. If th e program is resu med, th e termin al an d th e man u al con trol pen dan t are au tomatically reattach ed if th ey were attach ed before th e termin ation . NOTE: It is possible th at an oth er program task cou ld h ave attach ed th e termin al or man ­ u al con trol pen dan t. Th at wou ld resu lt in an error message wh en th e stopped task is restarted. Reading Th e RE AD in stru ction processes in pu t from all devices. Th e basic RE AD in stru ction issu es a requ est to th e device attach ed on th e in dicated LUN an d waits u n til a complete data record is received before program execu tion con tin u es. (Th e len gth of th e last record read can be obtain ed with th e IOSTAT fu n ction with its secon d argu men t set to 2 .) Th e GE TC real­valu ed fu n ction retu rn s th e n ext data byte from an I/O device with ou t waitin g for a complete data record. It is common ly u sed to read data from th e serial lin es or th e sys­ tem termin al. It also can be u sed to read disk files in a byte­by­byte man n er. Special mode bits to allow readin g with n o ech o are su pported for termin al read operation s. Termin al in pu t also can be performed u sin g th e PROMPT in stru ction . Th e GE TE VE NT in stru ction can be u sed to read in pu t from th e system termin al. Th is may be u sefu l in writin g programs th at operate on both graph ics an d n on graph ics­based systems. To read data from a disk device, a file mu st be open on th e correspon din g logical u n it. Th e FOPE N_ in stru ction s open disk files. Writing Th e WRITE in stru ction processes ou tpu t to serial an d disk devices an d to th e termin al. Th e basic WRITE in stru ction issu es a requ est to th e device attach ed on th e in dicated LUN, an d waits u n til th e complete data record is ou tpu t before program execu tion con tin u es. WRITE in stru ction s accept format con trol specifiers th at determin e h ow ou tpu t data is for­ matted, an d wh eth er or n ot an en d of record mark sh ou ld be written at th e en d of th e rec­ ord. Termin al ou tpu t also can be performed u sin g th e PROMPT or TYPE in stru ction s. A file mu st be open u sin g th e FOPE NW or FOPE NA in stru ction s before data can be written to a disk device. FOPE NW open s a n ew file. FOPE NA open s an existin g file an d appen ds data to th at file. V+ Lan gu age User's Gu ide Page 2 0 8 Serial an d Disk I/O Basics Input Wait Modes Normally, V+ waits u n til th e data from an in pu t in stru ction is available before con tin u in g with program execu tion . However, th e RE AD in stru ction an d GE TC fu n ction accept an option al argu men t th at specifies n o­wait mode. In n o­wait mode, th ese in stru ction s retu rn imme­ diately with th e error statu s ­5 2 6 (No data received) if th ere is n o data available. A program can loop an d u se th ese operation s repeatedly u n til a su ccessfu l read is completed or u n til some oth er error is received. Th e disk devices do n ot recogn ize n o­wait mode on in pu t an d treat su ch requ ests as n ormal in pu t­with ­wait requ ests. Output Wait Modes Normally, V+ waits for each I/O operation to be completed before con tin u in g to th e n ext pro­ gram in stru ction . For example, th e in stru ction : TYPE /X50 cau ses V+ to wait for th e en tire record of 5 0 spaces to be tran smitted (abou t 5 0 millisecon ds with th e termin al set to 9 6 0 0 bau d) before con tin u in g to th e n ext program in stru ction . Similarly, WRITE in stru ction s to serial lin es or disk files will wait for an y requ ired ph ysical ou t­ pu t to complete before con tin u in g. Th is waitin g is n ot performed if th e /N (n o wait) format con trol is specified in an ou tpu t in stru c­ tion . In stead, V+ immediately execu tes th e n ext in stru ction . Th e IOSTAT fu n ction ch ecks wh eth er or n ot th e ou tpu t h as completed. It retu rn s a valu e of zero if th e previou s I/O is n ot complete. If a secon d ou tpu t in stru ction for a particu lar LUN is en cou n tered before th e first n o­wait oper­ ation h as completed, th e secon d in stru ction au tomatically waits u n til th e first is don e. Th is sch eme mean s th e n o­wait ou tpu t is effectively dou ble­bu ffered. If an error occu rs in th e first operation , th e secon d operation is can celed, an d th e IOSTAT valu e is correct for th e first oper­ ation . With V+, th e IOSTAT fu n ction can be u sed with a secon d argu men t of 3 to explicitly ch eck for th e completion of a n o­wait write. V+ Lan gu age User's Gu ide Page 2 0 9 Disk I/O Disk I/O Th e followin g section s discu ss disk I/O. Attaching Disk Devices A disk LUN refers to a local disk device, su ch as a 3 ­1 /2 in ch diskette drive, th e h ard disk on a SIO based system, or th e Compact Flash in an AWC (AdeptWin dows Con troller) system. Also, a remote disk may be accessed via th e Kermit protocol or a n etwork. Th e type of device to be accessed is determin ed by th e DE FAULT comman d or th e ATTACH in stru ction . If th e defau lt device type set by th e DE FAULT comman d is n ot appropriate at a particu lar time, th e ATTACH in stru ction can be u sed to override th e defau lt. Th e syn tax of th e ATTACH in stru ction is: ATTACH ( lun, m o d e ) $ d e v i c e See th e docu men tation for th e TTACH program in stru ction for th e mode option s an d pos­ A sible device n ames. Th e in stru ction : ATTACH (dlun, 4) "DISK" attach es to an available disk logical u n it an d retu rn s th e n u mber of th e logical u n it in th e var­ iable dlu n , wh ich can th en be u sed in oth er disk I/O in stru ction s. If th e device n ame is omitted from th e in stru ction , th e defau lt device for th e specified LUN is u sed. Adept recommen ds th at you always specify a device n ame with th e ATTACH in stru c­ tion . (Th e device SYSTE M refers to th e device specified with th e DE FAULT mon itor com­ man d.) On ce th e attach men t is made, th e device can n ot be ch an ged u n til th e logical u n it is detach ed. However, an y of th e u n its available on th e device can be specified wh en open in g a file. For example, th e V+ DISK u n its are A, C an d D. After attach in g a DISK device LUN, a pro­ gram can open an d close files on eith er of th ese disk u n its before detach in g th e LUN. Disk I/O and the Network File System (NFS) In addition to local disk devices, an Adept system equ ipped with th e option al E th ern et h ard­ ware an d th e TCP/IP an d NFS licen ses can mou n t remote disk drives. On ce mou n ted, th ese remote disk drives can be accessed in th e same fash ion as local disks. Th e followin g section s describe accessin g a disk drive regardless of wh eth er it is a local drive or a remotely mou n ted drive. See th e AdeptNet User's Gu ide for details on creatin g an NFS mou n t. Disk Directories Th e FOPE N_ in stru ction s, wh ich open disk files for readin g an d writin g, u se directory path s in th e same fash ion as th e mon itor comman ds LOAD, STORE , etc. Files on a disk are grou ped in directories. If a disk is th ou gh t of as a file cabin et, th en a directory can be th ou gh t of as a drawer in th at cabin et. Directories allow files (th e file folders in ou r file cabin et an alogy) th at V+ Lan gu age User's Gu ide Page 2 1 0 Disk I/O h ave some relation sh ip to each oth er to be grou ped togeth er an d separated from oth er files. See th e ch apter Usin g Files in th e V+ Operatin g System User's Gu ide for more details on th e directory stru ctu re. Disk File Operations All I/O requ ests to a disk device are made to a file on th at device. A disk file is a logical col­ lection of data records1 on a disk. E ach disk file h as a n ame, an d all th e n ames on a disk are stored in a directory on th e disk. Th e FDIRE CTORY mon itor comman d displays th e n ames of th e files on a disk. A disk file can be accessed eith er sequ en tially, wh ere data records are accessed from th e begin n in g of th e file to its en d, or ran domly, wh ere data records are accessed in an y order. Sequ en tial access is simplest an d is assu med in th is section . Ran dom access is described later in th is ch apter. Open in g a Disk File Before a disk file can be open ed, th e disk th e file is on mu st be ATTACHed. Th e FOPE N_ in stru ction s open disk files (an d file directories). Th ese in stru ction s associate a LUN with a disk file. On ce a file is open , th e RE AD, GE TC, an d WRITE in stru ction s access th e file. Th ese in stru ction s u se th e assign ed LUN to access th e file so th at mu ltiple files may be open on th e same disk an d th e I/O operation s for th e differen t disk files will n ot affect each oth er.2 Th e simplified syn tax for FOPE N_ is: FOPEN_ (lun)file_spec wh ere: lu n logical u n it n u mber u sed in th e ATTACH in stru ction file_ spec file specification in th e form, u n it:path \filen ame.ext u n it is an option al disk u n it n ame. Th e stan dard local disk u n its are A, C, an d D. If n o u n it is specified, th e colon also mu st be omitted. Th en th e defau lt u n it (as deter­ min ed by th e DE FAULT comman d) is assu med. path \ is an option al directory path strin g. Th e directory path is defin ed by on e or more directory n ames, each fol­ lowed by a \ ch aracter. Th e actu al directory path is determin ed by combin in g an y specified path with th e path set by th e DE FAULT comman d. If path is pre­ ceded with a \, th e path is absolu te. Oth erwise, th e path is relative an d is added to th e cu rren t DE FAULT path specification . (If u n it is specified an d is differen t from th e defau lt u n it, th e path is always absolu te.) V+ Lan gu age User's Gu ide Page 2 1 1 Disk I/O filen ame is a n ame with 1 to 8 ch aracters, wh ich is u sed as th e n ame of th e file on th e disk. ext is th e filen ame exten sion ­a strin g with 0 to 3 ch ar­ acters, wh ich is u sed to iden tify th e file type. Th e fou r open comman ds are: 1 . Open for read on ly (FOPE NR). If th e disk file does n ot exist, an error is retu rn ed. No write operation s are allowed, so data in th e file can n ot be modified. 2 . Open for write (FOPE NW). If th e disk file already exists, an error is retu rn ed. Oth er­ wise, a n ew file is created. Both read an d write operation s are allowed. 3 . Open for appen d (FOPE NA). If th e disk file does n ot exist, a n ew file is created. Oth er­ wise, an existin g file is open ed. No error is retu rn ed in eith er case. A sequ en tial write or a ran dom write with a zero record n u mber appen ds data to th e en d of th e file. 4 . Open for directory read (FOPE ND). Th e last directory in th e specified directory path is open ed. On ly read operation s are allowed. E ach record read retu rn s an ASCII strin g con tain in g directory in formation . Directories sh ou ld be open ed u sin g variable­len gth sequ en tial­access mode. Wh ile a file is open for write or appen d access, an oth er con trol program task can n ot access th at file. However, mu ltiple con trol program tasks can access a file simu ltan eou sly in read­ on ly mode. W ritin g to a Disk Th e in stru ction : WRITE (dlun) $in.string writes th e strin g stored in $ in .strin g to th e disk file open on dlu n . Th e in stru ction : error = IOSTAT(dlun) retu rn s an y errors gen erated du rin g th e write operation . Readin g From a Disk Th e in stru ction : READ (dlun) $in.string reads (from th e open file on dlu n ) u p to th e first CR/LF (or en d of file if it is en cou n tered) an d store th e resu lt in $ in .strin g. Wh en th e en d of file is reach ed, V+ error n u mber ­5 0 4 Un expected en d of file is gen erated. Th e IOSTAT() fu n ction mu st be u sed to recogn ize th is error an d h alt readin g of th e file: V+ Lan gu age User's Gu ide Page 2 1 2 Disk I/O DO READ (dlun) $in.string TYPE $in.string UNTIL IOSTAT(dlun) == -504 Th e GE TC fu n ction reads th e file byte by byte if you wan t to examin e in dividu al bytes from th e file (or if th e file is n ot delimited by CR/LFs). Detach in g Wh en a disk logical u n it is detach ed, an y disk file th at was open on th at u n it is au tomatically closed. However, error con dition s detected by th e close operation may n ot be reported. Th ere­ fore, it is good practice to u se th e FCLOSE in stru ction to close files an d to ch eck th e error statu s afterwards. FCLOSE en su res th at all bu ffered data for th e file is written to th e disk, an d u pdates th e disk directory to reflect an y ch an ges made to th e file. Th e DE TACH in stru ction frees u p th e logical u n it. Th e followin g in stru ction s close a file an d detach a disk LUN: FCLOSE (dlun) IF IOSTAT(dlun) THEN TYPE $ERROR(IOSTAT(dlun)) END DETACH (dlun) Wh en a program completes n ormally, an y open disk files are au tomatically closed. If a pro­ gram stops abn ormally an d execu tion does n ot proceed, th e KILL mon itor comman d closes an y files left open by th e program. CAUTI ON: Wh ile a file is open on a floppy disk, do n ot replace th e floppy disk with an oth er disk: Data may be lost an d th e n ew disk may be corru pted. Disk I /O Example Th e followin g example creates a disk file, writes to th e file, closes th e file, reopen s th e file, an d reads back its con ten ts. AUTO dlun, i AUTO $file.name $file.name = "data.tst" ; Attach to a disk logical unit ATTACH (dlun, 4) "DISK" IF IOSTAT(dlun) < 0 GOTO 100 ; Open a new file and check status FOPENW (dlun) $file.name IF IOSTAT(dlun) < 0 GOTO 100 V+ Lan gu age User's Gu ide Page 2 1 3 Disk I/O ; Write the text FOR i = 1 TO 10 WRITE (dlun) "Line "+$ENCODE(i) IF IOSTAT(dlun) < 0 GOTO 100 END ; Close the file FCLOSE (dlun) IF IOSTAT(dlun) < 0 GOTO 100 ; Reopen the file and read its contents FOPENR (dlun) $file.name IF IOSTAT(dlun) < 0 GOTO 100 READ (dlun) $txt WHILE IOSTAT(dlun) > 0 DO TYPE $txt READ (dlun) $txt END ;End of file or error IF (IOSTAT(dlun) < 0) AND (IOSTAT(dlun) <> -504) THEN 100 TYPE $ERROR(IOSTAT(dlun)) ;Report any errors END FCLOSE (dlun) ;Close the file IF IOSTAT(dlun) < 0 THEN TYPE $ERROR(IOSTAT(dlun)) END DETACH (dlun) 1A variable­len gth record is a text strin g termin ated by a CR/LF (ASCII 1 3 /ASCII 1 0 ). 2Wh en accessin g files on a remote system (for example, wh en u sin g Kermit), th e u n it can be an y n ame strin g, an d th e file n ame an d exten sion can be an y arbitrary strin g of ch aracters. V+ Lan gu age User's Gu ide Page 2 1 4 Advan ced Disk Operation s Advanced Disk Operations Th is section in trodu ces addition al parameters to th e FOPE N an d FOPE NR program in stru c­ tion s. For details, see th e OPE N an d OPE NR docu men tation in th e + Lan gu age Referen ce F F V Gu ide for details. Variable-Length Records Th e defau lt disk file access mode is variable­len gth record mode. In th is mode, records can h ave an y len gth (u p to a maximu m of 5 1 2 bytes) an d can cross th e bou n daries of 5 1 2 ­byte sectors. Th e en d of a record is in dicated by a Lin e­Feed ch aracter (ASCII 1 0 ). Also, th e en d of th e file is in dicated by th e presen ce of a Ctrl+Z ch aracter (2 6 decimal) in th e file. Variable­ len gth records sh ou ld n ot con tain an y in tern al Lin e­Feed or Ctrl+Z ch aracters as data. Th is format is u sed for loadin g an d storin g V+ programs, an d is compatible with th e IBM PC stan d­ ard ASCII file format. Variable­len gth record mode is selected by settin g th e record len gth parameter in th e FOPE N_ in stru ction to zero, or by omittin g th e parameter completely. In th is mode, WRITE in stru ction s au tomatically appen d Retu rn (ASCII 1 3 ) an d Lin e­Feed ch aracters to th e ou tpu t data­wh ich makes it a complete record. If th e /S format con trol is specified in an ou tpu t spec­ ification , n o Retu rn /Lin e­Feed is appen ded. Th en an y su bsequ en t WRITE will h ave its data con caten ated to th e cu rren t data as part of th e same record. If th e /Cn format con trol is spec­ ified, n Retu rn /Lin e­Feeds are written , creatin g mu ltiple records with a sin gle WRITE . Wh en a variable­len gth record is read u sin g a RE AD in stru ction , th e Retu rn /Lin e­Feed sequ en ce at th e en d is removed before retu rn in g th e data to th e V+ program. If th e GE TC fu n ction is u sed to read from a disk file, all ch aracters are retu rn ed as th ey appear in th e file­ in clu din g Retu rn , Lin e­Feed, an d Ctrl+Z ch aracters. Fixed-Length Records In fixed­len gth record mode, all records in th e disk file h ave th e same specific len gth . Th en th ere are n o special ch aracters embedded in th e file to in dicate wh ere records begin or en d. Records are con tigu ou s an d may freely cross th e bou n daries of 5 1 2 ­byte sectors. Fixed­len gth record mode is selected by settin g th e record len gth parameter in th e FOPE N_ in stru ction to th e size of th e record, in bytes. WRITE in stru ction s th en pad data records with zero bytes or tru n cate records as n ecessary to make th e record len gth th e size specified. No oth er data bytes are appen ded, an d th e /S format con trol h as n o effect. In fixed­len gth mode, RE AD in stru ction s always retu rn records of th e specified len gth . If th e len gth of th e file is su ch th at it can n ot be divided in to an even n u mber of records, a RE AD of th e last record will be padded with zero bytes to make it th e correct len gth . Sequential-Access Files Normally, th e records with in a disk file are accessed in order from th e begin n in g to th e en d with ou t skippin g an y records. Su ch files are called sequ en tial files. Sequ en tial­access files V+ Lan gu age User's Gu ide Page 2 1 5 Advan ced Disk Operation s may con tain eith er variable­len gth or fixed­len gth records. Random-Access Files In some application s, disk files n eed to be read or written in a n on sequ en tial or ran dom order. V+ su pports ran dom access on ly for files with fixed­len gth records. Records are n u mbered startin g with 1 . Th e position of th e first byte in a ran dom­access record can be compu ted by: byte_position = 1 + (record_number -1) * record_length Ran dom access is selected by settin g th e ran dom­access bit in th e mode parameter of th e FOPE N_ in stru ction . A n on zero record len gth mu st also be specified. A specific record is accessed by specifyin g th e record n u mber in a RE AD or WRITE in stru ction . If th e record n u mber is omitted, or is zero, th e record followin g th e on e last accessed is u sed. (See th e OPE N docu men tation .) F Buffering and I/O Overlapping All ph ysical disk I/O occu rs as 5 1 2 ­byte sector reads an d writes. Records are u n packed from th e sector bu ffer on in pu t, an d addition al sectors are read as n eeded to complete a record. To speed u p read operation s, V+ au tomatically issu es a read requ est for th e n ext sector wh ile it is processin g th e cu rren t sector. Th is requ est is called a preread. Preread is selected by defau lt for both sequ en tial­access an d ran dom­access modes. It can be disabled by settin g a bit in th e mode parameter of th e FOPE N_ in stru ction . If prereads are en abled, open in g a file for read access immediately issu es a read for th e first sector in th e file. Preread operation s may actu ally degrade system performan ce if records are accessed in tru ly ran dom order, sin ce sectors wou ld be read th at wou ld n ever be u sed. In th is case, prereads sh ou ld be disabled an d th e FSE E K in stru ction sh ou ld be u sed to in itiate a preread of th e n ext record to be u sed. Th e fu n ction IOSTAT(lu n , 1 ) retu rn s th e completion statu s for a pen din g preread or FSE E K operation . On ou tpu t, records are packed in to sector bu ffers an d written after th e bu ffers are filled. If n o­ wait mode is selected for a write operation by u sin g th e /N format con trol, th e WRITE in stru c­ tion does n ot wait for a sector to be written before allowin g program execu tion to con tin u e. In ran dom­access mode, a sector bu ffer is n ot n ormally written to disk u n til a record n ot con ­ tain ed in th at bu ffer is accessed. Th e FE MPTY in stru ction empties th e cu rren t sector bu ffer by immediately writin g it to th e disk. A file may be open ed in n on bu ffered mode, wh ich is mu ch slower th an n ormal bu ffered mode, bu t it gu aran tees th at in formation th at is written will n ot be lost du e to a system crash or power failu re. Th is mode was in ten ded primarily for u se with log files th at are left open ed over an exten ded period of time an d in termitten tly u pdated. For th ese types of files, th e addition al (sign ifican t) overh ead of th is mode is n ot as importan t as th e ben efit. V+ Lan gu age User's Gu ide Page 2 1 6 Advan ced Disk Operation s Wh en a file is bein g created, in formation abou t th e file size is n ot stored in th e disk directory u n til th e file is closed. Closin g a file also forces an y partial sector bu ffers to be written to th e disk. Note th at abortin g a program does n ot force files associated with it to be closed. Th e files are n ot closed (an d th e directory is n ot u pdated) u n til a KILL comman d is execu ted or u n til th e aborted program is execu ted again . Disk Commands Th ere are several disk­orien ted mon itor comman ds th at do n ot h ave a correspon din g pro­ gram in stru ction . Th e FCMND in stru ction mu st be u sed to perform th e followin g action s from with in a program: l Ren ame a file l Format a disk l Create a su bdirectory l Delete a su bdirectory Th e MCS in stru ction can be u sed to issu e an FCOPY comman d from with in a program. FCMND is similar to oth er disk I/O in stru ction s in th at a logical u n it mu st be attach ed an d th e su ccess or failu re of th e comman d is retu rn ed via th e IOSTAT real­valu ed fu n ction . For details, see th e docu men tation for th e CMND program in stru ction . F Th e FCMND in stru ction is described in detail in th e V+ Lan gu age Referen ce Gu ide. See th e Adept MV Con troller User's Gu ide Accessing the Disk Directories Th e V+ directory stru ctu re is iden tical to th at u sed by th e IBM PC DOS operatin g system (ver­ sion 2 .0 an d later). For each file, th e directory stru ctu re con tain s th e file n ame, attribu tes, creation time an d date, an d file size. Directory en tries may be read after su ccessfu lly execu t­ in g an FOPE ND in stru ction . E ach directory record retu rn ed by a RE AD in stru ction con tain s an ASCII strin g with th e in for­ mation sh own in th e followin g table. Disk Directory Format Byte S ize Description 1 ­8 8 ASCII file n ame, padded with blan ks on righ t 9 1 ASCII period ch aracter (4 6 decimal) 1 0 ­1 2 3 ASCII file exten sion , padded with blan ks on righ t 1 3 ­2 0 8 ASCII file size, in sectors, righ t ju stified V+ Lan gu age User's Gu ide Page 2 1 7 Advan ced Disk Operation s 21 1 ASCII space ch aracter (3 2 decimal) 2 2 ­2 8 7 Attribu te codes, padded with blan ks on righ t 2 9 ­3 7 9 File revision date in th e format dd­mm­yy 38 1 ASCII space ch aracter (3 2 decimal) 3 9 ­4 6 8 File revision time in th e format h h :mm:ss Th e followin g ch aracters are possible in th e file attribu te code field of directory en tries: File Attribu te Codes Ch aracter Mean in g D E n try is a su bdirectory L E n try is th e volu me label (n ot su pported by V+) P File is protected an d can n ot be read or modified R File is read­on ly an d can n ot be modified S File is a system file Th e attribu te field is blan k if n o special attribu tes are in dicated. Th e file revision date an d time fields are blan k if th e system date an d time h ad n ot been set wh en th e file was created or last modified. (Th e system date an d time are set with th e TIME mon itor comman d or program in stru ction .) AdeptNE T AdeptNE T provides th e ability to perform TCP/IP commu n ication s with oth er equ ipmen t, per­ form NFS mou n ts on remote disks, an d perform FTP tran sfers of files between local an d remote disks. See th e AdeptNet User's Gu ide for details. V+ Lan gu age User's Gu ide Page 2 1 8 Serial Lin e I/O Serial Line I/O Th e V+ con troller h as several serial lin es th at are available for gen eral u se. Th is section describes h ow th ese lin es are u sed for simple serial commu n ication s. To u se a serial lin e for a special protocol su ch as DDCMP an d Kermit (described later in th is ch apter), th e lin e mu st be con figu red u sin g th e Adept con troller con figu ration u tility program.1 I/O Configuration In addition to selectin g th e protocol to be u sed, th e Adept con troller con figu ration program allows th e bau d rate an d byte format for each serial lin e to be defin ed. On ce th e serial lin e con figu ration is defin ed on th e V+ system boot disk, th e serial lin es are set u p au tomatically wh en th e V+ system is loaded an d in itialized. After th e system is ru n n in g, th e FSE T program in stru ction can be u sed to recon figu re th e serial lin es. Th e followin g byte formats are avail­ able: l Byte data len gth of 7 or 8 bits, n ot in clu din g parity l On e or two stop bits l Parity disabled or en abled l Odd or even parity (adds 1 bit to byte len gth ) Th e followin g bau d rates are available: 110, 300, 600, 1200, 2400, 4800, 7200, 9600, 19200, 38400 In addition , V+ provides au tomatic bu fferin g with option al flow con trol for each serial lin e. Th e I/O con figu ration program can be u sed to en able ou tpu t flow con trol with wh ich V+ rec­ ogn izes Ctrl+S (1 9 decimal) an d Ctrl+Q (1 7 decimal) an d u ses th em to su spen d an d resu me, respectively, serial lin e ou tpu t. Th e con figu ration program can also en able in pu t flow con trol, with wh ich V+ gen erates Ctrl+S an d Ctrl+Q to su spen d an d resu me, respectively, in pu t from an extern al sou rce. With Ctrl+S an d Ctrl+Q flow con trol disabled, all in pu t an d ou tpu t is totally tran sparen t, an d all 8 ­bit data bytes can be sen t an d received. Serial lin es may also be con figu red to u se h ardware modem con trol lin es for flow con trol. (Th e RTS/CTS lin es mu st be in stalled in th e modem cable­stan dard modem cables often leave th ese lin es ou t.) For pin assign men ts, see th e docu men tation on serial I/O con n ectors in th e u ser gu ide for you r con troller: Adept SmartCon troller User's Gu ide or Adept MV Con troller User's Gu ide. Attaching/Detaching Serial I/O Lines Serial lin es mu st be attach ed before an y I/O operation s can take place. Note th at on ly on e con trol program task can be attach ed to a sin gle serial lin e at an y on e time. All oth er attach ­ men t requ ests will qu eu e or fail, depen din g on th e settin g of th e mode parameter in th e ATTACH program in stru ction s. V+ Lan gu age User's Gu ide Page 2 1 9 Serial Lin e I/O Attach in g or detach in g a serial lin e au tomatically stops an y ou tpu t in progress an d clears all in pu t bu ffers. Serial lin es are n ot au tomatically detach ed from a program u n less it completes with su ccess, so it is possible to sin gle­step th rou gh a program or proceed from a PAUSE in stru ction with ou t loss of data. Input Processing In pu t data is received by V+ accordin g to th e byte format specified by th e I/O con figu ration program. Th e size of th e bu ffer can be set with th e CONFIG_ C u tility program. Data errors su ch as parity or framin g errors are also bu ffered an d are retu rn ed in th e proper order. Th e possible data errors from th e serial in pu t lin es are: ­5 2 2 * Data error on device* A data byte was received with in correct parity, or th e byte gen erated a framin g error. ­5 2 4 * Commu n ication s overru n * Data bytes were received after th e in pu t bu ffer was fu ll, or faster th an V+ cou ld process th em. ­5 2 6 * No data received* If data is expected, con tin u e pollin g th e serial lin e. ­5 0 4 * Un expected en d of file* A BRE AK was received from th e remote device. Serial lin e in pu t data is n ormally read u sin g th e GE TC fu n ction , sin ce it allows th e most flex­ ible respon se to commu n ication s errors. Th e RE AD in stru ction also can be u sed provided th at in pu t data is termin ated by a Lin e­Feed ch aracter (1 0 decimal). V+ does n ot su pport in pu t ech oin g or in pu t lin e editin g for th e serial lin es. Output Processing All serial lin e ou tpu t is performed u sin g th e WRITE in stru ction . All bin ary data (in clu din g NULL ch aracters) is ou tpu t with ou t con version . If th e serial lin e is con figu red to su pport parity, a parity bit is au tomatically appen ded to each data byte. By defau lt, th e WRITE in stru ction appen ds a Retu rn ch aracter (1 3 decimal) an d a Lin e­Feed ch aracter (1 0 decimal) to each data record u n less th e /S format con trol is specified in th e in stru ction parameter list. If ou tpu t flow con trol is en abled an d ou tpu t h as been su spen ded by a Ctrl+S ch aracter from th e remote device, a WRITE requ est may wait in defin itely before completin g. V+ Lan gu age User's Gu ide Page 2 2 0 Serial Lin e I/O S erial I /O Examples Th e first example attach es to a serial lin e an d performs simple WRITE s an d RE ADs on th e lin e: .PROGRAM serial.io() ; ABSTRACT: Example program to write and read lines of ; text to and from serial port 1 on the SIO module. AUTO slun ;Logical unit to communicate to serial port AUTO $text ; Attach to a logical unit(open communications path ; to serial port) ATTACH (slun, 4) "SERIAL:1" IF IOSTAT(slun) < 0 GOTO 100 ; Write text out to the serial port WRITE (slun) "Hello there! " IF IOSTAT(slun) < 0 GOTO 100 ; ; ; ; Read line line text a line of text from the serial port. The incoming of text must be terminated by a carriage return and feed. The READ instruction will wait until a line of is received. READ (slun) $text IF IOSTAT(slun) < 0 GOTO 100 ; Display any errors 100 IF (IOSTAT(slun) < 0) THEN TYPE IOSTAT(slun), " ", $ERROR(IOSTAT(slun)) END DETACH (slun) ;Detach from logical unit .END Th e n ext example reads data from a serial lin e u sin g th e GE TC fu n ction with n o­wait mode. Records th at are received are displayed on th e termin al. In th is program, data records on th e serial lin e are assu med to be termin ated by an E TX ch aracter, wh ich is n ot displayed. An empty record termin ates th e program. .PROGRAM display() ; ABSTRACT: Monitor a serial line and read ; available AUTO $buffer, c, done, etx, ienod, etx = 3 ;ASCII ienod = -526 ;Error ATTACH (line, 4) "SERIAL:1" IF IOSTAT(line) < 0 GOTO 90 ;Check data when line code for ETX character code for no data for errors V+ Lan gu age User's Gu ide Page 2 2 1 Serial Lin e I/O $buffer = "" ;Initialize buffer to empty done = FALSE ;Assert not done DO CLEAR.EVENT c = GETC(line,1) ;Read byte from the ser. line WHILE c == ienod DO ;While there is no data... WAIT.EVENT 1 ;Wait for an event CLEAR.EVENT c = GETC(line,1) ;Read byte from the ser. line END IF c < 0 GOTO 90 ;Check for errors IF c == etx THEN ;If ETX seen... TYPE $buffer, /N ;Type buffer done = (LEN($buffer) == 0) ;Done if buffer length is 0 $buffer = "" ;Set buffer to empty ELSE $buffer = $buffer+$CHR(c) ;Append next byte ;to buffer END UNTIL done 90 100 ;Loop until empty buffer seen GOTO 100 ;Exit TYPE "SERIAL LINE I/O ERROR: ", $ERROR(IOSTAT(line)) PAUSE DETACH (line) RETURN .END 1Th e con troller con figu ration u tility is available in th e file CONFIG_ C.V2 . V+ Lan gu age User's Gu ide Page 2 2 2 DDCMP Commu n ication Protocol DDCMP Communication Protocol DDCMP is a rigorou s protocol th at au tomatically h an dles th e detection of errors an d th e retran smission of messages wh en an error occu rs. (Th e n ame stan ds for Digital Data Com mu n ication s Message Protocol.) Origin ally, th is protocol was u sed in Digital E qu ipmen t Cor­ poration 's compu ter n etwork DE Cn et. Th e Adept implemen tation of DDCMP does n ot su pport main ten an ce messages or mu ltidrop lin es. In all oth er respects it is a fu ll implemen tation of th e protocol. Th is section is n ot in ten ded to be a th orou gh description of DDCMP. For addition al details on protocol operation an d implemen tation , refer to DDCMP docu men tation wh ich is available on th e World Wide Web1. General Operation All messages tran smitted by DDCMP are embedded in a packet th at in clu des sequ en ce in for­ mation an d ch eck codes. Upon receipt, a message packet is ch ecked to verify th at it is received in sequ en ce an d with ou t tran smission errors. To in itiate commu n ication s, a system sen ds special start­u p messages u n til th e proper ackn owledgmen t is received from th e remote system. Th is h an dsh akin g gu aran tees th at both sides are active an d ready to exch an ge data packets. If a start requ est is received after th e protocol is active, it mean s th at a system h as stopped an d restarted its en d of th e pro­ tocol, an d an error is sign aled to th e local system. On ce th e protocol is active, each tran smitted message is ackn owledged by th e remote sys­ tem, in dicatin g th at it was received correctly or requ estin g retran smission . If a message is n ot ackn owledged after a certain time, th e remote system is sign aled an d a retry sequ en ce is in itiated. If a message is n ot sen t correctly after a n u mber of retries, DDCMP stops th e pro­ tocol an d sign als an error to th e local system. Th e followin g table sh ows th e stan dard DDCMP NAK reason codes gen erated by th e Adept implemen tation of DDCMP. S tan dard DDCMP NAK Reason Codes Code Description 1 Ch eck code error in data h eader or con trol message 2 Ch eck code error in data field 3 RE P respon se with NUM in RE P <> R 8 Bu ffer temporarily u n available for in comin g data 9 Bytes lost du e to receiver over­ ru n V+ Lan gu age User's Gu ide Page 2 2 3 DDCMP Commu n ication Protocol 16 Message too lon g for bu ffer 17 Header format error (bu t ch eck code was okay) Controller Configuration for DDCMP DDCMP makes u se of on e or more of th e gen eral­pu rpose on troller serial lin es. To be u sed for c DDCMP, a serial lin e mu st be con figu red u sin g th e Adept CONFIG_ C u tility program available in th e file CONFIG_ C.V2 (for details, see th e CONFIG_ C docu men tation in th e In stru ction s for Adept Utility Programs gu ide). DDCMP is available on ly on global serial ports (i.e., th e serial ports on th e IO modu le, an d S ports RS-2 3 2 -1 an d RS-2 3 2 -2 on th e Adept SmartCon troller CX produ ct). Attaching/Detaching DDCMP Devices An ATTACH requ est in itiates th e DDCMP protocol for th e specified logical u n it. Th e attach will n ot complete u n til th e remote system also starts u p th e protocol an d ackn owledges th e local requ est. Th ere is n o time­ou t limit for start u p, so th e attach requ est can wait in defin itely. For application s th at service mu ltiple lin es, n o­wait ATTACH mode can be u sed, an d th e logical u n it for each lin e can be polled with th e IOSTAT fu n ction to detect wh en th e remote system h as started. A DE TACH requ est stops th e protocol, flu sh es an y pen din g in pu t data, an d deactivates th e lin e. An y data received on th e lin e is ign ored. Input Processing Wh en th e protocol is active, received DDCMP data messages are stored in in tern al data bu ff­ ers an d ackn owledged immediately. Th e maximu m in pu t message len gth is 5 1 2 bytes. Th e total n u mber of data bu ffers (sh ared by all th e DDCMP serial lin es) is in itially 1 0 . Th e Adept con troller con figu ration program (CONFIG_ C) can be u sed to ch an ge th e n u mber of bu ffers allocated for u se by DDCMP. On ce all th e DDCMP bu ffers are fu ll, addition al data messages are rejected with n egative ackn owledge (NAK) reason #8 (Bu ffer temporarily u n available). It is th e u ser's respon sibility to limit th e in pu t data flow u sin g a h igh er­level protocol on th e remote system. In pu t data is accessed via th e V+ RE AD in stru ction . E ach RE AD in stru ction retu rn s th e con ­ ten ts of th e n ext data bu ffer. If n o received data is available, th e read will n ot complete u n til a data message is received. No­wait RE AD mode can be u sed for readin g; th e serial lin e can be polled u sin g th e fu n ction IOSTAT(lu n , 1 ) to detect wh en th e read is completed. Keep in min d th at th e DDCMP ackn owledge was sen t wh en th e data was origin ally received an d bu ffered, n ot wh en th e RE AD in stru ction is execu ted. V+ Lan gu age User's Gu ide Page 2 2 4 DDCMP Commu n ication Protocol Output Processing Ou tpu t on a DDCMP lin e is performed u sin g th e V+ WRITE in stru ction . E ach WRITE in stru c­ tion sen ds a sin gle data message with a maximu m len gth of 5 1 2 bytes. Th e write requ est does n ot complete u n til th e remote system ackn owledges su ccessfu l receipt of th e message. Retran smission becau se of errors is h an dled au tomatically with ou t an y action requ ired by th e V+ program. If th e n o­wait format con trol (/N) is specified in th e format list for th e WRITE in stru ction , V+ processin g con tin u es with ou t waitin g for th e write to complete. Like oth er ou tpu t requ ests, a secon d write issu ed before th e first h as completed will force th e V+ program to wait for th e first write to complete. Th e IOSTAT(lu n ,3 ) fu n ction can be u sed to determin e wh eth er or n ot a n o­wait write h as completed. Protocol Parameters Certain parameters can be set to con trol th e operation of DDCMP. Th ese parameters are set with th e V+ FCMND in stru ction . Th e followin g parameters can be set: 1 . Time before message con firmation or retran smission is attempted. An ackn owledge requ est mu st h ave been received before th is period of time, or a time­ou t occu rs. Th e defau lt valu e is 3 secon ds. It can be set to an y valu e from 1 to 2 5 5 secon ds. 2 . Nu mber of su ccessive time­ou ts before an u n recoverable error is sign aled, h altin g th e protocol an d abortin g I/O requ ests. Th e defau lt valu e is 8 . It can be set to an y valu e from 1 to 2 5 5 . 3 . Nu mber of su ccessive n egative ackn owledge (NAK) packets th at can be received before an u n recoverable error is sign aled, h altin g th e protocol an d abortin g I/O requ ests. Th e defau lt valu e is 8 . It can be set to an y valu e from 1 to 2 5 5 . Th e FCMND in stru ction to set th e parameters is as follows (see th e VFCMND docu men tation for more in formation on th is in stru ction ): FCMND(lun, 501)$CHR(time.out)+$CHR(time.retry)+ $CHR(nak.retry) wh ere lu n is th e logical u n it n u mber for th e serial lin e time.ou t is th e time­ou t in terval, in secon ds time.retry is th e su ccessive time­ou t maximu m n ak.retry is th e su ccessive NAK maximu m For example, th e in stru ction V+ Lan gu age User's Gu ide Page 2 2 5 DDCMP Commu n ication Protocol FCMND (lun, 501) $CHR(2)+$CHR(20)+$CHR(8) specifies a time­ou t in terval of 2 secon ds, with a maximu m of 2 0 time­ou ts an d 8 NAK retries. 1Th e origin al pu blication on DE Cn et is en titled DE Cn et Digital Network Arch itectu re, Digital Data Commu n ication s Message Protocol (DDCMP) Specification , Version 4 .0 , March 1 , 1 9 7 8 . Digital E qu ipmen t Corporation order n u mber AA­D5 9 9 A­TC. In formation on DE Cn et is avail­ able at th e followin g URL: ttp://www.cisco.com/u n ivercd/cc/td/doc/cisin twk/ito_ doc/dec­ h n et.pdf. V+ Lan gu age User's Gu ide Page 2 2 6 Kermit Commu n ication Protocol Kermit Communication Protocol Th e Kermit protocol is an error­correctin g protocol for tran sferrin g sequ en tial files between compu ters over asyn ch ron ou s serial commu n ication lin es. Th is protocol is available as an option to th e Adept V+ system. Kermit is n on proprietary an d was origin ally developed at Colu mbia Un iversity. Compu ter u sers may copy Kermit implemen tation s from on e an oth er, or th ey may obtain copies from Colu mbia Un iversity for a n omin al ch arge.1 Th e followin g in formation is n ot in ten ded to be a th orou gh description of Kermit an d its u se. You sh ou ld refer to th e Kermit User Gu ide an d th e Referen ce Kermit Protocol Man u al (both available from Colu mbia Un iversity) for more details on implemen tation an d operation of th e Kermit protocol. Th e Adept implemen tation of Kermit can commu n icate on ly with a server (see th e Kermit User Gu ide for a defin ition of terms). Th e followin g material describes u se of Kermit from th e V+ system. In addition to th is in formation , you will n eed to kn ow h ow to perform steps on you r compu ter to in itiate th e Kermit protocol an d access disk files. Wh en th e V+ implemen tation of th e Kermit protocol is en abled, it makes u se of on e of th e gen eral­pu rpose USE R serial lin es on th e Adept system con troller. For a serial lin e to be u sed with Kermit, th e lin e mu st h ave been con figu red u sin g th e Adept con troller con figu ration pro­ gram.2 Starting a Kermit Session Th is section will lead you th rou gh th e steps in volved with in itiatin g a Kermit file tran sfer ses­ sion u sin g Kermit with th e V+ system. Th e term remote system is u sed in th is discu ssion to refer to th e compu ter system th at is to be accessed with Kermit. NOTE: Th e followin g in formation sh ou ld be con sidered an example. Th e specific details may n ot be correct for th e compu ter system you are accessin g with Kermit. Th e first step is to start u p a Kermit server on th e remote system. On e way to do th is is to go in to pass­th rou gh mode on th e V+ system by typin g th e mon itor comman d: PASSTHRU KERMIT Th e system termin al is n ow con n ected directly to th e serial lin e to th e remote system: An y­ th in g you type at th e system termin al (except Ctrl+C an d Ctrl+P) is sen t directly to th e remote system. If you can n ot get an y respon se from th e remote system at th is poin t, th ere is probably a problem with th e serial lin e con n ection . A common problem is a mismatch of bau d rates or oth er commu n ication ch aracteristics, or a bad serial lin e con n ection . Previou s experien ce is h elpfu l in solvin g su ch problems. V+ Lan gu age User's Gu ide Page 2 2 7 Kermit Commu n ication Protocol On ce you are able to commu n icate with th e remote system, you may h ave to log on to th e remote system. After you h ave reach ed th e poin t of bein g able to en ter comman ds to th e sys­ tem, th e Kermit program may be started simply by typin g: KERMIT or a similar comman d appropriate to th e operatin g system of th e remote compu ter. Th e Kermit program starts u p in its comman d mode, with a prompt su ch as: C-Kermit> You may th en en ter comman ds directly to th e Kermit program. For example, you may wan t to en ter comman ds to in itialize variou s parameters in preparation for commu n ication with th e V+ Kermit. For in stan ce, you may type: SET FILE TYPE TEXT to in itialize th e remote file type to ASCII. (Th e actu al syn tax n eeded for th ese comman ds will depen d on th e remote system. Refer to th at system's u ser gu ide. Most Kermit programs are equ ipped with h elp facilities th at can be in voked by typin g HE LP or a qu estion mark [? ].) After su ccessfu lly in itializin g th e desired parameters, th e Kermit server can be started by typ­ in g: SERVER Th e remote server starts u p an d typed a sh ort message abou t basic server u sage. Th is mes­ sage may n ot be applicable to u se of Kermit commu n ication s with th e V+ system. Wh en ever th e in stru ction s for h an dlin g an d termin atin g th e server differ from th ose in th is man u al, th e in stru ction s in th is man u al sh ou ld be followed. At th is poin t, you sh ou ld escape back to th e (local) V+ system by typin g a Ctrl+C to termin ate th e PASSTHRU comman d. NOTE:A Ctrl+C may be typed at an y time wh ile in PASSTHRU mode to escape back to th e local system. Th is implies th at you will n ot be able to sen d a Ctrl+C to th e remote system. If th e remote system u ses Ctrl+C for special pu rposes (for example, th e DE C VAX/VMS sys­ tem u ses it to in terru pt operation s), you will h ave to u se some oth er mean s to ach ieve th ose special pu rposes. Most Kermit servers can n ot be aborted or termin ated, except by a special commu n ication packet. In order to termin ate th e remote server wh en commu n icatin g with a V+ system, you mu st go in to PASSTHRU mode as described earlier. Th en , wh en a Ctrl+P is typed, a special packet of in formation is sen t to th e remote server th at cau ses it to termin ate. After th is is ach ieved, th e remote Kermit program retu rn s to comman d mode an d displays its comman d prompt. You may th en exit Kermit an d log off th e remote system. V+ Lan gu age User's Gu ide Page 2 2 8 Kermit Commu n ication Protocol File Access Using Kermit After th e remote Kermit server h as been in itiated, you are ready to u se th e Kermit lin e for file access. In gen eral, to access a file via Kermit with th e V+ system, all you h ave to do is specify th e KE RMIT> ph ysical device in a n ormal V+ file­access comman d or in stru ction . For example, th e comman d: LOAD K>file_spec loads (from th e remote system) th e programs or data con tain ed in th e specified file. Th e file specification may be a simple file n ame, or it may con tain device an d directory in formation . Th e actu al in terpretation of th e file specification depen ds on th e remote Kermit server as well as on th e type of remote system bein g u sed. You may also u se th e V+ DE FAULT comman d to defin e th e defau lt disk device to be th e Ker­ mit lin e. For example, you can en ter: DEFAULT = K>directory/ In th is comman d, K> tells th e V+ system it sh ou ld access th e Kermit device (wh en th e local disk device is n ot explicitly specified), an d directory represen ts directory in formation to be u sed as th e defau lt in su bsequ en t file specification s. After th e above DE FAULT comman d is en tered, th e comman d: LOAD file_name loads a program or data file from th e Kermit lin e. It is also possible for a V+ program to RE AD an d WRITE to remote sequ en tial files over th e Kermit lin e. To do th at, th e program h as to perform th e followin g steps: 1 . ATTACH a disk logical u n it, specifyin g th e ph ysical device KE RMIT (explicitly or via th e cu rren t defau lt). NOTE: On ly on e logical u n it in th e en tire V+ system can be attach ed to th e KE R­ MIT ph ysical device at an y on e time. An attempt to perform a secon d attach men t will resu lt in th e error * Device n ot ready* . 2 . FOPE N_ th e desired file on th at logical u n it (if th e file is open in fixed­len gth ­record mode as lon g as th e len gth is less th an abou t 9 0 ). 3 . RE AD or WRITE variable­len gth records u sin g th at logical u n it. Th e followin g V+ comman ds an d in stru ction s can be u sed to access files with Kermit: FCOPY FOPE ND STORE STORE S FDE LE TE FOPE NR STORE L VLOAD FLIST FOPE NW STORE P VSTORE FDIRE CTORY LOAD STORE R V+ Lan gu age User's Gu ide Page 2 2 9 Kermit Commu n ication Protocol VLOAD an d VSTORE can be u sed with Kermit on ly in bin ary mode. Th e specific comman ds for th e remote system will depen d on th e system you are u sin g. Bin ary Files Disk files created by th e V+ system are called ASCII files becau se th e files con tain on ly ASCII ch aracters. V+ application programs (an d oth er compu ters) can create n on ­ASCII disk files, wh ich con tain in formation th at is n ot in terpreted as ASCII ch aracters. Su ch files are often called bin ary files. Wh en Kermit is tran sferrin g n ormal text (ASCII) files, th e file con ten ts are n ot adversely affected if th e eigh th bit of a byte is corru pted. For example, th e serial lin e h ardware wou ld affect th e eigh th bit if parity ch eckin g is en abled, sin ce th at bit is u sed for th e parity in for­ mation . However, wh en bin ary files n eed to be tran sferred, th e eigh th bit of each byte mu st be pre­ served. Th u s, th e serial lin e parity mu st be set to n o parity (th at is, th e serial ports on both th e V+ system an d th e remote system mu st be set). Also, th e Kermit file mode mu st be set to bin ary. Th e parity mode for th e V+ serial ports is set with th e Adept con troller con figu ration program (CONFIG_ C). You may be able to set th e modes on th e remote system by performin g th e fol­ lowin g steps: 1 . Go in to PASSTHRU mode at th e V+ system termin al. 2 . E n ter a comman d to th e remote system to exit th e Kermit program (it may first be n ec­ essary to termin ate th e server by typin g Ctrl+P). 3 . E n ter a comman d to th e remote system to set th e termin al mode to n o parity. 4 . E n ter a comman d to th e remote system to restart th e Kermit program. 5 . E n ter a comman d to th e remote Kermit to set its file mode to bin ary. For example: SET FILE TYPE BINARY 6 . E n ter a comman d to Kermit to start th e remote server. 7 . Type Ctrl+C to escape back to th e (local) V+ system. Wh en a bin ary file is accessed over th e Kermit lin e, th e file specified to V+ mu st h ave a /B qu alifier. For example, th e followin g comman d copies th e file RE MOTE .DAT from th e Kermit lin e to th e local disk drive A: FCOPY A:local.dat = K>remote.dat/B NOTE:If th e defau lt settin g for th e remote system's serial lin e is oth er th an n o parity, an d th ere is n o way you can ch an ge th at settin g, it will n ot be possible to su ccessfu lly tran sfer bin ary files u sin g Kermit. An ASCII file may be accessed as a bin ary file, bu t n ot vice versa. A file th at is tran sferred back an d forth over th e Kermit lin e mu st be tran sferred in th e V+ Lan gu age User's Gu ide Page 2 3 0 Kermit Commu n ication Protocol same file mode each time. For example, if a file is copied in bin ary mode from th e remote system to th e V+ system, th en it mu st be copied back to th e remote system in bin ary mode in order to preserve th e file con ten ts. Kermit Line E rrors Th e error * Non existen t file* is common wh en u sin g Kermit. Th is error cou ld mean an y of sev­ eral th in gs in addition to th e in ability to fin d th e desired file on th e remote system (th e com­ man d FDIR K> will verify th e con ten ts of a remote directory). Th e tran saction s over th e Kermit lin e are gen erally con sidered to be file tran sfers. Wh en th e V+ system tries to start a file operation , th e local Kermit driver gen erally tries to open a file on th e remote server. If th is operation fails, V+ retu rn s th e error * Non existen t file* . Amon g th e th in gs th at cou ld pos­ sibly cau se th is error are: mismatch ed lin e settin gs (like bau d rate an d parity), u n expected server state (th e server didn 't termin ate th e previou s tran saction as expected), th e server was n ot started correctly, or th e file may really n ot exist. NOTE:Wh en an error occu rs th at is associated with th e u se of Kermit, it sometimes h elps to perform th e followin g steps to make su re th e remote server is in a kn own state: (1 ) en ter PASSTHRU mode, (2 ) stop th e remote server by typin g Ctrl+P several times, an d (3 ) restart th e remote server. If a Kermit file access is aborted by th e u ser (for example, Ctrl+C is typed to abort a V+ mon itor comman d), it may take five secon ds for th e abort requ est to be processed. System Parameters for Kermit Two V+ system parameters are provided for settin g commu n ication parameters for th e Ker­ mit protocol. Th e parameter KE RMIT.TIME OUT sets th e amou n t of time th at th e remote server is to wait for a respon se from th e V+ system before th e remote server declares a time­ou t error an d retran smits its previou s message. Th is parameter sh ou ld be set to a h igh valu e (less th an or equ al to 9 5 secon ds) wh en V+ RE AD or WRITE in stru ction s performed on th e Kermit lin e are far apart, th at is, wh en th ere are lon g pau ses between disk requ ests. (Th is can occu r, for example, wh en th e V+ program is bein g execu ted in sin gle­step mode with th e program debu gger.) Th e parameter KE RMIT.RE TRY is th e n u mber of errors an d retran smission s th at are allowed by th e local V+ Kermit. Wh en th is n u mber of errors is exceeded, th e error * Too man y n et­ work errors* will occu r. Wh en th is parameter is set to a large valu e (less th an or equ al to 1 0 0 0 ), th e equ ivalen t parameter for th e remote server mu st be set to th e same valu e. Oth erwise, th e settin gs will n ot be effective. 1Kerm it docu men tation an d software are available from: Kermit Distribu tion Colu mbia Un iversity Cen ter for Compu tin g Activities 6 1 2 West 1 1 5 th Street V+ Lan gu age User's Gu ide Page 2 3 1 Kermit Commu n ication Protocol New York, NY 1 0 0 2 5 (USA) Web site <h ttp://www.colu mbia.edu /kermit/> 2On ly on e lin e can be con figu red at an y on e time for u se with Kermit. Th e con troller con ­ figu ration program is on th e Adept Utility Diskette in th e file CONFIG_ C.V2 . V+ Lan gu age User's Gu ide Page 2 3 2 DeviceNet DeviceNet Adept su pports DeviceNet an d DeviceNet protocols on both th e Adept SmartCon troller an d Adept MV con troller platforms. For more in formation on th e Adept DeviceNet en viron men t, h ardware an d software con figu ration an d V+ programmin g for DeviceNet compon en ts, select a topic from th e table below. To... Refer to... Learn abou t th e Adept Device­ Net E n viron men t SmartCon troller's User's Gu ide Con figu re DeviceNet h ardware SmartCon troller's User's Gu ide Adept MV Con troller User's Gu ide Adept MV Con troller User's Gu ide Con figu re DeviceNet software Con figu rin g th e Adept Con troller as a DeviceNet Slave Ch an ge DeviceNet Con figu ration Man agin g DeviceNet com­ pon en ts from th e V+ operatin g system an d program en vi­ ron men t DE VICE NE T Used for readin g DeviceNet statu s. DN.RE START Restarts DeviceNet com­ mu n ication if th e Can Bu s goes offlin e. DN.THROTTLE On SmartCon troller sys­ tems, allows you to specify th e n u mber of n odes to be polled by th e DeviceNet driv­ ers to in crease CPU avail­ ability. ATTACH Makes a device available for u se by an application pro­ gram. FCMND Gen erates a device­specific comman d to th e in pu t/ou t­ pu t device specified by th e logical u n it. Th e FCMND doc­ u men tation provides th e DeviceNet comman d codes an d th e format of DeviceNet statu s in formation th at is available to programs. V+ Lan gu age User's Gu ide Page 2 3 3 Su mmary of I/O Operation s Summary of I/O Operations Th e followin g table su mmarizes th e V+ I/O in stru ction s: S ystem I n pu t/Ou tpu t Operation s Keyword Type Fu n ction AIO.IN RF Read a ch an n el from on e of th e an alog IO boards. AIO.OUT PI Write to a ch an n el on on e of th e an alog IO boards. AIO.div> RF Test wh eth er an an alog in pu t or ou tpu t ch an n el is in stalled. ATTACH PI Make a device available for u se by th e application pro­ gram. BITS PI Set or clear a grou p of digital sign als based on a valu e. BITS RF Read mu ltiple digital sign als an d retu rn th e valu e cor­ respon din g to th e bin ary bit pattern presen t on th e sign als. $ DE FAULT SF Retu rn a strin g con tain in g th e cu rren t system defau lt device, u n it, an d directory path for disk file access. DE F.DIO PI Assign th ird­party digital I/O boards to stan dard V+ sign al n u mbers, for u se by stan dard V+ in stru ction s, fu n ction s, an d mon itor comman ds.Th is in stru ction requ ires th e Th ird­Party Board Su pport licen se. DE TACH PI Release a specified device from th e con trol of th e application program. DE VICE PI Sen d a comman d or data to an extern al device an d, option ally, retu rn data back to th e program. (Th e actu al operation performed depen ds on th e device ref­ eren ced.) DE VICE RF Retu rn a real valu e from a specified device. Th e valu e may be data or statu s in formation , depen din g u pon th e device an d th e parameters. V+ Lan gu age User's Gu ide Page 2 3 4 Su mmary of I/O Operation s DE VICE S PI Sen d comman ds or data to an extern al device an d option ally retu rn data. Th e actu al operation per­ formed depen ds on th e device referen ced. FCLOSE PI Close th e disk file, graph ics win dow, or graph ics icon cu rren tly open on th e specified logical u n it. FCMND PI Gen erate a device­specific comman d to th e in pu t/ou t­ pu t device specified by th e logical u n it. FE MPTY PI E mpty an y in tern al bu ffers in u se for a disk file or a graph ics win dow by writin g th e bu ffers to th e file or win dow if n ecessary. FOPE NR PI Open a disk file for read­on ly. FOPE NW PI Open a disk file for read­write. FOPE NA PI Open a disk file for read­write­appen d. FOPE ND PI Open a disk directory for read. FSE E K PI Position a file open for ran dom access an d in itiate a read operation on th e specified record. GE TC RF Retu rn th e n ext ch aracter (byte) from a device or in pu t record on th e specified logical u n it. IOGE T_ RF Retu rn a valu e from a device on th e VME bu s. $ IOGE TS SF Retu rn a strin g valu e from a device on th e VME bu s. IOPUT_ PI Write a valu e to a device on th e VME bu s. IOSTAT RF Retu rn statu s in formation for th e last in pu t/ou tpu t operation for a device associated with a logical u n it. IOTAS RF Con trol access to sh ared devices on th e VME bu s. KE RMIT.RE TRY P E stablish th e maximu m n u mber of times th e (local) Kermit driver sh ou ld retry an operation before report­ in g an error. V+ Lan gu age User's Gu ide Page 2 3 5 Su mmary of I/O Operation s KE RMIT.TIME OUT P E stablish th e delay parameter th at th e V+ driver for th e Kermit protocol will sen d to th e remote server. KE YMODE PI Set th e beh avior of a grou p of keys on th e man u al con trol pen dan t. PE NDANT RF Retu rn in pu t from th e man u al con trol pen dan t. PROMPT PI Display a strin g on th e system termin al an d wait for operator in pu t. RE AD PI Read a record from an open file or from an attach ed device th at is n ot file orien ted. RE SE T PI Tu rn off all th e extern al ou tpu t sign als. SE TDE VICE PI In itialize a device or set device parameters. (Th e actu al operation performed depen ds on th e device ref­ eren ced.) SIG RF Retu rn th e logical AND of th e states of th e in dicated digital sign als. SIG.INS RF Retu rn an in dication of wh eth er or n ot a digital I/O sign al is con figu red for u se by th e system, or wh eth er or n ot a software sign al is available in th e system. SIGNAL PI Tu rn on or off extern al digital ou tpu t sign als or in ter­ n al software sign als. TYPE PI Display th e in formation described by th e ou tpu t spec­ ification s on th e system termin al. A blan k lin e is ou t­ pu t if n o argu men t is provided. WRITE PI Write a record to an open file or to an attach ed device th at is n ot file orien ted. PI: Program In stru ction , RF: Real­Valu ed Fu n ction , P: Parameter, SF: Strin g Fu n c­ tion V+ Lan gu age User's Gu ide Page 2 3 6 Graph ics Programmin g Graphics Programming Creating Windows ATTACH Instruction FO PEN Instruction FCLO SE Instruction FDELETE Instruction DETACH Instruction Custom W indow Example Monitoring Events GETEVENT Instruction FSET Instruction Building a Menu Structure Menu Example Defining Keyboard Shortcuts Creating Buttons GPANEL Instruction Button Example Creating a Slide Bar GSLIDE Example Graphics Programming Considerations Using IO STAT( ) Managing W indows Communicating With the System Windows The Main W indow The Monitor W indow The Vision W indow Additional Graphics Instructions Th e in stru ction s in th is ch apter requ ire a graph ics­based system. V+ Lan gu age User's Gu ide Page 2 3 7 Graph ics Programmin g NOTE:For clarity in presen tin g th e programmin g prin ciples, examples in th is ch apter leave ou t th e calls to IOSTAT() th at are critical to detectin g an d respon din g to I/O errors. V+ Lan gu age User's Gu ide Page 2 3 8 Creatin g Win dows Creating Windows V+ commu n icates to win dows th rou gh logical u n its, with logical u n it n u mbers (LUNs) 2 0 to 2 3 reserved for win dow u se. (E ach task h as access to its own set of fou r LUNs.) Th e basic strategy for u sin g a win dow (or an y of th e graph ics in stru ction s) is: 1 . ATTACH to a logical u n it 2 . FOPE N a win dow on th e logical u n it 3 . Perform th e win dow's tasks (or graph ics operation s) 4 . FCLOSE th e win dow 5 . FDE LE TE th e win dow 6 . DE TACH from th e logical u n it AT T ACH Instruction Th e ATTACH in stru ction sets u p a commu n ication s path so a win dow can be written to an d read from. Th e syn tax for th e ATTACH in stru ction is: ATTACH (glun, 4) "GRAPHICS" glu n variable th at receives th e n u mber of th e attach ed graph ics logical u n it. (All men u s an d graph ics comman ds th at take place with in a win dow will also u se glu n .) FOPE N Instruction FOPE N creates a n ew win dow or reselects an existin g win dow for in pu t an d ou tpu t. Wh en a win dow is created, its n ame is placed in th e list of available win dows displayed wh en th e adept logo is clicked on . Th e simplified syn tax for FOPE N is: FOPEN (glun) "window_name /MAXSIZE width height" glu n Th e logical u n it already ATTACHed to. win dow_ n ame Th e title th at appears at th e top of th e win dow. Also u sed to close an d select th e win dow. width /h eigh t Specify th e largest size th e win dow can be open ed to. Th is in stru ction will give you a win dow with all th e defau lt attribu tes. See th e description of FOPE N an d FSE T in th e V+ Lan gu age Referen ce Gu ide for details on h ow to con trol th e attrib­ u tes of a win dow e6 for example, backgrou n d color, size, an d scrollin g. V+ Lan gu age User's Gu ide Page 2 3 9 Creatin g Win dows FCLOSE Instruction FCLOSE closes a win dow to in pu t an d ou tpu t (bu t does n ot erase it or remove it from mem­ ory). Th e syn tax for FCLOSE is: FCLOSE (glun) glu n Th e logical u n it n u mber specified in th e FOPE N in stru ction th at open ed th e win dow. FDE LE T E Instruction FDE LE TE removes a closed, attach ed win dow from th e screen an d from graph ics memory. Th e syn tax for FDE LE TE is FDELETE (glun) "window_name" glu n Th e same valu es as specified in th e FOPE N in stru ction th at created th e win dow. DE T ACH Instruction DE TACH frees u p a LUN for u se by a su bsequ en t ATTACH in stru ction . Th e syn tax for DE TACH is: DETACH (glun) glu n Th e LUN specified in a previou s ATTACH in stru ction . Custom Window E xample Th is section of code will create an d delete a win dow: AUTO glun ; Graphics window LUN ATTACH (glun, 4) "GRAPHICS" ; Attach to a window LUN ; Open the window "Test" with a maximum size of ; 400 x 300 pixels FOPEN(glun) "Test","/MAXSIZE 400 300" ; Your code for processing within the window ; goes here; e.g: GTYPE (glun) 10, 10, "Hello!" ; When the window is no longer needed, close and delete the ; window and detach from the logical unit FCLOSE (glun) V+ Lan gu age User's Gu ide Page 2 4 0 Creatin g Win dows FDELETE (glun) "Test" DETACH (glun) V+ Lan gu age User's Gu ide Page 2 4 1 Mon itorin g E ven ts Monitoring Events Th e key to poin tin g­device­driven programmin g is an even t loop. In an even t loop, you wait for an even t (from th e keyboard or poin ter device) an d wh en th e correct even t occu rs in th e proper place, you r program in itiates some appropriate action . V+ can mon itor man y differen t even ts in clu din g bu tton u p, bu tton down , dou ble click, open win dow, an d men u select. Th e example code in th e followin g section s will u se even t 2 , bu tton u p, an d even t 1 4 , men u select. For details on th e differen t even ts th at can be mon itored, see th e docu men tation for th e GE TE VE NT program in stru ction . Th e basic strategy for an even t loop is: 1 . Wait for an even t to occu r. 2 . Wh en an even t is detected: a. If it is th e desired even t, go to step 3 b. Oth erwise, retu rn to step 1 . 3 . Ch eck th e data from th e even t array (n ot n ecessary for even t 1 4 , men u select): a. If it is appropriate, go to step 4 . b. Oth erwise, retu rn to step 1 . 4 . In itiate appropriate action . 5 . Retu rn to step 1 . GE T E VE NT Instruction Th e in stru ction th at in itiates mon itorin g of poin ter device an d keyboard even ts is GE TE VE NT. Its simplified syn tax is: GETEVENT (lun) event lu n Logical u n it n u mber of th e win dow to be mon itored. even t Array in to wh ich th e resu lts of th e detected even t are stored. Th e valu e stored in even t[0 ] in dicates wh ich even t was detected. If even t[0 ] is 2 , a bu tton ­u p even t was detected, in wh ich case: even t[1 ] in dicates th e n u mber of th e bu tton pressed. (For two­bu tton devices, 2 = left bu tton , 4 = righ t bu tton . For th ree­bu tton devices, 1 = left bu tton , 2 = middle bu tton , 4 = righ t bu tton .) even t[2 ] is th e X valu e of th e poin ter location of th e click. even t[3 ] is th e Y valu e of th e poin ter location of th e click. V+ Lan gu age User's Gu ide Page 2 4 2 Mon itorin g E ven ts If even t[0 ] is 1 4 , a click on a men u bar selection was detected, in wh ich case: If even t[1 ] is 0 , a click h as been made to th e top­level men u bar. In th is case, an FSE T in stru ction mu st be execu ted to display th e pu ll­down option s u n der th e men u bar selection an d even t[2 ] is th e n u mber (from left to righ t) of th e men u bar option selected. If even t[1 ] is 1 , th en a selection from a pu ll­down men u h as been made an d even t[2 ] is th e n u mber of th e pu ll­down option selected. You can n ot u se th e GE TE VE NT in stru ction to specify wh ich even ts to mon itor. It mon itors all th e even ts th at are en abled for th e win dow. For details on u sin g th e /E VE NT argu men t for en ablin g an d disablin g th e mon itorin g of variou s even ts, see th e docu men tation for th e FOPE N an d FSE T program in stru ction s. FSE T Instruction FSE T is u sed to alter th e ch aracteristics of a win dow open ed with an FOPE N in stru ction , an d to display pu ll­down men u s. We are goin g to describe on ly th e u se of FSE T to create th e top­ level men u bar, create th e pu ll­down men u selection s below th e top­level men u , an d in itiate mon itorin g of even ts. Th e in stru ction for displayin g a top­level men u is: FSET (glun) " /MENU 'item1' 'item2' ... 'item10' " glu n is th e logical u n it of th e win dow th e men u is displayed in . item1 ­item1 0 are th e men u titles for a top­level bar men u . Th e items appear from left to righ t. Th e in stru ction to display a pu ll­down men u (called wh en even t[0 ] = 1 4 an d even t[1 ] = 0 ) is: FSET (glun) "/PULLDOWN", top_level#," 'item1' ... ' itemn '" top_ level# is th e n u mber of th e top­level selection th e pu ll­down men u is to appear u n der. item1 ­ itemn are th e men u items in th e pu ll­down men u . Th e items appear from top to bottom. Th e relation sh ip between th ese two u ses of FSE T will become clear wh en we actu ally bu ild a men u stru ctu re. Th e basic FSE T in stru ction for mon itorin g men u an d mou se even ts is: F S E T ( glun) " / E V E N T B U T T O N M E N U " V+ Lan gu age User's Gu ide Page 2 4 3 Bu ildin g a Men u Stru ctu re Building a Menu Structure Th e strategy for implemen tin g a men u is: 1 . Declare th e top­level bar men u . 2 . Start a loop mon itorin g even t 1 4 (men u selection ). 3 . Wh en even t 1 4 is detected, ch eck to see if th e mou se even t was on th e top­level bar men u or on a pu ll­down option . 4 . If th e even t was a top­level men u selection , th en display th e proper pu ll­down option s. 5 . If th e even t was a pu ll­down selection , u se n ested CASE stru ctu res to take appro­ priate action based on th e selection s made to th e top­level men u an d its cor­ respon din g pu ll­down men u . Menu E xample Th is code segmen t will implemen t a men u stru ctu re for a win dow open on glu n : ; Set the top-level menu bar and enable monitoring of events FSET (glun) "/menu 'Menu 1' 'Menu 2' 'Menu 3'" FSET (glun) "/event button menu" ; Define the strings for the pull-down menus $menu[1] = "'Item 1-1' 'Item 1-2'" $menu[2] = "'Item 2-1' 'Item 2-2' 'Item 2-3'" $menu[3] = "'Quit'" ; Set variable for event to be monitored wn.e.menu = 14 ; Start the processing loop quit = FALSE DO GETEVENT (glun) event IF event[0] == wn.e.menu THEN ;The menu event (14) has two components; a button-down component ; corresponding to a click on a menu bar selection, and a ; button-up component corresponding to the pull-down selection ; made when the button is released. ; After the first component (pointer down on the menu bar), ; event[1] will be 0 and event[2] will have the number of the ; menu bar selection. ; Check to see if event[1] is 0, indicating a top-level menu select IF event[1] == 0 THEN ; Use the value in event[2] to select a pull-down menu FSET (glun) "/pulldown", event[2], $menu[event[2]] ; Else, execute the appropriate code for each menu selection ELSE V+ Lan gu age User's Gu ide Page 2 4 4 Bu ildin g a Men u Stru ctu re ; If event[1] is not 0, then the button has been released on a ; pull-down selection and: ; event[1] will have the value of the top-level selection (menu) ; event[2] will have the value of the pull-down selection (item) menu = event[1] item = event[2] ; The outer CASE structure checks the top-level menu selection ; The inner CASE structure checks the item selected from the pull-down CASE menu OF VALUE 1: ;Menu 1 CASE item OF VALUE 1: ;code for Item 1-1 VALUE 2: ;code for Item 1-2 END VALUE 2: ;Menu 2 CASE item OF VALUE 1: ;code for Item 2-1 VALUE 2: ;code for Item 2-2 VALUE 3: ;code for Item 2-3 END VALUE 3: ;Menu 3 CASE item OF VALUE 1: quit = TRUE ;time to quit END END ; case menu of END ; if event[1] END ; if event[0] UNTIL quit .END Implemen tin g th e above code an d th en clickin g on Men u 2 wou ld resu lt in th e win dow sh own in Sample Men u . V+ Lan gu age User's Gu ide Page 2 4 5 Bu ildin g a Men u Stru ctu re Sample Men u Defining Keyboard Shortcuts If you are u sin g AdeptWin dows, you can create keyboard sh ortcu ts on men u an d pu ll­down items by placin g an ampersan d (&) before th e desired letter. For example: FSET(lun) "/menu '&File' '&Edit'" In th is example, th e letters F an d E are u sed as sh ortcu ts wh en pressed with th e ALT key. Th u s, pressin g ALT+F displays th e File men u an d ALT+E displays th e E dit men u . Th e letters F an d E are u n derlin ed on th e men u or pu ll­down item to in dicate th e keyboard sh ortcu t. V+ Lan gu age User's Gu ide Page 2 4 6 Creatin g Bu tton s Creating Buttons Creatin g a bu tton in a win dow is a simple matter of placin g a graph ic represen tin g you r bu t­ ton on th e screen , an d th en lookin g to see if a mou se even t occu rred with in th e con fin es of th at graph ic. GPANE L Instruction Th e GPANE L in stru ction is u sefu l for creatin g stan dard bu tton graph ics. Th e syn tax for GPA­ NE L is: GPANEL (glun, mode) x, y, dx, dy glu n Th e logical u n it of th e win dow th e bu tton is in . mode is replaced with : 0 in dicatin g a raised, u n grooved pan el 2 in dicatin g a su n ken , u n grooved pan el 4 in dicatin g a raised, grooved pan el 6 in dicatin g a su n ken , grooved pan el (Addin g 1 to an y of th e mode valu es fills th e pan el with foregrou n d color.) xy Coordin ates of th e u pper left corn er of th e bu tton . dx dy Width an d h eigh t of th e bu tton . Button E xample Th is code segmen t places a bu tton on th e screen an d th en mon itor a bu tton ­u p even t at th at bu tton (th e logical u n it th e bu tton is accessin g mu st be ATTACHed an d FOPE Ned): ; Initialize monitoring of button events for a button FSET (glun) "/event button" ; Draw a 45x45 pixel panel at window coordinates 100,100 GPANEL (glun, 0) 100, 100, 45, 45 ; Put a label in the button GTYPE (glun) 102, 122, "Label" ; Declare a variable for pointer event 2 (button up) btn.up = 2 ; Set a variable that will stop the monitoring of button ; events hit = FALSE ; Start a loop waiting for a button-up event DO GETEVENT (glun) event V+ Lan gu age User's Gu ide Page 2 4 7 Creatin g Bu tton s ; The status of a button event will be stored in event[0]. ; Look to see if that event was a button-up event. IF event[0] == btn.up THEN ; Check if the button-up event was within the button area ; The x location is in event[1], the y location in event[2] hit = (event[2] > 99) AND (event[2] < 146) hit = hit AND (event[3] > 99) AND (event[3] < 146) END UNTIL hit ; The code for reacting to a button press is placed here. Th is code will work for a sin gle bu tton bu t will become very u n wieldy if several bu tton s are u sed. In th e case of several bu tton s, you sh ou ld place th e bu tton location s in arrays (or a two­dimen sion al array) an d th en pass th ese location s to a su brou tin e th at ch ecks wh eth er th e mou se even t was with in th e array parameters passed to it. V+ Lan gu age User's Gu ide Page 2 4 8 Creatin g a Slide Bar Creating a Slide Bar V+ allows you to create a featu re similar to th e win dow scroll bars called slide bars. Th e syn ­ tax for a slide bar is: GSLIDE (glun, mode) slide_id = x, y, len, max_pos, arrow.inc, handle glu n Th e logical u n it of th e win dow th e slide bar is created in . mode is replaced with : 0 in dicatin g a h orizon tal slide bar is to be created or u pdated. 1 in dicatin g a slide bar is to be deleted. 2 in dicatin g a vertical slide bar is to be created or u pdated. slide_ id A n u mber th at iden tifies th e slide bar. Th is n u mber is retu rn ed to th e even t qu eu e so you can distin gu ish wh ich slide was moved. xy Th e coordin ates of th e top left corn er of th e slide bar. len Th e width or h eigh t of th e bar. max_ pos Specifies th e maximu m valu e th e slide bar retu rn s. arrow_ in c Specifies th e in cremen t th e slide bar registers wh en th e arrows are clicked. (Th e slide bar is created with a scroll h an dle an d scroll arrows.) h an dle Specifies position th e scroll h an dle is in wh en th e slide bar is created. GSLIDE E xample We will be in terested in two even ts wh en mon itorin g a slide bar, even t 8 (slide bar poin ter move) an d even t 9 (slide bar bu tton u p). Addition al even t mon itorin g mu st be en abled with th e FSE T in stru ction . Object mu st be specified to mon itor slide bars an d move_ b2 mu st be specified to mon itor th e draggin g of th e middle bu tton . Th e valu es retu rn ed in th e GE TE VE NT array will be: l l l l even t[0 ] th e poin ter device even t code even t[1 ] th e ID of th e slide bar (as specified by slide_ id) even t[2 ] th e slide bar valu e even t[3 ] th e maximu m slide bar valu e Th e followin g code will display an d mon itor a slide bar: ; The slide bar will be in the window open on glun ; The slide bar will use events 8 and 9. A double-click event ; will halt ; monitoring of the slide bar btn.smov = 8 btn.sup = 9 V+ Lan gu age User's Gu ide Page 2 4 9 Creatin g a Slide Bar btn.dclk = 3 ; Slide bar position and start-up values x = 20 y = 60 length = 200 max.pos = 100 arrow_inc = 10 handle_pos = 50 ; Enable monitoring of slide bars and pointer drags FSET (glun) "/event object move_b2" ; Display the slide bar GSLIDE (glun, 0) 1 = x, y, length, max_pos, arrow_inc, handle_pos ; Begin monitoring events and take action when the slide bar ; is moved. Monitor ; events until a double click is detected, then delete the ; slide bar DO GETEVENT (glun) event IF (event[0] == btn.smov) OR (event[0] == btn.sup THEN ; Your code to monitor the slide bar value (event[2]) goes ; here END UNTIL event[0] == btn.dclk ; Delete the slide bar GSLIDE (glun, 1) 1 V+ Lan gu age User's Gu ide Page 2 5 0 Graph ics Programmin g Con sideration s Graphics Programming Considerations Bu tton s an d men u s can be mon itored in th e same win dow. However, th e code will get com­ plicated, an d you migh t con sider u sin g differen t win dows wh en th e bu tton an d men u stru c­ tu re becomes complex. On ly on e pu ll­down men u can be active at an y time. Design you r win dows with th e followin g mech an ical an d aesth etic con sideration s: l l l l Keep you r win dows as simple an d u n clu ttered as possible. Use color carefu lly an d pu r­ posefu lly. If you are u sin g mu ltiple win dows, u se similar graph ic elemen ts so th e screen ele­ men ts become familiar an d in tu itive. Let th e operator kn ow wh at is goin g on . Never leave th e operator in th e dark as to th e statu s of a bu tton pu sh or men u selection . Wh en ever possible, h ave you r win dows mimic th e real work world of th e operator. In th e in terest of clarity, th e examples in th is ch apter h ave n ot been gen eralized. Wh en you actu ally program an application , u se gen eralized su brou tin e calls for common ly u sed code, or you r code will qu ickly become u n man ageable. Using IOST AT ( ) Th e example code in th is ch apter leaves ou t critical error detection an d recovery procedu res. E ffective application code requ ires th ese procedu res. Th e IOSTAT fu n ction sh ou ld be u sed to bu ild error­h an dlin g rou tin es for u se with every ATTACH, FOPE N, FCLOSE , an d FSE T in stru c­ tion . Th e syn tax for u sin g IOSTAT to ch eck th e statu s of I/O requ ests is: IOSTAT(lun) lu n Th e LUN specified in th e previou s I/O requ est. Th e IOSTAT fu n ction retu rn s th e followin g valu es: 1 if th e last operation was su ccessfu l 0 if th e last operation is n ot yet complete < 0 if th e last operation failed, a n egative n u mber correspon din g to a stan dard Adept error code will be retu rn ed. Th e followin g code ch ecks for I/O errors: ; Issue I/O instruction (ATTACH, FOPEN, etc.) IF IOSTAT(lun) < 0 THEN ;your code to handle the error END ; The ERROR function can be used to return the text V+ Lan gu age User's Gu ide Page 2 5 1 Graph ics Programmin g Con sideration s ; of an error number. The code line is: TYPE $ERROR(IOSTAT(lun)) Managing Windows Win dows can be: l Hidden (bu t n ot deleted) A h idden win dow is removed from th e screen bu t n ot from graph ics memory, an d it can be retrieved at an y time: FSET(glun) "/NODISPLAY" FSET(glun) "/DISPLAY" l ;Hide a window ;Redisplay a window Sen t beh in d th e paren t's win dow stack: FSET(glun) "/STACK -1" l Brou gh t to th e fron t of th e win dow stack: FSET(glun) "STACK 1" If you will n ot be readin g even ts from a win dow, open it in write­on ly mode to save memory an d processin g time. On ly th e task th at open ed a win dow in read/write mode can read from it (mon itor even ts). Mu ltiple tasks can write to an open win dow. A secon d task can write to an already open win ­ dow by execu tin g its own ATTACHan d OPE N for th e win dow. Th e logical u n its' n u mbers n eed n ot match , bu t th e win dow n ame mu st be th e same. If a task h as th e win dow Test open , oth er tasks can write to th e win dow by: ATTACH(lun_1, 4) "GRAPHICS" FOPEN(lun_1) "Test /MAXSIZE 200 200 /WRITEONLY" V+ Lan gu age User's Gu ide Page 2 5 2 Commu n icatin g With th e System Win dows Communicating With the System Windows Th e Adept system h as th ree operatin g system level win dows: th e main win dow, th e mon itor win dow, an d th e vision win dow (on systems with th e AdeptVision option ). T he Main Window You can place men u option s on th e top­level men u bar by open in g th e win dow \Screen _ 1 . For example: ATTACH (glun, 2) "GRAPHICS" FOPEN(glun)"\Screen_1" FSET (glun)"/event menu" FSET (glun)"/menu 'item1' 'item2' 'item3'" open s th e main win dow an d place th ree items on th e top­level men u bar. Pu ll­down s an d even t mon itorin g can proceed as described earlier. Th e in stru ction : FSET (glun) "/menu " deletes th e men u items. T he Monitor Window Th e mon itor win dow can be open ed in write­on ly mode to ch an ge th e ch aracteristics of th e mon itor win dow. For example, th e followin g in stru ction open s th e mon itor win dow, disables scrollin g, an d disallows movin g of th e win dow: FOPEN (glun) "Monitor /WRITEONLY /SPECIAL NOPOSITION NOSIZE" To preven t a u ser from accessin g th e mon itor win dow, u se th e in stru ction : FOPEN (glun) "Monitor /WRITEONLY /NOSELECTABLE" To allow access: FSET (glun) "/SELECTABLE" T he Vision Window For systems equ ipped with th e Adept Vision option , text or graph ics can be ou tpu t to th e vision win dow, an d even ts can be mon itored in th e vision win dow. To commu n icate with th e vision win dow, you open it ju st as you wou ld an y oth er win dow. For th e win dow n ame you mu st u se Vision . For example: FOPEN (glun) "Vision" Remember, graph ics ou tpu t to th e vision win dow is displayed on ly wh en a graph ics display mode or overlay is selected. Wh en you are fin ish ed commu n icatin g with th e vision win dow, close an d detach from it ju st as you wou ld an y oth er win dow. Th is will free u p th e logical u n it, V+ Lan gu age User's Gu ide Page 2 5 3 Commu n icatin g With th e System Win dows bu t will n ot delete th e vision win dow. You can close an d detach from th e vision win dow, bu t you can n ot delete it. To preserve th e vision system pu ll­down men u s, open th e win dow in write­on ly mode: FOPEN (glun) "Vision /WRITEONLY" Th e followin g example open s th e vision win dow, writes to th e vision win dow, an d detach es th e vision win dow: .PROGRAM label.blob() ; ABSTRACT: This program demonstrates how to attach to the ; vision window and how to use the millimeter scaling mode of ; the GTRANS instruction to label a "blob" in the vision ; window. ; AUTO vlun cam = 1 ; Attach the vision window and get a logical unit number ATTACH (vlun, 4) "GRAPHICS" IF IOSTAT(vlun) < 0 GOTO 100 FOPEN (vlun) "Vision" ;Open the vision window IF IOSTAT(vlun) < 0 GOTO 100 ; Select display mode and graphics mode VDISPLAY (cam) 1, 1 ;Display grayscale frame and graphics ; Take a picture and locate an object VPICTURE (cam) ;Take a processed picture VLOCATE (cam, 2) "?" ;Attempt to locate an object IF VFEATURE(1) THEN ;If an object was found... 100 GCOLOR (vlun) 1 ;Select the color black GTRANS (vlun, 2) ;Select millimeter scaling GTYPE (vlun) DX(vis.loc), DY(vis.loc), "Blob", 3 ELSE ;Else if object was NOT found... GCOLOR (vlun) 3 ;Select the color red GTRANS (vlun, 0) ;Select pixel scaling GTYPE (vlun) 100, 100, "No object found!", 3 END ; Detach (frees up the communications path) DETACH (vlun) IF (IOSTAT(vlun) < 0) THEN ; Check for errors TYPE $ERROR(IOSTAT(vlun)) END .END V+ Lan gu age User's Gu ide Page 2 5 4 Addition al Graph ics In stru ction s Additional Graphics Instructions Th e followin g table lists th e graph ics in stru ction s available in th e V+ programmin g lan gu age. For complete details on an y in stru ction , click on th e comman d n ame in th e table, or refer to th e keyword docu men tation available in th e + Lan gu age Referen ce Gu ide. V List of Graph ics I n stru ction s Comman d Action GARC Draw an arc or circle in a graph ics win dow. GCHAIN Draw a ch ain of poin ts. GCLE AR Clear an en tire win dow to th e backgrou n d color. GCLIP Con strain th e area of a win dow with in wh ich graph ics are displayed. GCOLOR Set th e foregrou n d an d backgrou n d colors for su bsequ en t graph ics in stru ction s. GCOPY Copy on e area of a graph ics win dow to an oth er area in th e win dow. GFLOOD Flood an area with foregrou n d color. GICON Allows you to display icon s on th e screen . You can access th e prede­ fin ed Adept icon s or u se you r own icon s created with th e Icon E ditor (see th e n stru ction s for Adept Utility Programs). I GLINE Draw a lin e. GLINE S Draw mu ltiple lin es. GLOGICAL Set th e drawin g mode for th e n ext graph ics in stru ction . (Usefu l for erasin g existin g graph ics an d simu latin g th e draggin g of a graph ic across th e screen .) GPOINT Draw a sin gle poin t. GRE CTANGLE Draw a rectan gle. GSCAN Draw a series of h orizon tal lin es. GSLIDE Create a slide bar. V+ Lan gu age User's Gu ide Page 2 5 5 Addition al Graph ics In stru ction s GTE XTURE Develop a textu re for su bsequ en t graph ics. Set su bsequ en t graph ­ ics to tran sparen t or opaqu e. GTRANS Defin e a tran sformation to apply to all su bsequ en t G in stru ction s. GTYPE Display a text strin g. V+ Lan gu age User's Gu ide Page 2 5 6 Programmin g th e MCP Programming the MCP Introduction ATTACHing and DETACHing the Pendant Writing to the Pendant Display The Pendant Display Usin g WRITE With th e Pen dan t Detecting User Input Using READ W ith the Pendant Detecting Pendant Button Presses Keyboard Mode Toggle Mode Level Mode Monitoring the MCP Speed Bar Using the STEP Button Reading the State of the MCP Controlling the Pendant Control Codes for the LCD Panel The Pendant LEDs Making Pendant Buttons Non­repeat Buttons Auto-Starting Programs With the MCP W AIT.START Programming Example: MCP Menu V+ Lan gu age User's Gu ide Page 2 5 7 In trodu ction Introduction Th is ch apter provides an overview of strategies for programmin g th e man u al con trol pen dan t (MCP). For in formation on programmin g th e Adept T1 /T2 pen dan t, see Programmin g th e Adept T1 /T2 Pen dan t n page 2 7 6 . o AT T ACHing and DE T ACHing the Pendant Before an application program can commu n icate with th e MCP, th e MCP mu st first be ATTACHed u sin g th e ATTACH in stru ction . Th e logical u n it n u mber for th e MCP is 1 . Th e fol­ lowin g in stru ction readies th e MCP for commu n ication : mcp_lun = 1 ATTACH (mcp_lun) Wh en th e MCP is ATTACHed, th e USE R LE D on th e MCP is lit. As with all oth er devices th at are ATTACHed by a program, th e MCP sh ou ld be DE TACHed wh en th e program is fin ish ed with th e MCP. Th e followin g in stru ction frees u p th e MCP: DETACH (mcp_lun) Wh en th e MCP h as been ATTACHed by an application program, th e u ser can in teract with th e pen dan t with ou t selectin g man u al mode. As with all I/O devices, th e IOSTAT fu n ction sh ou ld be u sed to ch eck for errors after each I/O operation . V+ Lan gu age User's Gu ide Page 2 5 9 Writin g to th e Pen dan t Display Writing to the Pendant Display T he Pendant Display Th e MCP display is a 2 ­lin e, 8 0 ­ch aracter LCD display. You can u se th e WRITE in stru ction to write data to th e display. Usin g W RI TE W ith th e Pen dan t Th e followin g in stru ction s displays a welcome message on th e two lin es of th e pen dan t dis­ play: AUTO mcp_lun AUTO $intro ; Pendant LUN $intro = "Welcome to the MCP" mcp_lun = 1 ; Attach the MCP, check for errors and output message ATTACH (mcp_lun) IF IOSTAT(mcp_lun) < 1 GOTO 100 WRITE (mcp_lun) $intro WRITE (mcp_lun) "Instructions to follow...", /S 100 IF IOSTAT(mcp_lun) < 1 THEN ;Report errors TYPE IOSTAT(mcp_lun), " ", $ERROR(IOSTAT(MCP_LUN)) END DETACH(mcp_lun) Notice th at th e secon d WRITE in stru ction u ses th e /S qu alifier. Th is qu alifier su ppresses th e carriage retu rn ­lin e feed (<CR­LF>) th at is n ormally sen t by th e WRITE in stru ction . If th is qu alifier was n ot specified, th e first lin e displayed wou ld h ave been scrolled off th e top. Th e section Con trollin g th e Pen dan t on page 2 6 7 discu sses th e pen dan t con trol codes. Th ese codes con trol th e cu rsor position , th e ligh ts on th e MCP, an d th e in terpretation of MCP bu tton presses. Th ese codes are sen t to th e pen dan t u sin g th e WRITE in stru ction . Th e /S qu alifier mu st be sen t with th ese in stru ction s to avoid overwritin g th e pen dan t display. V+ Lan gu age User's Gu ide Page 2 6 0 Detectin g User In pu t Detecting User Input In pu t from th e pen dan t can be received in two ways: l l A series of bu tton presses from th e data en try bu tton s can be read. Th e RE AD in stru c­ tion is u sed for th is type of in pu t. A sin gle bu tton press from an y of th e bu tton s can be detected. Th ese sin gle bu tton presses can be mon itored in th ree differen t modes: l l l Th e bu tton s can be mon itored like keys on a n ormal keyboard. Th e bu tton s can be mon itored in toggle mode (on or off). Th e state of th e bu t­ ton is ch an ged each time th e bu tton is pressed. Th e keys can be mon itored in level mode. Th e state of th e bu tton is con sidered " on " on ly wh en th e bu tton is h eld down . Th e PE NDANT( ) fu n ction is u sed to detect bu tton presses in th ese modes. Th e KE YMODE in stru ction is u sed to set th e bu tton beh avior. Using RE AD With the Pendant Th e RE AD in stru ction accepts in pu t from th e pen dan t Data E n try Bu tton s (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 , ., +, ­). A RE AD in stru ction expects a <CR­LF> to in dicate th e en d of data en try. On th e MCP, th is sequ en ce is sen t by th e RE C/DONE bu tton (similar to th e E n ter or Retu rn key on a n ormal keyboard). Th e DE L bu tton beh aves like th e Backspace key on a n ormal key­ board. All oth er pen dan t bu tton s are ign ored by th e RE AD in stru ction . Note th at th e prede­ fin ed fu n ction bu tton s are active an d may be u sed wh ile an attach ed program is waitin g for in pu t. Th e in stru ction lin e: READ(1) $response pau ses th e program an d wait for in pu t from th e pen dan t. Th e u ser mu st sign al th e en d of in pu t by pressin g th e RE C/DONE bu tton . Th e in pu t is stored in th e strin g variable $ respon se. Th e in pu t can be stored as a real variable, bu t th e + an d ­ bu tton s mu st n ot be u sed for in pu t. Detecting Pendant Button Presses In dividu al MCP bu tton presses are detected with th e PE NDANT( ) fu n ction . Th is fu n ction retu rn s th e n u mber of th e first acceptable bu tton press. See th e followin g figu re for th e n u mbers of th e bu tton s on th e MCP. Th e in terpretation of a bu tton press is determin ed by th e KE YMODE n stru ction . See th e + Lan gu age Referen ce Gu ide for complete details. Th e i V basic u se of th ese two operation s is described below. V+ Lan gu age User's Gu ide Page 2 6 1 Detectin g User In pu t V+ Lan gu age User's Gu ide Page 2 6 2 Detectin g User In pu t MCP Bu tton Map Keyboard Mode Th e defau lt mode is keyboard. If a PE NDANT( ) in stru ction requ ests keyboard in pu t, th e bu t­ ton n u mber of th e first keyboard­type bu tton pressed is retu rn ed. Th e followin g code detects th e first soft bu tton pressed: ; Set the soft keys to keyboard mode KEYMODE 1,5 = 0 ; Wait for a button press from buttons 1 - 5 DO button = PENDANT(0) UNTIL button < 6 V+ Lan gu age User's Gu ide Page 2 6 3 Detectin g User In pu t Th e argu men ts to th e KE YMODE in stru ction in dicate th at pen dan t bu tton s 1 th rou gh 5 are to be con figu red in keyboard mode. Th e 0 argu men t to th e PE NDANT( ) fu n ction in dicates th at th e bu tton n u mber of th e first keyboard bu tton pressed is to be retu rn ed. Toggle Mode To detect th e state of a bu tton in toggle mode, th e PE NDANT( ) fu n ction mu st specify th e bu t­ ton to be mon itored. Wh en a bu tton is con figu red as a toggle bu tton , its state is main tain ed as on (­1 ) or off (0 ). Th e state is toggled each time th e bu tton is pressed. If an LE D is associated with th e bu tton , it is also toggled. Th e followin g code sets th e RE C/DONE bu tton to toggle mode an d waits u n til RE C/DONE is pressed: ; Set the REC/DONE button to toggle KEYMODE 8 = 1 ; Wait until the REC/DONE button is pressed DO WAIT UNTIL PENDANT(8) Th e argu men ts to KE YMODE in dicate th at MCP bu tton n u mber 8 (th e RE C/DONE bu tton ) is con figu red as a toggle bu tton . Th e argu men t to PE NDANT() in dicates th at th e state of MCP bu tton 8 is to be read. Level Mode To detect th e state of a bu tton in level mode, th e PE NDANT( ) fu n ction mu st specify th e bu t­ ton to be mon itored. Wh en a bu tton h as been con figu red as a level bu tton , th e state of th e bu tton is on as lon g as th e bu tton is pressed. Wh en th e bu tton is n ot pressed, its state is off. Th e followin g code u ses th e bu tton s labeled 2 , 4 , 6 , an d 8 (bu tton n u mbers 4 5 , 4 7 , 4 9 , an d 5 7 ­don 't con fu se th e bu t­ ton labels with th e n u mbers retu rn ed by th e PE NDANT fu n ction ) to move th e cu rsor arou n d th e termin al display. Th e bu tton s are con figu red as level bu tton s so th e cu rsor moves as lon g as a bu tton is depressed. ; Set the REC/DONE button to toggle KEYMODE 8 = 1 ; Set the data entry buttons labeled KEYMODE 45, 51 = 2 DO IF PENDANT(49) THEN TYPE /X1, /S END IF PENDANT(47) THEN TYPE $CHR(8) END IF PENDANT(51) THEN TYPE /U1, /S END "2" - "8" to level ;Cursor right ;Cursor left (backspace) ;Cursor up V+ Lan gu age User's Gu ide Page 2 6 4 Detectin g User In pu t IF PENDANT(45) THEN TYPE $CHR(12) END UNTIL PENDANT(8) ;Cursor down (line feed) Monitoring the MCP Speed Bar Th e speed bar on th e MCP retu rn s a valu e from ­1 2 8 to 1 2 7 depen din g on wh ere it is bein g pressed. An argu men t of ­2 to th e PE NDANT( ) fu n ction retu rn s th e valu e of th e speed bar. Th e followin g code displays th e state of th e speed bar. ; Set the REC/DONE button to toggle KEYMODE 8 = 1 ; Display speed bar value until the REC/DONE is pressed DO WRITE(1) PENDANT(-2) UNTIL PENDANT(8) Th e Slow bu tton is in ten ded to alter th e valu e retu rn ed by th e speed bar. Th e followin g code compresses th e ran ge of valu es retu rn ed by 5 0 % wh en ever th e Slow bu tton is on . ; Set the REC/DONE button to toggle KEYMODE 8 = 1 ; Do until the REC/DONE button is pressed DO IF PENDANT(36) THEN TYPE PENDANT(-2) * 0.5 ELSE TYPE PENDANT(-2) END UNTIL PENDANT(8) Using the ST E P Button Wh en man u al mode is selected, V+ programs can n ot in itiate motion s u n less you press th e STE P bu tton an d speed bar on th e MCP. To con tin u e th e motion on ce it h as started, you can release th e STE P bu tton bu t mu st con tin u e to press th e speed bar. Failu re to operate th e STE P bu tton an d th e speed bar properly resu lts in th e followin g error message (with error code ­6 2 0 ): *Speed pot or STEP not pressed* On ce a motion h as started in th is mode, releasin g th e speed bar also termin ates an y belt trackin g or motion defin ed by an ALTE R program in stru ction . Motion s started in th is mode h ave th eir maximu m speeds limited to th ose defin ed for man ­ u al con trol mode. As an addition al safegu ard, wh en h igh power is en abled an d man u al mode is selected, th e MCP is set to OFF mode, n ot COMP or MANUAL mode. V+ Lan gu age User's Gu ide Page 2 6 5 Detectin g User In pu t Reading the State of the MCP It is good programmin g practice to ch eck th e state of th e MCP before ATTACHin g to it. Th e in stru ction : cur.state = PENDANT(-3) retu rn s a valu e to be in terpreted as follows: 1 . In dicates th at on e of th e predefin ed fu n ction bu tton s h as been pressed. 2 . In dicates th at th e MCP is in backgrou n d mode (n ot ATTACHed to an application pro­ gram). 3 . In dicates th at an error is bein g displayed. 4 . In dicates th at th e MCP is in USE R mode (ATTACHed to an application program). See Programmin g E xample: MCP Men u on page 2 7 2 for a program example th at ch ecks th e MCP state. V+ Lan gu age User's Gu ide Page 2 6 6 Con trollin g th e Pen dan t Controlling the Pendant Th e MCP respon ds to a n u mber of con trol codes th at affect th e LCD pan el (wh eth er or n ot th e bu tton s are repeat bu tton s) an d th e LE Ds associated with th e pen dan t bu tton s. Th e con ­ trol codes are listed in th e table Pen dan t Con trol Codes. Th e con trol codes are sen t as ASCII valu es u sin g th e WRITE in stru ction . Th e n ormal way to sen d con trol codes is to u se th e $ CHR( ) fu n ction to con vert a con trol code to its ASCII valu e. Control Codes for the LCD Panel To clear th e display an d position th e cu rsor in th e middle of th e top lin e, issu e th e in stru ction : WRITE(mcp_lun) $CHR(12), $CHR(18), $CHR(20), /S $ CHR(1 2 ) lears th e pen dan t an d places th e cu rsor at position 1 (see th e figu re Pen dan t LCD c Display). $ CHR(1 8 ) in dicates th at th e n ext valu e received sh ou ld be in terpreted as a cu rsor location . $ CHR(2 0 ) in dicates th e cu rsor sh ou ld be placed at position 2 0 . /S mu st be appen ded to th e WRITE in stru ction or a <CR­LF> will be sen t. Notice th at u sin g con trol code 1 8 allows you to position th e cu rsor with ou t distu rbin g existin g text. Th e followin g code will place th e text E XIT in th e middle of th e bottom lin e an d set th e text blin kin g. WRITE(mcp_lun) $CHR(18), $CHR(58), "EXIT", /S WRITE(mcp_lun) $CHR(18), $CHR(58), $CHR(22), $CHR(4), /S $ CHR(2 2 ) ells th e pen dan t to start a series of blin kin g position s startin g at th e cu rren t cu r­ t sor location an d exten din g for th e n u mber of position s specified by th e n ext con trol code ($ CHR(4 )). Th is code will cau se an y text in position s 5 8 ­ 6 1 to blin k u n til an in stru ction is sen t to can cel th e blin kin g. Th e followin g code lin e disables th e blin k position s: WRITE(mcp_lun) $CHR(18), $CHR(58), $CHR(23), $CHR(4), /S $ CHR(2 3 ) tells th e pen dan t to can cel a series of blin kin g position s startin g at th e cu rren t cu r­ sor location an d exten din g for th e n u mber of position s specified by th e n ext con trol code ($ CHR(4 )). Text can be made to blin k as it is written to th e display, regardless of th e position th e text is in . Th e followin g code writes th e text E XIT to th e middle of th e bottom lin e, starts th e E blin k­ in g, an d th en beeps th e MCP: WRITE(mcp_lun) $CHR(18), $CHR(58), $CHR(2), "E", /S WRITE(mcp_lun) $CHR(3), "XIT", /S WRITE(mcp_lun) $CHR(7), /S $ CHR(2 ) tarts blin k mode. An y ch aracters sen t to th e MCP display will blin k. Blin k mode is s can celed by $ CHR(3 ). $ CHR(3 ) can cels blin k mode for su bsequ en t ch aracters; it does n ot can ­ V+ Lan gu age User's Gu ide Page 2 6 7 Con trollin g th e Pen dan t cel blin kin g of previou sly en tered ch aracters. It also does n ot can cel blin kin g of ch aracter posi­ tion s set by con trol code 2 2 . $ CHR(7 ) cau ses th e pen dan t to beep. Pen dan t LCD Display T he Pendant LE Ds Th e LE Ds on th e soft bu tton s, th e F bu tton s, an d th e RE C/DONE bu tton can be lit (eith er con ­ tin u ou sly or in termitten tly). Th e followin g code places th e text CLE AR an d E XIT over th e first two soft bu tton s, ligh ts th e LE D over th e first soft bu tton , an d blin ks th e ligh t over th e secon d soft bu tton : WRITE(mcp_lun) WRITE(mcp_lun) WRITE(mcp_lun) WRITE(mcp_lun) $CHR(18), $CHR(41), "CLEAR", /S $CHR(9), "EXIT", /S $CHR(31), $CHR(5), /S $CHR(30), $CHR(4), /S $ CHR(9 ) tabs th e cu rsor to th e n ext soft bu tton position . $ CHR(3 1 ) ligh ts an LE D. $ CHR(3 0 ) starts an LE D blin kin g. Th e bu tton LE D to be lit is specified in th e en su in g con trol code. In th e above example, bu tton 5 's LE D is tu rn ed on an d bu tton 4 's LE D is set blin kin g. Th e soft bu t­ ton s, F bu tton s, an d RE C/DONE bu tton are th e on ly bu tton s th at h ave programmable LE Ds. Making Pendant Buttons Non-repeat Buttons Pen dan t bu tton s th at are con figu red as keyboard bu tton s are n ormally repeat bu tton s: Bu t­ ton presses are recorded as lon g as th e bu tton is h eld down . Th e repeat fu n ction can be dis­ abled, requ irin g u sers to press th e bu tton on ce for each bu tton press th ey wan t recorded. Th e followin g in stru ction disables th e repeat option for th e period (.) bu tton : WRITE(mcp_lun) $CHR(25), $CHR(55), /S Th e repeat option is en abled with th e in stru ction : WRITE(mcp_lun) $CHR(24), $CHR(55), /S Th e followin g table lists all th e con trol codes u sed with th e pen dan t. V+ Lan gu age User's Gu ide Page 2 6 8 Con trollin g th e Pen dan t Pen dan t Con trol Codes S in gle Byte Con trol Codes Code Fu n ction 1 (Not Used) 2 E n able blin k mode for su bsequ en t ch aracters 3 Disable blin k mode for su bsequ en t ch aracters (ch aracters will still blin k if th ey appear in a blin kin g position set by code 2 2 ) 4 Display cu rsor (make th e cu rsor visible) 5 Hide cu rsor (make th e cu rsor in visible) 6 (Not Used) 7 Beep 8 Backspace (ign ored if cu rsor is in ch aracter position 1 ) 9 Tab to n ext soft bu tton 1 0 Lin e feed (move down in same position , scroll if on lin e 2 ) 1 1 Vertical tab (move u p in same position , do n ot scroll) 1 2 Home cu rsor an d clear screen (can cels an y blin kin g position s, bu t does n ot affect blin k mode set by code 2 ) 1 3 Carriage retu rn (move to colu mn 1 of cu rren t lin e) 1 4 Home cu rsor (move to ch aracter position 1 ) 1 5 Clear from cu rsor position to en d of lin e Dou ble Byte Con trol Codes Code Fu n ction Secon d Code 1 6 (Not Used) 1 7 (Not Used) 1 8 Position cu rsor 1 9 (Not Used) 2 0 (Not Used) 2 1 (Not Used) 2 2 E n able blin kin g position s start­ in g at cu rren t cu rsor location Cu rsor position (1 ­8 0 ) Nu mber of blin kin g position s (1 ­ 8 0 ) V+ Lan gu age User's Gu ide Page 2 6 9 Con trollin g th e Pen dan t 2 3 Disable blin kin g position s start­ in g at cu rren t cu rsor location Nu mber of blin kin g position s (1 ­ 8 0 ) 2 4 E n able repeat mode for bu tton Bu tton n u mber 2 5 Disable repeat mode for bu tton Bu tton n u mber 2 6 (Not Used) 2 7 (Not Used) Code Fu n ction Secon d Code 2 8 Tu rn off pen dan t bu tton LE D Ligh t n u mber * 2 9 (Not u sed) 3 0 Start pen dan t bu tton LE D blin k­ Ligh t n u mber * in g 3 1 Tu rn on pen dan t bu tton LE D Ligh t n u mber * * For soft bu tton s, F bu tton s, an d RE C/DONE bu tton on ly. V+ Lan gu age User's Gu ide Page 2 7 0 Au to­Startin g Programs With th e MCP Auto-Starting Programs With the MCP Th e CMD predefin ed fu n ction bu tton provides th ree option s for loadin g an d au to­startin g a program from th e pen dan t. Th ese th ree option s are AUTO START, CMD1 , an d CMD2 . Th e pro­ gram file requ iremen ts for all th ree option s are th e same: 1 . Th e file bein g loaded mu st be on th e defau lt disk. Th e defau lt disk is specified with th e DE FAULT DISK comman d. Th e u tility CONFIG_ C can be u sed to specify a defau lt disk at startu p.1 See th e In stru ction s for Adept Utility Programs for details on ru n n in g th is u tility. 2 . Th e file n ame mu st correspon d to th e MCP selection . If CMD1 is pressed, th e disk file mu st be n amed CMD1 .V2 . If AUTO START is pressed, th e u ser will be asked to in pu t on e or two digits. Th ese digits will be u sed to complete th e file n ame AUTO xx.V2 . A correspon din g file n ame mu st exist on th e defau lt drive. 3 . A comman d program with th e same n ame as th e file n ame (min u s th e exten sion ) mu st be on e of th e programs in th e file. If AUTO2 2 .V2 is loaded, th e program " au to2 2 " will be in voked as th ou gh with a COMMANDS mon itor comman d. See th e V+ Operatin g System Referen ce Gu ide for details on comman d programs. WAIT .ST ART Startin g a robot program wh ile th e operator is in th e workcell can be extremely dan gerou s. Th erefore, Adept h as in stalled th e followin g safety procedu re to preven t program startu p wh ile an operator is in th e workcell. Before a program au to­started from th e MCP will begin execu tion , th e operator mu st leave th e workcell, pu t th e con troller in au tomatic mode, an d press th e Start soft key on th e MCP. Th e WAIT.START in stru ction implemen ts th is safety fea­ tu re. Th is in stru ction is au tomatically in clu ded in an y programs started with th e AUTO START, CMD, CMD1 , CMD2 , an d CALIBRATE bu tton s on th e MCP. You sh ou ld in clu de th is safety featu re in an y pen dan t rou tin es you write th at in itiate mon itor comman d programs th at in clu de robot motion s. Th e comman d WAIT.START in a mon itor comman d program pau ses execu tion of a mon itor comman d program u n til th e au tomatic mode is selected an d th e START soft key on th e MCP is pressed. See th e V+ Lan gu age Referen ce Gu ide or oth er f u ses of WAIT.START. W ARNI NG: For th is safety featu re to be effective, th e option al fron t pan el mu st be in stalled ou tside th e workcell. 1Th e defau lt disk is n ot th e same as th e boot drive. Th e boot drive is set in h ardware an d is u sed du rin g th e boot procedu re to specify th e drive th at con tain s th e operatin g system. On ce th e system is loaded, th e defau lt disk is th e drive an d path specification for loadin g an d stor­ in g files. V+ Lan gu age User's Gu ide Page 2 7 1 Programmin g E xample: MCP Men u Programming Example: MCP Menu Th e followin g code implemen ts a men u stru ctu re on th e MCP. (For a program example th at illu strates u sin g th e MCP to teach robot location s, see Teach in g Location s With th e MCP on page 3 3 5 .) .PROGRAM mcp.main( ) ; ABSTRACT: This program creates and monitors a menu structure on the MCP. ; ; INPUT PARAMS: None ; ; OUTPUT PARAMS: None ; ; GLOBAL VARS: mcp MCP logical unit ;mcp.clr.scr_pendant control code, clear display & home cursor ;mcp.cur.pos_pendant control code, set cursor position ;mcp.off.led_pendant control code, turn off an LED ;mcp.blink.char_pendant control code, start blink position ;mcp.noblink.char_pendant control code, disable blink position ;mcp.beep_pendant control code, beep the pendant ;mcp.tab_pendant control code, tab to next soft button ;mcp.on.led_pendant control code, turn on an LED AUTO button AUTO quit ;Number of the soft button pressed ;Boolean indicating menu structure should be exited mcp = 1 quit = FALSE mcp.clr.scr = 12 mcp.cur.pos = 18 mcp.off.led = 28 mcp.blink.char = 2 mcp.noblink.cha = 3 mcp.beep = 7 mcp.tab = 9 mcp.on.led = 31 ; Check to see if the MCP is free IF PENDANT(-3) <> 2 THEN GOTO 100 END ; Attach to the MCP ATTACH (mcp) ; Verify ATTACH was successful IF IOSTAT(mcp) <> 1 THEN V+ Lan gu age User's Gu ide Page 2 7 2 Programmin g E xample: MCP Men u GOTO 100 END DO ;Main processing loop ; Display the top-level menu CALL mcp.disp.main() ; Get the operator selection (must be between 1 and 5) DO button = PENDANT(0) UNTIL (button < 6) ; Turn on the LED of the selected button WRITE (mcp) $CHR(mcp.on.led), $CHR(button), /S ; Respond to the menu item selected CASE button OF VALUE 1: ;Verify program exit CALL mcp.main.quit(quit) VALUE 2: CALL mcp.option.2() VALUE 3: CALL mcp.option.3() VALUE 4: CALL mcp.option.4() VALUE 5: CALL mcp.option.5() END ;CASE button of ; Turn off LED WRITE (mcp) $CHR(mcp.off.led), $CHR(button), /S UNTIL quit ; Detach from the MCP DETACH (mcp) 100 IF NOT quit THEN ;Exit on MCP busy TYPE /C34, /U17, "The MCP is busy or not connected." TYPE "Press the REC/DONE button to clear.", /C5 END V+ Lan gu age User's Gu ide Page 2 7 3 Programmin g E xample: MCP Men u .END .PROGRAM mcp.disp.main( ) ;ABSTRACT: This program is called to display a main menu above the five ;soft keys on the MCP. The program assumes the MCP has been attached. ; ; INPUT PARAMS: None ; ; OUTPUT PARAMS: None ; ; GLOBAL VARS: mcpMCP logical unit ;mcp.clr.scrn_pendant control code, clear display & home cursor ;mcp.cur.pos_pendant control code, set cursor position ;mcp.beep_pendant control code, beep the pendant ;mcp.tab_pendant control code, tab to next soft button ; Clear the display and write the top line WRITE (mcp) $CHR(mcp.clr.scr), $CHR(mcp.cur.pos), $CHR(16), "MAIN MENU", /S ; Write the menu options WRITE (mcp) $CHR(mcp.cur.pos), $CHR(41), /S WRITE (mcp) "Option5", $CHR(mcp.tab), "Option4", $CHR(mcp.tab), /S WRITE (mcp) "Option3", $CHR(mcp.tab), "Option2", $CHR(mcp.tab), " QUIT", /S ; Beep the MCP WRITE (mcp) $CHR(mcp.beep), /S .END .PROGRAM mcp.main.quit(quit) ; ABSTRACT: This program responds to a "Quit" selection from the MCP ; main menu. It verifies the selection and passes the result. ; ; INPUT PARAMS: None ; ; OUTPUT PARAM: quit Boolean indicating whether a "quit" ; has been verified ; ; GLOBAL VARS: mcp MCP logical unit ;mcp.clr.scr_pendant control code, clear display & home cursor ;mcp.off.led_pendant control code, turn off an LED ;mcp.blink.char_pendant control code, start blink position ;mcp.noblink.char_pendant control code, disable blink position ;mcp.tab - pendant control code, tab to next soft button V+ Lan gu age User's Gu ide Page 2 7 4 Programmin g E xample: MCP Men u ; ; quit = FALSE ;assume quit will not be verified ; Display submenu and start the "NO" option blinking WRITE (mcp) $CHR(mcp.clr.scr), "Quit. Are you sure?" WRITE (mcp) $CHR(mcp.tab), $CHR(mcp.tab), $CHR(mcp.tab), " YES", /S WRITE (mcp) $CHR(mcp.tab), $CHR(mcp.blink.char), " .noblink.cha), /S button = PENDANT(0) NO", $CHR(mcp- ; Set quit to true if verified, else turn off the "NO" soft button LED IF button == 2 THEN quit = TRUE ELSE WRITE (mcp) $CHR(mcp.off.led), $CHR(1), /S END .END V+ Lan gu age User's Gu ide Page 2 7 5 Programmin g th e Adept T1 /T2 Pen dan t Programming the Adept T1/T2 Pendant Introduction Writing to the Pendant Display Detecting User Input Controlling the Pendant Auto-Starting Programs With the Pendant Programming Example: Pendant Menu V+ Lan gu age User's Gu ide Page 2 7 6 In trodu ction Introduction Th is section provides an overview of h ow to program th e Adept T1 /T2 pen dan t. You can refer to th e Adept T1 Pen dan t User’s Gu ide or Adept T2 Pen dan t User’s Gu ide for in formation on in stallin g an d operatin g th e pen dan t. For in formation on programmin g th e MCP, see Pro­ grammin g th e MCP on page 2 5 7 . Legacy Issues with the MCP and T 1/T 2 Pendant Th e previou s gen eration of th e pen dan t was called th e MCP (man u al con trol pen dan t). Th e code examples sh own th rou gh ou t th is section con tain referen ces to MCP. Th e programmin g meth ods an d keywords are essen tially th e same for th e MCP an d th e T1 /T2 pen dan t. For in dicatin g th at a bu tton is active, th e T1 /T2 pen dan t u ses a differen t screen tech n ology th an th e LE Ds on th e MCP. In th e Adept T1 Pen dan t User’s Gu ide or Adept T2 Pen dan t User’s Gu ide, th e term " in dicator bar" is u sed to describe th is fu n ction . For th is programmin g sec­ tion , th e term LE D is u sed to main tain backwards compatibility with existin g code, an d LE D an d " in dicator bar" mean th e same th in g. AT T ACHing and DE T ACHing the Pendant Before an application program can commu n icate with th e pen dan t, th e pen dan t mu st first be ATTACHed u sin g th e ATTACH in stru ction . Th e logical u n it n u mber for th e pen dan t is 1 . Th e followin g in stru ction readies th e pen dan t for commu n ication : mcp_lun = 1 ATTACH (mcp_lun) Wh en th e pen dan t is ATTACHed, th e USE R in dicator in th e u pper left corn er of th e pen dan t tou ch screen is lit. As with all oth er devices th at are ATTACHed by a program, th e pen dan t sh ou ld be DE TACHed wh en th e program is fin ish ed with th e pen dan t. Th e followin g in stru c­ tion frees u p th e pen dan t: DETACH (mcp_lun) Wh en th e pen dan t h as been ATTACHed by an application program, th e u ser can in teract with th e pen dan t with ou t selectin g man u al mode. As with all I/O devices, th e IOSTAT fu n ction sh ou ld be u sed to ch eck for errors after each I/O operation . V+ Lan gu age User's Gu ide Page 2 7 8 Writin g to th e Pen dan t Display Writing to the Pendant Display Pendant Display Th e pen dan t display win dow is a 2 ­lin e, 8 0 ­ch aracter display. You can u se th e WRITE in stru c­ tion to write data to th e display. Using WRIT E with the Pendant Th e followin g in stru ction s display a welcome message on th e two lin es of th e pen dan t dis­ play: AUTO mcp_lun AUTO $intro ;Pendant LUN $intro = "Welcome to the MCP" mcp_lun = 1 ; Attach the MCP, check for errors and output message ATTACH (mcp_lun) IF IOSTAT(mcp_lun) < 0 GOTO 100 ; Write to the MCP display. WRITE (mcp_lun) $intro IF IOSTAT(mcp_lun) < 0 GOTO 100 WRITE (mcp_lun) "Instructions to follow...", /S ; Report any error. 100 IF IOSTAT(mcp_lun) < 0 THEN TYPE IOSTAT(mcp_lun), " ", $ERROR(IOSTAT(MCP_LUN)) END DETACH(mcp_lun) Notice th at th e secon d WRITE in stru ction u ses th e /S qu alifier. Th is qu alifier su ppresses th e carriage retu rn ­lin e feed () th at is n ormally sen t by th e WRITE in stru ction . If th is qu alifier was n ot specified, th e first lin e displayed wou ld h ave been scrolled off th e top. Refer to Con ­ trollin g th e Pen dan t on page 2 8 8 for a discu ssion on th e pen dan t con trol codes. Th ese codes con trol th e cu rsor position , th e ligh ts on th e pen dan t, an d th e in terpretation of pen dan t bu t­ ton presses. Th ese codes are sen t to th e pen dan t u sin g th e WRITE in stru ction . Th e /S qu al­ ifier gen erally mu st be u sed with WRITE in stru ction s to avoid overwritin g th e pen dan t display. V+ Lan gu age User's Gu ide Page 2 7 9 Detectin g User In pu t Detecting User Input In pu t from th e pen dan t can be received in two ways: l l A series of bu tton presses from th e data­en try bu tton s can be read. Th e RE AD in stru c­ tion is u sed to receive th is type of in pu t. A sin gle­bu tton press from an y of th e bu tton s can be detected. Th ese sin gle­bu tton presses can be mon itored in th ree differen t modes: l l l Th e bu tton s can be mon itored like keys on a n ormal keyboard. Th e bu tton s can be mon itored in toggle mode (on or off). Th e state of th e bu tton is ch an ged each time th e bu tton is pressed. Th e keys can be mon itored in level mode. Th e state of th e bu tton is con ­ sidered " on " on ly wh en th e bu tton is h eld down . Th e PE NDANT( ) fu n ction is u sed to detect bu tton presses in th ese modes. Th e KE YMODE in stru ction is u sed to set th e bu tton beh avior. Using RE AD With the Pendant Th e RE AD in stru ction accepts in pu t from th e pen dan t data­en try Bu tton s (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 , ., +, ­). A RE AD in stru ction expects a <CR­LF> to in dicate th e en d of data en try. On th e pen dan t, th is sequ en ce is sen t by th e RE C/DONE bu tton (similar to th e E n ter or Retu rn key on a n ormal keyboard). Th e DE L bu tton beh aves like th e Backspace key on a n ormal key­ board. All oth er pen dan t bu tton s are ign ored by th e RE AD in stru ction . Note th at th e prede­ fin ed fu n ction bu tton s are active an d may be u sed wh ile an attach ed program is waitin g for in pu t. See th e Adept T1 Pen dan t User’s Gu ide or Adept T2 Pen dan t User’s Gu ide for more in formation on th e predefin ed bu tton s. Th e in stru ction lin e: READ (1) $response cau ses th e program to wait for in pu t from th e pen dan t. Th e u ser mu st sign al th e en d of th e in pu t by pressin g th e RE C/DONE bu tton . Th e in pu t is stored in th e strin g variable $ respon se. Th e in pu t can be stored in a real variable, bu t th en th e + an d ­ bu tton s mu st be u sed in th e in pu t on ly to iden tify th e sign of th e variable (for example, ­1 2 .3 4 or +1 2 .3 4 ). If a real var­ iable is specified in th e RE AD in stru ction , an d th e + or ­ ch aracters are u sed in a differen t way, su ch as 1 1 +1 or ++9 7 , th e RE AD in stru ction will issu e an error. For example, en terin g 1 1 +1 will resu lt in th e followin g error message: *Unexpected text at end of line* an d ++9 7 will cau se th is error message: *Invalid number format* V+ Lan gu age User's Gu ide Page 2 8 0 Detectin g User In pu t Detecting Pendant Button Presses In dividu al pen dan t bu tton presses are detected with th e PE NDANT( ) real­valu ed fu n ction . (Th e figu re T1 /T2 Pen dan t Bu tton Map provides a referen ce for th e n u mbers of th e bu tton s on th e T1 /T2 pen dan t.) Th is fu n ction retu rn s th e n u mber of th e first acceptable bu tton press. Th e in terpretation of a bu tton press is determin ed by previou s execu tion of th e KE YMODE in stru ction . See th e V+ Lan gu age Referen ce Gu ide for complete details. Th e basic u se of th ese two operation s is described below. V+ Lan gu age User's Gu ide Page 2 8 1 Detectin g User In pu t T1 /T2 Pen dan t Bu tton Map Keyboard Mode Th e defau lt mode is Keyboard. If a PE NDANT( ) fu n ction requ ests an y keyboard in pu t, th e bu tton n u mber of th e first Keyboard mode bu tton pressed is retu rn ed. Th e followin g code detects th e first soft bu tton pressed: ; Set the soft keys to keyboard mode KEYMODE 1,5 = 0 ; Wait for a button press from buttons 1 - 5 DO button = PENDANT(0) UNTIL button < 6 Th e argu men ts to th e KE YMODE in stru ction in dicate th at pen dan t bu tton s 1 th rou gh 5 are to be con figu red in Keyboard mode. Th e 0 argu men t to th e PE NDANT( ) fu n ction in dicates th at th e bu tton n u mber of th e first keyboard bu tton pressed is to be retu rn ed. V+ Lan gu age User's Gu ide Page 2 8 2 Detectin g User In pu t T oggle Mode To detect th e state of a bu tton in Toggle mode, th e PE NDANT( ) fu n ction mu st specify th e bu t­ ton to be mon itored. Wh en a bu tton is con figu red as a toggle bu tton , its state is main tain ed as on (­1 ) or off (0 ). Th e state is toggled each time th e bu tton is pressed. If an in dicator bar (LE D) is associated with th e bu tton , it is also toggled. Th e followin g code sets th e RE C/DONE bu tton to Toggle mode an d waits u n til RE C/DONE is pressed: ; Set the REC/DONE button to toggle KEYMODE 8 = 1 ; Wait until the REC/DONE button is pressed WHILE NOT PENDANT(8) DO RELEASE -1 END To detect th e state of a bu tton in Level mode, th e PE NDANT( ) fu n ction mu st specify th e bu t­ ton to be mon itored. Wh en a bu tton h as been con figu red as a level bu tton , th e state of th e bu tton is on as lon g as th e bu tton is pressed. Wh en th e bu tton is n ot pressed, its state is off. Th e followin g code u ses th e bu tton s labeled 2 , 4 , 6 , an d 8 (bu tton n u mbers 4 5 , 4 7 , 4 9 , an d 5 1 ­ don 't con fu se th e bu tton labels with th e n u mbers retu rn ed by th e PE NDANT fu n ction ) to move th e cu rsor arou n d th e termin al display. Th e bu tton s are con figu red as level bu tton s so th e cu rsor moves as lon g as a bu tton is depressed. ; Set the REC/DONE button to toggle mode KEYMODE 8 = 1 ; Set the data-entry buttons labeled "2" - "8" to level mode KEYMODE 45, 51 = 2 ; Respond to the data-entry buttons DO IF PENDANT(49) THEN TYPE /X1, /S ;Cursor right END IF PENDANT(47) THEN TYPE $CHR(8) ;Cursor left (backspace) END IF PENDANT(51) THEN TYPE /U1, /S ;Cursor up END IF PENDANT(45) THEN TYPE $CHR(12) ;Cursor down (line feed) END UNTIL PENDANT(8) Level Mode To detect th e state of a bu tton in Level mode, th e PE NDANT( ) fu n ction mu st specify th e bu t­ ton to be mon itored. V+ Lan gu age User's Gu ide Page 2 8 3 Detectin g User In pu t Wh en a bu tton h as been con figu red as a level bu tton , th e state of th e bu tton is on as lon g as th e bu tton is pressed. Wh en th e bu tton is n ot pressed, its state is off. Th e followin g code u ses th e bu tton s labeled 2 , 4 , 6 , an d 8 (bu tton n u mbers 4 5 , 4 7 , 4 9 , an d 5 1 ­ don 't con fu se th e bu tton labels with th e n u mbers retu rn ed by th e PE NDANT fu n ction ) to move th e cu rsor arou n d th e termin al display. Th e bu tton s are con figu red as level bu tton s so th e cu rsor moves as lon g as a bu tton is depressed. ; Set the REC/DONE button to toggle mode KEYMODE 8 = 1 ; Set the data-entry buttons labeled "2" - "8" to level mode KEYMODE 45, 51 = 2 ; Respond to the data-entry buttons DO IF PENDANT(49) THEN TYPE /X1, /S ;Cursor right END IF PENDANT(47) THEN TYPE $CHR(8) ;Cursor left (backspace) END IF PENDANT(51) THEN TYPE /U1, /S ;Cursor up END IF PENDANT(45) THEN TYPE $CHR(12) ;Cursor down (line feed) END UNTIL PENDANT(8) Notes on Button Behaviors Some bu tton s on th e pen dan t h ave particu lar beh aviors, depen din g on th e situ ation . Here are th e differen t beh aviors for th ose bu tton s: l l Th e MODE bu tton may appear as a MAN bu tton (2 2 ) or as a COMP/PWR bu tton press (2 3 ). Wh en u sin g th e MODE bu tton to switch from th e FRE E mode to th e COMP mode, th e MODE bu tton will appear as if a COMP/PWR bu tton h as been pressed. Th e Join t “ +” an d “ ­“ bu tton s will first issu e a Join t selection bu tton press (2 9 ­3 4 ), bu t on ce th e selection h as been su ccessfu l an d wh ile th e bu tton is still h eld down , th e bu tton will issu e on ly a speed sign al. E ach followin g press of th e same join t “ +” or “ ­“ bu tton s will also issu e on ly a speed sign al, respectively positive or n egative, for as lon g as th e bu tton is h eld down . If th e first Join t selection is u n su ccessfu l, each press of th e same bu tton will retry th e same Join t selection (2 9 ­3 4 ). In differen t modes, th e YE S/+ an d NO/­ bu tton s will issu e th e speed sign al in combin ation of th eir own bu tton presses (5 3 ­5 4 ) (see Mon itorin g th e Pen dan t Speed Sign al). Monitoring the Pendant Speed Signal Th e speed th at is sen t from th e pen dan t h as a valu e from ­1 2 8 to 1 2 7 depen din g on th e posi­ tion of th e speed slider. An argu men t of ­2 to th e PE NDANT( ) fu n ction retu rn s th e valu e V+ Lan gu age User's Gu ide Page 2 8 4 Detectin g User In pu t determin ed by th e position of th e speed slider. Note th at th e speed in dicator to th e righ t of th e speed bar in dicates a valu e between 1 an d 1 0 0 . Th e speed in dicator expresses a per­ cen tage of th e maximu m valu e. Th e direction (n egative or positive) is specified by th e bu tton pressed. For example, pressin g th e Join t­1 “ +” bu tton will sen d a positive valu e from 1 to 1 2 7 , an d th e Join t­1 “ ­“ bu tton will sen d a n egative valu e from – 1 2 8 to – 1 . Th e valu e retu rn ed by th e fu n ction will be 0 if n o movemen t is requ ested from th e pen dan t. Th e fol­ lowin g code sh ows th e speed on th e pen dan t display wh en pressin g th e YE S/+ or NO/­ bu t­ ton s. ; Set the REC/DONE button to toggle KEYMODE 8 = 1 ; Display speed value until the REC/DONE button is pressed DO WRITE (1) PENDANT(-2) WAIT UNTIL PENDANT(8) Th e SLOW bu tton alters th e valu e retu rn ed by th e speed slider. Th e speed in dicator on th e righ t is adju sted wh en th e SLOW bu tton is on , th e ran ge is ch an ged to 1 to 2 5 , in stead of 1 to 1 0 0 . Th e followin g code compresses th e ran ge of valu es retu rn ed down to 2 5 % wh en ever th e SLOW bu tton is on , displayin g on th e PC mon itor th e comman ded speed th at th e robot will receive. ; Set the REC/DONE button to toggle KEYMODE 8 = 1 ; Do until the REC/DONE button is pressed DO IF PENDANT(36) THEN TYPE PENDANT(-2)*0.25 ELSE TYPE PENDANT(-2) END WAIT.EVENT , 1 UNTIL PENDANT(8) ;Delay 1 second Man y con trols on th e pen dan t may sen d th e speed sign al, depen din g on th e situ ation . Th e Join t bu tton s on th e righ t of th e pen dan t sen d th e speed sign al wh en th ey are u sed to jog th e robot, wh en th e pen dan t is in on e of th e followin g pen dan t con trol modes: WORLD, TOOL, or JOINT. Some V+ application s, like AIM or an y u ser’s program, may requ ire readin g th e speed sign al. In th is particu lar case, wh en th e pen dan t is in OFF or COMP mode, th e YE S/+ an d NO/­ bu t­ ton s will sen d th eir own bu tton code, alon g with th e speed sign al defin ed by th e speed slider. Addition ally, wh en th e T1 bu tton is on , th e YE S/+ an d NO/­ bu tton s also sen d th e speed sig­ n al, bu t do n ot sen d th eir own bu tton code. Th e followin g table su mmarizes th e beh avior of th e YE S/+ an d NO/­ bu tton s. Yes/+ an d No/- Bu tton s Mode S pecial Con dition S en d Bu tton Code S en d S peed S ign al V+ Lan gu age User's Gu ide Page 2 8 5 Detectin g User In pu t Man u al T1 /T2 On no yes Man u al T1 /T2 Off yes no COMP ­ yes yes OFF ­ yes yes Fin ally, for backward compatibility with th e MCP4 , pressin g th e STE P bu tton an d th e Speed Bar simu ltan eou sly will also sen d th e speed sign al. Th is is u sefu l wh en th e Fron t Pan el key switch is in " Man u al" position (described in th e n ext section ). Using the ST E P Button Wh en th e Au to/Man u al key switch is set to Man u al, V+ programs can n ot in itiate motion s u n less High Power is en abled, th e pen dan t is set to COMP mode, an d you press th e STE P bu t­ ton an d th e Speed Bar on th e pen dan t. To con tin u e a motion con sistin g of mu ltiple MOVE in stru ction s on ce it h as started, you mu st con tin u e to press th e STE P bu tton an d th e Speed Bar. Motion s started in th is mode h ave th eir maximu m speeds limited to th ose defin ed for Man u al con trol mode. If a program attempts to in itiate a motion wh en th e STE P bu tton an d Speed Bar are n ot pressed, th e followin g error message is displayed on th e pen dan t an d on th e system Mon itor: *Speed pot or STEP not pressed* On ce a motion h as started in th is mode, releasin g th e Speed Bar immediately termin ates th e motion as well as an y belt trackin g or motion defin ed by an ALTE R program in stru ction . Th e error message sh own above is displayed on th e pen dan t an d on th e system Mon itor. If a motion is in process, an d you release th e STE P bu tton wh ile still pressin g th e Speed Bar, th e robot will fin ish th e cu rren t MOVE in stru ction an d stop. After th at, th e error message sh own above is displayed on th e pen dan t an d on th e system Mon itor. As an addition al safegu ard, wh en High Power is en abled an d th e keyswitch is set to Man u al, th e pen dan t is in itially set to Off mode, n ot COMP mode or Pen dan t Con trol mode. Note for V+ programmers: application programs design ed to move th e robot in Man u al mode sh ou ld read th e statu s of th e STE P bu tton an d th e Speed Bar before startin g th e move. Th e program sh ou ld prompt th e u ser as requ ired. MCP.NO.POT System Switch Th e V+ system switch MCP.NO.POT is in clu ded in V+ 1 6 .2 an d later revision s. Wh en th is switch is en abled, th e fu n ction ality is ch an ged from th at description above. Th e differen ces are th at th e error message men tion ed in th e previou s section is n ot displayed, an d th e Speed Bar does n ot n eed to be pressed. V+ Lan gu age User's Gu ide Page 2 8 6 Detectin g User In pu t Refer to th e V+ Lan gu age Referen ce Gu ide for th e complete details on th is switch . Reading the State of the Pendant It is good programmin g practice to ch eck th e state of th e pen dan t before ATTACHin g to it. Th e in stru ction : cur.state = PENDANT(-3) retu rn s a valu e to be in terpreted as follows: 1 . In dicates th at on e of th e predefin ed fu n ction bu tton s h as been pressed. 2 . In dicates th at th e pen dan t is in th e Backgrou n d state (n ot ATTACHed to an application program). 3 . In dicates th at an error is bein g displayed. 4 . In dicates th at th e pen dan t is in th e USE R state (ATTACHed to an application program). See Programmin g E xample: Pen dan t Men u on page 2 9 3 for a program example th at ch ecks th e pen dan t state. V+ Lan gu age User's Gu ide Page 2 8 7 Con trollin g th e Pen dan t Controlling the Pendant Th e pen dan t respon ds to a n u mber of con trol codes th at affect th e pen dan t display win dow, wh eth er or n ot th e bu tton s are repeat bu tton s, an d th e LE Ds associated with th e pen dan t bu tton s. (Repeat­bu tton presses are recorded as lon g as th e bu tton is h eld down .) Th e con trol codes are listed in th e table Pen dan t Con trol Codes. Th e con trol codes are sen t as ASCII valu es u sin g th e WRITE in stru ction . Th e n ormal way to sen d con trol codes is to u se th e $ CHR( ) fu n ction to con vert a con trol code to its ASCII valu e. Control Codes for Pendant Display Window To clear th e display an d position th e cu rsor in th e middle of th e top lin e, issu e th e in stru ction : WRITE (mcp_l un) $CHR(12), $CHR(18), $CHR(20), /S $ CHR(1 2 ) clears th e pen dan t an d places th e cu rsor at position 1 (see Pen dan t Display Win ­ dow). $ CHR(1 8 ) in dicates th at th e n ext valu e received sh ou ld be in terpreted as a cu rsor loca­ tion . $ CHR(2 0 ) in dicates th e cu rsor sh ou ld be placed at position 2 0 . If “ /S” is n ot appen ded to th e WRITE in stru ction , a <CR­LF> will be sen t. Notice th at u sin g con trol code 1 8 allows you to position th e cu rsor with ou t distu rbin g existin g text. Th e followin g code will place th e text E XIT in th e middle of th e bottom lin e an d set th e text to blin kin g. WRITE (mcp_l un) $CHR(18), $CHR(58), "E X IT", /S WRITE (mcp_l un) $CHR(18), $CHR(58), $CHR(22), $CHR(4), /S $ CHR(2 2 ) tells th e pen dan t to start a series of blin kin g position s startin g at th e cu rren t cu r­ sor location an d exten din g for th e n u mber of position s specified by th e n ext con trol code ($ CHR(4 )). Th is code will cau se an y text in position s 5 8 ­ 6 1 to blin k u n til an in stru ction is sen t to can cel th e blin kin g. Th e followin g code lin e disables th e blin k position s: WRITE (mcp_l un) $CHR(18), $CHR(58), $CHR(23), $CHR(4), /S $ CHR(2 3 ) ells th e pen dan t to can cel a series of blin kin g position s startin g at th e cu rren t cu r­ t sor location an d exten din g for th e n u mber of position s specified by th e n ext con trol code ($ CHR(4 )). Text can be made to blin k as it is written to th e display, regardless of th e position th e text is in . Th e followin g code writes th e text “ E XIT” to th e middle of th e bottom lin e, starts th e “ E ” blin kin g, an d th en beeps th e pen dan t: WRITE (mcp_l un) $CHR(18), $CHR(58), $CHR(2), "E ", /S WRITE (mcp_l un) $CHR(3), "X IT", /S WRITE (mcp_l un) $CHR(7), /S V+ Lan gu age User's Gu ide Page 2 8 8 Con trollin g th e Pen dan t Pen dan t Display W in dow NOTE: Avoid “ floodin g” th e Pen dan t Display Win dow with text or codes by u sin g th e WRITE in stru ction repeatedly. If mu ltiple ch aracters or codes mu st be sen t, u se th e WAIT.E VE NT in stru ction between th e WRITE in stru ction s to avoid th e overflow. Remember th at th is display is u sed for sen din g messages, wh ich th e u ser mu st h ave time to read. Pendant LE Ds (Indicator Bars) Th e LE Ds on th e Soft bu tton s an d th e F1 , F2 , an d Dev/F3 bu tton s can be lit (eith er con ­ tin u ou sly or in termitten tly). Th e followin g code places th e text “ CLE AR” an d “ E XIT” over th e two left­h an d Soft bu tton s (bu tton s #4 an d #5 ), ligh ts th e LE D for th e first Soft bu tton , an d blin ks th e ligh t for th e secon d Soft bu tton : WRITE (mcp_l un) $CHR(18), $CHR(41), "CLE A R", /S WRITE (mcp_l un) $CHR(9), "E X IT", /S WRITE (mcp_l un) $CHR(31), $CHR(5), /S WRITE (mcp_l un) $CHR(30), $CHR(4), /S $ CHR(9 ) tabs th e cu rsor to th e n ext Soft bu tton position . $ CHR(3 1 ) ligh ts an LE D. $ CHR(3 0 ) starts an LE D blin kin g. Th e bu tton LE D to be lit is specified in th e n ext con trol byte. In th e above example, th e LE D for bu tton 5 is tu rn ed on an d th e LE D for bu tton 4 is set blin kin g. Th e Soft bu tton s an d th e F1 , F2 , an d Dev/F3 bu tton s are th e on ly bu tton s th at h ave pro­ grammable LE Ds. Making Pendant Buttons Non-Repeat Buttons Pen dan t bu tton s th at are con figu red as keyboard bu tton s are n ormally repeat bu tton s. Th at is, bu tton presses are recorded as lon g as th e bu tton is h eld down . Th e repeat fu n ction can be disabled, requ irin g u sers to press th e bu tton on ce for each bu tton press th ey wan t recorded. Th e followin g in stru ction disables th e repeat option for th e period (.) bu tton : WRITE (mcp_l un) $CHR(25), $CHR(55), /S Th e repeat option for th at bu tton is en abled with th e in stru ction : WRITE (mcp_l un) $CHR(24), $CHR(55), /S Th e Pen dan t Con trol Codes table below lists all th e con trol codes u sed with th e pen dan t. Pen dan t Con trol Codes S in gle-Byte Con trol Codes Code Fu n ction V+ Lan gu age User's Gu ide Page 2 8 9 Con trollin g th e Pen dan t 1 (Not Used) 2 E n able blin k mode for su bsequ en t ch aracters 3 Disable blin k mode for su bsequ en t ch aracters (ch aracters will still blin k if th ey appear in a blin kin g position set by code 2 2 ) 4 Display th e cu rsor (make th e cu rsor visible) 5 Hide th e cu rsor (make th e cu rsor in visible) 6 (Not Used) 7 Beep 8 Backspace (ign ored if cu rsor is in ch aracter position 1 ) 9 Tab to n ext Soft bu tton 10 Lin e feed (move down in same position , scroll if on lin e 2 ) 11 Vertical tab (move u p in same position , do n ot scroll) 12 Home cu rsor an d clear screen (can cels an y blin kin g position s, bu t does n ot affect blin k mode set by code 2 ) 13 Carriage retu rn (move to colu mn 1 of cu rren t lin e) 14 Home cu rsor (move to ch aracter position 1 ) 15 Clear from cu rsor position to en d of lin e Dou ble-Byte Con trol Codes Code Fu n ction S econ d Byte 16 (Not Used) 17 (Not Used) 18 Position cu rsor 19 (Not Used) 20 (Not Used) 21 (Not Used) 22 E n able blin kin g position s startin g at cu rren t cu rsor location 23 Disable blin kin g position s startin g at Nu mber of blin kin g position s (1 ­8 0 ) cu rren t cu rsor location 24 E n able repeat mode for bu tton Cu rsor position (1 ­8 0 ) Nu mber of blin kin g position s (1 ­8 0 ) Bu tton n u mber V+ Lan gu age User's Gu ide Page 2 9 0 Con trollin g th e Pen dan t 25 Disable repeat mode for bu tton Bu tton n u mber 26 (Not Used) 27 (Not Used) Code Fu n ction S econ d Code 28 Tu rn off pen dan t bu tton LE D Ligh t n u mber * 29 (Not u sed) 30 Start pen dan t bu tton LE D blin kin g Ligh t n u mber * 31 Tu rn on pen dan t bu tton LE D Ligh t n u mber * * For Soft bu tton s an d bu tton s F1 , F2 , an d Dev/F3 on ly. V+ Lan gu age User's Gu ide Page 2 9 1 Au to­Startin g Programs With th e Pen dan t Auto-Starting Programs With the Pendant Th e CMD predefin ed fu n ction bu tton provides th ree option s for loadin g an d au to­startin g a program from th e pen dan t. Th ese th ree option s are AUTO START, CMD1 , an d CMD2 . Th e pro­ gram file requ iremen ts for all th ree option s are th e same: 1 . Th e file bein g loaded mu st be on th e defau lt disk. Th e defau lt disk is specified with th e DE FAULT Mon itor comman d. Th e u tility CONFIG_ C can be u sed to specify a defau lt disk at startu p. NOTE: Th e defau lt disk is n ot th e same as th e boot drive. Th e boot drive is set in h ardware an d is u sed du rin g th e boot procedu re to specify th e drive th at con tain s th e operatin g system. On ce th e system is loaded, th e defau lt disk is th e drive an d path specification for loadin g an d storin g files. See th e In stru ction s for Adept Utility Programs for details on ru n n in g th is u tility. 2 . Th e file n ame mu st correspon d to th e pen dan t selection . If CMD1 is pressed, th e disk file CMD1 .V2 will be accessed. If AUTO START is pressed, th e u ser will be asked to in pu t on e or two digits. Th ese digits will be u sed to complete th e file n ame AUTOxx.V2 . A correspon din g file mu st exist on th e defau lt drive. 3 . A comman d program with th e same n ame as th e file n ame (min u s th e exten sion ) mu st be on e of th e programs in th e file. For example, if th e file AUTO2 2 .V2 is loaded, th e program " au to2 2 " will be in voked as th ou gh with a COMMANDS mon itor com­ man d. See th e V+ Operatin g System Referen ce Gu ide for details on comman d pro­ grams. WAIT .ST ART Command Startin g a robot program wh ile th e operator is in th e workcell can be extremely dan gerou s. Th erefore, Adept h as in stalled th e followin g safety procedu re to preven t program startu p wh ile an operator is in th e workcell. Before a program au to­started from th e pen dan t will begin execu tion , th e operator mu st leave th e workcell, pu t th e con troller in au tomatic mode, an d press th e Start soft key on th e pen dan t. Th e WAIT.START comman d implemen ts th is safety featu re. Th is comman d is au tomatically in clu ded in an y programs started with th e AUTO START, CMD1 , CMD2 , an d CALIBRATE bu tton s on th e pen dan t. You sh ou ld in clu de th is safety featu re in an y mon itor comman d programs th at in clu de robot motion s th at will be in voked from th e pen dan t. Th e comman d WAIT.START in a mon itor comman d program pau ses execu tion of th e mon itor comman d program u n til th e au tomatic mode is selected an d th e START soft key on th e pen dan t is pressed. See th e V+ Operatin g System Referen ce Gu ide for oth er u ses of WAIT.START. W ARNI NG: For th is safety featu re to be effective, th e option al fron t pan el mu st be in stalled ou tside th e workcell. V+ Lan gu age User's Gu ide Page 2 9 2 Programmin g E xample: Pen dan t Men u Programming Example: Pendant Menu Th e followin g code implemen ts a men u stru ctu re on th e Adept T1 /T2 pen dan t. (For a pro­ gram example th at illu strates u sin g th e MCP to teach robot location s, see Teach in g Location s With th e MCP on page 3 3 5 .) .PROGRAM mcp.main( ) ; ABSTRACT: This program creates and monitors a menu structure on the MCP. ; ; INPUT PARAMS: None ; ; OUTPUT PARAMS: None ; ; GLOBAL VARS: mcp MCP logical unit ;mcp.clr.scr_pendant control code, clear display & home cursor ;mcp.cur.pos_pendant control code, set cursor position ;mcp.off.led_pendant control code, turn off an LED ;mcp.blink.char_pendant control code, start blink position ;mcp.noblink.char_pendant control code, disable blink position ;mcp.beep_pendant control code, beep the pendant ;mcp.tab_pendant control code, tab to next soft button ;mcp.on.led_pendant control code, turn on an LED AUTO button AUTO quit ;Number of the soft button pressed ;Boolean indicating menu structure should be exited mcp = 1 quit = FALSE mcp.clr.scr = 12 mcp.cur.pos = 18 mcp.off.led = 28 mcp.blink.char = 2 mcp.noblink.cha = 3 mcp.beep = 7 mcp.tab = 9 mcp.on.led = 31 ; Check to see if the MCP is free IF PENDANT(-3) <> 2 THEN GOTO 100 END ; Attach to the MCP ATTACH (mcp) ; Verify ATTACH was successful IF IOSTAT(mcp) <> 1 THEN V+ Lan gu age User's Gu ide Page 2 9 3 Programmin g E xample: Pen dan t Men u GOTO 100 END DO ;Main processing loop ; Display the top-level menu CALL mcp.disp.main() ; Get the operator selection (must be between 1 and 5) DO button = PENDANT(0) UNTIL (button < 6) ; Turn on the LED of the selected button WRITE (mcp) $CHR(mcp.on.led), $CHR(button), /S ; Respond to the menu item selected CASE button OF VALUE 1: ;Verify program exit CALL mcp.main.quit(quit) VALUE 2: CALL mcp.option.2() VALUE 3: CALL mcp.option.3() VALUE 4: CALL mcp.option.4() VALUE 5: CALL mcp.option.5() END ;CASE button of ; Turn off LED WRITE (mcp) $CHR(mcp.off.led), $CHR(button), /S UNTIL quit ; Detach from the MCP DETACH (mcp) 100 IF NOT quit THEN ;Exit on MCP busy TYPE /C34, /U17, "The MCP is busy or not connected." TYPE "Press the REC/DONE button to clear.", /C5 END V+ Lan gu age User's Gu ide Page 2 9 4 Programmin g E xample: Pen dan t Men u .END .PROGRAM mcp.disp.main( ) ;ABSTRACT: This program is called to display a main menu above the five ;soft keys on the MCP. The program assumes the MCP has been attached. ; ; INPUT PARAMS: None ; ; OUTPUT PARAMS: None ; ; GLOBAL VARS: mcpMCP logical unit ;mcp.clr.scrn_pendant control code, clear display & home cursor ;mcp.cur.pos_pendant control code, set cursor position ;mcp.beep_pendant control code, beep the pendant ;mcp.tab_pendant control code, tab to next soft button ; Clear the display and write the top line WRITE (mcp) $CHR(mcp.clr.scr), $CHR(mcp.cur.pos), $CHR(16), "MAIN MENU", /S ; Write the menu options WRITE (mcp) $CHR(mcp.cur.pos), $CHR(41), /S WRITE (mcp) "Option5", $CHR(mcp.tab), "Option4", $CHR(mcp.tab), /S WRITE (mcp) "Option3", $CHR(mcp.tab), "Option2", $CHR(mcp.tab), " QUIT", /S ; Beep the MCP WRITE (mcp) $CHR(mcp.beep), /S .END .PROGRAM mcp.main.quit(quit) ; ABSTRACT: This program responds to a "Quit" selection from the MCP ; main menu. It verifies the selection and passes the result. ; ; INPUT PARAMS: None ; ; OUTPUT PARAM: quit Boolean indicating whether a "quit" ; has been verified ; ; GLOBAL VARS: mcp MCP logical unit ;mcp.clr.scr_pendant control code, clear display & home cursor ;mcp.off.led_pendant control code, turn off an LED ;mcp.blink.char_pendant control code, start blink position ;mcp.noblink.char_pendant control code, disable blink position V+ Lan gu age User's Gu ide Page 2 9 5 Programmin g E xample: Pen dan t Men u ;mcp.tab - pendant control code, tab to next soft button ; ; quit = FALSE ;assume quit will not be verified ; Display submenu and start the "NO" option blinking WRITE (mcp) $CHR(mcp.clr.scr), "Quit. Are you sure?" WRITE (mcp) $CHR(mcp.tab), $CHR(mcp.tab), $CHR(mcp.tab), " YES", /S WRITE (mcp) $CHR(mcp.tab), $CHR(mcp.blink.char), " .noblink.cha), /S button = PENDANT(0) NO", $CHR(mcp- ; Set quit to true if verified, else turn off the "NO" soft button LED IF button == 2 THEN quit = TRUE ELSE WRITE (mcp) $CHR(mcp.off.led), $CHR(1), /S END .END V+ Lan gu age User's Gu ide Page 2 9 6 Con veyor Trackin g Conveyor Tracking Introduction to Conveyor Tracking Installation Calibration Basic Programming Concepts Belt Variables Nomin al Belt Tran sformation Th e Belt E n coder Th e E n coder Scalin g Factor Th e E n coder Offset Th e Belt Win dow Belt­Relative Motion Instructions Motion Termination Defining Belt­Relative Locations Moving-Line Programming Instructions and Functions Belt Variable Defin ition s E n coder Position an d Velocity In formation Win dow Testin g Statu s In formation System Switch System Parameters Sample Programs V+ Lan gu age User's Gu ide Page 2 9 7 In trodu ction to Con veyor Trackin g Introduction to Conveyor Tracking Th is ch apter describes th e Adept Con veyor Trackin g (movin g­lin e) featu re. Th e movin g­lin e featu re allows th e programs to specify location s th at are au tomatically modified to com­ pen sate for th e in stan tan eou s position of a con veyor belt. Motion location s th at are defin ed relative to a belt can be tau gh t an d played back wh ile th e belt is station ary or movin g at arbi­ trarily varyin g speeds. Con veyor trackin g is available on ly for systems th at h ave th e option al V+ E xten sion s software. For V+ to determin e th e in stan tan eou s position an d speed of a belt, th e belt mu st be equ ipped with a device to measu re its position an d speed. As part of th e movin g­lin e h ard­ ware option , Adept provides an in terface for coordin atin g two separate con veyor belts. Robot motion s an d location s can be specified relative to eith er belt. Th ere are n o restriction s con cern in g th e placemen t or orien tation of a con veyor belt relative to th e robot. In fact, belts th at move u ph ill or down h ill (or at an an gle to th e referen ce frame of th e robot) can be treated as easily as th ose th at move parallel to an axis of th e robot ref­ eren ce frame. Th e on ly restriction regardin g a belt is th at its motion mu st follow a straigh t­ lin e path in th e region wh ere th e robot is to work. Th e followin g section s con tain in stallation an d application in stru ction s for u sin g th e movin g­ lin e featu re. Before u sin g th is ch apter, you sh ou ld be familiar with V+ an d th e basic oper­ ation of th e robot. V+ Lan gu age User's Gu ide Page 2 9 9 In stallation Installation To set u p a con veyor belt for u se with a robot con trolled by th e V+ system: 1 . In stall all th e h ardware compon en ts an d secu rely fasten th em in place. Th e con veyor frame an d robot base mu st be mou n ted rigidly so th at n o motion can occu r between th em. 2 . In stall th e en coder on th e con veyor. 3 . Sin ce an y jitter of th e en coder will be reflected as jitter in motion s of th e robot wh ile trackin g th e belt, make su re th e mech an ical con n ection between th e belt an d th e en coder operates smooth ly. In particu lar, elimin ate an y backlash in gear­driven sys­ tems. 4 . Wire th e en coder to th e robot con troller. (See th e Adept MV Con troller User's Gu ide for location of th e en coder ports.) 5 . Start u p th e robot system con troller in th e n ormal man n er. 6 . Calibrate th e location of th e con veyor belt relative to th e robot by execu tin g th e Belt Calibration Program. Th at program is provided in th e file BE LT_ CAL.V2 on th e Adept Utility Disk su pplied with you r robot system.1 Wh en th ese steps h ave been completed, th e system is ready for u se. However, each time th e system is restarted, th e belt calibration data mu st be reloaded (from th e disk file created in th e above steps). Th e n ext section describes loadin g belt calibration . 1See th e In stru ction s for Adept Utility Programs for details. V+ Lan gu age User's Gu ide Page 3 0 0 Calibration Calibration Th e position an d orien tation of th e con veyor belt mu st be precisely kn own in order for th e robot to track motion of th e belt. Th e file BE LT_ CAL.V2 on th e Adept Utility Disk con tain s a program to calibrate th e relation sh ip between th e belt an d th e robot. Th e program saves th e calibration data in a disk file for later u se by application programs. Th e DE FBE LT an d WINDOW program in stru ction s mu st be execu ted before th e associated belt is referen ced in a V+ program. For details, see Belt Variable Defin ition s n page 3 0 9 . We o su ggest you in clu de th ese in stru ction s in an in itialization section of you r application pro­ gram. Alth ou gh th ese in stru ction s n eed be execu ted on ly on ce, n o h arm is don e if th ey are execu ted su bsequ en tly. Th e file LOADBE LT.V2 on th e Adept Utility Disk con tain s a V+ su brou tin e th at will load th e belt calibration data from a disk file an d execu te th e DE FBE LT an d WINDOW in stru ction s. (See th e n ext section .) Wh ile th e robot is movin g relative to a belt (in clu din g motion s to an d from th e belt), all motion s mu st be of th e straigh t­lin e type. Th u s APPROS, DE PARTS, MOVE S, an d MOVE ST can be u sed, bu t APPRO, DE PART, DRIVE , MOVE , an d MOVE T can n ot. Motion relative to a belt is termin ated wh en th e robot moves to a location th at is n ot defin ed relative to th e belt var­ iable or wh en a belt­win dow violation occu rs. V+ Lan gu age User's Gu ide Page 3 0 1 Basic Programmin g Con cepts Basic Programming Concepts Th is section describes th e basic con cepts of th e Con veyor Belt Trackin g featu re. First, th e data u sed to describe th e relation sh ip of th e con veyor belt to th e robot is presen ted. Th en a description is given of h ow belt­relative motion in stru ction s are specified. Fin ally, a descrip­ tion is presen ted of h ow belt­relative location s are tau gh t. Th e V+ operation s associated with belt trackin g are disabled wh en th e BE LT system switch is disabled. Th u s, application programs th at u se th ose operation s mu st be su re th e BE LT switch is en abled. Belt Variables Th e primary mech an ism for specifyin g motion s relative to a belt is a V+ data type called a belt variable. By defin in g a belt variable, th e program specifies th e relation sh ip between a spe­ cific belt en coder an d th e location an d speed of a referen ce frame th at main tain s a fixed posi­ tion an d orien tation relative to th e belt. Altern atively, a belt variable can be th ou gh t of as a tran sformation (with a time­varyin g compon en t) th at defin es th e location of a referen ce frame fixed to a movin g con veyor. As a con ven ien ce, more th an on e belt variable can be asso­ ciated with th e same ph ysical belt an d belt en coder. In th is way, several work station s can be easily referen ced on th e same belt. Like oth er variable n ames in V+, th e n ames of belt variables are assign ed by th e pro­ grammer. E ach n ame mu st start with a letter an d can con tain on ly letters, n u mbers, peri­ ods, an d u n derlin e ch aracters. (Letters u sed in variable n ames can be en tered in eith er lowercase or u ppercase. V+ always displays variable n ames in lowercase.) To differen tiate belt variables from oth er data types, th e n ame of a belt variable mu st be pre­ ceded by a percen t sign (%). As with all oth er V+ data types, arrays of belt variables are per­ mitted. Hen ce th e followin g are all valid belt­variable n ames: %pallet.on.belt %base.plate %belt[1] Th e DE FBE LT in stru ction mu st be u sed to defin e belt variables (see th e Movin g­Lin e Pro­ grammin g section of th is ch apter). Th u s, th e followin g are n ot valid operation s: SET %new_belt = %old_belt or HERE %belt[1] Compared to oth er V+ data types, th e belt variable is rath er complex in th at it con tain s sev­ eral differen t types of in formation . Briefly, a belt variable con tain s th e followin g in formation : 1 . Th e n omin al tran sformation for th e belt. Th is defin es th e position an d direction of travel of th e belt an d its approximate cen ter. 2 . Th e n u mber of th e en coder u sed for readin g th e in stan tan eou s location of th e belt (from 1 to 6 ). 3 . Th e belt en coder scalin g factor, wh ich is u sed for con vertin g en coder cou n ts to mil­ limeters of belt travel. V+ Lan gu age User's Gu ide Page 3 0 2 Basic Programmin g Con cepts 4 . An en coder offset, wh ich is u sed to adju st th e origin of th e belt frame of referen ce. 5 . Win dow parameters, wh ich defin e th e workin g ran ge of th e robot alon g th e belt. Th ese compon en ts of belt variables are described in detail in th e followin g section s. Un like oth er V+ data types, belt variables can n ot be stored in a disk file for later loadin g. How­ ever, th e location an d real­valu ed data u sed to defin e a belt variable can be stored an d loaded in th e n ormal ways. After th e data is loaded from disk, DE FBE LT an d WINDOW in stru ction s mu st be execu ted to defin e th e belt variable. For details, see Belt Variable Defin ition s n page o 3 0 9 . (Th e file LOADBE LT.V2 on th e Adept Utility Disk con tain s a su brou tin e th at will read belt data from a disk file an d execu te th e appropriate DE FBE LT an d WINDOW in stru ction s.) Nomin al Belt Tran sformation Th e position , orien tation , an d direction of motion of a belt are defin ed by a tran sformation called th e n omin al belt tran sformation . Th is tran sformation defin es a referen ce frame align ed with th e belt as follows: its X­Y plan e coin cides with th e plan e of th e belt, its X axis is parallel to th e direction of belt motion , an d its origin is located at a poin t (fixed in space) ch osen by th e u ser. Sin ce th e direction of th e X axis of th e n omin al belt tran sformation is taken to be th e direction alon g wh ich th e belt moves, th is compon en t of th e tran sformation mu st be determin ed with great care. Fu rth ermore, wh ile th e poin t defin ed by th is tran sformation (th e origin of th e frame) can be selected arbitrarily, it n ormally sh ou ld be approximately at th e middle of th e robot's workin g ran ge on th e belt. Th is tran sformation is u su ally defin ed u sin g th e FRAME location ­valu ed fu n ction with recorded robot location s on th e belt. (Th e easiest way to defin e th e n omin al belt tran sformation is with th e con veyor belt calibration program provided by Adept.) Th e in stan tan eou s location described by th e belt variable will almost always be differen t from th at specified by th e n omin al tran sformation . However, sin ce th e belt is con strain ed to move in a straigh t lin e in th e workin g area, th e in stan tan eou s orien tation of a belt variable is con ­ stan t an d equ al to th at defin ed by th e n omin al belt tran sformation . To determin e th e in stan tan eou s location defin ed by a belt variable, th e V+ system performs a compu tation th at is equ ivalen t to mu ltiplyin g a u n it vector in th e X direction of th e n omin al tran sformation by a distan ce (wh ich is a fu n ction of th e belt en coder readin g) an d addin g th e resu lt to th e position vector of th e n omin al belt tran sformation . Symbolically, th is can be rep­ resen ted as instantaneous_XYZ = nominal_XYZ + (belt_distance * X_direction_of_nominal_transform) wh ere belt_distance = (encoder_count - encoder_offset) * encoder_scaling_factor Th e en coder variables con tain ed in th is fin al equ ation are described in later section s. V+ Lan gu age User's Gu ide Page 3 0 3 Basic Programmin g Con cepts Th e Belt En coder Six belt en coders are su pported by th e con veyor trackin g featu re. E ach belt en coder gen erates pu lses th at in dicate both th e distan ce th at th e belt h as moved an d th e direction of travel. Th e pu lses are cou n ted by th e belt in terface, an d th e cou n t is stored as a sign ed 2 4 ­bit n u mber. Th erefore, th e valu e of an en coder cou n ter can ran ge from 2 23 ­1 (8 ,3 8 8 ,6 0 7 ) to ­2 23 (­8 ,3 8 8 ,6 0 8 ). For example, if a sin gle cou n t of th e en coder cor­ respon ds to 0 .0 2 millimeters (0 .0 0 0 0 8 in ch ) of belt motion , th en th e fu ll ran ge of th e cou n ter wou ld represen t motion of th e belt from approximately ­1 6 7 meters (­5 5 0 feet) to +1 6 7 meters (+5 5 0 feet). After a cou n ter reach es its maximu m positive or n egative valu e, its valu e will roll over to th e maximu m n egative or positive valu e, respectively. Th is mean s th at if th e en coder valu e is in creasin g an d a rollover occu rs, th e sequ en ce of en coder cou n ter valu es will be ... ; 8 ,3 8 8 ,6 0 6 ; 8 ,3 8 8 ,6 0 7 ; ­8 ,3 8 8 ,6 0 8 ; ­8 ,3 8 8 ,6 0 7 ; ... As lon g as th e distan ce between th e workspace of th e robot an d th e n omin al tran sformation of th e belt is with in th e distan ce th at can be represen ted by th e maximu m en coder valu e, V+ application programs n ormally do n ot h ave to take in to accou n t th e fact th at th e cou n ter will periodically roll over. Th e belt_ dis­ tan ce equ ation described above is based u pon a relative en coder valu e: encoder_count - encoder_offset an d V+ au tomatically adju sts th is calcu lation for an y belt rollover th at may occu r. Care mu st be exercised, h owever, if an application processes en coder valu es in an y way. For example, a program may save en coder valu es associated with in dividu al parts on th e con ­ veyor, an d th en later u se th e valu es to determin e wh ich parts sh ou ld be processed by th e robot. In su ch situ ation s th e application program may n eed to con sider th e possibility of roll­ over of th e en coder valu e. NOTE:Wh ile th e en coder cou n ter valu e is stored as a 2 4 ­bit n u mber, th e rate of ch an ge of th e belt en coder (th e speed of th e belt) is main tain ed on ly as a 1 6 ­bit n u mber. Th e belt speed is u sed in tern ally by V+ to predict fu tu re position s on th e belt. Th erefore, th e rate of ch an ge of th e belt en coder sh ou ld n ot exceed 3 2 ,7 6 8 cou n ts per 1 6 millisecon ds. Th e Adept application program for belt calibration in clu des a test for th is con dition an d prin ts a warn in g if th is restriction will be violated. Th is requ iremen t will be a limitation on ly for very h igh ­speed con veyors with very h igh ­resolu tion en coders. Th e En coder S calin g Factor For an y given con veyor/en coder in stallation , th e en coder scalin g factor is a con stan t n u mber th at represen ts th e amou n t th e en coder cou n ter ch an ges du rin g a ch an ge in belt position . Th e u n its of th e scalin g factor are millimeters/cou n t. Th is factor can be determin ed eith er directly from th e details of th e mech an ical cou plin g of th e en coder to th e belt or experimen tally by readin g th e en coder as th e belt is moved. Th e V+ Lan gu age User's Gu ide Page 3 0 4 Basic Programmin g Con cepts Adept belt calibration program su pports eith er meth od of determin in g th e en coder scalin g fac­ tor. If th e en coder cou n ter decreases as th e belt moves in its n ormal direction of travel, th e scal­ in g factor will h ave a n egative valu e. Th e En coder Offset Th e last en coder valu e n eeded for proper operation of th e movin g­lin e system is th e belt en coder offset. Th e belt en coder offset is u sed by V+ to establish th e in stan tan eou s location of th e belt referen ce frame relative to its n omin al location . In particu lar, if th e belt offset is set equ al to th e cu rren t belt en coder readin g, th e in stan ­ tan eou s belt tran sformation will be equ al to th e n omin al tran sformation . Th e belt en coder off­ set can be u sed, in effect, to zero th e en coder readin g, or to set it to a particu lar valu e wh en ever n ecessary. Un like th e en coder scalin g factor, wh ich is con stan t for an y given con ­ veyor/en coder setu p, th e valu e of th e belt en coder offset is variable an d will u su ally be ch an ged often . Normally, th e in stan tan eou s location of th e referen ce frame will be establish ed u sin g extern al in pu t from a sen sory device su ch as a ph otocell or th e AdeptVision system. For example, th e VFE ATURE fu n ction provided by AdeptVision retu rn s as on e of its compu ted valu es th e belt en coder offset th at mu st be set in order to grasp an object iden tified by th e vision system. Th e DE VICE real­valu ed fu n ction also retu rn s latch ed or u n latch ed en coder valu es for u se with SE TBE LT. Th e en coder offset is set with th e SE TBE LT program in stru ction , described in Belt Variable Def­ in ition s n page 3 0 9 . o Th e Belt W in dow Th e belt win dow con trols th e region of th e belt in wh ich th e robot is to work. Th e figu re Con ­ veyor Terms illu strates th e terms u sed h ere. A win dow is a segmen t of th e belt bou n ded by two plan es th at are perpen dicu lar to th e direction of travel of th e belt. Wh en defin in g th e win ­ dow, en su re th at th e robot can reach all con veyor location s with in th e belt win dow. Th is is especially importan t for revolu te (i.e., n on ­Cartesian ) robots. NOTE: Th e win dow h as limits on ly in th e direction alon g th e belt. With in V+, a belt win dow is defin ed by two tran sformation s with a WINDOW program in stru c­ tion . Th e win dow bou n daries are compu ted by V+ as plan es th at are perpen dicu lar to th e direction of travel of th e belt an d th at pass th rou gh th e position s defin ed by th e tran s­ formation s. If th e robot attempts to move to a belt­relative location th at h as n ot yet come with in th e win ­ dow (is u pstream of th e win dow), th e robot can be in stru cted eith er to pau se u n til it can accomplish th e motion or immediately gen erate a program error. If a destin ation moves ou t of th e win dow (is down stream of th e win dow), it is flagged as an error con dition an d th e appli­ V+ Lan gu age User's Gu ide Page 3 0 5 Basic Programmin g Con cepts cation program can specify wh at action is to be taken . (See th e description of th e BE LT.MODE system parameter in V+ Lan gu age Referen ce Gu ide.) If th e n ormal error testin g option s are selected, wh en ever th e V+ system is plan n in g a robot motion to a belt­relative location an d th e destin ation is ou tside th e belt win dow bu t u pstream, th e system au tomatically delays motion plan n in g u n til th e destin ation is with in th e win dow. However, if an application program attempts to perform a motion to a belt­rel­ ative destin ation th at is ou t of th e win dow at plan n in g time (or is predicted to be ou t by th e time th e destin ation wou ld be reach ed) an d th is destin ation is down stream, a win dow­vio­ lation con dition exists. Also, if du rin g th e execu tion of a belt­relative motion or wh ile th e robot is trackin g th e belt, th e destin ation moves ou tside th e belt win dow for an y reason , a win dow violation occu rs. Depen din g u pon th e details of th e application program, th e program eith er prin ts an error message an d h alts execu tion or bran ch es to a specified su brou tin e wh en a win dow violation occu rs. In order to provide flexibility with regard to th e operation of th e win dow­testin g mech an ism, several modification s to th e n ormal algorith ms can be selected by modifyin g th e valu e of th e BE LT.MODE system parameter. To assist in teach in g th e belt win dow, th e Adept con veyor belt calibration program con tain s rou tin es th at lead th e operator th rou gh defin ition of th e requ ired bou n din g tran sformation s. Con veyor Terms V+ Lan gu age User's Gu ide Page 3 0 6 Basic Programmin g Con cepts Belt-Relative Motion Instructions To defin e a robot motion relative to a con veyor belt, or to defin e a relative tran sformation with respect to th e in stan tan eou s location of a movin g frame of referen ce, a belt variable can be u sed in place of a regu lar tran sformation in a compou n d tran sformation . For example, th e in stru ction MOVES %belt:loc_1 directs th e robot to perform a straigh t­lin e motion to location loc_ 1 , wh ich is specified relative to th e location defin ed by th e belt variable %belt. If a belt variable is specified, it mu st be th e first (th at is, leftmost) elemen t in a compou n d tran sformation . On ly on e belt variable can appear in an y compou n d tran sformation . Motion s relative to a belt can be on ly of th e straigh t­lin e type. Attemptin g a join t­in terpolated motion relative to a belt cau ses an error an d h alts execu tion of th e application program. E xcept for th ese restriction s, motion statemen ts th at are defin ed relative to a belt are treated ju st like an y oth er motion statemen t. In particu lar, con tin u ou s­path motion s relative to belts are permitted. On ce th e robot h as been moved to a destin ation th at is defin ed relative to a belt, th e robot tool will con tin u e to track th e belt u n til it is directed to a location th at is n ot relative to th e belt. For example, th e followin g series of in stru ction s wou ld move th e tool to a location rel­ ative to a belt, open th e h an d, track th e belt for two secon ds, close th e h an d, an d fin ally move off th e belt to a fixed location . MOVES %belt[1]:location3 OPENI DELAY 2.00 CLOSEI MOVES fixed.location If th is example did n ot h ave th e secon d MOVE S statemen t, th e robot wou ld con tin u e to track th e belt u n til a belt win dow violation occu rred. As with motion s defin ed relative to a belt, motion s th at move th e tool off a belt (th at is, to a fixed location ) mu st be of th e straigh t­lin e type. Motion T ermination Wh en movin g th e robot relative to a belt, special atten tion mu st be paid to th e con dition s u sed to determin e wh en a motion is completed. At th e con clu sion of a con tin u ou s­path motion V+ n ormally waits u n til all th e join ts of th e man ipu lator h ave ach ieved th eir fin al des­ tin ation s to with in a tigh t error toleran ce before proceedin g to th e n ext in stru ction . In th e case of motion s relative to a belt, th e destin ation is con stan tly ch an gin g an d, depen din g u pon th e magn itu de an d variability of th e belt speed, th e robot may n ot always be able to ach ieve fin al position s with th e defau lt error toleran ce. V+ Lan gu age User's Gu ide Page 3 0 7 Basic Programmin g Con cepts Th erefore, if a motion does n ot su ccessfu lly complete (th at is, it is aborted du e to a Time­ou t n u llin g error), or if it takes an excessive amou n t of time to complete, th e error toleran ce for th e motion sh ou ld be in creased by precedin g th e motion in stru ction with a COARSE in stru c­ tion . In extreme situ ation s it may even be n ecessary to en tirely disable ch eckin g of th e fin al error toleran ce. Th is can be don e by specifyin g NONULL before th e start of th e motion . Defining Belt-Relative Locations In order to defin e location s relative to a belt, belt­relative compou n d tran sformation s can be u sed as parameters to all th e stan dard V+ teach in g aids. For example, all th e followin g com­ man ds defin e a location loc_ 1 relative to th e cu rren t belt location :1 HERE %belt:loc_1 POINT %belt:loc_1 TEACH %belt:loc_1 In each of th ese cases, th e in stan tan eou s location correspon din g to %belt wou ld be deter­ min ed (based u pon th e readin g of th e belt en coder associated with %belt); loc_ 1 wou ld be set equ al to th e differen ce between th e cu rren t tool location an d th e in stan tan eou s location defin ed by %belt. Wh ile a belt variable can be u sed as th e first (leftmost) elemen t of a compou n d tran s­ formation to defin e a tran sformation valu e, a belt variable can n ot appear by itself. For exam­ ple, LISTL will n ot display a belt variable directly. To view th e valu e of a belt variable, en ter th e comman d: LISTL %belt_variable:NULL 1Before defin in g a location relative to a belt, you mu st make su re th e belt en coder offset is set properly. Th at u su ally in volves issu in g a mon itor comman d in th e form: DO SETBELT %belt = BELT(%belt) V+ Lan gu age User's Gu ide Page 3 0 8 Movin g­Lin e Programmin g Moving-Line Programming Th is section describes h ow to access th e movin g­lin e capabilities with in V+. A fu n ction al over­ view is presen ted th at su mmarizes th e exten sion s to V+ for Con veyor Trackin g. All th e V+ movin g­lin e keywords are described in detail in th e V+Lan gu age Referen ce Gu ide. Th e movin g­lin e exten sion s to V+ in clu de: l In stru ction s an d fu n ction s (th ere are n o mon itor comman ds) l System switch l System parameters Instructions and Functions Th is section su mmarizes th e V+ in stru ction s an d fu n ction s dedicated to movin g­lin e proc­ essin g. Th e belt­related fu n ction s retu rn real valu es. Belt Variable Definitions Th e followin g keywords are u sed to defin e th e parameters of belt variables. Some param­ eters are typically set on ce, based u pon in formation derived from th e belt calibration pro­ cedu re. Oth er parameters are ch an ged dyn amically as th e application program is execu tin g. DE FBE LT Program in stru ction th at creates a belt variable an d defin es its static ch ar­ acteristics: n omin al tran sformation , en coder n u mber, an d en coder scal­ in g factor. SE TBE LT Program in stru ction to set th e en coder offset of a belt variable. Th is defin es th e in stan tan eou s belt location relative to th at of th e n omin al belt tran sformation . WINDOW Program in stru ction for establish in g th e belt win dow bou n daries an d specifyin g a win dow­violation error su brou tin e. E ncoder Position and Velocity Information Th e followin g fu n ction is u sed to read in formation con cern in g th e en coder associated with a belt variable. BE LT Real­valu ed fu n ction th at retu rn s th e in stan tan eou s en coder cou n ter valu e or th e rate of ch an ge of th e en coder cou n ter valu e. Window T esting Th e followin g fu n ction allows an application program to in corporate its own specialized work­ in g­region strategy, in depen den t of th e strategy provided as an in tegral part of th e V+ V+ Lan gu age User's Gu ide Page 3 0 9 Movin g­Lin e Programmin g con veyor trackin g system. WINDOW Real­valu ed fu n ction th at in dicates wh ere a belt­relative location is (or will be at some fu tu re time) relative to a belt win dow. Status Information Th e followin g fu n ction in dicates th e cu rren t operatin g statu s of th e movin g­lin e software. BSTATUS Real­valu ed fu n ction th at retu rn s bit flags in dicatin g th e statu s of th e movin g­lin e software. System Switch Th e switch BE LT en ables/disables th e operation of th e movin g­lin e software. (See th e descrip­ tion of E NABLE , DISABLE , an d SWITCH for details on settin g an d displayin g th e valu e of BE LT.) BE LT Th is switch mu st be en abled before an y con veyor trackin g processin g begin s. System Parameters Th e followin g parameter selects altern ative modes of operation of th e belt win dow testin g rou ­ tin es. See th e description of PARAME TE R for details on settin g an d displayin g th e parameter valu es. BE LT.MODE Bit flags for selectin g special belt win dow testin g modes of operation . V+ Lan gu age User's Gu ide Page 3 1 0 Sample Programs Sample Programs Th e followin g program is an example of a robot task workin g from a con veyor belt. Th e task con sists of th e followin g steps: 1 . Wait for a sign al th at a part is presen t. 2 . Pick u p th e part. 3 . Place th e part at a n ew location on th e belt. 4 . Retu rn to a rest location to wait for th e n ext part. CAUTI ON: Th ese programs are mean t on ly to illu strate programmin g tech n iqu es u sefu l in typical application s. Movin g­lin e programs are h ard­ ware depen den t becau se of th e belt parameters, so care mu st be exer­ cised if you attempt to u se th ese programs. ; *** PROGRAM TO RELOCATE PART ON CONVEYOR *** ; Set up belt parameters ENABLE BELT PARAMETER BELT.MODE = 0 belt.scale = 0.03067 ;Encoder scale factor ; Define belt twice, for two stations DEFBELT %b1 = belt, 1, WINDOW %b1 = window.1, DEFBELT %b2 = belt, 2, WINDOW %b2 = window.1, WHILE TRUE DO WAIT part.ready bx = BELT(%b1) SETBELT %b1 = bx SETBELT %b2 = bx APPROS %b1:p1, 50 MOVES %b1:p1 CLOSEI DEPARTS 50 APPROS %b2:p2, 50 MOVES %b2:p2 OPENI DEPARTS 50 MOVES wait.location END ; *** End of program *** 32, belt.scale window.2, window.error 32, belt.scale window.2, window.error ;Loop indefinitely ;Wait for signal that part present ;Read present belt position ;Set encoder offset for pick-up... ;... and drop-off stations ;Move to the part and pick it up ;Carry part to drop-off location ;Return to rest location ;Wait for the next part V+ Lan gu age User's Gu ide Page 3 1 1 Sample Programs Th e WINDOW in stru ction in th e above program in dicates th at wh en ever a win dow violation occu rs, a su brou tin e n amed win dow.error is to be execu ted. Th e followin g is an example of wh at su ch a rou tin e migh t con tain . ; *** WINDOW VIOLATION ROUTINE *** TYPE /B, /C1, "** WINDOW ERROR OCCURRED **", /C1 ; Find out which end of window was violated IF DISTANCE(HERE,window.1) < DISTANCE(HERE,window.2) THEN ; Error occurred at window.2 TYPE "Part moved downstream out of reach" ;...(Respond to downstream window error) . ELSE ; Error occurred at window.1 TYPE "Part moved upstream out of reach" ;...(Respond to upstream window error) . END MOVES wait.location ;Move robot to rest location ; Use digital output signals to sound alarm and stop belt SIGNAL alarm, stop.belt HALT ;Halt program execution V+ Lan gu age User's Gu ide Page 3 1 2 Mu ltiProcessor Systems MultiProcessor Systems Introduction R equirements for Motion Systems Allocatin g Servos with an MI­3 or MI­6 Board Allocatin g Servos with a E JI Board Conveyor Belt Encoders Force Sensors Installing Processor Boards Processor Board Locations Slot O rdering of Processor Boards Processor Board Addressing Customizing Processor Workloads Assigning W orkloads W ith CO NFIG_C Using Multiple V+ Systems Requirements for Running Multiple V+ Systems Using V+ Commands W ith Multiple V+ Systems Au tostart Accessin g th e Comman d Prompt Intersystem Communications Shared Data IO TAS and Data Integrity Efficiency Considerations Digital I/O R estrictions With Multiprocessor Systems High ­Level Motion Con trol Tasks Periph eral Drivers V+ Lan gu age User's Gu ide Page 3 1 3 In trodu ction Introduction In most cases, you r con troller h as already been precon figu red at th e factory with su fficien t processors for you r application . Occasion ally, h owever, you r application s may be more deman din g an d n eed mu ltiple processors an d possibly mu ltiple. You can h ave an au xiliary processor board in stalled in an Adept MV con troller. To correctly u se mu ltiple (au xiliary) processors with you r system, you n eed to con sider th e followin g: l Processor an d memory requ iremen ts l In stallation of th e processor boards l Assign men t of th e processor workloads V+ Lan gu age User's Gu ide Page 3 1 5 Requ iremen ts for Motion Systems R equirements for Motion Systems Th is section details th e motion boards setu p wh en more th an on e motion board is presen t in th e system. Allocatin g S ervos with an MI -3 or MI -6 Board Wh en associatin g servo processes with a motion in terface board, all ch an n els of a motion in terface board mu st be serviced by th e same processor. In addition , wh en a motion in ter­ face board is assign ed to a processor board, it allocates all of th e available servo processes per board even if less th an th e maximu m n u mber of axes are bein g serviced. For example, if you are con trollin g a fou r­axis robot with two MI­3 boards, you mu st assign all th ree ch an n els of th e first MI­3 board to a sin gle processor as a grou p. Likewise, you mu st assign all th ree ch an n els of th e secon d MI­6 to a sin gle processor (alth ou gh it n eed n ot be th e same processor as th e first th ree axes). If you assign th e two MI­6 s to th e same proc­ essor, six servo processes on th at board are occu pied even th ou gh on ly fou r ch an n els are bein g u sed. In th is situ ation , th e processor compu tation al load correspon ds to th at for fou ­ raxes, bu t n o addition al MI­6 s can be con trolled by th is processor. Allocatin g S ervos with a EJI Board Wh en associatin g servo processes with an E JI (E n h an ced Join t In terface) board, all ch an n els of th e E JI mu st be serviced by th e same processor board. In addition , wh en an E JI is assign ed to a processor board, it allocates eigh t of th e available servo processes per board even if less th an eigh t axes are bein g serviced. For example, if you are con trollin g a fou r­axis robot with two E JI boards, you mu st assign all eigh t ch an n els of th e first E JI board to a sin gle processor as a grou p. Likewise, you mu st assign all eigh t ch an n els of th e secon d E JI to a sin gle processor (alth ou gh it n eed n ot be th e same processor as th e first 8 axes). If you assign th e two E JIs to th e same processor, 1 6 servo processes on th at board are occu pied even th ou gh on ly fou r ch an n els are bein g u sed. In th is situ ation , th e processor compu tation al load correspon ds to th at for fou r axes. Conveyor Belt E ncoders With a V+E xten sion s Licen se, you can in stall a maximu m of on e en coder device modu le. Th e E n coder Device modu le su pports u p to six en coders (th e defau lt is two). Th u s, you can in ter­ face a maximu m of six con veyor belt en coders to a con troller. E ach belt en coder requ ires on e servo ch an n el alth ou gh it adds a n egligible amou n t of compu tation al load. Th ese en coders are ph ysically con n ected th rou gh an E JI, MI­6 , MI­3 . Force Sensors Th e AdeptForce VME option allows u p to th ree force sen sors per con troller. E ach sen sor requ ires on e Force In terface Board (VFI). You can assign on e or two VFIs to each processor board. E ach of th ese force sen sors requ ires on e elemen t of th e servo axis allocation . V+ Lan gu age User's Gu ide Page 3 1 6 Requ iremen ts for Motion Systems Th e force sen sor loads th e processor compu tation ally on ly wh en a force­sen sin g operation is takin g place, an d th e load is somewh at less th an a sin gle serviced axis. V+ Lan gu age User's Gu ide Page 3 1 7 In stallin g Processor Boards Installing Processor Boards Th is section provides an overview of in stallin g au xiliary processor boards, in clu din g: l Board location s l Slot orderin g l Board addressin g l System con troller fu n ction s Processor Board Locations In each con troller, th e first slot available for processor boards mu st be occu pied by an AWC processor. Th is processor mu st be addressed as board 1 an d it mu st h ave th e system con ­ troller fu n ction s en abled. Th is processor is con sidered th e system processor. Slot Orderin g of Processor Boards In gen eral, you sh ou ld con figu re th e fastest processor with th e greatest amou n t of memory as processor #1 . Processor Board Addressing Th e system processor mu st reside in slot 1 an d be addressed as board 1 . Th e au xiliary proc­ essor mu st be addressed as processor 2 . It does n ot matter wh ich slot an au xiliary processor is in . For details on settin g th e board address see th e Adept MV Con troller User's Gu ide. V+ Lan gu age User's Gu ide Page 3 1 8 Cu stomizin g Processor Workloads Customizing Processor Workloads Gen erally, th e defau lt assign men t of processor workloads is su fficien t for most application s. However, if th e defau lt assign men ts do n ot su it you r application , you can cu stomize th em. You can assign th e followin g system tasks to th e au xiliary processor: l Vision processin g You can assign each vision system in th e con troller to a specific processor. l Servo processin g You can assign th e servo task for each VMI board to a specific processor. l A copy of th e V+comman d processor E ach processor can ru n an in dividu al copy of th e V+comman d processor. See Usin g Mu ltiple V+ Systems on page 3 2 0 for more details on mu ltiple copies of V+. Assigning Workloads With CONFIG_C Th e assign men t of workloads to th e differen t processors is au tomatic in most cases. How­ ever, you may examin e or override th e defau lts u sin g th e CONFIG_ C con figu ration u tility. Th e defau lt con figu ration implemen ts th e followin g processor workload con figu ration s: l l l If on ly on e processor is in stalled, all tasks ru n on th at processor. If a secon d processor is presen t, th e vision task an d servo tasks for th e first two motion boards are au tomatically assign ed to it. If th e V+ E xten sion s licen se is in stalled, a copy of th e V+ comman d processor is also available on each in stalled processor. In most cases, th e copy of V+ on th e au xiliary processor will be idle. Th at is, it will n ot be execu tin g an y u ser tasks. Wh en idle, V+ u ses less th an on e percen t of th e processor time. V+ Lan gu age User's Gu ide Page 3 1 9 Usin g Mu ltiple V+ Systems Using Multiple V+ Systems For application s deman din g extremely in ten sive V+processin g, it is possible to ru n a copy of V+ on every processor. Th is section details th e requ iremen ts an d con sideration s n eeded to ru n mu ltiple V+ systems. Requirements for Running Multiple V+ Systems You mu st h ave th e followin g items before you can u se mu ltiple processors to ru n mu ltiple V+ systems. l V+ E xten sion s licen se l CONFIG_ C u tility program l On e processor for every V+ system th at you in ten d to ru n l A graph ics­based system If you are u sin g addition al processors for vision or servo processin g on ly, you do n ot n eed a V+ E xten sion s licen se. Con tact you r local Adept sales office for more in formation on th is licen se. Using V+ Commands With Multiple V+ Systems If more th an on e processor is ru n n in g a copy of V+ an d th e MONITORS system switch is en a­ bled, mu ltiple mon itor win dows can be displayed. Th e first mon itor win dow is th e n ormal mon itor win dow for th e system processor (labeled Mon itor). Th e mon itor win dows for th e oth er V+ system is labeled Mon itor_ 2 . Th e processor can ru n its own in depen den t V+ sys­ tem, an d can perform all of th e V+ fu n ction s with th e exception s described in Restriction s With Mu ltiprocessor Systems on page 3 2 5 . Au tostart Wh en th e au tostart program is u sed with processor 1 , it fu n ction s in th e same man n er th at it does on a sin gle V+ system an d performs th e followin g comman ds: LOAD/Q auto COMM auto Wh en au tostart is u sed with V+ processor 2 , th e program performs th e followin g com­ man ds: LOAD/Q auto02 COMM auto02 wh ere n is V+ system n u mber 2 . You do n ot h ave to en able th e MONITORS system switch u n less you wan t access to th e V+ comman d lin e wh en u sin g au tostart to execu te programs on system 2 . V+ Lan gu age User's Gu ide Page 3 2 0 Usin g Mu ltiple V+ Systems Th e au tostart fu n ction is en abled for all processors u sin g CONFIG_ C u tility " Con troller NVRAM" men u selection . See th e In stru ction s for Adept Utility Programs for more details. Accessin g th e Comman d Prompt If you are n ot u sin g au tostart, you mu st en able th e MONITORS system switch an d u se th e Adept pu ll­down men u to select th e Mon itor win dow for th e system you wan t to comman d. You can th en en ter V+ comman ds (su ch as LOAD an d E XE CUTE ) at th e V+ comman d prompt (.). See th e V+ Lan gu age Referen ce Gu ide for a description of th e MONITORS system switch . E ach time th e con troller is tu rn ed on , th e defau lt is th at th e au xiliary mon itor win dow (Mon ­ itor_ 2 ) is h idden an d disabled. To en able it, type th e comman d E NABLE MONITORS. Intersystem Communications V+ application programs ru n n in g on th e same processor commu n icate in th e n ormal way, u sin g global V+ variables. V+ can execu te u p to seven tasks simu ltan eou sly on each proc­ essor, or u p to 2 8 tasks if th e V+ E xten sion s software licen se is in stalled. Wh en mu ltiple V+ systems are ru n n in g, each operates on its own processor an d fu n ction s in depen den tly. Programs an d global variables for on e V+ system are n ot accessible to th e oth er V+ systems. Application programs ru n n in g on differen t V+ systems can commu n icate th rou gh an 8 KB reserved section of sh ared memory on each board. Th is memory area is u sed on ly for com­ mu n ication between V+ application programs. It is n ot u sed for an y oth er pu rpose. You can access th is memory th rou gh th e followin g: l th e six IOPUT_ in stru ction s l l IOPUTD l IOPUTF l IOPUTL l IOPUTS l l IOPUTB IOPUTW th e five IOGE T_ real­valu ed fu n ction s l IOGE TB l IOGE TD l IOGE TF l IOGE TL l IOGE TW V+ Lan gu age User's Gu ide Page 3 2 1 Usin g Mu ltiple V+ Systems l th e strin g fu n ction $ IOGE TS E ach of th e above keywords h as a type parameter. Type 0 (zero), th e defau lt, is u sed to access memory on oth er Adept V+ processors. See th e V+ Lan gu age Referen ce Gu ide or f more details. You can u se th e real­valu ed fu n ction IOTAS to in terlock access to th is memory. Shared Data Th e IOGE T_ , $ IOGE TS, an d IOPUT_ keywords allow th e followin g to be written an d read: l Sin gle bytes l 1 6 ­bit words l 3 2 ­bit lon g­words l 3 2 ­bit sin gle­precision floatin g­poin t valu es l 6 4 ­bit dou ble­precision floatin g­poin t valu es l Strin gs u p to 1 2 8 bytes An address parameter in dicates th e position with in th e application sh ared area th at is to be written to or from. Acceptable address valu es are 0 to h exadecimal 1 FFF (decimal 8 1 9 1 ). An y Adept system processor can access th e sh ared memory areas of all th e Adept system processors (in clu din g its own area). Th e IOGE T_ , $ IOGE TS, IOPUT_ an d IOTAS keywords h ave an option al parameter to specify th e processor n u mber. Th e defau lt valu e for th e proc­ essor parameter is zero, wh ich is th e local processor (th at is, th e processor on wh ich th e in stru ction is execu tin g). A n on zero valu e for th e processor parameter cau ses th at processor to be accessed. (Note th at a processor can access itself as eith er processor 0 or by its real processor n u mber.) For example, th e in stru ction : IOPUTS ^HFF, 0, 2 = "Hello" will write five ASCII bytes to th e sh ared memory area on processor 2 at th e address ^HFF. Adept MV con trollers su pport fou r processors, n u mbered 1 th rou gh 4 . Th e processor n u mber is establish ed by th e board­address switch es on th e processor modu le. Th e V+ mon itor win ­ dow in dicates th e n u mber of th e processor with wh ich it is associated: Th e mon itor win dow for processor 1 is simply en titled Mon itor; th e win dow for processor 2 is en titled Mon itor_ 2 . CAUTI ON: V+ does n ot en force an y memory­protection sch emes for u se of th e application sh ared memory area. It is you r respon sibility to keep track of memory u sage. If you are u sin g application or u tility pro­ grams (for example, Adept AIM Vision Ware or AIM Motion Ware) you sh ou ld read th e docu men tation provided with th at software to be su re th at th ere is n o con flict with you r u sage of th e sh ared area. AIM u sers V+ Lan gu age User's Gu ide Page 3 2 2 Usin g Mu ltiple V+ Systems sh ou ld n ote th at Adept plan s to assign application sh ared memory start­ in g from th e top (address h exadecimal 1 FFF) an d workin g down . Th ere­ fore, you sh ou ld start at th e bottom (address 0 ) an d work u p. If you read a valu e from a location th at h as n ot been previou sly written to, you get an in valid valu e: You do n ot get an error message. Th e system provides a valu e based u pon th e defau lt memory con ten ts an d th e man n er in wh ich th e memory is bein g read. (E very byte of th e application sh ared area is in itialized to zero wh en V+ is in itialized.) Th e memory addresses are based on sin gle­byte (8 ­bit) memory location s. For example, if you write a 3 2 ­bit (4 ­byte) valu e to an address, th e valu e occu pies fou r address spaces (th e address th at you specify an d th e n ext th ree addresses). If you read a valu e from a location u sin g a format differen t from th e format th at was u sed to write to th at location , you also get an in valid valu e: You do n ot get an error message. Th e sys­ tem will provide a valu e based u pon th e defau lt memory con ten ts. (For example, if you write u sin g IOPUTF an d read u sin g IOPUTL, th e valu e read is in valid.) IOT AS and Data Integrity Some IOPUT_ an d IOGE T_ operation s in volve mu ltiple h ardware read or write cycles. For example, all 6 4 ­bit operation s will in volve at least two 3 2 ­bit data tran sfers (th ree tran sfers if th e operation crosses more th an on e 3 2 ­bit bou n dary). If a 1 6 ­bit or 3 2 ­bit operation crosses a 3 2 ­bit bou n dary, it in volves two tran sfers. You can in terlock operation s th at mu st cross a 3 2 ­bit bou n dary u sin g th e IOTAS( ) fu n ction . Th e syn tax an d an example are given in th e V+ Lan gu age Referen ce Gu ide. Th e IOTAS fu n ction performs a h ardware­level, read­modify­write (RMW) cycle on th e VME ­ bu s to make a Test An d Set operation in divisible in a mu ltiprocessin g en viron men t. If mu ltiple processors all access th e same byte by u sin g IOTAS, th e byte can serve as an in terlock between th e processors. W ARNI NG: Depen din g on th e application , th ere is a possibility th at a V+ program ru n n in g on on e processor may u pdate a sh ared­memory area wh ile a program on an oth er processor is readin g it. In th is case, data th at is read across a 3 2 ­bit bou n dary may be in valid. If th e data is bein g u sed for safety­critical operation s, in clu din g robot motion s, be su re to u se th e IOTAS fu n ction to preven t su ch con flicts. E fficiency Considerations You can pu t you r sh ared data on an y processor. However, it is most efficien t to pu t th e data on th e processor th at will u se it most often , or th at is performin g th e most time­critical oper­ ation s. (It takes sligh tly lon ger to access data on an oth er processor th an to access data on th e local processor.) If you wish , you can pu t some of you r data on on e processor an d oth er V+ Lan gu age User's Gu ide Page 3 2 3 Usin g Mu ltiple V+ Systems data on a differen t processor. You mu st be carefu l to keep track of wh ich data items are stored in wh ich location . 3 2 ­bit an d 6 4 ­bit operation s operate sligh tly faster if th e address is an exact mu ltiple of fou r. 1 6 ­bit operation s operate sligh tly faster if th e address is an exact mu ltiple of two. Digital I/O Th e digital I/O image­ in clu din g in pu t (1 0 0 1 ­1 5 1 2 ), ou tpu t (1 ­5 1 2 ), an d soft sign als (2 0 0 0 ­ 2 5 1 2 an d 3 0 0 1 ­3 0 0 4 )­is man aged by processor 1 . Th ese sign als are sh ared by all proc­ essors. You can u se th e soft sign als to pass con trol in formation between processors. V+ Lan gu age User's Gu ide Page 3 2 4 Restriction s With Mu ltiprocessor Systems R estrictions With Multiprocessor Systems You can set u p certain tasks to operate on an y processor board, in clu din g servo tasks, vision tasks, an d in some cases, V+ u ser tasks. However, th ere are several V+ operation s th at can be performed on ly from Processor 1 : l Robot con trol l System con figu ration ch an ges l Certain comman ds/in stru ction s l l E NABLE /DISABLE of ROBOT l l E NABLE /DISABLE of POWE R INSTALL High ­level motion con trol tasks l l kin ematic solu tion program execu tion l V+ motion in stru ction s su ch as MOVE in stru ction s l l trajectory gen eration V+ force in stru ction s su ch as FORCE .RE AD in stru ction s DeviceNet Processors oth er th an processor 1 always start u p with th e stan d­alon e con trol modu le, with n o belts or kin ematic modu les loaded. If attempted on an oth er processor, th e V+ operation s listed above retu rn s th e error: -666 *Must use Monitor #1* with th e exception of a V+ force in stru ction , wh ich retu rn s th e followin g error: -666 *Device Hardware not Present* High -Level Motion Con trol Tasks As more axes are added to th e system, th e h igh ­level motion con trol compu tation al load on processor 1 in creases, even if th e servo processin g is allocated to oth er processors. For an y given application , th e processin g power requ ired to execu te th e h igh ­level motion con trol is a fu n ction of wh ich kin ematic modu les are u sed. It mu st be evalu ated on a case­ by­case basis. Periph eral Drivers Th ere is an impact on processor 1 wh en ever an au xiliary processor accesses on e of th ese devices. However, commu n ication s between a processor board an d its local serial lin es, dig­ ital I/O, an d an alog I/O operate on th e processor on wh ich th e V+ in stru ction is execu ted. V+ Lan gu age User's Gu ide Page 3 2 5 E xample V+ Programs Example V+ Programs Introduction Pick and Place Features Introduced Program Listing Detailed Description Menu Program Features Introduced Program Listing Teaching Locations With the MCP Features Introduced Program Listing Defining a Tool Transformation V+ Lan gu age User's Gu ide Page 3 2 6 In trodu ction Introduction Th is ch apter con tain s a samplin g of V+ programs. Th e first program is presen ted twice: on ce in its en tirety exactly as it is displayed by V+ an d a secon d time with a lin e­by­lin e expla­ n ation . Th e program keywords are detailed in th e V+Lan gu age Referen ce Gu ide. NOTE:Th e programs in th is man u al are n ot n ecessarily complete. In most cases fu rth er refin emen ts cou ld be added to improve th e programs. For example, th e programs cou ld be made more toleran t of u n u su al even ts su ch as error con dition s. V+ Lan gu age User's Gu ide Page 3 2 8 Pick an d Place Pick and Place Th is program demon strates a simple pick­an d­place application . Th e robot picks u p parts at on e location an d places th em at an oth er. Features Introduced l Program in itialization l Variable assign men t l System parameter modification l FOR loop l Motion in stru ction s l Han d con trol l Termin al ou tpu t Program Listing .PROGRAM move.parts() ; ABSTRACT: Pick up parts at location pick and put them down at place parts = 100 ;Number of parts to be processed height1 = 25.4 ;Approach/depart height at "pick" height2 = 50.8 ;Approach/depart height at "place" PARAMETER HAND.TIME = 0.16 ;Set up for slow hand OPEN RIGHTY MOVE start ;Make sure the hand is open ;Make sure configuration is correct ;Move to safe starting location FOR i = 1 TO parts ;Process the parts APPRO pick, height1 MOVES pick CLOSEI DEPARTS height1 APPRO place, height2 MOVES place OPENI DEPARTS height2 END ;Go toward the pick-up ;Move to the part ;Close the hand ;Back away ;Go toward the put-down ;Move to the destination ;Release the part ;Back away ;Loop for next part TYPE "All done. ", /I0, parts, " parts processed" V+ Lan gu age User's Gu ide Page 3 2 9 Pick an d Place RETURN ;End of the program .END Detailed Description Th is program h as five section s: formal in trodu ction , in itialization of variables, in itialization of th e robot location , performan ce of th e desired motion sequ en ce, an d n otice to th e operator of completion of th e task. E ach of th ese section s is described in detail below. Th e first lin e of every program mu st h ave th e form of th e lin e below. It is a good practice to fol­ low th at lin e with a brief description of th e pu rpose of th e program. If th ere are an y special requ iremen ts for u se of th e program, th ey sh ou ld be in clu ded as well. .PROGRAM move.parts() Th is lin e iden tifies th e program to th e V+ system. In th is case we see th at th e n ame of th e program is move.parts. ; ABSTRACT: Pick up parts at location "pick" and put them down at "place" Th is is a very brief description of th e operation performed by th e program. (Most programs requ ires a more exten sive su mmary.) Use variables to represen t con stan ts for two reason s: Usin g a variable n ame th rou gh ou t a pro­ gram makes th e program easier to u n derstan d, an d on ly on e program lin e mu st be modified if th e valu e of th e con stan t is ch an ged. parts = 100 Tell th e program h ow man y parts to process du rin g a produ ction ru n . In th is case, 1 0 0 parts are processed. height1 = 25.4 Heigh t1 con trols th e h eigh t of th e robot path wh en approach in g an d departin g from th e loca­ tion wh ere th e parts are to be picked u p. Here it is set to 2 5 .4 millimeters (th at is, 1 in ch ). height2 = 50.8 Similar to h eigh t1 , h eigh t2 sets th e h eigh t of th e robot path wh en approach in g an d departin g from th e pu t­down location . It is set to 5 0 .8 millimeters (2 in ch es). PARAMETER HAND.TIME 0.16 Set th e system parameter HAND.TIME so th at su fficien t time is allowed to actu ate th e robot h an d. Th is settin g cau ses OPE NI an d CLOSE I in stru ction s to delay program execu tion for 1 6 0 mil­ lisecon ds wh ile th e h an d is actu ated. V+ Lan gu age User's Gu ide Page 3 3 0 Pick an d Place In itially, you sh ou ld also make su re th at th e robot h as th e desired h an d open in g, is at a safe startin g location , an d th at SCARA robots h ave th e desired con figu ration . RIGHTY Make su re th e robot h as a righ t­h an ded con figu ration (with th e elbow of th e robot to th e righ t side of th e workspace). Th is is importan t if th ere are obstru ction s in th e workspace th at mu st be avoided. Th is in stru ction cau ses th e robot to assu me th e requ ested con figu ration du rin g its n ext motion . OPEN Make su re th e h an d is in itially open . Th is in stru ction is execu ted du rin g th e n ext robot motion , rath er th an immediately as is don e by th e OPE NI in stru ction . MOVE start Move to a safe startin g location . Becau se of th e precedin g two in stru ction s, th e robot assu mes a righ t­h an ded con figu ration with th e h an d open . Th e location start mu st be defin ed before th e program is execu ted. Th at can be don e, for example, with th e HE RE comman d. Th e location mu st be ch osen su ch th at th e robot can move from it to th e pick­u p location for th e parts with ou t h ittin g an yth in g. After in itialization , th e followin g program section performs th e application tasks. FOR i = 1 TO parts Start a program loop. Th e followin g in stru ction s (down to th e E ND) will be execu ted parts times. After th e last time th e loop is execu ted, program execu tion con tin u es with th e TYPE in stru ction followin g th e E ND below. APPRO pick, height1 Move th e robot to a location th at is h eigh t1 millimeters above th e location pick. Th e APPROS in stru ction is n ot u sed h ere becau se its straigh t­lin e motion wou ld be slower th an th e motion comman ded by APPRO. MOVES pick Move th e robot to th e pick­u p location pick, wh ich mu st h ave been defin ed previou sly. Th e straigh t­lin e motion comman ded by MOVE S assu res th at th e h an d does n ot h it th e part du rin g th e motion . A MOVE in stru ction cou ld be u sed h ere if th ere is su fficien t clearan ce between th e h an d an d th e part to allow for a n on straigh t­lin e path . CLOSEI V+ Lan gu age User's Gu ide Page 3 3 1 Pick an d Place Close th e h an d. To assu re th at th e part is grasped before th e robot moves away, th e I form of th e CLOSE in stru ction is u sed­program execu tion will be su spen ded wh ile th e h an d is closin g. DEPARTS height1 Now th at th e robot is graspin g th e part, we can back away from th e part h older. Th is in stru c­ tion moves th e h an d back h eigh t1 millimeters, followin g a straigh t­lin e path to make su re th e part does n ot h it its h older. APPRO place, height2 MOVES place OPENI DEPARTS height2 Similar to th e above motion sequ en ce, th ese in stru ction s cau se th e part to be moved to th e pu t­down location an d released. END Th is marks th e en d of th e FOR loop. Wh en th is in stru ction is execu ted, con trol is tran sferred back to th e FOR in stru ction for th e n ext cycle th rou gh th e loop (u n less th e loop cou n t spec­ ified by parts is exceeded). Th e fin al section of th e program simply displays a message on th e system termin al an d ter­ min ates execu tion . TYPE "All done. ", /I0, parts, " pieces processed." Th e above in stru ction ou tpu ts th e message: All done. 100 pieces processed. (Th e /I0 format specification in th e in stru ction cau ses th e valu e of parts to be ou tpu t as an in teger valu e with ou t a decimal poin t.) RETURN Alth ou gh n ot absolu tely n ecessary for proper execu tion of th e program, it is good pro­ grammin g practice to in clu de a RE TURN (or STOP) in stru ction at th e en d of every program. .END Th is lin e is au tomatically in clu ded by th e V+ editor to mark th e program's en d. V+ Lan gu age User's Gu ide Page 3 3 2 Men u Program Menu Program Th is program displays a men u of operation s from wh ich an operator can ch oose. Features Introduced l Su brou tin es l Local variables l Termin al in teraction with operator l Strin g variables l WHILE an d CASE stru ctu res Program Listing .PROGRAM sub.menu() ; ABSTRACT: This program provides the operator with a menu of ; operation selections on the system terminal. After accepting ; input from the keyboard, the program executes the desired ; operation. In this case, the menu items include execution of ; the pick and place program, teaching locations for the pick ; and place program, and returning to a main menu. ; ; SIDE EFFECTS: The pick and place program may be executed, and ; locations may be defined. AUTO choice, quit, $answer quit = FALSE DO TYPE TYPE TYPE TYPE /C2, /C1, /C1, /C1, "PICK AND PLACE OPERATIONAL MENU" " 1 => Initiate pick and place" " 2 => Teach locations" " 3 => Return to previous menu", /C1 PROMPT "Enter selection and press RETURN: ", $answer choice = VAL($answer) ;Convert string to number CASE choice OF ;Process menu VALUE 1: ;...selection TYPE /C2, "Initiating Operation..." CALL move.parts() VALUE 2: ;...selection CALL teach() VALUE 3: ;...selection quit = TRUE ANY ;...any other V+ Lan gu age User's Gu ide Page 3 3 3 request... 1 2 3 selection Men u Program TYPE /B, /C1, "** Invalid input **" END ;End of CASE structure UNTIL quit ;End of DO structure .END V+ Lan gu age User's Gu ide Page 3 3 4 Teach in g Location s With th e MCP Teaching Locations With the MCP Th is program demon strates h ow an operator can teach location s with th e man u al con trol pen dan t, th u s allowin g th e con troller to operate with ou t a system termin al. Th e two­lin e liq­ u id crystal display (LCD) of th e pen dan t is u sed to prompt th e operator for th e location s to be tau gh t. Th e operator can th en man u ally position th e robot at a desired location an d press a key on th e pen dan t. Th e program au tomatically records th e location for later u se (in th is case, for th e pick­an d­place program). Features Introduced l Su brou tin e parameters l Attach men ts an d detach men ts l Man u al con trol pen dan t in teraction l WAIT in stru ction l Location defin ition with in a program Program Listing .PROGRAM teach(pick, place, start) ; ; ; ; ; ; ; ; ABSTRACT: This program is used for teaching the locations "pick", "place", and "start" for the "move.parts" program. INPUT PARAM: None OUTPUT PARAM: pick, place, and start SIDE EFFECTS: Robot is detached while this routine is active AUTO $clear.display $clear.display = $CHR(12)+$CHR(7) ATTACH (1) ;Connect to the pend- ant DETACH (0) the robot ;Release control of ; Output prompt to the display on the manual control pendant WRITE (1) $clear.display, "Move robot to 'START' & press RECORD" WRITE (1) /X17, "RECORD", $CHR(5), /S WRITE (1) $CHR(30), $CHR(3), /S ;Blink LED on control pendant WAIT PENDANT(3) ;Wait for key to be HERE start ;Record the location pressed "start" WAIT NOT PENDANT(3) ; Prompt for second location V+ Lan gu age User's Gu ide Page 3 3 5 Teach in g Location s With th e MCP WRITE (1) $clear.display, "Move robot to 'PICK' & press RECORD" WRITE (1) /X17, "RECORD", $CHR(5), /S WAIT PENDANT(3) ;Wait for key to be HERE pick ;Record the location pressed "pick" WAIT NOT PENDANT(3) ; Prompt for third location WRITE (1) $clear.display, "Move robot to 'PLACE' & press RECORD" WRITE (1) /X17, "RECORD", $CHR(5), /S WAIT PENDANT(3) ;Wait for key to be HERE place ;Record the location pressed "place" WAIT NOT PENDANT(3) ATTACH (0) ;Reconnect to the DETACH (1) ;Release the pendant RETURN ;Return to calling pro- robot gram .END V+ Lan gu age User's Gu ide Page 3 3 6 Defin in g a Tool Tran sformation Defining a Tool Transformation Th e followin g program establish es a referen ce poin t from wh ich tool tran sformation s can be tau gh t. .PROGRAM def.tool() ; ABSTRACT: Invoke a new tool transformation based on a predefined reference ; location and, optionally, teach the reference location. AUTO $answer TYPE /C1, "PROGRAM TO DEFINE TOOL TRANSFORMATION", /C1 ATTACH (1) ;Attach the pendant PROMPT "Revising a previously defined tool (Y/N)? ", $answer IF $answer <> "Y" THEN TYPE /C1, "Move the tool tip to the selected reference ", /S TYPE "location.", /C1, "Set 'ref.tool' equal to the ", /S TYPE "transformation for this location.", /C2, "Press ", /S TYPE "the REC/DONE button on the manual control pendant when ", /S TYPE "ready to proceed. ", /S DETACH (0) ;Release the robot to the user WAIT PENDANT(8) REC/DONE button ;Wait for user to press ATTACH (0) ;Regain control of the robot ;(automatically wait for COMP mode) TOOL ref.tool HERE ref.loc TYPE ;Record the reference location END TYPE /C1, "Install the new tool. Move its tip to the ", /S TYPE "reference location.", /C2, "Press the REC/DONE button ", /S TYPE "on the manual control pendant when ready to proceed. ", /S DETACH (0) WAIT PENDANT(8) REC/DONE button ATTACH (0) ;Release the robot to the user ;Wait for user to press ;Regain control of the robot ; Compute the new tool transformation, 'new.tool' TOOL ref.tool SET new.tool = ref.tool:INVERSE(HERE):ref.loc TOOL new.tool ;Apply the new tool transformation V+ Lan gu age User's Gu ide Page 3 3 7 Defin in g a Tool Tran sformation TYPE /C2, "All done. The tool transformation has been set ", /S TYPE "equal to 'new.tool' .", /C1 DETACH (1) RETURN ;Detach the pendant ;Return to calling program (or STOP) .END Becau se of compu tation al errors in trodu ced wh en compou n d tran sformation s are u sed, th e accu racy of th e program presen ted above can be improved by u sin g a simple tool with n o obliqu e rotation s as th e referen ce tool. In fact, you can get th e most accu rate resu lts if you can u se th e mou n tin g flan ge of th e robot with ou t a tool as th e in itial poin ter. In th is case, th e referen ce tool is th e defau lt n u ll tool. Th e program above can be simplified by deletin g th e ref­ eren ces to ref.tool in lin es 1 7 , 2 8 , 4 5 , an d 4 6 . Th e first time th e program is execu ted, respon d to th e prompt with N. Th e referen ce tool is defin ed. After th e program execu tes on ce, th e tool tran sformation can be u pdated by execu tin g th e program again . Th is time, respon d to th e prompt with Y. Th e program directs you to position th e n ew tool at th e same referen ce location as before. As lon g as th e valu es of ref.tool an d ref.loc h ave n ot been altered, a n ew tool tran sformation is au tomatically compu ted an d asserted. Th is is a con ven ien t meth od for occasion ally alterin g th e tool tran sformation to accou n t for tool wear. V+ Lan gu age User's Gu ide Page 3 3 8 E xtern al E n coder Device External Encoder Device Introduction Parameters Device Setup R eading Device Data V+ Lan gu age User's Gu ide Page 3 3 9 In trodu ction Introduction Th e extern al­en coder in pu ts on th e system con troller are n ormally u sed for con veyor belt trackin g with a robot. However, th ese in pu ts can also be u sed for oth er sen sin g application s. In su ch application s, th e DE VICE real­valu ed fu n ction an d SE TDE VICE program in stru ction allow th e extern al en coders to be accessed in a more flexible man n er th an th e belt­orien ted in stru ction s an d fu n ction s. Th is appen dix describes th e u se of th e DE VICE real­valu ed fu n ction an d th e SE T­ DE VICE program in stru ction to access th e extern al en coder device. In gen eral, SE TDE VICE allows a scale factor, offset, an d limits to be specified for a specified extern al en coder u n it. Th e DE VICE real­valu ed fu n ction retu rn s error statu s, position , or velocity in formation for th e specified en coder. Accessin g th e extern al en coders via DE VICE an d SE TDE VICE is in depen den t of an y belt­track­ in g comman ds or in stru ction s. Settin g belt parameters with SE TBE LT an d settin g en coder parameters with SE TDE VICE h ave n o effect on each oth er. Th e on ly exception s are th e SE T­ DE VICE in itialize comman d an d reset comman d, wh ich reset all errors for th e specified exter­ n al en coder, in clu din g an y belt­related errors. NOTE: See th e V+Lan gu age Referen ce Gu ide. for complete in formation on th e DE VICE real­valu ed fu n ction an d th e SE TDE VICE program in stru ction . V+ Lan gu age User's Gu ide Page 3 4 1 Parameters Parameters Th e extern al en coder device type is 0 . Th is mean s th at th e type parameter in all DE VICE or SE TDE VICE in stru ction s th at referen ce th e extern al en coders mu st h ave a valu e of zero. Th e stan dard Adept con troller allows two extern al en coder u n its. Th ese u n its are n u mbered 0 an d 1 . All DE VICE fu n ction s an d SE TDE VICE in stru ction s th at referen ce th e extern al en coders mu st specify on e of th ese u n it n u mbers for th e u n it parameter. V+ Lan gu age User's Gu ide Page 3 4 2 Device Setu p Device Setup Th e SE TDE VICE program in stru ction allows th e extern al en coders to be in itialized an d var­ iou s parameters to be set u p. Th e action taken by th e SE TDE VICE in stru ction depen ds u pon th e valu e of th e comman d parameter. Th e syn tax of th e SE TDE VICE in stru ction is SETDEVICE (0, unit, error, command) p1, p2 Th e followin g table describes th e valid comman ds. Comman d Parameter Valu es Comman d Description 0 In itialize Device Th is comman d sets all scale factors, offsets, an d limits to th eir defau lt valu es, as follows: offset = 0 ; scale factor = 1 ; n o limit ch eckin g. Th is comman d also resets an y errors for th e specified device.Th is com­ man d sh ou ld be issu ed before an y oth er comman ds for a particu lar u n it an d before u sin g th e DE VICE real­valu ed fu n ction for th e u n it. 1 Reset Device Th is comman d clears an y errors associated with th is en coder u n it. It does n ot affect th e scale factor, offset, or limits. 8 Set Scale Factor Th is comman d sets th e position an d velocity scale factor for th is en coder u n it to th e valu e of parameter p1 . Th e u n its are millimeters per en coder cou n t. Th e scale factor mu st be set before settin g th e off­ set or limits. If th e scale factor is ch an ged, th e offset an d limit valu es will n eed to be u pdated. 9 Set Position Offset Th is comman d sets th e position offset for th is en coder u n it to th e valu e of parameter p1 . Th e u n its are millimeters. Th e scale factor mu st be set before settin g th e offset. 10 Set Position Limits Th is comman d sets th e position limits for th e en coder u n it to th e valu es of option al parameters p1 an d p2 , wh ich are th e lower an d u pper limits, respectively. If a parameter is omitted, n o ch eckin g is performed for th at limit. Th e u n its are millimeters. Th e scale factor mu st be set before settin g th e limits. V+ Lan gu age User's Gu ide Page 3 4 3 Readin g Device Data R eading Device Data Th e DE VICE real­valu ed fu n ction retu rn s in formation abou t th e en coder error statu s, posi­ tion , an d velocity. Th e scale factor, offset, an d limits defin ed by th e SE TDE VICE in stru ction affect th e velocity an d position valu es retu rn ed. Th e syn tax for th is fu n ction is DEVICE(0, unit, error, select) Th e valu e retu rn ed depen ds u pon th e valu e of th e select parameter, as described in th e fol­ lowin g table. S elect Parameter Valu es select 0 Description Read Hardware Statu s Th e error statu s of th e en coder u n it is retu rn ed as a 2 4 ­bit valu e. Th e valid error bits for th is device are listed below. Th e correspon din g error listed is th e on e V+ wou ld report if th e error occu rred wh ile trackin g a belt en coder. Bit # Bit Mask Correspon din g Error Message an d Code 19 ^H0 4 0 0 0 0 * Lost en coder syn c* (­1 0 1 2 ) 20 ^H0 8 0 0 0 0 * E n coder qu adratu re error* (­1 0 1 3 ) 21 ^H1 0 0 0 0 0 * No zero in dex* (­1 0 1 1 ) On ly bit #2 0 , for en coder qu adratu re error, is detected by th e error parameter of th e DE VICE fu n ction to gen erate an error. 1 Read Position Th e cu rren t position of th e en coder (in millimeters) is retu rn ed, su bject to th e scale factor, offset, an d limits defin ed by th e SE TDE VICE in stru c­ tion . Th e valu e retu rn ed is compu ted by: position = scale* (en coder­offset) position = MAX(position , lower_ limit) position = MIN(position , u pper_ limit) 2 Read Velocity Th e cu rren t valu e of th e en coder velocity (in millimeters per secon d) is retu rn ed, su bject to th e scale factor defin ed by th e SE TDE VICE in stru c­ tion . Th e valu e retu rn ed is compu ted by: velocity = scale* en coder_ velocity V+ Lan gu age User's Gu ide Page 3 4 4 Readin g Device Data 3 Read Predicted Position Th e predicted position of th e en coder (in millimeters) is retu rn ed. Th e position is predicted 3 2 millisecon ds in th e fu tu re, based u pon th e cu r­ ren t position an d velocity. Th e valu e is scaled th e same as th e cu rren t position described above. 4 Read Latch ed Position Th e position or th e en coder (in millimeters) wh en th e last extern al trigger occu rred is retu rn ed. Th e LATCHE D real­valu ed fu n ction may be u sed to determin ed wh en an extern al trigger h as occu rred an d a valid position h as been recorded. V+ Lan gu age User's Gu ide Page 3 4 5 Ch aracter Sets Character Sets ASCII Con trol Valu es an d Adept Ch aracter Set list th e stan dard Adept ch aracter set. Valu es 0 to 1 2 7 (decimal) are th e stan dard ASCII ch aracter set. Ch aracters 1 to 3 1 are th e common set of special an d lin e­drawin g ch aracters. Ch aracters 0 an d 1 2 7 to 1 4 1 are Adept addition s to th e stan dard sets. Ch aracters 3 2 to 2 5 5 (exclu din g 1 2 7 th rou gh 1 4 1 ) are th e ISO stan d­ ard 8 8 5 9 ­1 ch aracter set. Ch aracters 1 4 5 to 1 5 9 are overstrike ch aracters (see th e OVE R­ STRIKE attribu te to th e /TE RMINAL argu men t for th e FSE T in stru ction in th e V+ Lan gu age Referen ce Gu ide). Valu es 1 to 3 1 are also given special mean in g in th e exten ded Adept ch ar­ acter set wh en th ey are ou tpu t to a graph ics win dow with th e GTYPE in stru ction . NOTE:Th e fu ll ch aracter set is defin ed for fon t #1 on ly. Fon ts #2 (mediu m fon t), #3 (large fon t), an d #4 (small fon t) h ave defin ed ch aracters for ASCII valu es 0 an d 3 2 ­ 1 2 7 . Fon ts #5 an d #6 h ave stan dard E n glish ch aracters for ASCII valu es 0 an d 3 2 ­ 1 3 5 wh ile ASCII 1 3 6 ­ 2 3 5 are Katakan a an d Hiragan a ch aracters. Fon t #5 is stan dard size an d fon t #6 con tain s large ch aracters. Th e last colu mn in Adept Ch aracter Set sh ows th e Kata­ kan a an d Hiragan a ch aracters. Th e Katakan a ch aracters are at ASCII 1 6 1 ­ 2 2 3 . Th e Hira­ gan a ch aracters are at ASCII 1 3 6 ­ 1 5 9 an d 2 2 4 ­ 2 5 5 . Th e ch aracter sets listed in ASCII Con trol Valu es an d Adept Ch aracter Set are for u se with VGB graph ics systems on ly an d do n ot apply to AdeptWin dows PC. Ch aracters with valu es 0 to 3 1 an d 1 2 7 (decimal) h ave th e con trol mean in gs listed in th e fol­ lowin g table wh en ou tpu t to a serial lin e, an ASCII termin al, or th e mon itor win dow (with TYPE , PROMPT, or WRITE in stru ction s). In files exported to oth er text editors or tran smitted across serial lin es, ch aracters 0 to 3 1 are gen erally in terpreted as h avin g th e specified con trol mean in g. Th e symbols sh own for ch aracters 0 to 3 1 an d 1 2 7 in th e table Adept Ch aracter Set can be displayed on ly with th e GTYPE in stru ction . Ch aracters in th e exten ded Adept ch aracter set can be ou tpu t u sin g th e $ CHR fu n ction . For example: TYPE $CHR(229) ou tpu ts th e ch aracter å to th e mon itor win dow. Th e in stru ction : GTYPE (glun) 50, 50, $CHR(229) ou tpu ts th e same ch aracter to th e win dow open on logical u n it glu n . AS CI I Con trol Valu es Ch aracter Decimal Valu e NU L 000 Hex. Valu e 00 Mean in g of Con trol Ch aracter Nu ll V+ Lan gu age User's Gu ide Page 3 4 6 Ch aracter Sets SOH 001 01 Start of h eadin g STX 002 02 Start of text E TX 003 03 E n d of text E OT 004 04 E n d of tran s­ mission E NQ 005 05 E n qu iry ACK 006 06 Ackn owledgmen t BE L 007 07 Bell BS 008 08 Backspace HT 009 09 Horizon tal tab LF 010 0A Lin e feed VT 011 0B Vertical tab FF 012 0C Form feed CR 013 0D Carriage retu rn SO 014 0E Sh ift ou t SI 015 0F Sh ift in DLE 016 10 Data lin k escape DC1 017 11 Direct con trol 1 DC2 018 12 Direct con trol 2 DC3 019 13 Direct con trol 3 DC4 020 14 Direct con trol 4 NAK 021 15 Negative ackn owledge V+ Lan gu age User's Gu ide Page 3 4 7 Ch aracter Sets SYN 022 16 Syn ch ron ou s idle E TB 023 17 E n d of tran s­ mission block CAN 024 18 Can cel EM 025 19 E n d of mediu m SUB 026 1A Su bstitu te E SC 027 1B E scape FS 028 1C File separator GS 029 1D Grou p separator RS 030 1E Record separator US 031 1F Un it separator DE L 127 7F Delete Adept Ch aracter S et Dec. Valu e Hex. Valu e Description Fon t 1 Fon ts 2 , 3, 4, 5, & 6 000 00 cell ou tlin e 001 01 diamon d 002 02 ch eckerboard 003 03 HT (Horizon tal Tab) H T n ot defin ed 004 04 FF (Form Feed) F n ot defin ed u n ot defin ed n ot defin ed F V+ Lan gu age User's Gu ide Page 3 4 8 Ch aracter Sets 005 05 CR (Carriage Retu rn ) C 006 06 LF (Lin e Feed) L 007 07 degree symbol 008 08 plu s/min u s ± n ot defin ed 009 09 NL (New lin e) N L n ot defin ed 010 0A VT (Vertical Tab) V n ot defin ed 011 0B lower righ t corn er n ot defin ed 012 0C u pper righ t corn er n ot defin ed 013 0D u pper left corn er n ot defin ed 014 0E lower left corn er n ot defin ed 015 0F in tersection n ot defin ed 016 10 scan lin e 3 ­ n ot defin ed 017 11 scan lin e 6 ­ n ot defin ed 018 12 scan lin e 9 ­ n ot defin ed 019 13 scan lin e 1 2 ­ n ot defin ed 020 14 scan lin e 1 5 ­ n ot defin ed 021 15 left T­bar n ot defin ed 022 16 righ t T­bar n ot defin ed R F n ot defin ed n ot defin ed n ot defin ed T V+ Lan gu age User's Gu ide Page 3 4 9 Ch aracter Sets 023 17 bottom T­bar n ot defin ed 024 18 top T­bar n ot defin ed 025 19 vertical bar | n ot defin ed 026 1A less th an or equ al to ≤ n ot defin ed 027 1B greater th an or equ al to ≥ n ot defin ed 028 1C pi (lowercase) π n ot defin ed 029 1D n ot equ al to ≠ n ot defin ed 030 1E sterlin g £ n ot defin ed 031 1F cen tered dot · n ot defin ed 032 20 space 033 21 exclamation ! ! 034 22 dou ble qu ote " " 035 23 pou n d # # 036 24 dollar sign $ $ 037 25 percen t % % 038 26 ampersan d & & 039 27 sin gle qu ote ' ' 040 28 open paren ( ( 041 29 close paren ) ) 042 2A asterisk * * 043 2B plu s + + n ot defin ed V+ Lan gu age User's Gu ide Page 3 5 0 Ch aracter Sets 044 2C comma , , 045 2D h yph en ­ ­ 046 2E period . . 047 2F slash / / 048 30 zero 0 0 049 31 on e 1 1 050 32 t wo 2 2 051 33 th ree 3 3 052 34 fou r 4 4 053 35 five 5 5 054 36 six 6 6 055 37 seven 7 7 056 38 eigh t 8 8 057 39 n in e 9 9 058 3A colon : : 059 3B semicolon ; ; 060 3C less th an < < 061 3D equ al to = = 062 3E greater th an > > 063 3F qu estion ? ? 064 40 at @ @ 065 41 A A A V+ Lan gu age User's Gu ide Page 3 5 1 Ch aracter Sets 066 42 B B B 067 43 C C C 068 44 D D D 069 45 E E E 070 46 F F F 071 47 G G G 072 48 H H H 073 49 I I I 074 4A J J J 075 4B K K K 076 4C L L L 077 4D M M M 078 4E N N N 079 4F O O O 080 50 P P P 081 51 Q Q Q 082 52 R R R 083 53 S S S 084 54 T T T 085 55 U U U 086 56 V V V V+ Lan gu age User's Gu ide Page 3 5 2 Ch aracter Sets 087 57 W W W 088 58 X X X 089 59 Y Y Y 090 5A Z Z Z 091 5B left bracket [ [ 092 5C back slash \ \ 093 5D righ t bracket 094 5E circu mflex (caret) ^ ^ 095 5F u n derscore _ _ 096 60 grave accen t 097 61 a a a 098 62 b b b 099 63 c c c 100 64 d d d 101 65 e e e 102 66 f f f 103 67 g g g 104 68 h h h 105 69 i i i 106 6A j j j 107 6B k k k V+ Lan gu age User's Gu ide Page 3 5 3 Ch aracter Sets 108 6C l l l 109 6D m m m 110 6E n n n 111 6F o o o 112 70 p p p 113 71 q q q 114 72 r r r 115 73 s s s 116 74 t t t 117 75 u v u 118 76 v v v 119 77 w w w 120 78 x x x 121 79 y y y 122 7A z z z 123 7B righ t brace } { 124 7C bar | | 125 7D left brace } } 126 7E tilde ~ ~ 127 7F solid 128 80 copyrigh t © © V+ Lan gu age User's Gu ide Page 3 5 4 Ch aracter Sets 129 81 registered trademark ® ® 130 82 trademark TM TM 131 83 bu llet · 132 84 su perscript + + 133 85 dou ble qu ote (modified) " 134 86 ch eckmark 135 87 righ t­poin tin g trian gle 136 88 approximately equ al symbol 137 89 OE ligatu re a 138 8A oe ligatu re i 139 8B beta ß u 140 8C Sigma Σ e 141 8D Omega Ω o 142 8E blan k ya 143 8F blan k yu 144 90 dotless i 145 91 grave accen t Dbl n ext con son an t 146 92 acu te accen t ­ 147 93 circu mflex A ≈ ı ≈ yo V+ Lan gu age User's Gu ide Page 3 5 5 Ch aracter Sets 148 94 tilde I 149 95 macron ¯ U 150 96 breve ˘ E 151 97 dot accen t ˙ O 152 98 dieresis ¨ KA 153 99 blan k 154 9A rin g ˚ KU 155 9B cedilla ¸ KE 156 9C blan k 157 9D h u n garu mlau t ˝ SA 158 9E ogon ek ˛ SHI 159 9F caron ˇ SU 160 A0 blan k 161 A1 in verted excla­ mation poin t ¡ Closed cir­ cle 162 A2 cen t ¢ Start qu ote 163 A3 sterlin g £ E n d qu ote 164 A4 cu rren cy ¤ Comma 165 A5 yen ¥ E n d sen ­ ten ce 166 A6 broken bar ¦ o 167 A7 section § a 168 A8 dieresis ¨ i KI KO Yen symbol V+ Lan gu age User's Gu ide Page 3 5 6 Ch aracter Sets 169 A9 copyrigh t © u 170 AA femin in e ordi­ n al ª e 171 AB left gu illemot « o 172 AC logical n ot ¬ ¬ya 173 AD en dash ­­ yu 174 AE registered ® yo 175 AF macron ¯ Dbl n ext con son an t 176 B0 degree ° ­ 177 B1 plu s/min u s ± A 178 B2 su perscript 2 ² I 179 B3 su perscript 3 ³ U 180 B4 acu te accen t ´ E 181 B5 mu µ O 182 B6 paragraph ¶ KA 183 B7 cen tered dot · KI 184 B8 cedilla ¸ KU 185 B9 ¹ 1 KE 186 BA mascu lin e ordi­ n al º KO 187 BB righ t gu illemot » SA 188 BC 1 /4 ¼ SHI V+ Lan gu age User's Gu ide Page 3 5 7 Ch aracter Sets 189 BD 1 /2 ½ SU 190 BE 3 /4 ¾ SE 191 BF in verted qu es­ tion mark ¿ SO 192 C0 A grave À TA 193 C1 A acu te Á CHI 194 C2 A circu mflex  TSU 195 C3 A tilde à TE 196 C4 A dieresis Ä TO 197 C5 A rin g Å NA 198 C6 AE ligatu re Æ NI 199 C7 C cedilla Ç NU 200 C8 E grave È NE 201 C9 E acu te É NO 202 CA E circu mflex Ê HA 203 CB E dieresis Ë HI 204 CC I grave Ì FU 205 CD I acu te Í HE 206 CE I circu mflex Î HO 207 CF I dieresis Ï MA 208 D0 E th Ð MI 209 D1 N tilde Ñ MU V+ Lan gu age User's Gu ide Page 3 5 8 Ch aracter Sets 210 D2 O grave Ò ME 211 D3 O acu te Ó MO 212 D4 O circu mflex Ô YA 213 D5 O tilde Õ YU 214 D6 O dieresis Ö YO 215 D7 mu ltiply × RA 216 D8 O slash Ø RI 217 D9 U grave Ù RU 218 DA U acu te Ú RE 219 DB U circu mflex Û RO 220 DC U dieresis Ü WA 221 DD Y acu te Ý N 222 DE Th orn Þ Voiced con ­ son an t 223 DF German dou ­ ble s ß Voiced con ­ son an t­P 224 E0 a grave à SE 225 E1 a acu te á SO 226 E2 a circu mflex â TA 227 E3 a tilde ã CHI 228 E4 a dieresis ä TSU 229 E5 a rin g å TE V+ Lan gu age User's Gu ide Page 3 5 9 Ch aracter Sets 230 E6 ae ligatu re æ TO 231 E7 c cedilla ç NA 232 E8 e grave è NI 233 E9 e acu te é NU 234 EA e circu mflex ê NE 235 EB e dieresis ë NO 236 EC i grave ì HA 237 ED i acu te í HI 238 EE i circu mflex î FU 239 EF i dieresis ï HE 240 F0 eth ð HO 241 F1 n tilde ñ MA 242 F2 o grave ò MI 243 F3 o acu te ó MU 244 F4 o circu mflex ô ME 245 F5 o tilde õ MO 246 F6 o dieresis ö YA 247 F7 divide ÷ YU 248 F8 o slash ø YO 249 F9 u grave ù RA 250 FA u acu te ú RI 251 FB u circu mflex û RU V+ Lan gu age User's Gu ide Page 3 6 0 Ch aracter Sets 252 FC u dieresis ü RE 253 FD y acu te ý RO 254 FE th orn þ WA 255 FF y dieresis ÿ N V+ Lan gu age User's Gu ide Page 3 6 1 ...
View Full Document

Ask a homework question - tutors are online