simultaneous rotations

Post your NXJ projects, project ideas, etc here!

Moderators: 99jonathan, roger, imaqine

simultaneous rotations

Postby legobob » Mon Sep 15, 2008 11:27 pm

I'm trying to rotate two motors simultaneously. What I've tried is the code:

Motor.A.rotate(120);
Motor.B.rotate(90);

This first rotates motor A 120 degrees and then rotates motor B 90 degrees. I want both motors to start rotating at the same time. Anyone know how I can do that?
legobob
New User
 
Posts: 3
Joined: Mon Sep 15, 2008 11:23 pm

Postby gloomyandy » Mon Sep 15, 2008 11:44 pm

Last edited by gloomyandy on Thu Oct 30, 2008 11:12 pm, edited 2 times in total.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3642
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby legobob » Tue Sep 16, 2008 7:44 am

That worked. Thanks
legobob
New User
 
Posts: 3
Joined: Mon Sep 15, 2008 11:23 pm

rotate simultaneously

Postby plotterbonger » Mon Sep 29, 2008 7:01 pm

Hi! Try this:
Motor.A.rotate(120, true);
Motor.B.rotate(90, true);

This way, the calls will return immediately, resulting in the motors starting simultaneously. My current project is a plotter, and when drawing a straight line I need to start the paper feeder and the carriage motors at the same time too.

The problem I am about to work around are these:
- Some time passes between the execution of the two commands, resulting in the motors not starting exactly at the same time.
- The speed of the motors need to be carefully adjusted according to the direction of the line to be drawn.
- The synchronization of the accelerations seem to be the biggest problem. Each line my plotter draws starts to be drawn in an awkward direction, and it takes a few millimeters until the right direction is achieved through proper adjustment of motor speeds.
plotterbonger
New User
 
Posts: 1
Joined: Mon Sep 29, 2008 6:49 pm

Postby tsanalp » Thu Oct 30, 2008 8:33 pm

what worked?
tsanalp
New User
 
Posts: 6
Joined: Thu Oct 30, 2008 2:55 pm

Postby gloomyandy » Thu Oct 30, 2008 11:14 pm

Hi,
For some reason my post does not show up correctly in some browsers. It was a pointer to the leJOS documentation for the version of rotate that takes two parameters. The second parameter tells the rotate call not to wait for the move to complete and so enables more than one motor to run at once...

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

Re: simultaneous rotations

Postby choncha » Tue May 03, 2011 11:36 am

Hi @all

I want to rotate the motors simultaneously, too... I found the method with the immediateReturn argument but somehow this is not working for me. The documentation also says "If any motor method is called before the limit is reached, the rotation is canceled." I try to let one motor go forward and one backward to rotate on the spot. As long as "immediateReturn" is set to "true" the robot is doing nothing. If it's set to false it works like the other rotate method without the 2nd paramter. How can I make the robot rotating both wheels in different directions simultaneously? Thanks for helping!
choncha
New User
 
Posts: 1
Joined: Tue May 03, 2011 11:28 am

Re: simultaneous rotations

Postby TechnoX » Tue May 03, 2011 8:25 pm

Can you post your code here? :)
It should work without problems...
TechnoX
Novice
 
Posts: 52
Joined: Tue May 03, 2011 5:57 pm
Location: Sweden


Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff