Instructional Material: Using Encoders Quiz Answers

Printer-friendly version

1. An encoder measures the rotations of a motor shaft either optically or magnetically and makes a count of shaft movements available to your program on the DcMotor class. There are typically a number of counts per revolution of the motor shaft.

 

2. motor.setmode(DcMotor.RunMode.RUN_TO_POSITION);

Runs motor to the position (encoder count) you set with setTargetPosition() at the power level set with setPower() and stops the motor when the target position is reached.

motor.setmode(DcMotor.RunMode.RUN_USING_ENCODER);

Runs the motor at a constant speed set as a percentage of motor maximum speed with the setPower() method. Does not stop the motor based on the current target position.

motor.setmode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);

Runs the motor without any automatic action based on encoder counts but does count and report encoder counts.

 

3. Using the number of encoder counts returned for one revolution of the motor shaft, set the target position to that number and run mode RUN_TO_POSITION. Apply power.

 

4. Set the run mode to RUN_WITH_ENCODER, set the speed to run with setPower(). Enter a wait for wait loop for wo seconds then set the power to zero.

 

5. The code sets the wrong run mode for using setTargetPosition(). The code does not set the power level of the motor to start movement.

 

Material Type: 
Lab Activity
Education Level: 
HW Platform: 
SW Platform: 
Interactivity Style: 
Copyright (c) 2017 by the author. All rights reserved.
Audience: