Third Servo Motor
I'm putting together a sumobot for a competition, and my strategy is based on using a third servo motor as a winch to draw up a forklift-type tool in the front of the robot. I've connected the motor, and have used it to successfully operate the tool, but when I try to add winching capabilities to something simple like the basic competition code that comes with the sumo kit, the robot acts weird -- it's moved more slowly than usual, driven off the edge of the mat where before it wouldn't have, and done other strange stuff.
In addition to that, I'm having some difficulty with writing my own code that doesn't even involve the winch motor at all. My code is pretty ugly, mostly Frankensteined together out of sample code (This competition allows only a very very short prep time, and I'm not at all familiar with BASIC), but I'll reply to this in a little while with some code and problems that I've observed trying to run it.
I'm looking for any help I can get: general tips about things to watch out for while trying to use a third servo, specific problems with my setup, anything.
In addition to that, I'm having some difficulty with writing my own code that doesn't even involve the winch motor at all. My code is pretty ugly, mostly Frankensteined together out of sample code (This competition allows only a very very short prep time, and I'm not at all familiar with BASIC), but I'll reply to this in a little while with some code and problems that I've observed trying to run it.
I'm looking for any help I can get: general tips about things to watch out for while trying to use a third servo, specific problems with my setup, anything.
Comments
If you're not a code wizard, consider using a DC motor instead of a servo. You can turn that on and off with a simple high or low command that closes a reed relay. It needn't interfere with your drive servo loop.
Attach your code and maybe someone can help.
Regarding my initial question about the winch, here's a pseudocode example of something that I tried to add to the "Lunge" section of "Mini Sumo 5.1 : Basic Competition Program"
this appeared to cause the robot to move significantly slower than it had been, and it also tended to drive off the edge of the mat, even though the border avoidance should have stopped it.
-Does PAUSE mean that the robot doesn't do anything at all for x number of milleseconds?
-Does the modulus function work in BASIC? If it does, would using it to split my QTI sensor readings (read left sensor on odd counts, right on evens) help me have a more efficient loop?
Correct, it's dead time; nothing happens during a pause. Better to be doing something useful, like checking sensors umpteen or hundreds of times to while away the lonely (20) milliseconds...
Look at driving all 3 servos simultaneously like this:
z=750
main:pulsout leftmotor,x
pulsout rightmotor,y
pulsout winch,z
blah testsensor
blah testsensor
if blah calculate new x
if blah calculate new y
if blah calculate new z
pause 5
goto main
Here you're driving your winch servo at zero speed (pulsout 750) in that fast loop until you decide to change z, which starts to rotate your servo. Notice that I used a pause 5 instead of 20. All your sensor tests, calculations and if checks takes some time, so if you have a lot of those, they will burn up some time and effectively reduce your pause time. In practice, many servos don't need a full 20 ms pause between pulsouts; they can use a shorter interval, but not longer. Test yours and see what works best for your servos.