PDA

View Full Version : Programing the Parallax Servo Controller (USB)



MinyFly92
02-04-2008, 07:37 PM
OK, Ive been working on a project and heve everything done, except the software. But let me first give you a rundown on the robot it-self. It has differential steering with the wheels powered by servos. The servos then run to the Parallax Servo Controller (USB) (root of the problem), and the controller connects to a laptop that sits on top. (I chose to use a laptop for two reasons. 1. ease of use 2. internet controlled.) I also have a pan and tilt system with a web cam on it.
http://i119.photobucket.com/albums/o128/minyfly/Robot.jpg
The pan and tilt system needs software too.I would then run the software on the laptop and connect to it using remote desktop connection or similar program. But thats my program no software. So i need an easy to use software where i click and old on the button and it moves it that direction.
Here is just an idea of what it would look like
http://i119.photobucket.com/albums/o128/minyfly/Control.jpg
So if someone is willing to write me a program that would be great or simply tell me how. I know a little (and its really a little) in Virtual Basic.

Thanks for your time.

Matt
02-05-2008, 12:14 PM
Hey,

This is a pretty good set up. It's very close to the first mobile robot I built using phidgets. I suggest downloading the express versions of the MS languages which are free.
http://www.microsoft.com/express/

You can take your time learning how to build a form like the one you have planned. Programming is scary at first, but once you start getting a little bit accomplished it rapidly gets easier. I think you will have far more enjoyment building robotics if you are empowered yourself to keep adding to the code. It is easier to get started with some sample code though, having a template to work off of helps a lot. For this reason I would highly recommend looking into the Phidget 4 servo controller (http://www.trossenrobotics.com/store/p/3188-Servo-4-Motor-Controller.aspx) since there is plenty of sample code for the Phidgets and more programmers out there using them. But maybe someone has some Visual Basic samples out there for the Parallax board that can get you started using that one.

Matt
02-05-2008, 12:20 PM
Check this out! Just what you need, Express samples and everything

http://forums.parallax.com/forums/default.aspx?f=5&m=212536

Be sure to also follow the link to another thread half way down the page.

cheers!

misiu
03-06-2008, 09:10 AM
I am having a buddy help me break it down for me today. I will post what we find out. The issue is converting the SPBASIC programming code into something that VB can output. If you follow the examples in the documents posted above you can create a great sliding scale controller. Sadly that will not work for my needs. As I said I will post the sample code we come up with.

MinyFly92
03-06-2008, 12:23 PM
Hey misiu, thanks a lot. I kinda got it figured out using roborealm, but it still doesnt do exactly what i want it to do.

misiu
03-07-2008, 08:10 AM
Why dont you post what you have and when i get up and running We can compare notes.

MinyFly92
03-08-2008, 02:44 AM
ok sorry this reply has taken so long, ive been away from my laptop.

Ok time to get started. Roborealm was the easiest way i could find to accomplish what i need it to do. And strangely enough using an xbox 360 controller was easier than programing the buttons on a keyboard. Ill also give you the saved project for roborealm.

Ok im not sure if your with fimilure with a 360 controller so ill make a picture to help you out.


http://i119.photobucket.com/albums/o128/minyfly/robotxbox.jpg



As far as RoboRealm goes I set variables so when the joystick reaches a certain y axis it tells the paralax servo controller program thats in roborealm to move to a certain position. The pan and tilt was a little different because the d pad on the controller is treated like a hat switch and not a joystick. But looking at my code it should be that hard to figure out.


http://i119.photobucket.com/albums/o128/minyfly/roborealm.jpg
I could get this picture as big as i wanted it so here is the link http://i119.photobucket.com/albums/o128/minyfly/roborealm.jpg

Here is the code i used. Its mostly all copied and pasted from a tutorial project on the website.

set the initial move to nothing
move=129
mover=128



' if the joystick is to the right assign bit 2
if GetVariable("left_y") < -300 then
move = 1
' otherwise if it is to the left assign bit 3
elseif GetVariable("left_y") > 300 then
move = 254
end if

' if the joystick is to the right assign bit 2
if GetVariable("right_y") < -300 then
mover = 254
' otherwise if it is to the left assign bit 3
elseif GetVariable("right_y") > 300 then
mover = 1
end if

' if the joystick is to the right assign bit 2
if GetVariable("pat") = 0 then
tilt = 2 + (tilt)
' otherwise if it is to the left assign bit 3
elseif GetVariable("pat") = 18000 then
tilt = (tilt) - 2
end if

' if the joystick is to the right assign bit 2
if GetVariable("pat") = 9000 then
pan = 2 + (pan)
' otherwise if it is to the left assign bit 3
elseif GetVariable("pat") = 27000 then
pan = (pan) - 2
end if

' if back botton on controller is pressed resets pan
if GetVariable("center") = 1 then
pan = 128
end if

' if back botton on controller is pressed resets tilt
if GetVariable("center") = 1 then
tilt = 128
end if

' if back botton on controller is pressed resets mover
if GetVariable("center") = 1 then
mover = 128
end if

' if back botton on controller is pressed resets move
if GetVariable("center") = 1 then
move = 129
end if

' the results are in the single
' variable move. Assign that
' back into RoboRealm so we
' can use it in other modules
SetVariable "move", move

' the results are in the single
' variable move. Assign that
' back into RoboRealm so we
' can use it in other modules
SetVariable "mover", mover

' the results are in the single
' variable move. Assign that
' back into RoboRealm so we
' can use it in other modules
SetVariable "tilt", tilt

' the results are in the single
' variable move. Assign that
' back into RoboRealm so we
' can use it in other modules
SetVariable "pan", panWell thats basicly it in a nutshell. If you have any questions dont hesitate to ask. I dont need it but if you want some help translating the xbox controller to a keyboard i would be glad to help. Its something i should probably get done anyway.

misiu
03-10-2008, 09:02 AM
Sorry it took me a little while to respond. My friend was able to put together a DLL that made communicating with the servos significantly easier. However he was hesitant to let me pubish it. Although if your still interested in getting your hands on it send me a PM and ill send you the DLL and the way its used. Very very easy