Hi,
I'm working on the small project and I wanted to control one or two servos from my Asus 500g wireless router. It has mips Broadcom BCM4704 CPU, 4 ethernet ports and 2 USB. I'm running dd-wrt firmware on it, which is basically a Linux, kernel 2.4.34, with all goodies like ssh, samba, openvpn etc.
On my second linux, standard PC with Fedora (kernel 2.6) I've installed cross-compiler so I can produce binary for the mips.
I have 4 Motor PhidgetServo Kit and it is running perfectly OK on my PC linux box. I can connect it to usb port (uhci_hcd), run test program which basically calls setMotorPosition in a loop going from -23 to 231 doing getMotorPosition to confirm the position and usleep, more or less something like that:
Code:
for (i = -23; i < 231; i += step) {
ret = CPhidgetServo_setMotorPosition(servo, 0, i);
... if ret != OK print error ...
ret = CPhidgetServo_getMotorPosition(servo, 0, &cur);
... if ret != OK print error ...
printf("Current position is: %f, %f\n, i, cur);
usleep(20000);
}
This way I can rotate servo smoothly full 180 degrees, when connected to my PC Linux, it's perfectly fine.
I've got libphidgets (ver 2.1.2) and my software compiled for mips.
When I attach servo to the Asus (uhci module and usbfs mounted in /proc/bus/usb) and run my program, the servo is moving, but very unpredictable. I mean, I can control in which direction in rotates, but I cannot get full control over the rotation and it is far from being smooth. If I go from -23 to 231 the servo eventually will do almost 180 degree but it will move quickly couple of degrees, then stop, 'shake' for a while, then rotate another couple of degrees etc. If I didn't know that the motor is OK I would think that it is broken.
If I try to run setMotorPosition once then it won't move at all.
setMotorPosition never returns an error, but getMotorPosition very often
returns
9: Value is Unknown (State not yet received from device).
When it doesn't return the error it returns zero or -23 even if the servo is in different position. On some rare ocassion it returns the real position.
This is a part of the output, first is the position I try to set, and the second value is obtained by calling getMotorPosition (see pseudo code above, step = 0.1)
Current position is 60.700000 0.000000
Current position is 60.800000 0.000000
9: Value is Unknown (State not yet received from device).
Current position is 60.800000 0.000000
Current position is 60.900000 0.000000
Current position is 60.900000 -23.000000
...
Current position is 79.700000 -23.000000
Current position is 79.700000 79.550000
Current position is 79.800000 79.550000
Current position is 79.800000 79.550000
Current position is 79.900000 79.550000
I have enabled
CPhidget_enableLogging(6, "./phidgetlog.txt"), but nothing interesting there.
I'm stuck and have no idea what's wrong.
I've finished writing the software, it is OK on PC, but cannot get it working on Asus. It's very frustrating because servo is doing something, it is rotating, but it doesn't exactly do what it should.
Any advice or suggestion is highly appreciated.
Thanks,
Mike
P.S part of lsusb output from Asus:
Bus 002 Device 002: ID 06c2:0038
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x06c2
idProduct 0x0038
bcdDevice 3.0d
iManufacturer 1 Phidgets Inc.
iProduct 2 PhidgetServo
iSerial 3 20536
[/code]