VAL3 参考手册
第 7 版
D28077110A – 23/08/2010
说明书原本的翻译版
VAL 3 © Stäubli 2010
您可在与控制箱一起交货的 CDROM 的 "readme.pdf" 文档中找到附录和勘误表
2 / 192
© Stäubli 2010 – D28077110A
VAL 3
目录
目录
1 - 引言 ..................................................................................................................... 13
2 - VAL 3 语言基础知识........................................................................................ 17
2.1 软件应用....................................................................................................................................................... 19
2.1.1 定义.................................................................................................................................................. 19
2.1.2 默认内容 ......................................................................................................................................... 19
2.1.3 程序启动和终止 ............................................................................................................................ 19
2.1.4 软件应用参数................................................................................................................................. 19
2.1.4.1 长度单位 ....................................................................................................................... 20
2.1.4.2 栈内存的数量............................................................................................................... 20
2.2 程序 ............................................................................................................................................................... 21
2.2.1 定义.................................................................................................................................................. 21
2.2.2 重入程序 ......................................................................................................................................... 21
2.2.3 Start() 程序..................................................................................................................................... 21
2.2.4 Stop() 程序 ..................................................................................................................................... 21
2.2.5 程序控制指令................................................................................................................................. 22
注释 // .............................................................................................................................................. 22
call 程序 .................................................................................................................................................................. 22
return .............................................................................................................................................. 22
if 控制指令 ............................................................................................................................................................. 23
while 控制指令 ...................................................................................................................................................... 24
do ... until 控制指令 ............................................................................................................................................. 24
for 控制指令 ........................................................................................................................................................... 25
switch 控制指令 .................................................................................................................................................... 26
2.3 数据 ............................................................................................................................................................... 28
2.3.1 定义.................................................................................................................................................. 28
2.3.2 简单类型 ......................................................................................................................................... 28
2.3.3 结构类型 ......................................................................................................................................... 28
2.3.4 数据容器 ......................................................................................................................................... 29
2.4 数据初始化 .................................................................................................................................................. 29
2.4.1 简单类型数据................................................................................................................................. 29
2.4.2 结构类数据..................................................................................................................................... 29
2.5 变量 ............................................................................................................................................................... 30
2.5.1 定义.................................................................................................................................................. 30
2.5.2 变量的作用范围 ............................................................................................................................ 30
2.5.3 访问一个变量值 ............................................................................................................................ 30
2.5.4 适用于所有变量的指令................................................................................................................ 31
num size(*) ...................................................................................................................................... 31
bool isDefined(*) ............................................................................................................................. 31
bool insert(*) ................................................................................................................................... 32
bool delete(*) .................................................................................................................................. 33
num getData(string sDataName, *) ................................................................................................. 34
VAL 3
© Stäubli 2010 – D28077110A
3 / 192
2.5.5 数组变量的特殊指令..................................................................................................................... 35
void append(*) ................................................................................................................................. 35
num size(*, num nDimension) ......................................................................................................... 35
void resize(*, num nDimension, num nSize) ................................................................................... 35
2.5.6 集合变量的特殊指令..................................................................................................................... 36
string first(*) .................................................................................................................................... 36
string next(*) .................................................................................................................................... 36
string last(*) ..................................................................................................................................... 36
string prev(*) .................................................................................................................................... 36
2.6 程序参数 ....................................................................................................................................................... 37
2.6.1 按元素值的参数 ............................................................................................................................. 38
2.6.2 按元素引用的参数 ......................................................................................................................... 38
2.6.3 按数组或集合引用的参数 ............................................................................................................ 39
3 - 简单类型............................................................................................................. 41
3.1 BOOL 类型................................................................................................................................................... 43
3.1.1 定义 .................................................................................................................................................. 43
3.1.2 运算符 .............................................................................................................................................. 43
3.2
NUM 类型 ..................................................................................................................................................... 44
3.2.1 定义 .................................................................................................................................................. 44
3.2.2 运算符 .............................................................................................................................................. 45
3.2.3 指令 .................................................................................................................................................. 46
num sin(num nAngle) ...................................................................................................................... 46
num asin(num nValue) .................................................................................................................... 46
num cos(num nAngle) ..................................................................................................................... 46
num acos(num nValue) ................................................................................................................... 46
num tan(num nAngle) ...................................................................................................................... 46
num atan(num nValue) .................................................................................................................... 47
num abs(num nValue) ..................................................................................................................... 47
num sqrt(num nValue) .................................................................................................................... 47
num exp(num nValue) ..................................................................................................................... 47
num power(num nX, num nY) ......................................................................................................... 47
num ln(num nValue) ........................................................................................................................ 48
num log(num nValue) ...................................................................................................................... 48
num roundUp(num nValue) ............................................................................................................ 48
num roundDown(num nValue) ....................................................................................................... 48
num round(num nValue) ................................................................................................................. 48
num min(num nX, num nY) ............................................................................................................. 49
num max(num nX, num nY) ............................................................................................................ 49
num limit(num nValue, num nMin, num nMax) ............................................................................... 49
num sel(bool bCondition, num nValue1, num nValue2) .................................................................. 49
3.3 位字段类型 ................................................................................................................................................... 50
3.3.1 定义 .................................................................................................................................................. 50
3.3.2 运算符 .............................................................................................................................................. 50
3.3.3 指令 .................................................................................................................................................. 50
num bNot(num nBitField) ................................................................................................................ 50
num bAnd(num nBitField1, num nBitField2) ................................................................................... 50
num bOr(num nBitField1, num nBitField2) ...................................................................................... 51
num bXor(num nBitField1, num nBitField2) .................................................................................... 51
num toBinary(num nValue[], num nValueSize, string sDataFormat, num& nDataByte[]) ............... 52
num fromBinary(num nDataByte[], num nDataSize, string sDataFormat, num& nValue[]) ............ 52
4 / 192
© Stäubli 2010 – D28077110A
VAL 3
目录
3.4
3.5
3.6
3.7
STRING 类型 .............................................................................................................................................. 54
3.4.1
定义 ................................................................................................................................................ 54
3.4.2 运算符 ............................................................................................................................................. 54
3.4.3 指令.................................................................................................................................................. 54
string toString(string sFormat, num nValue) .................................................................................. 54
string toNum(string sString, num& nValue, bool& bReport) ........................................................... 55
string chr(num nCodePoint) ............................................................................................................ 56
num asc(string sText, num nPosition) ............................................................................................. 57
string left(string sText, num nSize) ................................................................................................. 57
string right(string sText, num nSize) ............................................................................................... 57
string mid(string sText, num nSize, num nPosition) ....................................................................... 57
string insert(string sText, string sInsertion, num nPosition) ............................................................ 58
string delete(string sText, num nSize, num nPosition) ................................................................... 58
string replace(string sText, string sReplacement, num nSize, num nPosition) .............................. 58
num find(string sText1, string sText2) ............................................................................................ 58
num len(string sText) ...................................................................................................................... 58
DIO 类型....................................................................................................................................................... 59
3.5.1 定义.................................................................................................................................................. 59
3.5.2 运算符 ............................................................................................................................................. 59
3.5.3 指令.................................................................................................................................................. 60
void dioLink(dio& diVariable, dio diSource) ................................................................................... 60
num dioGet(dio diArray[]) ............................................................................................................... 60
num dioSet(dio diArray[], num nValue) ........................................................................................... 61
num ioStatus(dio diInputOutput) .................................................................................................... 61
num ioStatus(dio diInputOutput, string& sDescription, string& sPhysicalPath) .............................. 62
AIO 类型....................................................................................................................................................... 63
3.6.1 定义.................................................................................................................................................. 63
3.6.2 指令.................................................................................................................................................. 63
void aioLink(aio& aiVariable, aio aiSource) .................................................................................... 63
num aioGet(aio aiInput) .................................................................................................................. 63
num aioSet(aio aiOutput, num nValue) ........................................................................................... 63
num ioStatus(aio aiInputOutput) .................................................................................................... 64
num ioStatus(aio diInputOutput, string& sDescription, string& sPhysicalPath) .............................. 64
SIO 类型....................................................................................................................................................... 65
3.7.1 定义.................................................................................................................................................. 65
3.7.2 运算符 ............................................................................................................................................. 65
3.7.3 指令.................................................................................................................................................. 66
void sioLink(sio& siVariable, sio siSource) .................................................................................... 66
num clearBuffer(sio siVariable) ...................................................................................................... 66
num sioGet(sio siInput, num& nData[]) ........................................................................................... 66
num sioSet(sio siOutput, num& nData[]) ........................................................................................ 66
num sioCtrl(sio siChannel, string nParameter, *value) .................................................................. 67
4 - 用户界面............................................................................................................. 69
4.1 用户页面....................................................................................................................................................... 71
4.2 屏幕类型....................................................................................................................................................... 71
4.2.1 用户屏幕的选择 ............................................................................................................................ 71
4.2.2 用户屏幕上的写入 ........................................................................................................................ 71
4.2.3 从用户屏幕读入 ............................................................................................................................ 71
VAL 3
© Stäubli 2010 – D28077110A
5 / 192
4.3 指令................................................................................................................................................................ 72
void userPage(), void userPage(screen scPage), void userPage(bool bFixed) ............................ 72
void gotoxy(num nX, num nY), void gotoxy(screen scPage, num nX, num nY) ............................ 72
void cls(), void cls(screen scPage) ................................................................................................. 72
void setTextMode(num nMode),
void setTextMode(screen scPage, num nMode) ............................................................................ 72
num getDisplayLen(string sText) ................................................................................................... 73
void put(string sText), void put(screen scPage, string sText)
void put(num nValue), void put(screen scPage, num nValue),
void putln(string sText), void putln(screen scPage, string sText),
void putln(num nValue), void putln(screen scPage, num nValue), ................................................ 74
void title(string sText), void title(screen scPage, string sText) ....................................................... 74
num get(string& sText),num get(screen scPage, string& sText),
num get(num& nValue),num get(screen scPage, num& nValue),
num get(),num get(screen scPage) ................................................................................................ 74
num getKey(), num getKey(screen scPage) .................................................................................. 76
bool isKeyPressed(num nCode),
bool isKeyPressed(screen scPage, num nCode) ........................................................................... 76
void popUpMsg(string sText) .......................................................................................................... 76
bool logMsg(string sText) ............................................................................................................... 77
string getProfile() ............................................................................................................................77
num setProfile(string sUserLogin, string sUserPassword) ............................................................. 77
string getLanguage() ...................................................................................................................... 78
bool setLanguage(string sLanguage) ............................................................................................. 79
string getDate(string sFormat) ........................................................................................................ 79
5 - 任务 ..................................................................................................................... 81
5.1 定义................................................................................................................................................................ 83
5.2 运行时错误后的重启 .................................................................................................................................. 83
5.3 可见性............................................................................................................................................................ 83
5.4 时序................................................................................................................................................................ 84
5.5 同步任务 ....................................................................................................................................................... 85
5.6 超时运行 ....................................................................................................................................................... 85
5.7 输入 / 输出刷新 ........................................................................................................................................... 85
5.8 同步................................................................................................................................................................ 86
5.9 资源分配 ....................................................................................................................................................... 87
5.10 指令................................................................................................................................................................ 88
void taskSuspend(string sName) ................................................................................................... 88
void taskResume(string sName, num nSkip) ................................................................................. 88
void taskKill(string sName) ............................................................................................................. 89
void setMutex(bool& bMutex) ......................................................................................................... 89
string help(num nErrorCode) ........................................................................................................... 89
num taskStatus(string sName) ....................................................................................................... 90
void taskCreate string sName, num nPriority, program(...) ............................................................. 91
void taskCreateSync string sName, num nPeriod, bool& bOverrun, program(...) .......................... 92
void wait(bool bCondition) ............................................................................................................... 93
void delay(num nSeconds) .............................................................................................................. 93
num clock() ..................................................................................................................................... 94
bool watch(bool bCondition, num nSeconds) ................................................................................. 94
6 / 192
© Stäubli 2010 – D28077110A
VAL 3
目录
6 - 库 ......................................................................................................................... 95
6.1 定义 ............................................................................................................................................................... 97
6.2 接口 ............................................................................................................................................................... 97
6.3 接口标识符 .................................................................................................................................................. 97
6.4 内容 ............................................................................................................................................................... 97
6.5 加密 ............................................................................................................................................................... 98
6.6 加载和卸载 .................................................................................................................................................. 99
6.7 指令 ............................................................................................................................................................. 101
num identifier:libLoad(string sPath) .............................................................................................. 101
num identifier:libLoad(string sPath, string sPassword) ................................................................ 101
num identifier:libSave(), num libSave() ........................................................................................ 101
num libDelete(string sPath) .......................................................................................................... 101
string identifier:libPath(), string libPath() .................................................................................... 102
bool libList(string sPath, string& sContents[]) .............................................................................. 102
bool identifier:libExist(string sSymbolName) ................................................................................ 102
7 - 用户类型.......................................................................................................... 103
7.1 定义 ............................................................................................................................................................. 105
7.2 创建 ............................................................................................................................................................. 105
7.3 使用 ............................................................................................................................................................. 105
8 - 机器人控制...................................................................................................... 107
8.1 指令 ............................................................................................................................................................. 109
void disablePower() ..................................................................................................................... 109
void enablePower() ...................................................................................................................... 109
bool isPowered() .......................................................................................................................... 109
bool isCalibrated() ........................................................................................................................ 110
num workingMode(), num workingMode(num& nStatus) ........................................................... 110
num esStatus() ............................................................................................................................. 111
bool safetyFault(string& sSignalName) ........................................................................................ 111
num ioBusStatus(string& sErrorDescription[]) ............................................................................. 111
num getMonitorSpeed() ............................................................................................................... 112
num setMonitorSpeed(num nSpeed) .......................................................................................... 112
string getVersion(string sComponent) ......................................................................................... 113
9 - 机器人手臂位置 ............................................................................................. 115
9.1 引言 ............................................................................................................................................................. 117
9.2
JOINT 类型................................................................................................................................................ 117
9.2.1 定义................................................................................................................................................ 117
9.2.2 运算符 ........................................................................................................................................... 118
9.2.3 指令................................................................................................................................................ 118
joint abs(joint jPosition) ................................................................................................................. 118
joint herej() .................................................................................................................................... 119
bool isInRange(joint jPosition) ...................................................................................................... 119
void setLatch(dio diInput) (CS8C only) ........................................................................................ 120
bool getLatch(joint& jPosition) (CS8C only) ................................................................................. 120
VAL 3
© Stäubli 2010 – D28077110A
7 / 192
9.3
9.4
9.5
9.6
TRSF 类型................................................................................................................................................. 121
9.3.1 定义 ............................................................................................................................................... 121
9.3.2 方向 ............................................................................................................................................... 122
9.3.3 运算符 ........................................................................................................................................... 124
9.3.4 指令 ............................................................................................................................................... 124
num distance(trsf trPosition1, trsf trPosition2) .............................................................................. 124
trsf interpolateL(trsf trStart, trsf trEnd, num nPosition) ................................................................ 125
trsf interpolateC(trsf trStart, trsf trIntermediate, trsf trEnd, num nPosition) .................................. 126
trsf align(trsf trPosition, trsf Reference) ........................................................................................ 126
FRAME 类型............................................................................................................................................. 127
9.4.1 定义 ............................................................................................................................................... 127
9.4.2 使用 ............................................................................................................................................... 127
9.4.3 运算符 ........................................................................................................................................... 128
9.4.4 指令 ............................................................................................................................................... 128
num setFrame(point pOrigin, point pAxisOx, point pPlaneOxy, frame& fResult) .......................... 128
trsf position(frame fFrame, frame fReference) ............................................................................. 128
void link(frame fFrame, frame fReference) ................................................................................... 128
TOOL 类型 ................................................................................................................................................ 129
9.5.1 定义 ............................................................................................................................................... 129
9.5.2 使用 ............................................................................................................................................... 129
9.5.3 运算符 ........................................................................................................................................... 130
9.5.4 指令 ............................................................................................................................................... 130
void open(tool tTool) ..................................................................................................................... 130
void close(tool tTool) ..................................................................................................................... 131
trsf position(tool tTool, tool tReference) ....................................................................................... 131
void link(tool tTool, tool tReference) ............................................................................................. 131
POINT 类型............................................................................................................................................... 132
9.6.1 定义 ............................................................................................................................................... 132
9.6.2 运算符 ........................................................................................................................................... 132
9.6.3 指令 ............................................................................................................................................... 133
num distance(point pPosition1, point pPosition2) ......................................................................... 133
point compose(point pPosition, frame fReference, trsf trTransformation) .................................... 133
point appro(point pPosition, trsf trTransformation) ........................................................................ 134
point here(tool tTool, frame fReference) ....................................................................................... 134
point jointToPoint(tool tTool, frame fReference, joint jPosition) ................................................... 134
bool pointToJoint(tool tTool, joint jInitial, point pPosition, joint& jResult) ..................................... 135
trsf position(point pPosition, frame fReference) ........................................................................... 135
void link(point pPoint, frame fReference) ...................................................................................... 135
9.7 CONFIG 类型 ........................................................................................................................................... 136
9.7.1 引言 ............................................................................................................................................... 136
9.7.2 定义 ............................................................................................................................................... 136
9.7.3 运算符 ........................................................................................................................................... 137
9.7.4 姿态 (RX/TX 机器人手臂).................................................................................................... 138
9.7.4.1 肩部姿态 ..................................................................................................................... 138
9.7.4.2 肘部姿态 ..................................................................................................................... 139
9.7.4.3 腕部姿态 ..................................................................................................................... 139
9.7.5 姿态 (RS/TS 机器人手臂).................................................................................................... 140
9.7.6 指令 ............................................................................................................................................... 140
config config(joint jPosition) .......................................................................................................... 140
8 / 192
© Stäubli 2010 – D28077110A
VAL 3