用tmcl与trinamic步进电机进行串行通信

pyTMCL的Python项目详细描述


python tmcl客户端库

Latest ComitTravisPyPI versionpyversions

克隆NativeDesign/python-tmcl

Trinamic用于控制TMCM步进器模块的TMCL串行接口的Python包装器 通过串行到RS485转换器。

安装

使用pip

安装
> pip install pytmcl

安装时不带PIP

> git clone https://github.com/LukeSkywalker92/pyTMCL.git
> cd pyTMCL
> python setup.py install

用法

使用RS485到串行适配器将PC连接到一个或多个TMCM模块。 在开始之前,您应该检查模块的串行地址和波特率 已知的价值。开箱即用(warning:anecdotal)模块通常有一个地址 但这是不保证的。最简单的检查方法 这些值是通过在windows计算机上使用TMCL IDE获得的。

如果使用多个TMCM模块连接到同一个rs485总线,则必须确保 每个模块都被设置为一个不同的序列地址,这样它们就不会发生冲突。

示例用法(单轴模块)
fromserialimportSerialfromtimeimportsleepimportpyTMCL## serial-address as set on the TMCM module.MODULE_ADDRESS=1## Open the serial port presented by your rs485 adapterserial_port=Serial("/dev/tty.usbmodem1241")## Create a Bus instance using the open serial portbus=pyTMCL.connect(serial_port)## Get the motormotor=bus.get_motor(MODULE_ADDRESS)## From this point you can start issuing TMCL commands## to the motor as per the TMCL docs. This example will## rotate the motor left at a speed of 1234 for 2 secondsmotor.rotate_left(1234)sleep(2)motor.stop()

示例用法(多轴模块)
fromserialimportSerialimportpyTMCL## Open the serial port presented by your rs485 adapterserial_port=Serial("/dev/tty.usbmodem1241")## Create a Bus instance using the open serial portbus=pyTMCL.connect(serial_port)## Get the motor on axis 0 of module with address 1module=bus.get_module(1)a0=module.get_motor(0)a1=module.get_motor(1)a2=module.get_motor(2)

示例用法(回调)

fromserialimportSerialfromtimeimportsleepimportpyTMCL# serial-address as set on the TMCM module.MODULE_ADDRESS=0# Open the serial port presented by your rs485 adapterserial_port=Serial("COM4")# Create a Bus instance using the open serial portbus=pyTMCL.connect(serial_port)# Get the motormotor=bus.get_motor(MODULE_ADDRESS)motor.axis.max_positioning_speed=200# From this point you can start issuing pyTMCL commands# to the motor as per the pyTMCL docs. This example will# rotate the motor left at a speed of 1234 for 2 secondsdefangle_to_steps(angle):returnint(angle*256/1.8)defcallback(arg1,arg2):print("Argument 1: "+str(arg1)+"  Argument2: "+str(arg2))motor.move_relative(angle_to_steps(360),callback=callback,args=("Finished Moving","Turned 360 Degree"))

API概述

类电动机(总线、地址、轴)
move_absolute (position, callback=None, args=(), kwargs={})

将电机移动到指定的absolute位置。 到达位置时用*args**kwargs调用回调函数。(回调是可选的)。

move_relative (offset, callback=None, args=(), kwargs={})

将电机相对于当前位置移动指定的偏移量。 到达位置时用*args**kwargs调用回调函数。(回调是可选的)。

reference_search (rfs_type)

启动参考搜索程序以定位限位开关。

rotate_left (velocity)

以指定的速度向左旋转电机

rotate_right (velocity)

以指定的速度向右旋转电机。

run_command (cmd)

执行写入tmcm模块固件的预定义用户子程序

send (cmd, type, motorbank, value)

向马达发送原始TMCL命令

stop ()

停止电机

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在mongodb中获取用户有权访问的数据库列表?   基于契约和类不变量的java设计   java我的代码有什么问题,似乎是正确的,但事实并非如此   java Android初学者:布局按钮和文本   400错误Paypal令牌API与Java(HttpURLConnection)   为什么Java从socket中随机读取数据,而不是整个消息?   如果我调用scanner,我会扫描两次。先是下一个,然后是扫描仪。下一个   如果消息发送失败,java ActiveMQ/JMS不重试   java有没有类似于dynaTrace的开源框架?   java Android:获取zip中的文件数(使用存储卷/存储访问框架)   java无法将流图像解码为片段   java如何修复Jenkins插件中的“此位置的预期stackmap帧”   java如何使用javac编译器编译AndroidManifest。xml文件?