Single wire encoders PROS

how would I use a shaft encoder with only one wire plugged in or with the old single wire encoders? when initializing the encoder would I just set one of the ports to 0?

Hey @BottomNotch, PROS doesn’t have a single wire encoder driver since they were discontinued when PROS was first developed, but it’s very simple to implement - in fact, we did so this year with our flywheels using line followers. You can plug the encoder wire into any interrupt-able digital port (1-12, not 10). Next, you’ll likely want to create a new source/header file for the driver (say SingleWireEncoder.c/.h - but you can name it whatever, obviously). It’s important to note that with the single wire encoder, it’s impossible to determine direction from one signal wire - which is why the quadrature encoder has two.

This is the source file based off of our current encoder driver. I’ve only changed renamed variables and deleted the code second flywheel encoder:

static volatile int encTicks;

#include "main.h"

void encoderHandler(int pin) {

// This method gets called in initialize()
void initEncoder() {
	pinMode(1, INPUT);
	ioSetInterrupt(1, INTERRUPT_EDGE_FALLING, encoderHandler);

int getEncoderTicks() {
	return encTicks;

void resetEncoder() {
	encTicks = 0;

In this example, you will use


to tell the Cortex to execute


every time the microcontroller witnesses an edge falling (going from 1 to 0). In the handler, you’ll increment your tick counter by one. To access the value, you can call


, which simply returns the value of the tick counter. If you want to have multiple encoders, you’ll need to add an additional counter variable, encoderHandler function, and getEncoderValue function.

Hope this helps!

Thanks, and What divisor would I use to calculate the velocity of a motor using an IME?

I typically do something like this:

unsigned long prevTime = millis();
int prevTicks = 0, currTicks = 0;
double velocity = 0.0;
imeGet(1, &prevTicks);
while(true) {
    imeGet(1, &currTicks);
    velocity = (double)(currTicks - prevTicks) / (millis() - prevTime);
    prevTicks = currTicks;
    prevTime = millis();

This will give you velocity in ticks per microsecond.

I didn’t ask my question very well, let me rephrase it. Using imeGetVelocity() what divisor do I use for turbo speed to get the RPM at the shaft? The documentation only has the divisor for 269 motor, 393 with torque gearing, and 393 with high speed gearing.

I think I just figured it out on my own. the motors page on VEX’s website says that turbo speed gearing is 140% faster than standard gearing, or 2.4 times faster. Assuming this information is accurate, 39.2 is the divisor for standard gearing so 39.2 / 2.4 = 16.333. So dividing the return value of imeGetVelocity by 16.333 would get me the RPM of the shaft right?