V5 smart motor encoders

I have a student that is in worlds, but wants to use the encoders on the smart motors to help keep motors running evenly for a lack of a better term. how would this programed?

What programming language are they in? (Vex Coding Studio, VexCode, Robot Mesh, or PROS)

Sorry i for got to add that.
Vex coding studio

I won’t be able to help too much being on Cortex (still…) , but someone else will probably help.

any help will help. i need a starting point

what exactly would this be used for, driving straight in auton?

1 Like

more for driver control and auto.

  1. How exactly would this be used during driver? I find it easier to leave normal driving controls alone.

  2. During auton you can set a motor to [motorName].startrotateto(velocity and degree stuffs);

for driver i thought you can measure the rotations and if one has more slow it down or correct the other?

You could, but for the most part the V5 motor built-in PID takes care of that. If I am understanding it correctly, whenever you assign a V5 motor to rotate, it always tries to reach whatever value you assigned it to(whether that be velocity, degrees, or anything of the sort) and actively tries to stay at that value. In addition to this, a program to keep your motors at the same speed whilst accounting for driver input is a lot more complicated than it would seem at first glance.

The only reason you use it for auton is for more precise, reliable movements.

ok, now to figure the programming side of it.

thank you

I will be able to show you our autonomous built off of degree rotations in a little bit if you would like.

yes please that would be great

I would also like to see this… link?

There is probably a better way to format this, but you should get the concept.

void autonomous()
{
    LiftL.startRotateTo(360,rotationUnits::deg,100,velocityUnits::rpm);
    LiftR.rotateTo(360,rotationUnits::deg,100,velocityUnits::rpm);
   task::sleep(1);
    LiftL.startRotateTo(0,rotationUnits::deg,100,velocityUnits::rpm);
    LiftR.rotateTo(0,rotationUnits::deg,100,velocityUnits::rpm);
   task::sleep(100);
    FR.startRotateFor(925,rotationUnits::deg,150,velocityUnits::rpm);
    BR.startRotateFor(925,rotationUnits::deg,150,velocityUnits::rpm);
    FL.startRotateFor(925,rotationUnits::deg,150,velocityUnits::rpm);
    BL.rotateFor(925,rotationUnits::deg,150,velocityUnits::rpm);
   task::sleep(1);
    FL.startRotateFor(400,rotationUnits::deg,150,velocityUnits::rpm);
    BL.rotateFor(400,rotationUnits::deg,150,velocityUnits::rpm);
   task::sleep(1);
    FL.startRotateFor(-400,rotationUnits::deg,150,velocityUnits::rpm);
    BL.rotateFor(-400,rotationUnits::deg,150,velocityUnits::rpm);
   task::sleep(1);
    LiftL.startRotateTo(50,rotationUnits::deg,100,velocityUnits::rpm);
    LiftR.rotateTo(50,rotationUnits::deg,100,velocityUnits::rpm);
   task::sleep(1);
    FL.startRotateFor(-500,rotationUnits::deg,150,velocityUnits::rpm);
    BL.rotateFor(-500,rotationUnits::deg,150,velocityUnits::rpm);
   task::sleep(100);
    FR.startRotateFor(600,rotationUnits::deg,150,velocityUnits::rpm);
    BR.startRotateFor(600,rotationUnits::deg,150,velocityUnits::rpm);
    FL.startRotateFor(600,rotationUnits::deg,150,velocityUnits::rpm);
    BL.rotateFor(600,rotationUnits::deg,150,velocityUnits::rpm);
   task::sleep(1);
    FR.startRotateFor(100,rotationUnits::deg,150,velocityUnits::rpm);
    BR.rotateFor(100,rotationUnits::deg,150,velocityUnits::rpm);
   task::sleep(100);
    FR.startRotateFor(750,rotationUnits::deg,150,velocityUnits::rpm);
    BR.startRotateFor(750,rotationUnits::deg,150,velocityUnits::rpm);
    FL.startRotateFor(750,rotationUnits::deg,150,velocityUnits::rpm);
    BL.rotateFor(750,rotationUnits::deg,150,velocityUnits::rpm);
   task::sleep(1);
    LiftL.startRotateTo(0,rotationUnits::deg,100,velocityUnits::rpm);
    LiftR.rotateTo(0,rotationUnits::deg,100,velocityUnits::rpm);
}

Be advised that if you run into something the motor cannot push through, it will stop at that part of your autonomous until the motor can complete it’s task.

btw you could also try to run it without the sleep tasks unless you wanted to put a delay between functions. (Im not 100% on this though)

do you want to use PID or ramping (these are motion control systems with pros and cons to both of them)

PID is three variables that based on each other. You can find more here:
https://github.com/acetousk/potatehoes/blob/master/include/PDFs/PID.pdf

Ramping is helpful for eliminating wheel slippage to make it so that it adds or takes away speed to the motors at the right time. (anyone else want to explain ramping a little better… maybe find a pdf?)

I hope that this will help…

You may also want to check out: