付费下载
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Power PMAC Script Program Flow January 2012if (JogMotorStatus = 0) / No motor jogging? JogMotor = MotorSelectSw + 1;/ Read switch to select motor Ldata.Motor = JogMotor;/ Specify motor for jog commands JogMode = IncJogSw;/ Read switch to select jog mode if (JogMode = 0) / Continuous mode? if (MotorJ
2、ogMotor.JogTa 0) / Accel & jerk times specified? JogDecelDist = MotorJogMotor.JogSpeed * MotorJogMotor.JogTa * 0.5; JogDecelDist += MotorJogMotor.JogSpeed * MotorJogMotor.JogTs * 0.5; JogDecelDist += MotorJogMotor.JogSpeed * (pow(MotorJogMotor.JogTs,2) / MotorJogMotor.JogTa) * 0.5; else / Zero accel
3、 specified JogDecelDist = MotorJogMotor.JogSpeed * 200 * 0.5; / As for 200 msec Ta / if (JogTa 0) else / if (JogTa 1)EnabledClosed-loopNot in both hardware overtravel limitsSelected motion program (and any jump label) must be present and validPower PMAC must be able to compute all axis starting posi
4、tions from present motor positions (Coordx.Csolve = 1, indicating valid definitions)If resuming from suspended state that is not at a programmed point, all motors must be at suspended positionsNote that a motion program can be executed in a coordinate system with no motors assigned to position axes;
5、 this provides a fast “dry run” capability.Motion Program Execution SequencingEach real-time interrupt (RTI), each active C.S. checks its internal “block-request” flagBlock-request flag can be set by either:Command to start execution (e.g. r, s, start), orMove execution (interpolation) progressing f
6、rom one programmed move to the nextIf flag is set, program calculations start at present program counterProgram calculations continue until either:Equations of motion for enough moves have been computed and put into motion queue to fill the queue enough for this modeProgram calculations suspended, b
7、lock-request flag clearedProgram counter jumps back toward top of program more than Coordx.GoBack + 1 timesBlending disabled to prevent possible run-time error from indefinite loopBlock-request flag cleared until queued move(s) completedProgram calculations thus automatically sequenced by the moveMo
8、tion Program Sequencing ExampleX0 Y0;/ Compute move, suspendXpos = Rad * cos(Angle);Ypos = Rad * sin(Angle);X(Xpos) Y(Ypos);/ Compute move, suspendwhile (Interlock = 0) / Suspend if loop ct GoBack + 1X(-Xpos) Y(-Ypos);/ Compute move, suspendif (ExtendedPause = 1) PauseTime = 100; else PauseTime = 50
9、; LaserOn = 1;dwell(PauseTime);/ Compute “move”, suspendSequencing Example Time LineCalculating “n” moves ahead (value of “n” dependent on mode) 1n+1n+21234timeRExecuteCalculatenn+3n+4How Much Pre-Calculation is Required?For basic point-to-point moves, no pre-calculation required program calculation
10、s resume after end of move executionFor rapid mode moves, other modes with Coordx.NoBlend = 1, dwellsFor basic blending without acceleration control one move aheadFor linear, circle mode moves with segmentation, no lookaheadFor blending with simple acceleration control two moves aheadFor linear mode
11、 moves with no segmentation (acceleration limiting)For spline mode moves (acceleration continuity)For blending with full (lookahead) acceleration control enough moves to keep lookahead segment buffer full (Coordx.LHDistance segments)For linear, circle, pvt mode moves with segmented lookahead activeF
12、or 2D cutter radius compensation active enough moves for intersection and interference-check calculations (Coordx.CCDistance moves)For linear or circle mode moves with 2D cutter comp activeRotary Motion Program BuffersPermit simultaneous download and execution of motion programUseful for programs to
13、o large for Power PMAC memory (multi-megabyte)Useful for programs created in real timeCommonly used for CNC-style part programs, as from CAD/CAMReuses buffer memory from program lines already executedProgram commands that cause jumps to other lines in program are not permitted (cannot be sure that l
14、ine will be present in buffer)goto, gosub, callsub commands, jump labelsMultiple-line if branches*else branches (single or multi-line)Multiple-line while and do/while loops*switch commandscall commands to subprograms are permitted (including G, M, T, & D codes)No debugging breakpoints can be added*
15、Multiple actions on a single line are permittedRotary Buffer Management Commands&n define rotary program buffer size,line buffer sizeReserves specified memory for C.S. rotary bufferProgram buffer size must be = 2048 bytesDefault line buffer size is 1024 bytes (sufficient for virtually all apps)&n op
16、en rotary opens C.S. rotary buffer for entry, does not clear (so can add to end)&n clear rotary erases content of buffer, but preserves buffer itself&n close closes C.S. rotary buffer if open ( mended when done entering)&n b0 sets C.S. program counter to rotary buffer at latest point that has not al
17、ready been calculated&n list rotary reports present contents of buffer starting at latest point that has not already been calculatedclear all buffers erases the buffers themselvesScript PLC Program Execution SequencingExecution of active PLC program automatically started at appropriate time in real-
18、time interrupt (RTI) or background cycleExecution continues until end of program or end of (true) while loop constitutes end of one “scan”Next scan does not start until next RTI or next turn in background cycleNext scan starts at top of program (if previous scan got to end), or at top of while loop
19、(if previous scan exited at bottom of loop)If PLC program commands motion (e.g. jog, homing, or axis move), program execution does not stop as motion program doesMust monitor in user code for end of moveSynchronous variable assignment useful to ensure move has startedNo need to place program within
20、while loop to cause continued scans; Power PMAC will automatically call repeatedlyFor “one-shot” PLC, last line of program should be disable plc nPower PMAC Script PLC Program ExecutionPLC 0 always executes in real-time interrupt (RTI)PLCs 1, 2, & 3 can execute in RTI or backgroundPLCs 4 31 always e
21、xecute in backgroundSys.MaxRtPlc (= 0, 1, 2, or 3) sets highest numbered PLC to execute in RTISys.RtIntPeriod sets RTI frequency (every Sys.RtIntPeriod+1 servo interrupts)Linux OS starts background scan after “sleep” interval (which releases processor for separate applications)enable plc list comman
22、d (on-line or program) starts execution at next “slot” for scandisable plc list command (on-line or program) prevents execution starting at next scanPower PMAC Program Line LabelsJump labels: e.g. N1200:, N4375821:Label must be at start of a program lineValue must be a constant (unsigned 32-bit inte
23、ger), followed by a colonCan jump to label with goto, gosub, callsub, call, G, M, T, DJump command can use expression to specify label numberCan point to label with b, begin commands (using fractional part of value)Synchronizing labels: e.g. N1200, N(P10)Value can be constant or expression, no follo
24、wing colonExpression value truncated (if necessary) to unsigned 32-bit integerRegular assignment (at “lookahead” time) of value to Coordx.NcalcSynchronous assignment of value to Coordx.NsyncOccurs at start of actual execution of next move or dwellThis assignment reversible during lookahead retrace o
25、perationUseful for monitoring program and motion executionCommonly used in CNC-style applications for operator displayOK to use both labels together: e.g. N1200: N1200 X10 Y20Power PMAC ConditionsUse in if and while statements (including do while)C-style conditional syntax (not BASIC-style)Can be ex
26、plicit comparison or just expression (new!)if (P1) is valid syntaxExpression must evaluate exactly to 0.0 to be “false”8 standard comparators: =, !=, , =, , =, , !Note that = (single equals sign) is not a valid comparatorOutside of condition, = is synchronous assignment operator3 alternate comparato
27、rs: , ! (stored as standard equivalent)Logical negation operator ! e.g. if (!(P1) P2+;2 conditional combinatorial operators: & (and), | (or)e.g. while (P1=0) Power PMAC Conditional ActionsSingle-line conditional actions: same line as conditionalif (condition) command;else command;while (condition) c
28、ommand;Null action requires empty curly bracketse.g. while (Motor3.DesVel) Multi-line conditional actions: delimited by curly bracketsNo ENDIF, ENDWHILE statements, as in PMAC/Turbo PMACif/while (condition) command;else command;command;Power PMAC “switch” StatementVery similar to C “switch” statemen
29、t general syntax:switch (expression) case constant: command; break;case constant: command; break;default: command;Value of expression after switch rounded down to next integerconstant after case must be an integerOptional break stops execution of a particular caseOtherwise execution can continue int
30、o next casedefault can be used for when value matches no caseLimited to 256 cases unless declare more, e.g.: switch(P1),512(IDE automatically allocates minimum required number)Calling Subroutines and Subprogramsgosubdata Jump to label Ndata: of same programNo R-variable (stack) argument passing perm
31、ittedcallsubdata Jump to label Ndata: of same programR-variable (stack) argument passing is permittedcalldata Jump to subprogintdataFractional part of data specifies jump label within programMultiply fractional part by 1,000,000 to get jump label number(Note that PMAC/Turbo PMAC multiplied by 100,00
32、0)Jump back in all cases on returnImplicit return at end of all subprogramsCalling can be up to 255 levels deepPLCs as well as motion program (progs) can use theseNote that call is always to subprog (not prog or plc)When top-level program is PLC, all subprograms obey PLC execution rulesRS-274 “G-Cod
33、e” Subroutine CallsBasically the same as PMAC/Turbo PMAC schemeFor customizable execution of RS-274 programsTreated as call commands to specific subprograms by default:Gdata - subprog1000 Ndata*1000:/ Preparatory codesMdata - subprog1001 Ndata*1000:/ Machine codesTdata - subprog1002 Ndata*1000:/ Too
34、l-select codesDdata - subprog1003 Ndata*1000:/ Tool-data codesSince line jump label numbers can be 100,000, code numbers = 100 (but 1000) can be supported in these programs (new!)Fractional code values (to thousandths) supportedTypically these subroutines will not use synchronizing line labels, as m
35、ost users want to monitor only place in main part programSubprograms used can be changed with Coordx.Gprog, .Mprog, .Tprog, .Dprog saved setup elements, permitting different subroutines for different coordinate systemsPassing Arguments to Subroutines with “read”Supports pure “letter/number” program
36、format of RS-274 “G-codes”Permits sophisticated processing of CAD/CAM-generated programsSimilar to PMAC scheme, but with enhancementsread command in subroutine gets values associated with specified letters e.g. read(X,Y,XX,YY) Arguments read into subroutine local “D-variables” (not Q-variables)“A” a
37、rg into D1, “B” into D2, , “Z” into D26“AA” arg into D27, “BB” into D28, , “ZZ” into D52Bits 0 51 of D0 note which arguments passed in latest readBit (n-1), with value 2n-1, shows whether new value read into DnOne set of D-variables per coordinate systemNo stack for subsequent read commands; watch f
38、or overwritingSample G-Code Subprogramopen subprog 1000/ Default G-code subprogramN0: rapid; return;/ G00 RAPID modeN1000: linear; return;/ G01 LINEAR modeN2000: circle1; return;/ G02 CW CIRCLE modeN3000: circle2; return;/ G03 CCW CIRCLE modeN4000: read(P);/ G04 DWELL command if(D0 & $8000) dwell(D1
39、6 * 1000); / P dwell time in seconds return;N17000: normal K-1; return;/ G17 XY plane setN18000: normal J-1; return;/ G18 ZX plane setN19000: normal I-1; return;/ G19 YZ plane setN40000: ccmode0; return;/ G40 cutter comp offN41000: ccmode1; return;/ G41 cutter comp on leftN42000: ccmode2; return;/ G
40、42 cutter comp on rightN61000: Coord1.NoBlend = 1; return;/ G61 exact stop modeN64000: Coord1.NoBlend = 0; return;/ G64 continuous modeN90000: abs; return;/ G90 absolute move modeN91000: inc; return;/ G91 incremental move modecloseSample “G-Code” Part Programopen prog 15/ Open motion program bufferG
41、17 G90 G64/ XY plane, abs mode, blendedG00 X0 Y0/ Rapid move to originG04 P1.75/ Dwell for 1750 msecG01 X5 F10/ Linear move to (5,0), speed 10G03 Y10 J5/ CCW circle move to (5,10)G01 X0/ Linear move to (0,10)X-5 Y15/ Linear move to (-5,15)X-10 Y10/ Linear move to (-10,10)Y7.5/ Linear move to (-10,7.
42、5)G03 Y2.5 J-2.5/ CCW circle move to (-10,2.5)G01 Y0/ Linear move to (-10,0)X-5 Y-5/ Linear move to (-5,-5)X0 Y0/ Linear move to (0,0)G04 P1/ Dwell for 1000 msecclosePassing & Returning Variables with SubroutinesUsing local (L) variables for C.S. (when starting from PROG) or PLC programVariable Rn o
43、f calling routine equivalent to Ln of calledRn of calling routine equivalent to L(n+StackOffset) of sameStackOffset is 256 by defaultTo change, set explicitly when entering calling program:open prog n,StackOffsetTotal of 8192 L-variables per C.S. or PLC31 levels of passing to/from subroutines at def
44、ault stack offsetCan support all 255 possible levels with StackOffset = 32IDE automatically allocates minimum required offset valueLocal Variable Stack ExampleThis example uses default “stack offset” of 256Other offsets can be declaredIDE declares optimal offsets automaticallyRn of calling routine e
45、quivalent to Ln of called routineRn of calling routine equivalent to L(n + StackOffset) of calling routinePass/return arguments should start with R0 of calling, L0 of calledIDE manages these definitions and assignments automaticallyExample of Passing and Returning Variables(No substitutions of varia
46、ble or program names)Subprogram to execute Pythagorean theoremopen subprog 100L3 = L0 * L0;/ Uses R0 from calling routine L4 = L1 * L1;/ Uses R1 from calling routineL2 = sqrt(L3 + L4);/ Result will be R2 in calling routineclose/ Implicit return on closeSample calling program:open prog 5R0 = Motor1.F
47、ltrVel * P50;/ Will be L0 in subprogramR1 = Motor2.FltrVel * P50;/ Will be L1 in subprogramcall 100;P60 = R2 * P51;/ R2 was L2 in subprogramExample of Passing and Returning Variables(Using substitutions of variable and program names)User-specified program within IDE project manager:open subprog Pyth
48、ag (Rise, Run, &Hypot)local RiseSqrd, RunSqrd;RiseSqrd = Rise * Rise;RunSqrd = Run * Run;Hypot = sqrt(RiseSqrd + RunSqrd);closeAutomatically es for download:#define Pythag auto-assigned #open subprog Pythag/ open subprog auto-assigned #define RiseL0/ First variable in subprogram declaration#define R
49、unL1/ Second variable in subprogram declaration#define HypotL2/ Third variable in subprogram declaration#define RiseSqrdL3/ First internally declared local variable#define RunSqrdL4/ Second internally declared local variableRiseSqrd = Rise * Rise;/ L3 = L0 * L0;RunSqrd = Run * Run;/ L4 = L1 * L1Hypo
50、t = sqrt(RiseSqrd + RunSqrd);/ L2 = sqrt(L3 + L4);closeExample of Passing and Returning Variables(continued)Subroutine call statement in calling program written ascall Pythag (XDist, YDist, &VecDist);Automatically es for download:R0=XDist; R1=YDist; call Pythag; VecDist=R2;Pythag is substituted by a
51、uto-assigned #Power PMAC PLC Program EnhancementsAbility to use program-flow constructs formerly available to motion programs onlyLine-jump labels (e.g. N550:)goto, gosub, callsub jumps within programscall jumps to subprogs (not other PLCs)Local variable passing to subroutines with callsub and callA
52、bility to command axis moves directlye.g. if (P1=1) X3.5 Y12.1Acts on C.S. addressed by PLC (set by value of Ldata.Coord)rapid-mode moves only (C.S. automatically switched into this mode)No automatic execution of pmatch functionCommand only starts move; program execution is not suspended hereMove co
53、mmands can break into running rapid moves (altered destination)Debugging featuresCycle counters for instructionsBreak points on instructions (at prescribed cycle count)Single-step capabilityPower PMAC Program Direct CommandsProvide the equivalent of many on-line commands from within motion and (main
54、ly) PLC programsSyntax is longer version of equivalent on-line commandLargely replace the CMDon-line command syntax of Turbo PMACHOME and HOMEZ were only program commands of this type in Turbo PMACMotor-specific direct commands act on addressed or listed motor(s)If no list (e.g. jog+), acts on motor
55、 presently addressed by programLdata.Motor=expression sets addressed motor in programIf has list (e.g. jog+1,3,5), acts on listed motor(s), does not change modally addressed motorC.S.-specific direct commands act on addressed or listed C.S.(s)If no list (e.g. abort), acts on C.S. presently addressed
56、 by programLdata.Coord=expression sets addressed C.S. in programIf has list (e.g. abort2,4,6), acts on listed C.S.(s), does not change modally addressed C.S.Program Direct Motor Commandscoutlist:data Command open-loop output of specified % of fulldkilllist Command motor kill (delayed for brake engag
57、ement)homelist Command homing-search movehomezlist Command zero-move homingjog+list Command indefinite positive jogjog-list Command indefinite negative jogjog/list Command jog stop (or close loop)jogretlist Command return to pre-jog positionjoglist=data Command jog to specified positionjoglist:data
58、Command jog of specified distance from desiredjoglistdata Command jog of specified distance from actualjogretlist=data Command jog to specified position, make it pre-jog posjoglist=datadata Command triggered jog movejoglist:datadata Command triggered jog movejoglistdatadata Command triggered jog mov
59、ekilllist Command motor kill (immediate)Program Direct Coordinate System CommandsIf no coordinate system list, acts on addressed C.S. onlyIf uses coordinate system list, acts on all listed C.S.senablelist Put disabled motors in coordinate system(s) into closed-loop, enabled, zero-velocity state (alr
60、eady enabled motors not affected)disablelist Put all motors in coordinate system(s) immediately into open-loop, disabled (“killed”) stateddisablelist Put all motors in coordinate system(s) into open-loop, disabled, (“killed”) state after delay for brake engagementabortlist Command abort (closed-loop
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 某电子厂来料检验细则
- 2026年10月梅岭街道锦旺社区招聘临时性公益性岗位2人考试模拟试题及答案解析
- 2027国家林业和草原局直属单位公开招聘应届毕业生282人(黑龙江19人)考试参考题库及答案解析
- 2026河北唐山弘慈医院招聘工作人员13名考试备考试题及答案解析
- 2026年10月广东珠海市教育局招聘直属学校事业编制教师178人考试参考题库及答案解析
- 2026天津市排球运动管理中心招聘高层次人才、急需紧缺人才2人笔试参考题库及答案解析
- 2026福建福州市江南智慧城市建设运营有限公司招聘3人笔试备考题库及答案解析
- 中国医学科学院基础医学研究所 北京协和医学院基础学院派遣人员招聘8人笔试备考题库及答案解析
- 2026年户外床行业洞察报告及未来五至十年发展趋势报告
- 2026年棕制品制造行业市场深度调研报告及未来五至十年技术路径与产业化前景
- 企业融资申请书范本及填写指南
- 藏羌碉楼营造技艺传承-洞察及研究
- DB35∕T 1036-2023 10kV及以下电力用户业扩工程技术规范
- 河北食品经营许可现场核查表及核查意见(食品销售)
- 数字智慧方案5445丨企业碳资产管理案例分享北京环境交
- 《奶牛的饲养管理》课件
- 中国文化概论教学课件
- 冷库储存生姜合同范例
- 气管切开套管的选择与更换
- GB/T 9799-2024金属及其他无机覆盖层钢铁上经过处理的锌电镀层
- 半球电压力锅说明书
评论
0/150
提交评论