Shaft Encoder Programming in V5

In prevoius years (with the old Cortex) we used for programming, but now that we upgraded to V5, I can’t figure out how to configure the Shaft Encoder (with 2, 3 wire male connectors) in the three wire ports of the new V5 Brain. I’m programming in C++ in VEXCode V5 Text (Pro).

Here are the ones that we are working with

image

Any help is appreciated

First of all you need to plug them certain way:

Then you define encoder variable over a triwire port and could get its rotation() or velocity values():

vex::encoder enc1 = vex::encoder(Brain.ThreeWirePort.A);

double r = enc1.rotation(rotationUnits::deg);

https://api.vexcode.cloud/v5/html/classvex_1_1encoder.html

2 Likes