Changes between Version 1 and Version 2 of ControlSystems/SoftwareTeam/Training/GettingStarted/ServoMotor


Ignore:
Timestamp:
Oct 31, 2019, 6:46:41 PM (6 years ago)
Author:
David Albert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/Training/GettingStarted/ServoMotor

    v1 v2  
    11== Servo Motor Control
    22
    3 Robots must be able to interact with the environment around them too.  Many types of actuators are used in FRC robotics; one of them is the [https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599703-repeatable-low-power-movement-controlling-servos-with-wpilib Servo Motor]. A servo motor is a special type of motor that can rotate to a precise position, usually between 0 and 180 degrees.  They come in a variety of sizes and strengths.  You can connect a servo motor to any of the [http://www.ni.com/pdf/manuals/375274a.pdf#_OPENTOPIC_TOC_PROCESSING_d443e2165 PWM ports] on the !RoboRIO.  Examine the PWM ports and identify which row of pins are ground ([[Image(GroundSymbol.png,25px)]], +6V, and Signal (S).  Make sure you connect them to the proper pins on the Servo motor: black or brown goes to Ground, red or orange goes to +6V, yellow/white/blue goes to Signal.  You can read more about servo motors [https://learn.sparkfun.com/tutorials/servo-trigger-hookup-guide/all here]
     3Robots can interact with their environment.  Many types of actuators are used in FRC robotics to manipulate the environment; one of them is the [https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599703-repeatable-low-power-movement-controlling-servos-with-wpilib Servo Motor].  [[Image(ServoMotor.jpg,right,250px,margin=10)]] A servo motor is a special type of motor that can rotate to a precise position, usually between 0 and 180 degrees.  They come in a variety of sizes and strengths.  You can connect a servo motor to any of the [http://www.ni.com/pdf/manuals/375274a.pdf#_OPENTOPIC_TOC_PROCESSING_d443e2165 PWM ports] on the !RoboRIO.  Examine the PWM ports and identify which row of pins are ground ([[Image(GroundSymbol.png,25px)]], +6V, and Signal (S).  Make sure you connect them to the proper pins on the Servo motor: black or brown goes to Ground, red or orange goes to +6V, yellow/white/blue goes to Signal.  You can read more about servo motors [https://learn.sparkfun.com/tutorials/servo-trigger-hookup-guide/all here]
    44
    55Create another program using the !TimedRobot java template and name it !ServoTest. Modify the generated code as follows:
     
    1717* in robotInit() instantiate the controller and motor objects
    1818  {{{
    19     xbox = new XboxController(0); // Xbox controller on port 0
    20     servo = new Servo(1);         // Servo connected to PWM 1
     19    xbox = new XboxController(0); // Xbox controller on USB port 0
     20    servo = new Servo(2);         // Servo connected to roboRIO PWM 2
    2121  }}}
    2222* in teleopPeriodic() read the xbox controller and adjust the servo motor accordingly
     
    3232  }}}
    3333
    34 Connect a Servo motor to PWM port 1 on the roboRIO and run your program.  You'll need to press the Enable button on the driver station to put the robot in Teleop mode so that teleopPeriodic() is called repeatedly.
     34Connect a Servo motor to PWM port 2 on the roboRIO and run your program. 
     35Launch the driver station on your laptop and select Teleop mode (bottom left side of the window).  You'll need to press the Enable button on the driver station to put the robot in Teleop mode.  When teleop is enabled, teleopInit() will be called once and then teleopPeriodic() is called repeatedly until the robot is disabled.
    3536
    3637* Extra credit: use buttons on the Xbox controller to set the servo to a specific position (e.g. 45-degrees, 90-degrees, 135-degrees).