Files
ai-titration/Auto_Ctrl/burette_velocity.py
flt6 2c2822ff11 src
Former-commit-id: 43bc977a970a5bba09d0afa6f2a85169fe1ed253
2025-05-15 23:49:13 +08:00

36 lines
972 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import serial
import time
port = "COM5" # 串口名,根据实际情况修改
baudrate = 9600 # 波特率,根据实际情况修改
ser = serial.Serial(port, baudrate)
# 这里模拟的是开度略大的情况
data = b"q1h14d"
ser.write(data)
time.sleep(0.01)
data = b"q2h90d"
ser.write(data)
time.sleep(0.01)
# 以上是逆时针旋转的速度参数,由于开度略大,这里设定了一个比原始开度略小的速度
# 可以反复调节,以达到逐滴滴定的效果
data = b"q5h1d" # 转1秒
ser.write(data)
time.sleep(0.01)
data = b"q6h3d" # 逆时针
ser.write(data)
time.sleep(5.01)
# 这里的等待时间决定了阀门开启时间不能小于1秒也就是阀门转开的时间
data = b"q1h15d"
ser.write(data)
time.sleep(0.01)
data = b"q2h0d"
ser.write(data)
time.sleep(0.01)
# 回转的速度参数,建议与主程序中慢滴的速度一致,保证正反转角度一致
data = b"q6h2d" # 顺时针
ser.write(data)
ser.close()