Changes between Version 2 and Version 3 of ControlSystems/SoftwareTeam/Training/GettingStarted/Encoders
- Timestamp:
- Oct 31, 2019, 12:34:41 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/Training/GettingStarted/Encoders
v2 v3 1 1 == Encoders 2 In the example above, we controlled the amount of power we were delivering the motor (0=none, 1.0=full power), but that doesn't tell us how fast the robot is moving or the wheel is turning. Just like a car or a bicycle, the speed a robot will go under a given amount of power depends on how heavy the robot is, whether it's going up a hill or down a hill, how good the traction is, etc. To determine how fast a wheel is turning or exactly how far it has turned, we use encoders.2 In the [wiki://ControlSystems/SoftwareTeam/Training/GettingStarted/DCMotor previous example], we controlled the amount of power we were delivering the motor (0=none, 1.0=full power), but that doesn't tell us how fast the robot is moving or the wheel is turning. Just like a car or a bicycle, the speed a robot will go under a given amount of power depends on how heavy the robot is, whether it's going up a hill or down a hill, how good the traction is, etc. To determine how fast a wheel is turning or exactly how far it has turned, we use encoders. 3 3 4 4 An encoder is a device attached to the motor or wheel shaft that generates a pulse with each partial rotation (e.g. every 1-degree or 5-degrees of rotation, another pulse is generated). By counting these pulses, we can tell how fast the wheel is turning or what position it is in. We can use this information to do things like make a robot travel a fixed distance or at a set speed. You can read more about encoders [https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599717-encoders-measuring-rotation-of-a-wheel-or-other-shaft here]. … … 36 36 37 37 === Encoder connected to a TalonSRX smart motor controller (Hazelnut) 38 Create another program using the !TimedRobot java template and name it !EncoderTest2. Modify the generated code as follows:38 Create another program using the !TimedRobot java template and name it SRXencoderTest. Modify the generated code as follows: 39 39 40 40 * Add the following imports: