[c++] How can I get wheels to begin spinning concurrently?

In short, if I do something like

  motor1.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
  motor2.spin(vex::directionType::rev, 100, vex::velocityUnits::pct);

Then motor1 will spin for several milliseconds before motor2 begins spinning (I assume because of the delay of running the spin function, though I am not sure).

This spinning of motor1 will lead to a non-insignificant inaccuracy with where the wheels/robot should be positioned. Is there anyway to cause both motors to spin at exactly the same time or a workaround for this problem.

What is your full code?

This is basically my full code. This is all I’m running.

If there is several milliseconds between those two lines, then that means your thread scheduler probably decided to yield at some point during one of the spin calls after it fired off the first command but before it fired off the second one.

OK, that makes sense. How can I resolve this though?

In VCS and VEXcode? No idea. I don’t know enough about their scheduler to know how to force it to do certain things over others, or if it’s even possible.

Nothing really to do with VCS or VEXcode, there’s always the potential for some small delay between starting motors, but it should be no more than 10mS. How are you measuring the delay ?

This is an issue in real life too, have to deal with this on industrial scales to a degree… gotta love how it all works.


A quick, imperfect workaround might look something like this:

motor1.spin(vex::directionType::fwd, 50, vex::velocityUnits::pct);
motor2.spin(vex::directionType::rev, 100, vex::velocityUnits::pct);
motor1.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);