'Communication with a stepper motor controller through a USB COM?
I have a stepper motor controller that I can command through a USB COM on windows. The manufacturer provided a software but I want to create my own on python (In fact, I want to include the control of the stepper into a python code that control another device using the stepper). The problem is that I don't have any information about the commands to send to the controller to move the motor. I want to know if there is a way to read the command sent to the controller using the manufacturer software (like move the motor and read the command sent) and then use that command to write my own code on python ? I want to know if my idea is pure fantasy or if this can actually be done ? Thanks
Solution 1:[1]
I was able to solve my problem by reverse engineering the protocol of the device :
- Wireshark usbcap to sniff the data while using the device's software to move the motor.
- pyUSB to write my own program to control the device based on the packet retrieved using wireshark
import time
import usb.core
import usb.util
from sys import exit
import sys
'''
On windows : Install libusb-win32
Install zadig
Launch Zadig :
choose the driver
choose libusb-win32
choose "install filter driver"
restart the computer
'''
VID = 0x04d8
PID = 0x000a
dev = usb.core.find(idVendor=VID, idProduct=PID)
if not dev:
print("Could not find device ")
exit(1)
else:
print("Yeeha! Found the device")
dev.set_configuration()
# command : Limit
dev.write(2, (0x59, 0x4c, 0x0d))
Solution 2:[2]
I think it's a bit hard since the manufacturer already has its own software meaning their software already bind with the firmware of the controller.
One way to do that is you have to look for the way to communicate with the firmware between python and your controller. Who know to do this? the manufacturer. If you have a basic of electrical engineering I think its possible but still hard.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | gtn_03 |
Solution 2 | danangjoyoo |