KSR10 Robot Arm (aka Maplin arm aka OWI-535) working in VB6

[color=#FF0000]I now have the arm working on XP, windows 7 and windows 8[/color] with my vb6 program, utilising the open source libusb-win32.

I bought one of these robotic arms to assemble with my son.
That went well and the supplied software was … ok and worked on windows XP.

I got it working on windows 7 using the 64 bit driver and software at:
http://www.owirobot.com/pages/Downloads.html
The driver is un-signed, as was the original, so you have to enable unsigned driver installation. (Lots of info on the net for that)
The same package worked poorly on windows 8 and I was never impressed with the “programming” system on the software, anyway.

So, I decided to write my own interface in vb6.
My code works on XP, Windows 7 and windows 8.
(Windows 8 was a bit of a pain to install due to its tedious disable digital signing method.)

Download my vb6 code http://www.davepatterson.me.uk/public/usbarm.zip

Using libusb-win32:
To access the arm (or any usb device) in windows :

  1. Download latest libusb-win32 library from sourceforge
    This is an open source library for usb devivces

http://sourceforge.net/projects/libusb-win32/files/
http://sourceforge.net/apps/trac/libusb-win32/wiki/libusbwin32_documentation

Copy the library files to the correct system directory- details in:
\libusb-win32-bin-1.2.6.0\bin\libusb-win32-bin-README.txt
System32 on xp and SysWOW64 on 7 & 8

  1. Run the install filter wizard in
    \libusb-win32-bin-1.2.6.0\bin\x86

Follow the directions to create a driver filter.
This filter driver does not seem to replace the original driver.
The Original software continues to work.

  1. Test recognition with testlibusb-win.exe

  2. If the arm is not recognised, use the install filter wizard to remove the patch.

The sourceforge documentation appears to suggest that their preferred installation method is to replace the driver.
Note that the inf-wizard driver did not work with the original software, on my PC. (Nor did I expect it to)

Use inf-wizard.exe in \libusb-win32-bin-1.2.6.0\bin (with the device attached)
Retest with testlibusb-win.exe.

You may find that it is possible to retry the filter patch at this stage:
a) Remove the alternative libusb0 driver using device manager.
b) Re-install the original software.
c) Re-apply the filter driver
d) Test if the filter driver picks up the arm this time
e) Test that the original software still works

  1. I found it difficult to establish the correct calling system to libusb0.dll.

However the following page contained a link to a first rate piece of work.
It provides a bridge using libusbvb0.dll between the vb6 dll calling system and the libusb0.dll.
Calls to libusbvb0.dll, with the detailed structure, are passed to libusb0.dll and do work!

http://libusb.6.n5.nabble.com/Visual-Basic-6-0-How-to-access-the-libusb-td10562.html

The downloadable zip attachment (with a pdf extension) provides the libusbvb0.dll library.
Library libusbvb0.dll should be copied to system32 on XP and SysWOW64 on 7 & 8

The zip attachment on the libusb.6.n5.nabble.com site also contains a vb6 program which is very well documented.

I had to modify only one call definition in this work.
I altered the usbcontrolmsg call and added a 3 byte buffer:

Type buffer
first As Byte
second As Byte
third As Byte
End Type

Declare Function UsbControlMsg Lib “libusbvb0.dll” _
Alias “vb_usb_control_msg” ( _
ByVal dev As Long, _
ByVal requesttype As Long, _
ByVal request As Long, _
ByVal value As Long, _
ByVal index As Long, _
ByRef buf As buffer, _
ByVal size As Long, _
ByVal timeout As Long) As Long

This will also work:
ByRef buf As any, _

  1. Arm rotation codes are detailed here:
    http://notbrainsurgery.livejournal.com/38622.html?view=119262#t121310
    On my arm, the Base rotation codes were the reverse of those detailed in this excellent article:

  2. Overview of dll calls:

rem Initialise usb connection and set error debug
UsbInit
UsbSetDebug (255)
rem connect to arm using device pid and vid numbers
arm = UsbOpen(0, &H1267, &H0)
If arm = 0 Then
rem output to a textbox using subroutine display
display “Could not attach”
Else
display vbNewLine + “Arm attached”
rem set usb configuration and claim interface
config = 1
interface = 0
UsbSetConfiguration arm, config
UsbClaimInterface arm, interface
End If

rem send 3 bytes
Private Sub sendarm(var1 As Byte, var2 As Byte, var3 As Byte)
Dim retval As Long
Dim mybuffer As buffer
mybuffer.first = var1
mybuffer.second = var2
mybuffer.third = var3

USB_TYPE_VENDOR =&H40

rem retval should return with 3, the number of bytes sent, or a negative error number
rem See forgesource documentation for details. -5 i/o error -116 timeout error
rem the last parameter in UsbControlMsg is a usb timeout in mS. Increase if problematic

retval = UsbControlMsg(arm, USB_TYPE_VENDOR, 6, &H100, 0, mybuffer, 3, 20)
If retval <> 3 Then display “Sent: (” + Str(var1) + “,” + Str(var2) + _
“,” + Str(var3) + ") Return value " + Str(retval)
End Sub

rem release the interface when done
Call sendarm(0, 0, 0)
UsbReset arm
UsbClose arm
UsbReleaseInterface arm, interface


Declare Sub UsbInit Lib “libusbvb0.dll” Alias “vb_usb_init” ()
Declare Sub UsbSetDebug Lib “libusbvb0.dll” Alias “vb_usb_set_debug” (ByVal level As Long)
Declare Function UsbOpen Lib “libusbvb0.dll” Alias “vb_usb_open” (ByVal index As Long, ByVal vid As Long, ByVal pid As Long) As Long

Declare Function UsbClaimInterface Lib “libusbvb0.dll” Alias “vb_usb_claim_interface” ( _
ByVal dev As Long, ByVal interface As Long) As Long

Declare Function UsbReset Lib “libusbvb0.dll” Alias “vb_usb_reset” ( ByVal dev As Long) As Long
Declare Function UsbClose Lib “libusbvb0.dll” Alias “vb_usb_close” (ByVal dev As Long) As Long

Declare Function UsbReleaseInterface Lib “libusbvb0.dll” Alias “vb_usb_release_interface” ( _
ByVal dev As Long, ByVal interface As Long) As Long


On another point, half of the batteries are not in use!
On my arm the Batteries on the switch side of the box are wired to the PCB board.
However the solder point for the live goes no-where.
The arm runs on only two batteries!

David