View unanswered posts | View active topics It is currently Thu Aug 21, 2014 8:41 am






Reply to topic  [ 3 posts ] 
Question: setMotorDirection(theMotors, direction); 
Author Message
Rookie

Joined: Fri Mar 16, 2007 10:24 pm
Posts: 2
Post Question: setMotorDirection(theMotors, direction);
I'm trying to use the function:
setMotorDirection(theMotors, direction);

What do i use for the direction parameter if i'd like to reverse the natural direction of the motor? (i assume this is what the function does)

thanks


Wed Apr 04, 2007 10:13 am
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 439
Location: Pittsburgh, PA
Post Re: Question: setMotorDirection(theMotors, direction);
larzw wrote:
I'm trying to use the function:
setMotorDirection(theMotors, direction);

What do i use for the direction parameter if i'd like to reverse the natural direction of the motor? (i assume this is what the function does)

thanks


You should actually use this function:

Code:
bMotorReflected[motorA] = true;


Obviously, if you don't want to flip motorA then you should set it to the motor you want to flip. Hope this helps..

_________________
Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Use the ROBOTC Ticketing system

Robotc.net| Robomatter Store | Robotics Academy | CS2N


Wed Apr 04, 2007 2:04 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
Mindstorms bricks can also be programmed using the graphical Robolab system. Robolab shares similar firmware with RobotC for both the RCX and NXT bricks.

'setMotorDirection' is a legacy feature required for Robolab compatibility. In Robolab, there's a series of common functions for manipulating motors that was the original RCX motor functions commands. Some of these functinos are not "natural" for the NXT and some emulation and conversion "glue" code was written to behave as close as possible to the legacy functions.

"setMotorDirection" is one of these legacy compatibility functions and it is not recommended for use in new RobotC programs.

To change motor direction you use either positive or negative power
Code:
levels to set the direction. For example
motor[motorA] =  50; // 50% of full speed, forward
motor[motorA] = -50; // 50% of full speed, reverse

// Assume 'power' is a positive integer representing the target power level
motor[motorA] =   power; // forward
motor[motorA] = -power;  // reverse

// "Flip" existing direction
motor[motorA][ = - motor[motorA];


The 'motorReflected' function is a nifty feature to chang the motor performance. Suppose you've got your robot built and you find the configuation is that one (or more) motors ends up moving in the logically opposite direction due to mechanical orientatino of the motor. On the RCX, this was easy to fix -- you simply rotated the black connector a quarter turn and this would reverse the way the pair of wires was connected to the RCX.

Connectors on the NXT are polarized and you can't use the RCX trick of physically flipping the way the wires are connected. So, the variable "bMotorReflection' is used to achieve the same effect in software.


Wed Apr 04, 2007 2:53 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.