The Daily Click ::. Forums ::. Klik Coding Help ::. Serial Object & USB Servo Controller
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
4th January, 2013 at 04/01/2013 16:59:23 -

I'm attempting to use the Serial object to use a USB Servo Controller with MMF2, but so far without any success.

The relevant instructions provided by the manufacturer are here:
http://www.pololu.com/docs/0J40/5.c
http://www.pololu.com/docs/0J40/5.e

I've tried both protocols, but I'm mainly interested in the simpler "Mini SSC protocol".

This is some simple code that I've tried:

+ Start of frame
-> Binary: Resize binary to 3 bytes
-> Serial: Open COM 7 with a baud rate of 9600 // I got COM7 from device manager

+ Serial: COM port is open
+ Only one action when event loops
-> Button: Enable // The button is disabled by default

+ Button clicked
-> Binary: Set byte 0 to 255 // 255 is the command byte for "SetTarget"
-> Binary: Set byte 1 to 5 // I want to set servo #5
-> Binary: Set byte 2 to 127 // 127 = return the servo to its centre
-> Serial: Send string$( "Binary object", 0, 3)

It opens the port alright, but nothing happens when I click the button (it should set servo #5 to its centre position).
I don't get any error messages from MMF2 or the Serial object.

If anyone has any suggestions or thoughts on what I might be doing wrong, I'd be most appreciative

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
12th January, 2013 at 12/01/2013 03:27:59 -

I have no idea unfortunately but i would create some debugging counters. Can you read the byte numbers back once they have been set?

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
12th January, 2013 at 12/01/2013 14:02:55 -

The byte numbers being sent are correct, but there's no way of telling what happens after they are sent. I think it's probably something to do with data types - like it's expecting a byte array, but the serial extension can only send strings.
I've also tried using a .dll instead of the serial object (sending integer buffer), but the same thing happens - it connects okay, but can't successfully send commands. Again, I suspect I'd need to send a "byte buffer", which the .dll extension can't do.
I also tried using the provided .NET assemblies (the manufacturer doesn't provide win32 .dlls, which is really poor) with the .NET extension - I based the code on one of the examples, but it still didn't work (posted it on the manufacturer's forums, and they couldn't tell me what was wrong with it).
Anyway, I've given up for now, and will probably end up switching to a different controller. It's a shame because on paper, the actual hardware is perfect (better than Arduino etc), but the support and resources just aren't good enough.


VB.NET code:

Imports Pololu.UsbWrapper
Imports Pololu.Usc
Imports System
Imports System.Collections.Generic

Public Class Main

Function TrySetTarget(ByVal channel As Byte, ByVal target As UInt16)
Using device As Usc = connectToDevice()
device.setTarget(channel, target)
End Using
End Function

Function connectToDevice() As Usc
' Get a list of all connected devices of this type.
Dim connectedDevices As List(Of DeviceListItem) = Usc.getConnectedDevices()
For Each dli As DeviceListItem In connectedDevices
Dim device As Usc = New Usc(dli) ' Connect to the device.
Return device ' Return the device.
Next
End Function

End Class

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
12th January, 2013 at 12/01/2013 19:48:45 -

Can you control it with a simple C program?

If you can get it working with something else first then you know there isn't a problem with the hardware, but a problem with the serial object.

I doubt that object has been tested much.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
12th January, 2013 at 12/01/2013 20:41:54 -

Oh yeah, the manufacturer provides a number of ready-made control programs and those work just fine (using any of the various connection modes), so I'm confident the hardware is okay.

Unfortunately, when it comes to MMF2, none of the following have worked:
* serial object
* DLL object + third-party serial communication .dll
* .NET object + manufacturer's own .NET assemblies

They connect to the port okay (the return values are as I'd expect), but that's it.

All I've managed to achieve so far is melting the battery holder (not sure what happened - my guess would be that the servo was being forced to rotate beyond its limit and drew too much current from the batteries, which then overheated).
When I tried to get this working a year or two ago (I've had it a while), it ended up melting the servos - probably the same way (the servos this time are much beefier, so I guess they can handle more current).

 
n/a
   

Post Reply



 



Advertisement

Worth A Click