Author |
Message |
jaruj9
Rookie
Joined: Tue Oct 01, 2013 10:23 am Posts: 13
|
 ROBOTC motor programming
Hay guys...i build my cnc from lego mut i have problem..I cant figure out how to turn two motors on the same time but just wor specifite nmotorencodor value. Both motors will have different values.
Can anyone help me please??
Thank you for time!
|
Tue Oct 01, 2013 10:26 am |
|
 |
rcahoon
Site Admin
Joined: Tue Oct 09, 2012 10:34 am Posts: 192
|
 Re: ROBOTC motor programming
Hi jaruj9, From an example given on http://www.robotc.net/support/nxt/MindstormsWebHelp/index.htm#page=nxt_functions/Motors/Motors.htmYou can change the nMotorEncoderTarget and motor power values individually for each of the motors. Cheers, --Ryan
_________________ Ryan Cahoon CMU Robotics Academy RVW Software Developer
Robot Potato Head; Virtual NXT
|
Thu Oct 03, 2013 5:13 pm |
|
 |
jaruj9
Rookie
Joined: Tue Oct 01, 2013 10:23 am Posts: 13
|
 Re: ROBOTC motor programming
Thank you for response!
But this function turn off both motors when one reach the possition. I need that, motor which will reach possition will turn off but the another which still did not will continue.
Tahank you!
|
Wed Oct 09, 2013 9:55 am |
|
 |
rcahoon
Site Admin
Joined: Tue Oct 09, 2012 10:34 am Posts: 192
|
 Re: ROBOTC motor programming
My fault for not testing The problem with the last code is that the wait while loop exited whenever either motor reached its target, but we want it to wait until both have reached their targets - in other words, we want to keep waiting while either motor is still running, instead of both motors running. We can do this by changing the "and" (&&) operator to an "or" (||) operator in the loop's condition:
_________________ Ryan Cahoon CMU Robotics Academy RVW Software Developer
Robot Potato Head; Virtual NXT
|
Wed Oct 09, 2013 10:05 am |
|
 |
jaruj9
Rookie
Joined: Tue Oct 01, 2013 10:23 am Posts: 13
|
 Re: ROBOTC motor programming
aaaa yesss thank you really much now it works!!
I have one more question. With the nmotorencoder overflow. The tutorial says that maximum counts is 32 767 but when I use for exampel 40 000 it works completelly good. My question is how is it possible?
Tahank you for your time!
|
Wed Oct 09, 2013 10:15 am |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: ROBOTC motor programming
That information in the link rcahoon gave you is outdated. The encoder variable was upped from 16-bits to 32-bits a while ago. Resulting in +-~2,147,483,648 degree limit.
_________________A.K.A. inxt-generation Self-proclaimed genius, and future world dominator. My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor Bow down to Nikola Tesla, King of the Geek Gods.
|
Wed Oct 09, 2013 10:20 am |
|
 |
jaruj9
Rookie
Joined: Tue Oct 01, 2013 10:23 am Posts: 13
|
 Re: ROBOTC motor programming
aaa perfect thank you really really much!!!
|
Wed Oct 09, 2013 10:26 am |
|
 |
jaruj9
Rookie
Joined: Tue Oct 01, 2013 10:23 am Posts: 13
|
 Re: ROBOTC motor programming
I found in that program one mistake!
In the case that one of the nmotorencoder value is 0(and the speed 0 too) the program does not continue after reach the position from another motor! Can you please help me with this problem??
Thank you really much!!!
|
Wed Oct 09, 2013 10:41 am |
|
|