Mini Maestro 12 + VB + Logitech F310

I’ve beat my head on the computer for a few weeks now and can’t seam to figure this out.
What I would like to do is have my mini maestro and joystick hooked up to the computer and controlled by one VB script. I’ve read and reread the manual. Looked through all the forum post on joysticks and just can’t get the two combined. I’ve tried several different joystick codes and all of the mini maestro sample scripts.
The simplest codes I’ve found are below:
vbjoystick.zip (77.9 KB)
pololu_usb_sdk\Maestro\MaestroEasyExampleVb

I just want them combined so that I can control the mini maestro from the joystick. I have limited programming experience and would be willing to pay for someone to code this little project for me. I will be posting a drawing of the end product tomorrow. Any help would be great.

Ok so I did a little playing last night and got the codes combined into one code. Might not be pretty but it works.
MaestroEasyExampleVb.zip (224 KB)
Next I need to figure out how to use the joystick input and send that to the mini maestro. I think I’ll use some of the code from the advanced example.

        private void RunSequence()
        {
            if (sequence_counter < 10)
            {
                usc.setTarget(0, 4000);
            }
            else if (sequence_counter < 20)
            {
                usc.setTarget(0, 6000);
            }
            else if (sequence_counter < 30)
            {
                usc.setTarget(0, 8000);
            }
            else
            {
                sequence_counter = 0;
            }

            // increment the counter by 1 every 100 ms
            sequence_counter += 1;
        }

I just have to figure out the arguments that will replace the 4000, 6000, and 8000 in the above code. I plan on taking out the if, else if, and sequence counter and just use the usc.setTarget(0, “joystick input”)
Anyone done this before?

Hello.

I have not done this, but I can give some advice. You should be able to modify the joystick code to store the input from one its axes in a public integer somewhere called joystickInput. You should figure out the range of values that the integer takes (probably 0 to 255), and then write a method to linearly scale those values to the 4000-8000 range suitable for Maestro servo targets. In the end your code would look something like:

usc.setTarget(0, scaleJoystick(joystickInput));

–David

Thanks David. I figured it would be something simple like that. The output from the joystick is 0-255. I figured the equation would be ((joystick*15.68)+4000) should get it pretty close. I’ll have to play around with it tonight. Thanks again for the help.

Here are a few pis of what I want the finished project to look like.
maars.pdf (84.2 KB)
New tank.pdf (144 KB)

Ok so I now have a modified code that will allow my joystick to communicate with the Maestro via usb. Now I would like to cut the cord and use xbee to comunicate via the serial port. I have tested the xbees (x-ctu). They work. I have set the maestro to uart fixed baud rate (9600). I have made sure that the grounds for the xbee and the maestro are common. The problem I’m having is the maestro doesn’t respond. I used the terminal program in x-ctu to send some of the sample strings from the manual. Nothing seems to work. What is the right protocal for serial communication? What do I change the following line to to make this work?

TrySetTarget(0, x)

I assume it would be serial.write type of command.

I realize I’ll have to rewrite the VB code. I’m sure the USC and usb wrapper will no longer be needed. Thank you in advance for your help. Here is a copy of the complete USB code for those that need it.
final joystick code.zip (235 KB)

Yes, you cannot use Usc.dll and UsbWrapper.dll anymore. I’m not sure exactly how you have the XBee connected to your computer, but you probably have a COM port for it. You can send bytes to the XBee’s COM port using Write method of the .NET SerialPort class. You do not have to rewrite all of your code; you probably just have to rewrite TrySetTarget. Any of the serial protocols documented in the Maestro User’s Guide will work. You probably want to use the Compact Protocol and the Set Target command.

–David

Hi,I know this post is old but,Is there any chance you could send your final code as I have a similar project and im getting a headache trying to figure out swapping ove to xbees. It would be much appreciated.