PMAC training note.docx
《PMAC training note.docx》由会员分享,可在线阅读,更多相关《PMAC training note.docx(12页珍藏版)》请在冰豆网上搜索。
![PMAC training note.docx](https://file1.bdocx.com/fileroot1/2022-10/29/f775ff40-b065-472d-bf35-6da2b37b387f/f775ff40-b065-472d-bf35-6da2b37b387f1.gif)
PMACtrainingnote
PMAC变量及其功能
1.I-变量(Non-Turbo1024,Turbo8192)
♦初始化和设置参数
♦有固定的定义
♦有一部分影响整个卡
♦有一部分只针对电机
♦有一部分只针对坐标系
♦有一部分只针对编码器
I-变量类型
♦开关型
♦数值型
♦整型数
♦浮点数
♦地址型
2.P-变量(Non-Turbo1024,Turbo8192)
♦通用用户变量
♦48-bit浮点数
♦全局变量
P-变量:
是用户在进行PMAC编程计算时通用的全局变量
♦48-bit浮点数
♦1024个从P0到P1023
用于:
♦1.计算
♦P100=P101*(sin(45))
♦2.软件触发
♦IF(M1!
=1ANDP10=0)
3.Q-变量(Non-Turbo1024,Turbo8192)
♦通用用户变量
♦48-bit浮点数
♦座标系变量
Q-变量是用户在进行PMAC编程计算时坐标系内部通用的变量
多坐标系时可以用Q-变量来进行管理
Q变量在不同坐标系中的物理地址是不一样的.
可以用同一个Q变量访问不同的物理内存地址
&1Q0访问地址$1400
&2Q0访问地址$1600
&7Q0访问地址$1580
&8Q0访问地址$1780
假设我们有8个坐标系分别运行8个运动程序,所有的程序都可以用同一个Q变量Q0toQ127而没有冗余因此不会有内存冲突
我们也可以用不同的Q变量来访问相同的物理内存地址
&1Q0访问地址$1400
&2Q512访问地址$1400
&7Q640访问地址$1400
&8Q128访问地址$1400
4.M-变量(Non-Turbo1024,Turbo8192)
♦提供客户有权使用内存和I/O
♦用户定义地址,偏移量,宽度
M-变量用于访问PMAC内存和I/O点的地址指针
M-变量没有预先定义.用户必须自己定义,例如:
M9->Y:
$FFC2,8,8;JOPTO端口输出
一旦定义以后,M-变量就可以进行置位,计算,判别
M9->Y:
$FFC2,8,8
X:
1to24bitsX-memory固定点
Y:
1to24bitsY-memory固定点
D:
48bitsX-andY-memory固定点
L:
48bitsX-andY-memory浮点
DP:
32bits(XandY低16位)固定点(使用DPRAM时)
F:
32bits(XandY低16位)浮点(使用DPRAM时)
X:
{地址},{偏移量},{宽度},{格式}
Y:
{地址},{偏移量},{宽度},{格式}
偏移量–起始位
宽度–缺省为1;可以是1,4,8,12,16,20,or24位宽
格式–缺省为U(无符号);可以是S(有符号)
PMAC1内存地址Y:
$FFC2指向JOPTOport:
8inputsand8outputs
在PMAC软件手册中推荐详细的M变量定义
M0->x:
$0000,0,24;PointtoServoClock
M1->Y:
$FFC2,8,1;PointtoMachineOutput1
M9->Y:
$FFC2,8,8;PointtoMachineOutput1-8
M102->Y:
$C003,8,16,s;PointtoDAC1output
M197->X:
$0806,0,24,s;PointtoFeedrateOverride
M120->Y:
$C000,20,1;PointtoHomeFlagAxis1
M172->L:
$082B;Pointto#1VariableJog
M1000->*;SelfReferenced(pointingtothememory;locationofitself)
M-变量使用
M1=1;TurnonMachineOutput1
M9=45;TurnonMachineOutputs1,3,4,6andturnoffMachineOutputs2,5,7,8
;45=00101101binary
PMACPLCPrograms
WhatisaPLC
ØAPMACPLCprogramisageneral-purposeprogramthatrunsinPMACthatcanruneitherinbackgroundtime(forPLCandPLCC)orforegroundtime(PLC0andPLCC0)
ØScansthroughasfastasprocessorspeedallowsbeforethenextservointerrupt
ØIdealforanytaskthatisasynchronoustomotionprogramsequencesandforjoggingandhomingroutines
ØSomecommonusesforPLCprograms:
Monitoringinputs,settingoutputs
Changinggains
Monitoringcardstatus
Commandingactions
Sendingmessages
Joggingmotors
Configuringhardware
Startingorstoppingmotionprograms
DifferentTypesofPLCs
BackgroundPLCs:
ØPLC(numbered1-31,31totalavailable):
Uncompiled;i.e.,interpretedbyPMAC
SlowerthanPLCC,butcanbeuploadedeasilyfromPMAC
PMACscanscompletelytotheendofonePLConceeachbackgroundcycle,orifthePLCisinaWhilelooppresently,scanstotheendofthelooponceeachbackgroundcycle
ØPLCC(numbered1-31,31totalavailable):
Compiled;moreefficientandflexiblethanuncompiledPLCs
Canoperate10-30xfasterthanPLCswhenprogrammedproperly
PMACscansthroughallbackgroundPLCCs(1-31)eachbackgroundcycle
ForegroundPLCs:
ØPLC0andPLCC0
SpecialpriorityPLCs–willexecutetoptobottomattheendofeveryRealTimeInterrupt(RTI)
Executeeveryreal-timeinterruptaslongasthetasksfromthepreviousRTIhavebeencompleted
KeeptheseshorttopreventstarvingbackgroundoftimeortrippingWatchdogtimer
WhatMakesaPLCCSoMuchFaster
ØThefasterexecutionofthecompiledPLCscomesfromtwofactors:
Fromtheeliminationofinterpretationtime
FromthecapabilityofthecompiledPLCprogramstoexecuteintegerarithmetic
See“OptimizationforSpeed”onpage380oftheTurboPMACUserManual
ØFloating-pointoperationsincompiledPLCprogramsruntwotothreetimesfasterthanininterpretedPLCprograms;integer(includingBoolean)operationsrun20to30timesfasterincompiledform
ØCanuseL-Variablesforfastintegerarithmetic–justreplaceyourM-VariabledefinitionsusingL-Variables
ØL-andF-Variablesarepointerslinkedatcompiletime,ratherthanatruntimelikeM-Variablesare
BackgroundPLC/PLCCExecutionOrder
Executionorder:
PLC0andPLCC0areatahigherprioritylevelandcaninterruptanyofthebackgroundPLC's
EveryPLCCscansthroughbetweeneachPLCscan
Uncompiled:
PLC1,2,3…31
Compiled:
PLCC1,2,3,4…31
WritingandDownloadingaPLC
ØAllPLCsmusthaveanopeningstatementandaclosingstatement,e.g.:
OpenPLC1Clear
//PLCContents
Close
OpenPLCC1Clear
//PLCCContents
Close
ØOncewrittenintheEditorwindow(fromPeWin32Pro2clickFileNewFile),clickthe“Download”buttontodownloadtoPMAC
EnablingandDisablingaPLC
ØSetI5topermitthePLCtypesyouplantouse:
I5Setting
SettingMeaning
0
ForegroundPLCsoff;backgroundPLCsoff
1
Foreground