To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.nxtOpen lugnet.robotics.nxt in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / NXT / 871
870  |  872
Subject: 
FW: RotateMotorEx hangs
Newsgroups: 
lugnet.robotics.nxt
Date: 
Thu, 9 Aug 2007 13:44:47 GMT
Viewed: 
22166 times
  
Thank you to both John and Roger, I'll try it out later next week.

--Elizabeth

-----Original Message-----
From: news-gateway@lugnet.com [mailto:news-gateway@lugnet.com] On Behalf Of
John Hansen
Sent: Wednesday, August 08, 2007 6:20 PM
To: lugnet.robotics.nxt@lugnet.com
Subject: Re: RotateMotorEx hangs

In lugnet.robotics.nxt, Roger Glassey wrote:
In lugnet.robotics.nxt, Elizabeth Mabrey wrote:
Subject: RE: Idea on how to interrupt RotateMotor?

Hi Elizabeth:
Here is how you could do it in Java:


<snipped>

The RotateMotor call is designed to block.  If you don't want to block then
you
can write code almost exactly like what Roger wrote in Java using other NXC
API
calls.  Like so:

#define UF_TLSM UF_UPDATE_TACHO_LIMIT+UF_UPDATE_SPEED+UF_UPDATE_MODE
#define OM_RBM OUT_MODE_REGULATED+OUT_MODE_BRAKE+OUT_MODE_MOTORON

task main()
{
  SetSensorLight(S1);
  TextOut(0, LCD_LINE1, "wait for dark");
  SetOutput(OUT_A, Power, 75, TachoLimit, 3600, RegMode, OUT_REGMODE_SPEED,
            RunState, OUT_RUNSTATE_RUNNING, OutputMode, OM_RBM,
            UpdateFlags, UF_TLSM);

  // wait for dark or 10 revolutions
  while((MotorRunState(OUT_A) == OUT_RUNSTATE_RUNNING) && (SENSOR_1 > 40));
  Off(OUT_A);
  NumOut(0, LCD_LINE2, MotorTachoCount(OUT_A));
  Wait(10000); // to see the value on screen
}

The NXT firmware takes care of regulating the motor and it will stop
automatically at 3600 degrees.  The SetOutput call can easily be wrapped
into
any number of preprocessor macros or user-defined functions to further
simplify
what is already trivially easy in NXC.  The SetOutput call can take a
variable
number of arguments so you can set any number of output fields that you want
in
a single call.  For synchronization just pass in OUT_AB or one of the other
paired motor constants and set the RegMode to OUT_REGMODE_SYNC instead of
OUT_REGMODE_SPEED.

John Hansen



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in NXT programmable brick

 
Verified and Trusted Team of Hackers
17 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR