Pages

Sunday 16 January 2011

The simplest code!

Here is a very simple python code which will let you control the arm:

# Minimalist version of USB arm control to show how simple it could be! (c) N Polwart,  2011

import usb.core, time

dev = usb.core.find(idVendor=0x1267, idProduct=0x0000)
if dev is None:
    raise ValueError('Device not found')           # if device not found report an error

dev.set_configuration()

datapack=0x40,0,0      # change this to vary the movement
bytesout=dev.ctrl_transfer(0x40, 6, 0x100, 0, datapack, 1000)

time.sleep(1)    # waits for 1 second whilst motors move.

datapack=0,0,0
bytesout=dev.ctrl_transfer(0x40, 6, 0x100, 0, datapack, 1000)

A version with some more detailed comments / documentation and user feedback when it runs is available to download arm_0.py

There programs all require the pyUSB library - which can be downloaded from sourceforge.  This is the version I am using.  Download it, extract the zip file and run "python setup.py install" and it should be done.

3 comments:

  1. Hello thanls for the code however i am currently having problems with trying to make it work. The problem is that it days 'Backend not avaliable' meaning none of the libusb or openusb are connecting. Do you have to have libusb installed on my system for it to work?

    ReplyDelete
  2. Andrew, I think the pyUSB module does need libusb installed.

    A quick check of my system suggests I have libusb.1.0.0 installed here, and seems to have been installed by default under Linux Mint. libusb should be in your software/package manager (e.g. sudo apt install libusb-1.0-0 )

    Details on the pyUSB module are here: http://sourceforge.net/apps/mediawiki/pyusb/index.php?title=Main_Page this implies you could use libusb v0.1 or v1.0 or openusb. I've not tried these combinations - but I'm not doing anything too clever with it so it would expect them to all work...

    You might want to note there is a later version of the software out now which is quite a bit more sophisticated than this simple version: http://python-poly.blogspot.com/2011/01/another-version.html

    ReplyDelete
  3. Thanks for the quick reply. I will install libusb tomorrow and see what happens. Thanks again for the support and sharing this code.

    ReplyDelete