简体   繁体   中英

How to send commands from Python 3.4 to a Motorized XY Microscope Stage with db15 input socket

I have a Motorized XY Microscope Stage which is currently controlled by a joystick, the joystick signals are transformed into data and sent to the motors in the XY Microscope Stage through a cable which is a db15. I need to move it with commands from my computer, replacing the joystick.

I also have a USB to DB15 converter "USB Game Port Adapter Rockfire RM-203" that I got from here http://www.rockfire.com.tw/en/products/accessory/usb-accessory/7-rm-203-usb-nest-converter.html which creates in Human Interface Devices a HID-compliant game controller and a new USB input device

I am having some issues sending a command (lets say moving a motor from position 0 to position 100 in X axis) from my laptop to the XY Microscope Stage, I do not know how to send the command from Python 3.4 to the motors.

As I have this HID, I can use pywinusb 0.4.1 from here https://pypi.python.org/pypi/pywinusb/ , Docs here https://github.com/rene-aguirre/pywinusb , but I cannot see how to sent a coomand to the HID

I think I have to identify and open the HID port, then write the commands and send them through, so the motors will move, like I did with a serial port which was using instead of HID a COM port, and It was way much easier than this

Can somebody help me Thanks

Edit

I have check some information online but there is little or no examples about it. Here is an approach that I tryed How to send hid data to device using python / pywinusb? then it did not work so I breaked into pieces and tryed this

from pywinusb import hid
filter = hid.HidDeviceFilter()
print (filter)
hid_device = filter.get_devices()
print (hid_device)
if hid_device:
    print("Found %d matching hid devices" + str(len(all_devices)))
else:
    print("no hid devices")
hid_device.open()

And I got this

<pywinusb.hid.core.HidDeviceFilter object at 0x0000000003FC0240>
{}
no hid devices
Traceback (most recent call last):
  File "C:/Users/me/Desktop/other.py", line 15, in <module>
    hid_device.open()
AttributeError: 'dict' object has no attribute 'open'

So sadly, even though the keyboard, mouse and USB to DB15 cable are connected, and I can see they are connected on the Device manager, this program does not recognise them.

Here other examples

https://stackoverflow.com/search?page=1&tab=relevance&q=pywinusb
https://stackoverflow.com/questions/12802401/simple-reading-writing-from-to-a-usb-hid-device-in-python
http://cooder.org/questions/18709253
https://github.com/jrowberg/pywinusb/commit/8a0c7ac0aca6ac66eb944520a2b5e4c538f06a8c
http://www.developerfusion.com/project/31693/pywinusb/
http://nullege.com/codes/show/src@p@y@pywinusb-0.3.3@examples@pnp_qt.py
http://www.developerfusion.com/project/31693/pywinusb/
https://developer.mbed.org/cookbook/USBHID-bindings-

Still, I do not know how to even recognize the cable in Python 3.4

please help

Nevermind, I was trying to control the MAC5000 from this link http://ludl.com/?portfolio=mac-6000 I have emailed the manufacturer, and they said that probably after all the test performed I have to use the "control box" of the device and not trying to control it directly from the db15 port. although such db port has 15 pins I can not use USB to GPIB or USB to DB15 adapters, python packets pyvisa and pywinusb respectively. this control box has a serial port so I will use pyserial to send commands and get reply messages from the MAC5000.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM