Programming with the new VEX Integrated Encoder Modules

From ROBOTC API Guide
Jump to: navigation, search
Tutorials → VEX Speaker module


VEX Speaker
ROBOTC 3.06 now includes functionality to support the new VEX Integrated Encoder Modules!

The VEX Integrated Encoder Modules (IEMs) replace the plastic caps on the backs of 2-Wire Motors (269 and 393) with quadrature encoders. Unlike the existing VEX Shaft Encoders, they connect to the Cortex Microcontroller using the I2C port and provide feedback directly from the motor (with the added benefit of not hogging up your digital ports). These encoders will allow you to identify and control how fast the motors spin, how far the robot travels, and what direction it should move.

For more information and assembly instructions for the Integrated Motor Encoder for the VEX 2-wire 393 Motor, click here.

For more information and assembly instructions for the Integrated Motor Encoder for the VEX 2-wire 269 Motor, click here.

All of the basic Fischertechnik sensors meet these qualifying characteristics, making them perfect candidates for use with the VEX Cortex!


Contents


I2C Overview

As stated above, these new encoders connect to the single I2C port on the Cortex:
I2C port
Unlike the DIGITAL and ANALOG ports on the Cortex, having only one I2C port does not limit you to only one I2C device. I2C ports allow multiple devices to be connected in a manner frequently referred to as daisy-chaining:
Daisychain
The Integrated Encoder Modules support this by having built-in sets of input and output pins. A 4-wire cable connects the Cortex to Motor 1, another 4-wire cable connects Motor 1 to Motor 2, another 4-wire cable connects Motor 2 to Motor 3, and so on. In fact, ROBOTC 3.06 will support up to 8 devices on the single I2C port!
269


Programming Overview

Motors and Sensors Setup

ROBOTC has undergone substantial changes to support the new encoders. Some of the most visually noticeable changes are in the Motors and Sensors Setup. On the Motors tab, the Type drop-down box allows you to choose from the different motors available in the VEX Robotics System:
Tut vex-motor-encoders 5.png
This is significant because each of the new IEMs return a different number of encoder counts per revolution. Specifically, the IEM for the 2-wire 269 motor measures 240.448 counts per revolution of the motor output shaft. The 2-wire 393 motor measures 627.2 counts per revolution of the output shaft in its default high-torque configuration and 392 counts per revolution of the output shaft in its modified high-speed configuration.


Let’s take a look at a physical robot and configure it using the Motors and Sensors Setup.

Tut vex-motor-encoders 6.jpg
  • This robot has two 269 motors with encoders.
  • The right motor is connected on MOTOR port 1. The left motor is connected on MOTOR port 10.
  • The encoder on the right motor is the first device plugged into the I2C port.
  • The encoder on the left motor is the second device, daisy-chained off of the right motor.
Tut vex-motor-encoders 7.jpg
We can configure this in ROBOTC by going to the Robot > Motors and Sensors Setup menu.
Tut vex-motor-encoders 8.png
On the motors tab, we can enter all of the information necessary so that it matches our physical robot:
Tut vex-motor-encoders 9.png
Note that:
  • “rightMotor” was configured in port1 as a VEX 269 Motor.
  • rightMotor was “Reversed” so that positive power levels will allow the robot to move forward.
  • The “Encoder” box was checked and “I2C_1″ was chosen since it is the first device plugged in to the Cortex.
  • “leftMotor” was configured in port10 as a VEX 269 Motor.
  • The “Encoder” box was checked and “I2C_2″ was chosen since it is the second device along the daisy-chain.
  • It is not necessary that the order of your motor ports correspond with the order of the I2C ports, although doing so will reduce confusion. It is necessary that your Motors and Sensors Setup perfectly match the physical setup of your robot.


Additionally, you’ll notice that there is also a new “I2C Sensors” tab in the Motors and Sensors Setup:

Tut vex-motor-encoders 10.png
The additional configuration you can do here is optional. Like existing VEX Sensors, you can use this tab to name your I2C devices and monitor their values in the Sensor Debug Window. Note that these values are the raw values – not adjusted for polarity or the “Reversed” checkbox on the Motors tab.

When you’re done configuring your motors and encoders, you can press OK to apply your changes.


Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox