View unanswered posts | View active topics It is currently Tue Sep 23, 2014 8:25 pm






Reply to topic  [ 7 posts ] 
Basic Questions 
Author Message
Rookie

Joined: Mon Feb 25, 2013 11:41 am
Posts: 7
Post Basic Questions
Hi, we are St. James School in Highwood, IL and we are new to RobotC Mindstorms. We have lots of questions and hope you guys can help us along.

First Question: Is it necessary to sync the motors prior to each command?

Second Question: Is it necessary to do the nMotorEncoder procedure before each command?

More questions to follow. :biggrin:
Sorry for being such newbies, but it's all new to us.


Mon Feb 25, 2013 11:50 am
Profile
Rookie

Joined: Tue Feb 19, 2013 4:11 pm
Posts: 8
Post Re: Basic Questions
To answer your questions:

1. No, syncing the motors only needs to be done once. The statement will need to be before you make any commands.

2. Not sure exactly what you want as an answer for this one... The nMotorEncoder[motor] statement is used to retrieve the encoder value from a particular motor (with encoder equipped).
For the NXT motors, encoder values are calculated in degrees of rotation (360 per rotation) and Tetrix encoders are calculated in quarter-degrees of rotation (1440 per rotation). These values are useful for determining distance travelled.

Hope this helps,

Team 5009


Mon Feb 25, 2013 2:16 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: Basic Questions
More info: Synching motors is not useful for every robot configuration. only use it when you want a motor to always travel at a speed related to the speed of another motor. On question 2, nMotorEncoder is not a procedure. It is a 3-value array holding the values of each motor's internal encoder. Please note the difference between procedures and variables. Anyway, there are two things you can do with this variable: read it and reset it. You seem to be interested in reseting it. To do that, you would write zero to it, like: nMotorEncoder[motorB] = 0 . You do not have to do this before every motor command, either; however, you might want to. If the nature of the command is to set the power, reseting has no effect on it. if you are going to set an encoder target, you may or may not want to reset it. It all depends on How you want your robot to behave.

Also, don't be sorry about being newbies. We all were at one time and we are here to help!

I hope this helps!

-Coder A

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Mon Feb 25, 2013 2:45 pm
Profile
Rookie

Joined: Mon Feb 25, 2013 11:41 am
Posts: 7
Post Re: Basic Questions
Thanks to both of you for responding.

Robo5009: So when you say the syncing only needs to be done once, do you mean once per program or if I sync the motors for a given program, and I change the program, do I need to re-sync?

Coder A: Shouldn't we use the nmotorencoderTarget procedure for each distance calculation?

I guess our primary concern is making the robot travel in a straight line.

And again, I apologize for such simple questions, but as you see, we have a lot to learn.


Mon Feb 25, 2013 3:41 pm
Profile
Moderator
Moderator

Joined: Mon Oct 04, 2010 2:18 pm
Posts: 196
Post Re: Basic Questions
Hey, have you checked out the ROBOTC for Lego Mindstorms curriculum:

http://www.education.rec.ri.cmu.edu/pre ... index.html

If you are just beginning, it's a great place to start. I've been using it in my classroom for a few years now. Don't worry about asking basic questions. The forum is a great place to ask those questions.


Mon Feb 25, 2013 8:19 pm
Profile
Rookie

Joined: Mon Feb 25, 2013 11:41 am
Posts: 7
Post Re: Basic Questions
parkway wrote:
Hey, have you checked out the ROBOTC for Lego Mindstorms curriculum:

http://www.education.rec.ri.cmu.edu/pre ... index.html

If you are just beginning, it's a great place to start. I've been using it in my classroom for a few years now. Don't worry about asking basic questions. The forum is a great place to ask those questions.


Hi Parkway, Yes, I use the cirriculum regularly, but some things are not entirely clear to us. :crying:


Tue Feb 26, 2013 9:28 am
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: Basic Questions
If your main idea is to move the robot in a straight line, you will want to synch the motors. As for synching carrying over to other programs, I've never even thought about it. I would guess not, but I really don't know. Until you find out, it would be good just to synch at the beginning of every program that needs synching.

As for the target question, the best way to explain its use is with an example: Let's say you have a robot that travels in a straight line, using the synch program. It has already moved forward 40 degrees from the start position. If you want it to move forward 600 more degrees, there are two ways of doing it, shown below.

Way 1:

1. Reset the encoder.----------------nMotorEncoder[motorB] = 0;
2. Set the target.--------------------nMotorEncoderTarget[motorB] = 600;
3. Set the power.--------------------motor[motorB] = 75;


Way 2:

1. Set a new encoder target.---------nMotorEncoderTarget[motorB] = nMotorEncoder[motorB] + 600;
2. Set the power.----------------------motor[motorB] = 75;

The difference is that at the end of the code sequence, way 1's encoder says 600 and way 2's encoder says 640 (600 just moved plus the 40 already moved). Way 2 saves the encoder information, but way 1 overwrites it.

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Last bumped by StJamesSchool on Thu Apr 04, 2013 10:33 am.


Thu Apr 04, 2013 10:33 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.