LogoLogo
  • Introduction
  • Getting Started with Control Hub
    • Connect to the Robot Controller Console
    • Updating Wi-Fi Settings
    • Connecting Driver Station to Control Hub
    • Wiring Diagram
    • Next Steps
  • Getting Started with Driver Hub
  • Adding More Motors
    • SPARKmini Motor Controller
    • Adding an Expansion Hub
  • Troubleshooting the Control System
    • General Troubleshooting
    • Control Hub Troubleshooting
    • Driver Hub Troubleshooting
      • Driver Hub Battery Troubleshooting
    • Expansion Hub Troubleshooting
    • Status LED Blink Codes
  • System Overview
    • Control Hub Specifications
    • Expansion Hub Specifications
    • Driver Hub Specifications
    • Port Pinouts
    • Protection Features
    • Cables and Connectors
      • XT-30 - Power Cable
      • JST VH - Motor Power
      • JST PH - Sensors and RS485
    • Integrated Sensors
    • Dimensions and Important Component Locations
  • Updating and Managing
    • Managing Wi-Fi on the Control Hub
    • REV Hardware Client
    • Updating Firmware
      • Firmware Changelog
    • Updating Operating System
      • Control Hub Operating System Changelog
    • Updating Robot Controller Application
      • Updating Robot Controller Application via Android Studio
    • Updating the Driver Hub
      • Driver Hub OS - Change Log
    • Accessing Log Files
    • Android Studio - Deploying Code Wirelessly
  • Hello Robot - Intro to Blocks Programming
    • Welcome to Hello Robot!
    • Where to Program - Client vs. Browser
      • What is an OpMode?
    • Setting up a Configuration
      • Common Errors in Configuration
    • Using a Gamepad
    • Part 1: Tackling the Basics
      • Tackling the Basics Directory - Blocks
      • Creating an OpMode - Blocks
      • Programming Essentials
      • Programming Servos
        • Programming Servo Basics
        • Using a Gamepad with a Servo
        • Programming Servo Telemetry
      • Programming Motors
        • Programming Motors Basics
        • Programming a Motor with a Gamepad
        • Programming Motor Telemetry
      • Programming Touch Sensors
      • Programming Color Sensors
        • Color Sensor Telemetry
        • Detecting Color
    • Part 2: Robot Control
      • Robot Control Blocks Directory
      • Programming Drivetrain Motors
      • Arcade Style TeleOp - Blocks
        • Establishing Variables in Blocks
        • Motor Power vs. Robot Movement
        • Programming Arcade Drive
      • Arm Control - Blocks
        • Adding a Limit Switch
      • Robot Control Full Program
    • Part 3: Autonomous and Encoders
      • ElapsedTime - Blocks
        • ElapsedTime Setup
        • ElapsedTime Logic
        • ElapsedTime - Multiple Movements
      • Encoder Basics
      • Drivetrain Encoders - Blocks
        • Converting Encoder Ticks to a Distance
        • Moving to a Target Distance
        • Setting Velocity
        • Turning the Drivetrain Using RUN_TO_POSITION
      • Arm Control with Encoders - Blocks
        • Estimating the Position of the Arm
        • Calculating Target Position
        • Using Limits to Control Range of Motion
    • Part 4: Going Beyond!
      • Exploring Functions
      • Programming Mecanum - Simplified
      • Programming Mecanum - Refined
  • Hello Robot - Intro to OnBot Java Programming
    • Welcome to Hello Robot!
    • Where to Program - Client vs. Browser
      • What is an OpMode?
    • Setting up a Configuration
      • Common Errors in Configuration
    • Using a Gamepad
    • Part 1: Tackling the Basics
      • Tackling the Basics Directory - OnBot
      • Creating an OpMode - OnBot
      • Programming Essentials
      • Programming Servos
        • Programming Servo Basics
        • Using a Gamepad with a Servo
        • Programming Servo Telemetry
      • Programming Motors
        • Programming Motor Basics
        • Programming a Motor with a Gamepad
        • Programming Motor Telemetry
      • Programming Touch Sensors
    • Part 2: Robot Control
      • Robot Control OnBot Java Directory
      • Programming Drivetrain Motors
      • Arcade Style TeleOp - OnBot Java
        • Establishing Variables in OnBot Java
        • Motor Power vs. Robot Movement
        • Programming Arcade Drive
      • Arm Control - OnBot Java
        • Adding a Limit Switch
      • Robot Control Full Program
    • Part 3: Autonomous and Encoders
      • ElapsedTime - OnBot Java
        • ElapsedTime Setup
        • ElapsedTime Logic
        • ElapsedTime - Multiple Movements
      • Encoder Basics
      • Drivetrain Encoders - OnBot Java
        • Converting Encoder Ticks to a Distance
        • Moving to a Target Distance
        • Setting Velocity
        • Turning the Drivetrain Using RUN_TO_POSITION
      • Arm Control with Encoders - OnBot Java
        • Estimating the Position of the Arm
        • Calculating Target Position
        • Using Limits to Control Range of Motion
  • Sensors
    • Introduction to Sensors
    • Digital
    • Analog
    • I2C
      • IMU
        • Orientating the IMU
      • Adding an External IMU to your Hub
    • Encoders
      • REV Motor Encoders
      • Through Bore Encoder
    • Using 3rd Party Sensors
      • Sensor Compatibility Chart
  • Useful Links
    • REV DUO Build System
  • Legacy Documentation
    • Configuring Your Android Devices
    • Expansion Hub with Android Device Robot Controller
      • Driver Station and Robot Controller Pairing
      • Wiring Diagram
      • Configuration
    • REV Hub Interface Software
Powered by GitBook
On this page
  • What's Needed for the Conversion
  • Ticks per Revolution
  • Total Gear Reduction
  • Quick Summary
  • Adding Arm Encoders to the Program
  • Establishing Initialization Variables
  • Adding Calculations to the Variables
  • Adjusting our If/Else Statement

Was this helpful?

Export as PDF
  1. Hello Robot - Intro to Blocks Programming
  2. Part 3: Autonomous and Encoders
  3. Arm Control with Encoders - Blocks

Calculating Target Position

PreviousEstimating the Position of the ArmNextUsing Limits to Control Range of Motion

Last updated 6 months ago

Was this helpful?

Now that we have an estimate for our target position let's see if we can refine it to be more precise using similar methods to what we covered during the .

What's Needed for the Conversion

Ticks per Revolution

Recall, that ticks per revolution of the encoder shaft is different than the ticks per revolution of the shaft that is controlling a mechanism, such as what we determined on our .

For more information on the effect of motion transmission across a mechanism check out the section.

The amount of ticks per revolution of the encoder shaft is dependent on the motor and encoder. Manufacturers of motors with built-in encoders will have information on the amount of ticks per revolution.

Visit the manufacturers website for your motor or encoders for more information on encoder counts. For HD Hex Motors or Core Hex Motors visit the documentation.

In the there are two different Encoder Counts per Revolution numbers:

  • At the motor - 4 counts/revolution

  • At the output - 288 counts/revolution

At the motor is the number of encoder counts on the shaft that encoder is on. This number is equivalent to the 28 counts per revolution we used for the HD Hex Motor.

The 288 counts "at the output" accounts for the change in resolution after the motion is transmitted from the motor to the built in 72:1 gearbox.

Lets use the 288 as ticks per revolution so that we do not have to account for the gearbox in our total gear reduction variable.

Total Gear Reduction

Since we built the the gear reduction from the motor gearbox into the ticks per revolution the main focus of this section is calculating the gear reduction of the arm joint.

The motor shaft drives a 45 tooth gear that transmits motion to a 125 tooth gear. The total gear ratio is 125T:45T. To calculate the gear reduction for this gear train, we can simply divide 125 by 45.

12545=2.777778\frac{125}{45} = 2.77777845125​=2.777778

Quick Summary

To summarize, for the Class Bot V2 the following information is true:

Ticks per revolution

288 ticks

Total gear reduction

2.777778

Adding Arm Encoders to the Program

Establishing Initialization Variables

Now that we have this information lets create two constant variables:

  • COUNTS_PER_MOTOR_REV

  • GEAR_REDUCTION

Add the variables COUNTS_PER_MOTOR_REV and GEAR_REDUCTION variables to the initialization section of the program.

Our COUNTS_PER_MOTOR_REV and GEAR_REDUCTION variables will be set to a value that will then be used to calculate our other two variables COUNTS_PER_DEGREE and COUNTS_PER_GEAR_REV.

Let's go ahead and add these variables to our OpMode.

Adding Calculations to the Variables

Now that these two variables have been defined, we can use them to calculate two other variables: the amount of encoder counts per rotation of the 125T driven gear and the number of counts per degree moved.

To calculate the number of COUNTS_PER_DEGREE divide the COUNTS_PER_GEAR_REV variable by 360.

All together our variables will look like below:

Adjusting our If/Else Statement

We need to create one more non-constant variable that will act as our position. This will be called armPosition.

To get to the 90 degree position, the arm needs to move roughly 45 degrees therefore set arm position equal to COUNTS_PER_DEGREE times 45.

Save your OpMode and give it a test!

Once the variables are created and in place, use the blocks to set the first variables to the respective

Calculating counts per revolution of the 125T gear (or COUNTS_PER_GEAR_REV) is the same formula we used for , so to get this variable we can multiple COUNTS_PER_MOTOR_REV by GEAR_REDUCTION.

Add this variable to the section of the statement, as this section dictates the 90 degree position. Add the block to the block.

Drivetrain Encoders section
Compound Gearing
Motor
Core Hex Motor specifications
values
Drivetrain
COUNTS_PER_WHEEL_REV variable on our drivetrain
Adding COUNTS_PER_MOTOR_REV and GEAR_REDUCTION
Full list of initialization variables
All of the initialization variables calculated
Adjusting the If/Else to include the armPosition