FIRST Tech Challenge Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Sample Servo Control VIs (Archived)

Update: Update: This example applies to the 2010 FTC competition software and may not be compatiblw with current competiton software. Use the Schematic Editor to set up your servos motors.


I was recently asked if I knew of a sample program that showed how to control servos.

After a quick look, I couldn't find one, so I thought it would be helpfull (for me and them) if I created a program that showed how to control the servos, and was also usefull for setting up our own robots.

Quite often we need to to determine the servo value (0-255) to move the servo to a specific position to perform a function (eg: grab a baton), so it's handy to be able to control the servo using a joystick, and then be able to see the desired position value.

The two attached VI's do just this.  "4H-SingleServoExample.vi" does it using the "MoveServo" VI and  "4-HMultiServoExample.VI" does it using the "MoveServos" VI.

The difference between the two examples is how the positions for 4 servos are passed into the VI (Single value or array).

Here's a snipit showing the essense of the Multi version.

Key Points:

     This example runs like a Teleop program, so it needs to be enabled before the Servos will move.

     The program assumes a single servo controller plugged into NXT Port 1 with 4 servos plugged into Chan 1-4

     The Servo Values are displayed on the NXT screen

     Joystick values go from -127 to +127 so they need to be offset by 127 to go from 0 to 255.

     The TestServo.ctl file that's used to assign servo channels must be located with the example VI in the same folder.

     The servos will start out in their "center" position if the joysticks are centered.

     The Joystick to servo assignments are listed on the Front Panel page of the example VI.

MultiServoArray.png

Hope this helps out anyone using servos this year.

Phil.

Get a life? This IS my life!
Contributors