PDA

View Full Version : RC and autonomous control


jkjellman
04-26-2007, 05:10 PM
Hello,

I am a professional programmer by trade and work on robotics in my spare time. I wanted to strt using my Vex kits as simply as possible (MPLAB IDE looks great, but there isn't enough documentation to figure out what functions do what from what I've found).

I am trying to build a robot for a local club competition and wanted to have RC control via the RxInput block as well as autonomous control. Whenever I try to use both all the motor ports go crazy and start forwarding and reversing the motors.

I read the help file which stated you couldn't combine RC motor control and autonomous motor control (which makes sense) unless they are in different blocks of code.

As a simple test I made a loop that would first read a channel using RxInput and store that value in a variable on the first pass and then use that variable to set the motor speed on the second pass. Then the loop just keeps repeating. This works if I put a large delay after the if statement (about 250 ms seems to do it) but does not work without the delay or with a shorter delay. This long delay makes steering jerky and unresponsive.

Is there any reason why I cannot use RxInput and still manually set the motor speed and/or servo position?

BTW, I am not using any of the functions that directly link the RC data to a motor or servo as I only want RC control under certain circumstances for the competition.

Any help would be greatly appreciated.

Take care,
KJohn

kingofl337
04-27-2007, 08:18 AM
It sounds like you are using V1 of the software.

Try using "PWM Control" instead of the "Motor Module"

Motor Module is for Autonomous use only if you wish to run in a Mixed mode.
PWM Control should be the solution.

jkjellman
04-27-2007, 09:54 AM
Thanks for the reply, I'll try that once I get back to my robot later today.

Along those same lines, would PWMControl be able to be used to control a servo? I know servos need 1 ms to 2 ms pulse with at some maximum frequency that should be far below what a motor would use for PWM so my first instinct would be no, but I have to ask. ;-)

Take care,
KJohn

kingofl337
04-27-2007, 12:06 PM
As far as the Vex "motors" are concerned they are just servos with feedback disabled. When you command 0-255 to a motor it just spins at a speed in relationship to the value you sent. With a servo it uses 0-255 to command a position.

jkjellman
04-27-2007, 04:51 PM
Dude, it works! :D

You are 100% correcto-mundo and I am much appreciative.

Now I can finally start working on my bot. In case you're interested I am working on a three wheel design. It incorporates 4 motors driving 2 large wheels (not the knobby ones, but the ones just below them) on the basic box frame and a servo for turning the front wheel mounted on an extended forward bracket.

Once I complete some handling and speed tests (I had to move up to 4 motors as two motors didn't have enough torque to get the bot moving fast quickly) I will be adding a set of line sensors to the front and create an autonomous line follower for our May competition.

Thanks again!

Take care,
KJohn