element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs USB Robotics and a Raspberry Pi - Part 2
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Former Member
  • Date Created: 9 Feb 2015 9:42 PM Date Created
  • Views 474 views
  • Likes 0 likes
  • Comments 0 comments
  • raspberrypi_education
Related
Recommended

USB Robotics and a Raspberry Pi - Part 2

Former Member
Former Member
9 Feb 2015

So, hardware selected the next job was deciding how to control the USB ports. I selected PyUSB.

How to download and install PyUSB onto my Raspberry Pi.

 

Download PyUSB from sourceforge using this link http://sourceforge.net/projects/pyusb/

and then open up the console on your Pi and unpack the archive file by typing


sudo unzip pyusb_1.0.0b2.zip

 

You then need to navigate to the newly created directory by typing


cd pyusb_1.0.0b2


You can now install PyUSB by typing


sudo python setup.py install

 

This will install the PyUSB library on your Pi. This will then enable you to control the USB ports on your Pi thought Python.

In your Python programs you need to import the library using the following lines.

image

I then had to find out the Vendor and Product id numbers for the Rocket Launcher and the Robot Arm. After a fair amount of searching I found them.


Rocket Launcher : idVendor=0x2123, idProduct=0x1010

 

Maplin Robot Arm : idVendor=0x1267, idProduct=0x000

 

These codes are needed to connect the devices to the Kernel driver. In other words, without these codes the operating system doesn't know which devices are connected.



You're now ready to create a python program to connect the USB device to your Raspberry Pi.


imageimage

 

 


You should now be ready to start to send some commands to the USB devices.


The Rocket Launcher and Robot Arm take commands using a different arrangement of hex values. To make the interface I created a couple of functions which are passed the 'command' and a 'duration' as parameters. This made the basic 'user interface' section easier for pupils to understand.


image


In the Robot Arm section below, the MoveArm function is passed a tuple consisting of an integer (delay in seconds) and a list of 3 integers which relate to which motor to move and the direction of movement.


image

Robot arm commands...


[1,0,0]  Open the jaws

[2,0,0] Close the jaws

[4,0,0] Raise the wrist

[8,0,0] Lower the wrist

[16,0,0] Raise the elbow

[32,0,0] Lower the elbow

[64,0,0] Raise the shoulder

[128,0,0] Lower the shoulder

[0,1,0] Rotate the base clockwise

[0,2,0] Rotate the base anti-clockwise

[0,0,1] Turn the light on

[0,0,0,] Turn the light off

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube