View unanswered posts | View active topics It is currently Fri Jul 01, 2016 7:49 am

 Page 1 of 1 [ 9 posts ]
 Print view Previous topic | Next topic
Retrieving Values From Motors
Author Message
Rookie

Joined: Sat Oct 04, 2008 2:30 pm
Posts: 7
Retrieving Values From Motors
Hi,

I'm using the Lego NXT Mindstorms kit to make an advanced Line Tracker. I know its beginner stuff but thats what I am. Anyways, I need to know if it is possible to read and store the values from one of the motors.

Basically, I'm using the line sensor to get the robot to track a circle. After one complete rotation (i.e. tracking the circle and returning to its starting point on the circumference), the robot switches off it's light sensor and attempts to follow the circle once more. The way I'm trying to do this is to get the robot to store the values of the motor from the first time it went around the circle and then implement those the second time when it attempts to do it without the light sensor.

I know there are a lot of possible flaws in this logic etc. but its a good learning curve and so I just need to know if its possible to be able to read the values of the motors and store them for future use. Sort of like a scanf function but for a motor. Any help or advice in this matter is much appreciated.

Regards,

JD.

Fri Oct 17, 2008 10:14 am
Rookie

Joined: Sun Sep 28, 2008 1:06 pm
Posts: 27
Re: Retrieving Values From Motors
Are you trying to get the encoder values?
nMotorEncoder[motorA]; //substitute 'A' with what motor port you wish

That variable will retrieve how many degrees the said motor is turning.

Fri Oct 17, 2008 8:24 pm
Rookie

Joined: Sat Oct 04, 2008 2:30 pm
Posts: 7
Re: Retrieving Values From Motors
Hmmm... I'm not too sure. In my program, I just use lines like 'motor[motorA] = 35;'. What value is it that I'm assigning here? I'm pretty sure its not the encoders.

Mon Oct 20, 2008 11:22 am
Guru

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Re: Retrieving Values From Motors
no,
motor(motorA)=35
means the power level (35%) = sort of 35% speed

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)

Mon Oct 20, 2008 11:32 am
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Re: Retrieving Values From Motors
If I understand you correctly, you are adjusting the power to the motors as part of a line following program and want to record the right and left power levels periodically as a table of data to be "replayed" for subsequent loops around the course. If that is the case then I suggest looking into the Datalog feature. You can retrieve the current power level for a motor by using the motor[] array on the right side of an assignment statement like so:

currentPower = motor[motorA];

So, in your line-following code just log the right and left power levels on each itteration (or every n itterations) of the loop.

Then, run though the logged data over and over setting the motor power levels to the recorded values.

_________________
Jeff McBride
Benson Robotics Club

Mon Oct 20, 2008 1:15 pm
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616
Re: Retrieving Values From Motors
 The_JD wrote:I'm using the Lego NXT Mindstorms kit to make an advanced Line Tracker. I know its beginner stuff but thats what I am.

Beginner stuff is the simple line follower -- one motor turned on and the other motor turned off depending on bnary value of which side of the line edge the light sensor is detecting.

You can do true "post-graduate" education level work with more sophisticated algorithms that use variable speed for the motors and use the analog values of the light sensor. Or use multiple light sensors.

Wed Oct 22, 2008 6:22 am
Rookie

Joined: Sat Oct 04, 2008 2:30 pm
Posts: 7
Re: Retrieving Values From Motors
Thanks for the replies guys. Using more than one light sensor was my initial idea but unfortunately, we've been restricted to one and (in my case, eventually none).

The datalogging function seems to be quite handy though. However, is there a way to retrieve the values from the log? I now know how to write to the log but how can I retrieve those values ot be used later in the same program?

- JD.

Thu Oct 23, 2008 5:51 pm
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616
Re: Retrieving Values From Motors
If you want to retrieve during program run, then why not store the data points in a array?

Thu Oct 23, 2008 11:21 pm
Rookie

Joined: Sat Oct 04, 2008 2:30 pm
Posts: 7
Re: Retrieving Values From Motors
Thanks for all the help guys. Using datalog to write the values into an array and calling them in sequence was the easiest and least painful way to do it.

- JD.

Sat Oct 25, 2008 3:11 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 9 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning