SMC100电控箱控制方法_0926

本文档详细介绍了如何通过串口指令和SMC命令接口DLL文件来控制SMC100电控箱。提供了USB串口参数设置、ASCII命令集及常用指令的详细说明,包括加速度、速度、位置等参数的设置与查询。同时,还阐述了DLL函数的使用方法,如OpenInstrument、CloseInstrument、AC_Get、VA_Set等,用于在Python环境中操作电控箱。
摘要由CSDN通过智能技术生成

控制方式一:使用串口发送指令来控制电控箱

具体参考《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指令:设置或获取平移台的加速度

语法:xxACnnxxAC?

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指令:设置或获取平移台的速度

语法:xxVAnnxxVA?

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指令:移动平移台到绝对位置

语法:xxPAnnxxPA?

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指令:移动平移台到相对位置

语法:xxPRnnxxPR?

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指令:设置或获取正的软件最大位置限制

语法:xxSRnnxxSR?

xx是控制器地址,是整数类型(int),范围为1到31.

nn是正的软件最大位置限制,是浮点数类型(float),范围为0到1012,单位是unit.

示例:

1SR100 设置控制器1正的最大位置为100 units

3.9 SL—Set/Get negative software limit

SL指令:设置或获取负的软件最大位置限制

语法:xxSLnnxxSL?

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

#============================================================
#Initialization Start
#The script within Initialization Start and Initialization End is needed for properly
#initializing IOPortClientLib and Command Interface for SMC100 instrument.
#The user should copy this code as is and specify correct paths here.
import sys
#Command Interface DLL can be found here.
print "Adding location of Newport.SMC100.CommandInterface.dll to sys.path"
sys.path.append(r'C:\Program Files\Newport\MotionControl\SMC100\Bin)
# The CLR module provide functions for interacting with the underlying
# .NET runtime
import clr
# Add reference to assembly and import names from namespace
clr.AddReferenceToFile("Newport.SMC100.CommandInterface.dll")
from CommandInterfaceSMC100 import *
import System
#============================================================
# Instrument Initialization
instrument="COM5"
print 'Instrument Key=>', instrument
# create a device instance
SMC = SMC100()
result = SMC100.OpenInstrument(instrumentKey)
# Get positive software limit
result, response, errString = SMC.SR_Get(1)
if result == 0 :
print 'positive software limit=>', response
else:
print 'Error=>',errString
# Get negative software limit
result, response, errString = SMC.SL_Get(1)
if result == 0 :
print 'negative software limit=>', response
else:
print 'Error=>',errString
# Get controller revision information
result, response, errString = SMC.VE(1)
if result == 0 :
print 'controller revision=>', response
else:
print 'Error=>',errString
# Get current position
result, response, errString = SMC.TP(1)
if result == 0 :
print 'position=>', response
else:
print 'Error=>',errString
# Unregister device
SMC.UnregisterComponent();

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值