I'm hoping to be able to make a program in MMF2, to control a number of servos, connected to a computer via USB and one of these devices: http://www.pololu.com/catalog/product/1350
I've looked through the documentation & files, and it includes the C# source code for a dll which is supposed to simplify the task (takes care of all the low-level stuff for you). I'm hoping that I will be able to use the CallDll extension with this dll.
The problem is, I haven't been able to figure out what functions I can call, what parameters they take, and perhaps even what they actually do.
I would be extremely grateful if any of the programmers out there could take a look at the files, and see if they can work it out.
Finally, this is a real long shot I know, but how much work would it be to create an MMF2 extension from this source code?
How much would I likely have to pay someone for them to do it?
EDIT: I'm only really interested in how to set the position of each servo - not all the stuff like setting speed/acceleration, or returning any data.
looks interesting. too bad i have no knowledge of C#.
if you have the sources, have you tried building the dll yourself? id assume you can use any classes and/or methods within the sources after calling the dll.
edit: as for the mmf extension, the sources are in C#, mmf extension development is in C++. not sure how that would work -_-
I suggest trauling through the C# code and getting it to work from the .Net extension. Oh, and that source doesn't compile without the assembly . It's difficult for someone to help you with this given the hardware requirements, and there's not much reason to do so given that this is very specific to your needs. Maybe someone with some time to kill will be able to help.
You're much better off searching a regular coding site. There's loads of them out there.
If it's C# you're doing, try a site designed to help people with C# problems.
I think there's maybe 6 or 7 people total, maybe less who can code in a regular language that actually post here at TDC.
There's probably 5 more maybe lurking in the shadows here at TDC, but yea, try a REAL programming site.
I'm not where I want to be when it comes to working with "fake" programming as of yet, and until I can make some decent games with this stuff, I'll leave the Real programming alone (other than scanning through some books once in awhile for logic ideas of course).
Wish I could help other than telling you to look elsewhere. It just seems to lack any real value. I mean after all, you've probably been asking at the Real programming sites too and found the people to be abrasive and slow to respond, am I right?
That's one thing I've always loved about TDC, even if you don't get the answer you're looking for, at least you get an answer.
The sad thing is that you'll probably need to go to 10 different forums and wait for 2 weeks or more before you get a satisfactory answer and on top of that, you'll need to register for each and every one. I hate what the internet has turned into. It could have been so much more.
Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?
Lol, this isn't exactly something you can just go up and ask anyone on the Internet about. It's like an assignment for 4th year electrical engineering/comp science degree or at least something where a bunch of straight A undergraduates gather around and build some junk.
I could probably look through it, but I'm too lazy to do it without a lot of incentive, seeing how I go to TDC to get away from this stuff
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.
I know absolutely nothing about C# (or any other kind of C for that matter), so I guess I underestimated how difficult this is (although the files are commented, and the manufacturer claim it's supposed to be really easy).
I'll try posting on a programming forum, and I'll ask the manufacturers if they can shed any light on the matter.
I may also post in the bidding pool section on the clickteam forums - I would be prepared to pay for an extension to handle this stuff.
I think I may be gettign somewhere...
Part of the source file "Usc.cs" looks like this:
public void setTarget(byte servo, ushort value)
{
try
{
controlTransfer(0x40, (byte)uscRequest.REQUEST_SET_TARGET, value, servo);
}
catch (Exception e)
{
throw new Exception("Failed to set target of servo " + servo + " to " + value + ".", e);
}
}
I hope this suggests that the compiled dll will have a function called "setTarget", which takes two parameters - a byte which specifies which of the 6 servos to control, and a ushort which specifies the target position of the servo.
Does that sound right?
There are other similar functions that appear to set the speed/acceleration/etc of specific servos too.
I'm sort of a programmer - have rarely used C# but I'm familiar with the basics of it. The difficulty I have here is figuring out exactly what you want to do and which functions you need. I've heard of a servo but I'm not sure exactly what one is - could you give a bit of an overview?
Regarding the setTarget method, it'd be a good idea to have a look and see what the controlTransfer method does - also maybe try and find what uscRequest is. I'll have a quick look for you and see if I can help you out.
To be honest, I've not worked much with DLLs or the DLL extension for MMF - but are you even sure you can call parameters to source code that has been compiled to a DLL file?
Notes for myself
- setTarget takes 2 arguments - byte servo, ushort value
- setTarget calls controlTransfer, otherwise fails with exception
- controlTransfer takes arguments (0x40, (byte)uscRequest.REQUEST_SET_TARGET, value, servo);
- 0x40 Hex = 64 dec = 100 oct = @ char (seems to be used for setting target, speed, acceleration .etc)
- uscRequest.REQUEST_SET_TARGET = 0x85 (from Usc_protocol.cs)
- Would guess the controlTransfer method sets up packet transfer?
Thanks a lot for your help Flava - I appreciate it
Originally Posted by Flava
To be honest, I've not worked much with DLLs or the DLL extension for MMF - but are you even sure you can call parameters to source code that has been compiled to a DLL file?
What do you mean? Why wouldn't I be able to?
The library is apparently included specifically for people who want to create their own programs, so I hope it will be possible.
I only linked to the part I thought I needed before, but the complete SDK is here: http://www.pololu.com/docs/0J41
It includes an example application as well as the library, and the "UsbWrapper" library (see below).
controlTransfer is apparently a function in the "UsbWrapper" library, which does the complicated low-level stuff.
It looks like this:
- <member name="Mololu.WinusbHelper.WinUsbDevice.controlTransfer(Pololu.WinusbHelper.WinUsbDevice.WINUSB_SETUP_PACKET,System.Byte[])">
<summary>Performs a control transfer with a data stage. Calling this function is slightly safer than calling controlTransfer(WINUSB_SETUP_PACKET, Byte *) because this function can verify that buffer is not null and that buffer is long enough.</summary>
<param name="buffer">If this is a Read transfer, this is the buffer that the data from the device will be read in to during the data stage. If this is a Write transfer, this is the buffer that will be written to the device during the data stage.</param>
<param name="setupPacket">The SETUP packet to send to the device.</param>
<returns>The number of bytes transferred in the data stage. This is usually equal to setupPacket.wLength.</returns>
</member>
It seems that "setTarget" is probably the main function I want to use. The problem is if I also need to call some kind of initialization/setup functions as well.
Oh yeah, and a servo is like a stepper motor, except for it can't rotate continuously (generally only about 180 degrees). It has the normal positive and negative wires to supply power, and then a third wire which tells it what angle to rotate to (connected to a radio control receiver, or in this case a USB servo controller).
Can you actually upload the dll? I imagine the dll is written in C or C++, the C# code you uploaded requires a reference to that dll, so I can't compile the C# code without it.
i just played around with the sdk. the first thing you linked to, "Usc" is part of the Maestro Toolset. it cant compile by itself. you have to compile from the maestro C# solution.
it produces
Sequencer.dll
UsbWrapper.dll
Usc.dll
MaestroExample.exe
and
UscCmd.exe
and includes an already compiled dll called
Bytecode.dll
if you want me to upload the everything compiled from source for you to figure out what to do with it i'll be more than happy to. but dont ask me how to use any of those though cause i have no idea how to program in C# as i have not learned it yet.
Thanks, but I've managed to compile everything already.
The problem is working out how to use it - there's no way to get a list of functions/parameters from a compiled dll (I tried depends.exe), so I supplied the source instead, hoping someone might be able to make sense of it.
I think I've got most of what I need figured out now, but like I said - I need to experiment once the unit actually arrives.