实验室中的第三只手:滑轨参数以及控制接口
Posted 卓晴
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实验室中的第三只手:滑轨参数以及控制接口相关的知识,希望对你有一定的参考价值。
简 介: 大多数实验内部的滑轨以及机械臂,XY平移平台都是有步进电机驱动的。本文给出了用于这些实验设备驱动的模块所对应的接口。同时也给出了最初这些模块设计和制作的连接。
关键词
: 滑轨,步进电机,蓝牙,Zigbee,WiFi
§01 滑轨控制
对于实验室中的几个滑轨执行器的参数和控制接口进行总结。
1.1 WiFI单轴SH-20403
1.1.1 控制器外观
▲ 图1.1.1 控制器外观
1.1.2 控制接口命令
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# LSCM8.PY -- by Dr. ZhuoQing 2020-01-14
#
# Note:
#============================================================
from head import *
import serial
#------------------------------------------------------------
cmdportdef = 'COM2'
cmdport = serial.Serial(cmdportdef, baudrate=115200, timeout=0.1)
cmdport.setDTR(False)
#cmdport.setRTS(False)
printf("Open %s for LSCM8."%cmdportdef)
#------------------------------------------------------------
COMMAND_FRAME_HEAD = 0x56
COMMAND_FRAME_TAIL = 0x65
COMMAND_STATUS_WAIT = 0x0
COMMAND_STATUS_COMMAND = 0x1
COMMAND_STATUS_LENGTH = 0x2
COMMAND_STATUS_DATA = 0x3
COMMAND_STATUS_CHECK = 0x4
COMMAND_STATUS_TAIL = 0x5
#------------------------------------------------------------
COMMAND_HELLO_ECHO = 0x20
COMMAND_BEEP_ON = 0x21
COMMAND_BEEP_OFF = 0x22
COMMAND_DIR_ON = 0x23
COMMAND_DIR_OFF = 0x24
COMMAND_REL_ON = 0x25
COMMAND_REL_OFF = 0x26
COMMAND_PUL_SET = 0x27
COMMAND_PUL_STOP = 0x28
COMMAND_GOTO_HEAD = 0x29
COMMAND_GOTO_TAIL = 0x2A
COMMAND_GET_STATE = 0x2B
COMMAND_GET_PULSEOUT = 0x2C
COMMAND_CLEAR_PULSEOUT = 0x2D
#------------------------------------------------------------
def lscm8cmd(cmd, cmddata):
checksum = cmd + len(cmddata)
for cd in cmddata:
checksum = checksum + cd
checksum = (checksum & 0xff) ^ 0xff
cmdstr = b'' + byte(COMMAND_FRAME_HEAD) + byte(cmd) + byte(len(cmddata)) +\\
cmddata + byte(checksum) + byte(COMMAND_FRAME_TAIL)
# printf(cmdstr)
cmdport.write(cmdstr)
def lscm8hello():
lscm8cmd(COMMAND_HELLO_ECHO, b'')
def lscm8beepon():
lscm8cmd(COMMAND_BEEP_ON, b'')
def lscm8beepoff():
lscm8cmd(COMMAND_BEEP_OFF, b'')
#------------------------------------------------------------
def lscm8relon(bits):
cmd = bits.to_bytes(1, byteorder='big')
lscm8cmd(COMMAND_REL_ON, cmd)
#------------------------------------------------------------
# bits:0:relay0, 1:relay1
def lscm8reloff(bits):
cmd = bits.to_bytes(1, byteorder='big')
lscm8cmd(COMMAND_REL_OFF, cmd)
def lscm8diron(bits):
cmd = bits.to_bytes(1, byteorder='big')
lscm8cmd(COMMAND_DIR_ON, cmd)
def lscm8diroff(bits):
cmd = bits.to_bytes(1, byteorder='big')
lscm8cmd(COMMAND_DIR_OFF, cmd)
#------------------------------------------------------------
def lscm8setpulse(bits, pulse):
cmd = bits.to_bytes(1, byteorder='big') +\\
pulse.to_bytes(4, byteorder='big')
lscm8cmd(COMMAND_PUL_SET, cmd)
def lscm8stoppulse():
lscm8cmd(COMMAND_PUL_STOP, b'')
def lscm8gotohead():
lscm8cmd(COMMAND_GOTO_HEAD, b'')
def lscm8gototail():
lscm8cmd(COMMAND_GOTO_TAIL, b'')
def lscm8clearpulseout():
lscm8cmd(COMMAND_CLEAR_PULSEOUT, b'')
def lscm8mf(steps):
lscm8diron(3)
lscm8reloff(3)
lscm8setpulse(3, steps)
def lscm8mb(steps):
lscm8diroff(3)
lscm8reloff(3)
lscm8setpulse(3, steps)
#------------------------------------------------------------
if __name__ == "__main__":
time.sleep(.5)
if len(sys.argv) > 1:
step = int(sys.argv[1])
if step > 0:
lscm8mf(step)
else: lscm8mb(-step)
else:
lscm8mb(1000)
tspbeep(1500, 100)
printf('End of the command')
#------------------------------------------------------------
# END OF FILE : LSCM8.PY
#============================================================
1.2 蓝牙双轴SH-20403
1.2.1 控制器外观
▲ 图1.2.1 SH-20403两台驱动器外观
1.2.2 控制软件接口
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# SHAXIS12.PY -- by Dr. ZhuoQing 2020-01-14
#
# Note:
#============================================================
from head import *
from tsmodule.tshardware import *
#------------------------------------------------------------
def shcmd(cmd):
ccloadSerial.write(b'\\r')
cmd = bytes(cmd, 'utf-8') + b'\\r'
ccloadSerial.write(cmd)
def shaxis(n1=0, n2=0):
shcmd('sm2pul %d %d'%(n1, n2))
def shaxis1(n1):
shcmd('sm2pul1 %d'%n1)
def shaxis2(n1):
shcmd('sm2pul2 %d'%n1)
#------------------------------------------------------------
if __name__ == '__main__':
shaxis1(2200)
tspbeep(1200, 200)
#------------------------------------------------------------
# END OF FILE : SHAXIS12.PY
#============================================================
1.3 WiFiESP8266单轴控制器
1.3.1 控制器外观
▲ 图1.3.1 基于ESP8266 WiFi的步进电机控制器
1.3.2 控制命令
利用tshardward内部的rccw,rccw两个命令控制步进电机的运行。
RAIL_CONTROL_IP = '192.168.0.203'
RAIL_CONTROL_PORT = 6000
def rcccw(step):
strcmd = 'ccw %d'%step
udpsendstr(RAIL_CONTROL_IP,
RAIL_CONTROL_PORT,
strcmd)
def rccw(step):
strcmd = 'cw %d'%step
udpsendstr(RAIL_CONTROL_IP,
RAIL_CONTROL_PORT,
strcmd)
- rccw: 往下运动
- rcccw:往上运动;
- 参数: n~[0,4850]
- 运行时间: 15秒
1.4 Zigbee双轴DRV8825
1.4.1 外观照片
▲ 图1.4.1 Zigbee 双轴驱动器以及对应的XY移动平台
1.4.2 控制接口
使用tshardward中的zbcmd控制命令。
(1)命名说明
- zbcmd(b’drvm1 1000’) : 对于顶层移动;
- zbcmd(b’drvm2 1000’):对于底层驱动;
- zbcmd(b’drvorg’) : 两个电机都回复的复位原点。
1. 参数符号:当参数大于零时,平台远离步进电机;当参数小于0,平台靠近步进电机;
2. 移动参数: N= 200000,移动距离:6.6mm
L s t e p = 33 n M = 0.033 μ M L_step = 33nM = 0.033\\mu M Lstep=33nM=0.033μM
※ 控制器总结 ※
大多数实验内部的滑轨以及机械臂,XY平移平台都是有步进电机驱动的。本文给出了用于这些实验设备驱动的模块所对应的接口。同时也给出了最初这些模块设计和制作的连接。
■ 相关文献链接:
- 单轴步进驱动模块SH-20403
- SH-20403AXIS12双轴蓝牙移动框架
- 基于ESP8266 WiFi控制的步进升降机械平台
- 基于ESP8266WiFi步进电机控制
- DRV8825步进电机驱动控制模块以及双轴平台
● 相关图表链接:
以上是关于实验室中的第三只手:滑轨参数以及控制接口的主要内容,如果未能解决你的问题,请参考以下文章