Controlling multiple Jrk controllers /w Jrk.dll SDK exampe

I’ve got a VB 2008 project which I’m trying to use to control two Jrk motor controllers. I’m able to compile Jrk.dll in C# and import it into my VB project. When I open a connection and execute a Jrk function for one controller, and close the connection again, it seems to work fine.
However, I cannot open two connections simultaneously without getting a “System.Exception” indicating that the device is busy (according to the exception message), even though I’m initializing two different device serial numbers. Even if I try to set the target position for one controller, close the connection and try the second controller, I can get this exception if the loop I’m running executes too quickly.
Executing the same commands outside of loops or very slowly seems to work fine.

What am I doing wrong? I can’t seem to get the debugger to tell me where the glitch is in Jrk.dll, but it actually seems to get hung up on UsbWrapper.dll.
The problem shows up when I use the SetTarget() function, but it’s much worse when I try to use the GetVariables() function in the loop (I’ll get IOexceptions almost every time).


Can you please simplify your code to the smallest possible program that demonstrates the problem (ideally, about 10 lines), then post the code along with a copy of the exact error that you got? Please also tell us what version of Windows you are running and what version of .NET you have.


Haha, thanks for suggesting that. In the process of simplifying, I think I found the problem. Basically I need to make sure my threads exit gracefully! Anyway, what I did notice is that it takes about 3ms for the settarget() function to finish. Is there a way to speed this up, or is this a restriction of the USB connection?

Well, 3ms is around what I would expect for I/O operations on a multitasking operating system. Still, given how well my first suggestion worked out for you, could you also tell us what version of Windows you are running and what version of .NET you have?


How are you timing the setTarget function? Have you tried compiling your application in the Release configuration (instead of Debug)? Have you tried running your application on its own, with no other applications (including Visual Studio) running?