Prompt Title: XY滑台驅動修正

Created 8 months ago
Votes 0
Views 148 times
0

Prompt Detail:

我想要使用以下程式來驅動我的XY滑台: import serial import time class StageCommander: def __init__(self, port='COM3', baudrate=38400): self.ser = serial.Serial(port, baudrate) self.ser.timeout = 1 # Set a timeout for reading def send_command(self, command): self.ser.write(command.encode()) time.sleep(0.5) # Add a delay to ensure the command is processed return self.ser.readline().decode().strip() # Read the response from the device def drive_to_absolute_position(self, axis, position): command = f"{axis}:GOABSOLUTE {position}" # 注意這裡的空格 response = self.send_command(command) print(response) # Print the device's response def close(self): self.ser.close() # 使用範例: commander = StageCommander('COM3', 38400) # Drive X-axis to position 10: commander.drive_to_absolute_position(axis='X', position=10) # Drive Y-axis to position 10: commander.drive_to_absolute_position(axis='Y', position=10) # Drive X-axis to position 50: commander.drive_to_absolute_position(axis='X', position=50) # Drive Y-axis to position 20: commander.drive_to_absolute_position(axis='Y', position=20) # 結束通信 commander.close() 但發生了錯誤: E21 E21 E21 E21 根據說明書的意思,E21代表的未發送的分隔符錯誤,無分隔符 (CR) 或不正確。 請修正程式碼。
avatar
Shared 1 prompt
Created 8 months ago

Leave a Comment

Related Tag Prompts

0
0
123
1 year ago 2023-03-08 19:44:55 Serge123
0
0
ffffff
1 year ago 2023-03-09 02:23:48 dddd
0
0
영어번역
1 year ago 2023-03-10 23:56:11 KI
0
0
como decia mi abuela
1 year ago 2023-03-13 21:34:23 vanessa teniorio
0
0
Multi-choice questions
1 year ago 2023-03-14 21:24:00 Chu Vĩnh Quyên
0
0
pip install ttskit
1 year ago 2023-03-15 02:56:03 xyz
0
0
laptop service
1 year ago 2023-03-16 07:42:42 123
0
0
0
0
123456789
1 year ago 2023-03-22 02:14:43 thomas malthus
0
0
用户请求帮助
1 year ago 2023-03-25 07:38:10 test
0
0
Computers for Zambian School.
1 year ago 2023-03-29 07:29:50 OWENS
0
0
Program Java Umum.
1 year ago 2023-03-30 13:43:34 kyy
0
0
Computer Shop Business.
1 year ago 2023-03-30 14:33:38 123123
0
0
逆向分析工程师面试问题
1 year ago 2023-03-31 16:01:41 jack
0
0
0
0
share post
1 year ago 2023-04-05 20:33:28 afrah
0
0
공부 잘하는 방법
1 year ago 2023-04-10 06:00:16 없음
0
0
Blog Themes for Eye4Insight
1 year ago 2023-04-13 13:29:36 toby
0
0
"Live Authentically"
1 year ago 2023-04-20 04:11:02 z
0
0
Ciclos de reproducción.
1 year ago 2023-04-23 18:31:22 abc
0
0
Laughing Conversation Summarized.
1 year ago 2023-04-28 09:24:32 sdfs
0
0
Magic Conch: One Word
1 year ago 2023-04-28 13:43:19 aaaai
0
0
Jedzte rohlíky zdravo.
1 year ago 2023-04-28 21:30:45 1
0
0
Modello per Blackjack.
1 year ago 2023-04-29 16:38:24 Max