[VEX C++} Problem with 2 motor ball puncher code

Hi, newbie here and Ive got an issue.
I’ve been trying to program my 2 motor Ball Punch and I’ve ran into some trouble. I need one motor to move forwards at 30rpm and one to move in reverse at 50rpm while the button R2 is pressing and stop when it’s not pressing. When I run the code it does nothing? I used the exact same method for my 2 motor forklift with no issues whatsoever.

When I upload the code to the brain it does not have any error messages.
Any help would be greatly appreciated!
Here’s the code (Forklift code included too)

  while(true) {
      
   if (Controller1.ButtonL2.pressing()){
      FORKLIFT1.spin(directionType::fwd);
      FORKLIFT2.spin(directionType::rev);
   }
  else if (Controller1.ButtonL1.pressing()){
       FORKLIFT1.spin(directionType::rev);
       FORKLIFT2.spin(directionType::fwd); }
      else {
          FORKLIFT1.stop();
          FORKLIFT2.stop();
      }
   }

while(true) {

  if (Controller1.ButtonR2.pressing()){
      BALLPUNCH1.spin(directionType::fwd,30,velocityUnits::rpm);
      BALLPUNCH2.spin(directionType::rev,50,velocityUnits::rpm); }
   else {
       BALLPUNCH1.stop();
       BALLPUNCH2.stop();
   }
   }

@Flonkle, the problem appears to be that, that first while(true) loop never exits.

You want both controls for Forklift and Ballpunch to be in the same loop and having a little 10 msec delay is also a good idea:

I know the original question is about software and not your robot design.
Guessing from 30 and 50 rpm values I assume that one of the motors is connected to 36T gear and another to 60T that are meshing together. This puts unequal load on the motors and one of them could start overheating more then the other. That may work under relatively light load, but I would try, instead, to connect both motors to the equal size gears for the better load balancing.

2 Likes

Thank you for the advice I’ll definitely test that out!