Rotate synchronized wheel

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

hflores
New User
Posts: 14
Joined: Mon Feb 27, 2017 8:50 pm

Rotate synchronized wheel

Postby hflores » Fri Jul 07, 2017 5:07 am

I have the following code to make a 90 degree turn, but increase or decrease 3 degrees.

Code: Select all

      int tachoRow = 0;

       RIGHT_MOTOR.setSpeed(120);// 2 RPM
       LEFT_MOTOR.setSpeed(120);
      
       // perform four repetitions of the test
       for (int i = 0; i < 2; i++) {
          // wait for 200 milliseconds

         // turn back
          RIGHT_MOTOR.resetTachoCount();
          LEFT_MOTOR.resetTachoCount();
          RIGHT_MOTOR.synchronizeWith(new EV3LargeRegulatedMotor[] { LEFT_MOTOR });
          LEFT_MOTOR.startSynchronization();
          LEFT_MOTOR.rotate(-278, true);
          RIGHT_MOTOR.rotate(278, true);
          LEFT_MOTOR.endSynchronization();
         
         while (RIGHT_MOTOR.isMoving() && LEFT_MOTOR.isMoving())
            Thread.yield();
         
          // display the tacho counts and reset the // max, if changed
          currTachoCountDiff = displayTachoCounts(tachoRow++);
          if (currTachoCountDiff > maxTachoCountDiff)
             maxTachoCountDiff = currTachoCountDiff;
          
         buttons.waitForAnyPress();
       }
       // stop the motors
       LEFT_MOTOR.stop();
       RIGHT_MOTOR.stop();



why?

User avatar
gloomyandy
leJOS Team Member
Posts: 5871
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Rotate synchronized wheel

Postby gloomyandy » Fri Jul 07, 2017 8:29 am

I'm sorry I don't understand your question. What is the problem? Are you saying that the tacho readings after the move has completed are not 278 and -278? If so what are they? Are you saying that your robot does not rotate as you expect?


A few things...
1. To use the motor synchronization feature you must call the startSyncheonization/endSYnchronization method using the same motor that you created the sync group with. So in your code you should be using RIGHT_MOTOR not LEFT_MOTOR. See:
https://lejosnews.wordpress.com/2014/10 ... ms-part-2/
2. Do not call resetTachCount() this is not a good idea. The motor driver keeps track of things like slight errors in the motor position and will try and correct them on the next move. you will lose this correction if you reset the tacho count.
3. What is the acceleration value you are using? Using high acceleration values may result in motor position overshoot at the end of a move, this is not a good idea. Try different acceleration values to see if that helps.
4. Can you post a picture of your robot (or even better a video of it during this test).
5. It is better to call waitComplete on the two motors (see the example in the above link) rather than polling isMoving
leJOS news https://lejosnews.wordpress.com/


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 2 guests