自制拓竹AMS笔记

yao
yao
2024-03-18 / 0 评论 / 55 阅读 / 正在检测是否收录...

mqtt连接拓竹打印机

 通过mqtt连接拓竹3D打印机进行信息交互。监听拓竹换料信号,从而去控制YEC-AMS进行自动换料。

连接参数:

  • 用户名:默认bblp
  • 密码:局域网模式里面的密码
  • 订阅地址:device/序列号/report
  • 发送地址:device/序列号/request
  • 端口:默认为8883
  • 地址:为局域网模式内的ip地址
  • SSL/TLS:开启

mricropython mqtt 代码

from umqtt.simple import MQTTClient
from machine import Pin
import network
import time
import ujson
from bambu.bambu_commands import banbu_start,START_PUSH



class Bambu_mqtt_cliet:
    def __init__(self,mqtt_server,DEVICE_SERIAL,password,username="bblp",client_id="esp32",mqtt_port=8883):
        self.mqtt_server = mqtt_server  # 服务器地址
        self.DEVICE_SERIAL = DEVICE_SERIAL # 服务器序列好
        self.username = username # 用户
        self.password = password # 服务器密码
        self.client_id = client_id
        self.mqtt_port = mqtt_port
        # 订阅和发送的主题
        self.TOPIC_SUBSCRIBE = "device/" + DEVICE_SERIAL + "/report"
        self.TOPIC_PUBLISH = "device/" + DEVICE_SERIAL + "/request"
        self.new_message = {} # 订阅的消息
        self.client = None

    def sub_cb(self,topic,msg):
        self.new_message = ujson.loads(msg).get("print",{})

    # 连接和订阅
    def conent_and_subscribe(self):
        try:
            self.client = MQTTClient(self.client_id, self.mqtt_server, user=self.username, password=self.password, ssl=True)
            self.client.set_callback(self.sub_cb)
            self.client.connect()
            self.client.subscribe(self.TOPIC_SUBSCRIBE)
            print("成功连接到 %s, 订阅地址为 %s topic" % (self.mqtt_server, self.TOPIC_SUBSCRIBE))
        except Exception  as e:
            print("连接失败",str(e))
    def loop_updata(self):
        while True:
            time.sleep(1)
            self.client.check_msg()
            try:
                self.piblish(START_PUSH)
            except Exception as e:
                self.new_message = {}
                time.sleep(10)
                self.conent_and_subscribe()
                print("发布出错了",e)
        print("结束") 
    def piblish(self,operation_code):
        self.client.publish(self.TOPIC_PUBLISH, operation_code, retain=True)
  

mircropython 驱动tt电机

 DRV8833 具有两个 NMOS H 桥驱动器,使其能够控制两个直流有刷电机、一个双极步进电机、螺线管和其他电感负载。
 它的工作电压范围为 2.7 V 至 10.8 V,每个通道可连续提供高达 1.2 A 的电流。此外,它还可以承受每通道高达 2 A 的峰值电流几秒钟。
 DRV8833 还包含多种保护功能,例如欠压锁定、过流和过热保护,提供高水平的可靠性。这些事件中的每一个都会禁用 H 桥 MOSFET。故障情况消除后,设备将恢复运行。
 它还包括低功耗睡眠模式,可让您节省电量,尤其是在电机不使用时。
 所有这些功能使其成为为小型低压电机供电的绝佳选择。

ltwb78ju.png

  • 驱动旋转:两个引脚的高低电平设置旋转方向和驱动旋转
  • 旋转速度:通常为高电平的引脚上使用脉宽调制
输入1/输入3输入2/输入4旋转方向
低(0)低(0)电机关闭
高(1)低(0)向前
低(0)高(1)向后
高(1)高(1)电机关闭

当前进展:电路升级为8通,pcb绘制等待中,注意微动开关要与引脚直接连接。

参考地址

  1. DRV8833使用说明
1

评论 (0)

取消