控制方式一:使用串口发送指令来控制电控箱
具体参考《SMC100CC_SMC100PP_Users_Manual.pdf》
1. USB串口参数设置
也可以使用串口助手进行串口通信,设置界面如下,可以正常移动平移台,则说明通信成功。
2. 命令集
使用2个字母ASCII命令来配置和控制SMC100
通常的命令格式为:
nn — 可选或必需的控制器地址。
AA — 命令名称
xx — 可选或必选值或“?”查询当前值
由于多个SMC100CC/PP可以通过内部RS-485总线链接,每个控制器使用一个预先确定的地址(nn),通过解码传入命令的地址字段,它可以确定命令是否为它准备的。 有些命令可以在没有控制器地址的情况下传递。 在这种情况下,该命令适用于所有相关的控制器。 例如:ST0停止所有控制器上的运动,1ST0只停止控制器#1上的运动。
大多数命令都可以用来设置一个值(在这种情况下,命令名后面跟着值“xx”)或查询当前值(在这种情况下,命令名后面跟着“?”)。 当查询一个值时,控制器以接收到的命令和查询的值作为响应。 例如,1VA10将控制器#1的速度设置为10单位/秒。 1VA?控制器会发送响应1VA10。
3. 常用指令:
AC :获取或设置加速度
VA :获取或设置加速度
TP :获取当前位置
PA :移动绝对距离
PR :移动相对距离
ST :停止移动
ZT :获取所有配置参数
SR :获取或设置平移台正的位置限制
SL :获取或设置平移台负的位置限制
3.1 AC—Set/Get acceleration
AC指令:设置或获取平移台的加速度
语法:xxACnn 或 xxAC?
xx是控制器地址,是整数类型(int),范围为1到31.
nn是加速度值,是浮点数类型(float),范围为10-6到1012,单位是unit/s2
示例:
1AC500 将控制器#1设置加速度为500 unit/s2
向串口发送“1AC500”,即可设置加速度为500 unit/s2
1AC? 控制器返回1AC500
向串口发送“1AC?”的查询命令,获取平移台的加速度为500 unit/s2
3.2 VA—Set/Get velocity
VA指令:设置或获取平移台的速度
语法:xxVAnn 或 xxVA?
xx是控制器地址,是整数类型(int),范围为1到31.
nn是速度值,是浮点数类型(float),范围为10-6到1012,单位是unit/s.
示例:
1VA50 将控制器#1设置速度为50 unit/s
向串口发送“1VA500”,即可设置速度为50 unit/s
3.3 TP—Get current acceleration
TP指令:获取平移台的当前位置
语法:xxTP
xx是控制器地址,是整数类型(int),范围为1到31.
示例:
1TP 获取控制器1的当前位置
向串口发送“1TP”的查询指令,控制器返回1TP0,则平移台的当前位置为0 units
3.4 PA—Move absolute
PA指令:移动平移台到绝对位置
语法:xxPAnn 或 xxPA?
xx是控制器地址,是整数类型(int),范围为1到31.
nn是新的目标位置,是浮点数类型(float),范围为SL到SR,单位是unit.
示例:
1PA2.2 移动控制器#1的平移台到绝对位置2.2 units
向串口发送“1PA2.2”,平移台移动到2.2 units的位置
3.5 PR—Move relative
PR指令:移动平移台到相对位置
语法:xxPRnn 或 xxPR?
xx是控制器地址,是整数类型(int),范围为1到31.
nn是位移,是浮点数类型(float),范围为SL到SR,单位是unit.
示例:
1PR2.2 将控制器1上的平移台移动到离当前目标位置2.2 units的新位置。
1PR-2.2 将控制器1上的平移台移动到离当前目标位置-2.2 units的新位置。
3.6 ST—Stop motion
ST指令:平移台停止移动
语法:[xx]ST
xx是控制器地址,是整数类型(int),范围为1到31.
示例:
ST 停止所有平移台的移动
1ST0 只停止控制器#1上平移台的运动
3.7 ZT—Get all configuration parameters
PR指令:获取所有的配置参数
语法:xxZT
xx是控制器地址,是整数类型(int),范围为1到31.
示例:
1ZT 获取控制器1的配置数据,返回1PW1, 1AC320, 1BA0, 1VA80等等数据信息
3.8 SR—Set/Get positive software limit
SR指令:设置或获取正的软件最大位置限制
语法:xxSRnn 或 xxSR?
xx是控制器地址,是整数类型(int),范围为1到31.
nn是正的软件最大位置限制,是浮点数类型(float),范围为0到1012,单位是unit.
示例:
1SR100 设置控制器1正的最大位置为100 units
3.9 SL—Set/Get negative software limit
SL指令:设置或获取负的软件最大位置限制
语法:xxSLnn 或 xxSL?
xx是控制器地址,是整数类型(int),范围为1到31.
nn是负的软件最大位置限制,是浮点数类型(float),范围为-1012到0,单位是unit.
示例:
1SL-100 设置控制器1负的最大位置为-100 units
控制方式二:使用SMC命令接口dll文件来控制电控箱
具体参考《SMC100_Command_Interface_Manual.pdf》
1. dll介绍
Newport.SMC100.CommandInterface.dll 可以SMC100设备进行通信,这个 DLL可以用作可重用的软件组件,用于创建Python脚本或创建LabVIEW Vis等等。
Newport.SMC100.CommandInterface.dll 可以在 C:\Windows\Microsoft.NET\assembly\GAC_64\ 或者 C:\Windows\Microsoft.NET\assembly\GAC_32\ 找到
2. dll里面包括的常用函数
OpenInstrument( ) : 打开SMC100
CloseInstrument( ) : 关闭SMC100
GetDevices( ) : 获取COM端口
WriteToInstrument( ) : 向SMC100写入控制命令
AC_Get( ) : 获取加速度
AC_Set( ) : 设置加速度
VA_Get( ) : 获取速度
VA_Set( ) : 设置速度
TP( ) : 获取当前位置
PA_Get( ) :
PA_Set( ) : 移动绝对距离
PR_Get( ) :
PR_Set( ) : 移动相对距离
ST( ) : 停止移动
SR_Get( ) : 获取平移台正的位置限制
SR_Set( ) : 设置平移台正的位置限制
SL_Get( ) : 获取平移台负的位置限制
SL_Set( ) : 设置平移台负的位置限制
ZT( ) : 获取所有的配置参数
2.1 OpenInstrument
Syntax
int OpenInstrument(string strDeviceKey)
string strDeviceKey: the device key is a serial COM port
return: 0 = successful or -1 = failure
Decription
This function allows opening communication with the selected device. If the opening failed, the returned code is -1.
2.2 CloseInstrument
Syntax
int CloseInstrument()
return: 0 = successful or -1 = failure
Decription
This function allows closing communication with the selected device. If the closing failed, the returned code is -1.
2.3 GetDevices
Syntax
string[] GetDevices()
return: list of strings that contains the accessible COM ports.
Decription
This function returns the list of connected devices available to communicate.
2.4 WriteToInstrument
Syntax
int WriteToInstrument(string command, ref string response, int stage)
command: Instrument command
response: Response of the command
stage: Instrument Stage
return:
Decription
This Overridden function Queries or writes the command given by the user to the instrument.
2.5 AC_Get
Syntax
int AC_Get(int controllerAddress, out double Acceleration, out string errstring)
controllerAddress: controllerAddress
Acceleration: Acceleration
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous AC Get command which is used to Get acceleration. Refer to the Controller’s manual to get the command description.
2.6 AC_Set
Syntax
int AC_Set(int controllerAddress, double Acceleration, out string errstring)
controllerAddress: controllerAddress
Acceleration: Acceleration
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous AC Set command which is used to Set acceleration. Refer to the Controller’s manual to get the command description.
2.7 VA_Get
Syntax
int VA_Get(int controllerAddress, out double Velocity, out string errstring)
controllerAddress: controllerAddress
Velocity: Velocity
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous VA Get command which is used to Get velocity. Refer to the Controller’s manual to get the command description.
2.8 VA_Set
Syntax
int VA_Set(int controllerAddress, double Velocity, out string errstring)
controllerAddress: controllerAddress
Velocity: Velocity
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous VA Set command which is used to Set velocity. Refer to the Controller’s manual to get the command description.
2.9 TP
Syntax
int TP(int controllerAddress, out double CurrentPosition, out string errstring)
controllerAddress: controllerAddress
CurrentPosition: CurrentPosition
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous TP Get command which is used to Get current position. Refer to the Controller’s manual to get the command description.
2.10 PA_Get
Syntax
int PA_Get(int controllerAddress, out double TargetPosition, out string errstring)
controllerAddress: controllerAddress
TargetPosition: TargetPosition
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous PA Get command which is used to Move absolute. Refer to the Controller’s manual to get the command description.
2.11 PA_Set
Syntax
int PA_Set(int controllerAddress, double TargetPosition, out string errstring)
controllerAddress: controllerAddress
TargetPosition: TargetPosition
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous PA Set command which is used to Move absolute. Refer to the Controller’s manual to get the command description.
2.12 PR_Get
Syntax
int PR_Get(int controllerAddress, out double Step, out string errstring)
controllerAddress: controllerAddress
Step: Step
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous PR Get command which is used to Move relative. Refer to the Controller’s manual to get the command description.
2.13 PR_Set
Syntax
int PR_Set(int controllerAddress, double Step, out string errstring)
controllerAddress: controllerAddress
Step: Step
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous PR Set command which is used to Move relative. Refer to the Controller’s manual to get the command description.
2.14 ST
Syntax
int ST(int controllerAddress, out string errstring)
controllerAddress: controllerAddress
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous ST Set command which is us
2.15 SR_Get
Syntax
int SR_Get(int controllerAddress, out double RightLimit, out string errstring)
controllerAddress: controllerAddress
RightLimit: RightLimit
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous SR Get command which is used to Get positive software limit. Refer to the Controller’s manual to get the command description.
2.16 SR_Set
Syntax
int SR_Set(int controllerAddress, double RightLimit, out string errstring)
controllerAddress: controllerAddress
RightLimit: RightLimit
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous SR Set command which is used to Set positive software limit. Refer to the Controller’s manual to get the command description.
2.17 SL_Get
Syntax
int SL_Get(int controllerAddress, out double LeftLimit, out string errstring)
controllerAddress: controllerAddress
LeftLimit: LeftLimit
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous SL Get command which is used to Get negative software limit. Refer to the Controller’s manual to get the command description.
2.18 SL_Set
Syntax
int SL_Set(int controllerAddress, double LeftLimit, out string errstring)
controllerAddress: controllerAddress
LeftLimit: LeftLimit
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous SL Set command which is used to Set negative software limit. Refer to the Controller’s manual to get the command description.
2.19 ZT
Syntax
int ZT(int controllerAddress, out List Parameters, out string errstring)
controllerAddress: controllerAddress
Parameters: Parameters
errString: The failure reason
return: 0 in success and -1 on failure
Description
This function is used to process synchronous ZT Get command which is used to Get all axis parameters. Refer to the Controller’s manual to get the command description.
附录:python example
import sys
print "Adding location of Newport.SMC100.CommandInterface.dll to sys.path"
sys.path.append(r'C:\Program Files\Newport\MotionControl\SMC100\Bin)
import clr
clr.AddReferenceToFile("Newport.SMC100.CommandInterface.dll")
from CommandInterfaceSMC100 import *
import System
instrument="COM5"
print 'Instrument Key=>', instrument
SMC = SMC100()
result = SMC100.OpenInstrument(instrumentKey)
result, response, errString = SMC.SR_Get(1)
if result == 0 :
print 'positive software limit=>', response
else:
print 'Error=>',errString
result, response, errString = SMC.SL_Get(1)
if result == 0 :
print 'negative software limit=>', response
else:
print 'Error=>',errString
result, response, errString = SMC.VE(1)
if result == 0 :
print 'controller revision=>', response
else:
print 'Error=>',errString
result, response, errString = SMC.TP(1)
if result == 0 :
print 'position=>', response
else:
print 'Error=>',errString
SMC.UnregisterComponent();
|