Problem running two motors with different speeds

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

Moderators: 99jonathan, roger, imaqine

Problem running two motors with different speeds

Postby ahavriluk » Fri Jan 03, 2014 8:55 pm

My 9 years old son built a printer/plotter. It uses motor B to move a pen horizontally and motor A to move the paper vertically. I was trying to code a method which would draw a tilted line by utilizing two motors. Two draw a line at particular angle one of the motors has to move at slower speed. Here is a sample code:

Motor.A.setSpeed(1000);
Motor.B.setSpeed(500);

Motor.A.forward();
Motor.B.forward();

Delay.msDelay(1000);

Motor.A.stop(true);
Motor.B.stop();

The problem is that the vertical motor A stops sooner then motor B and the line looks like a hockey stick.
\
\
\
\__

Stopping motor B first makes no difference.

Looks like motor A gets stalled at the end. But why? Anybody can explain that?

If I use unregulated motors and set different powers to them the line is straight.


NXTMotor motorA = new NXTMotor(MotorPort.A);
NXTMotor motorB = new NXTMotor(MotorPort.B);

mMotorA.setPower(100);
motorB.setPower(50);

motorA.forward();
motorB.forward();

Delay.msDelay(1000);

motorA.stop(true);
motorB.stop();


Thank you!
Alexander.
ahavriluk
New User
 
Posts: 3
Joined: Fri Jan 03, 2014 8:37 pm

Re: Problem running two motors with different speeds

Postby gloomyandy » Fri Jan 03, 2014 9:08 pm

You are probably asking motor A to run too fast. Typically NXT motors will not run faster than 900 degrees per second you are asking for 1000. Try making both motors slower, say 600 and 300, if that works speed them both up etc.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3901
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Problem running two motors with different speeds

Postby ahavriluk » Fri Jan 03, 2014 9:38 pm

Good idea! I will try it tonight!
ahavriluk
New User
 
Posts: 3
Joined: Fri Jan 03, 2014 8:37 pm

Re: Problem running two motors with different speeds

Postby ahavriluk » Tue Jan 07, 2014 4:40 pm

I figured out that speed 500 or less works the best. Thank you!
ahavriluk
New User
 
Posts: 3
Joined: Fri Jan 03, 2014 8:37 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

more stuff