To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 20946
20945  |  20947
Subject: 
Re: Switching Direction
Newsgroups: 
lugnet.robotics
Date: 
Thu, 19 Jun 2003 02:26:33 GMT
Original-From: 
scott davis <rcx2man@hotmail&avoidspam&.com>
Viewed: 
625 times
  
----- Original Message -----
From: "Steven lane" <steveroblane@aol.com>
To: <lego-robotics@crynwr.com>
Sent: Wednesday, June 18, 2003 2:29 PM
Subject: Switching Direction


I have a motor which drives a rack mechanism and I'm using a rotation • sensor to
index my position on the rack.

When I program the motor (in NQC) to go forward I want the sensor to count • up.
If the sensor then actually goes down I want to test for this condition • and
correct it in software. This way I can index one end of the rack as 0 and • the
other as whatever. Either the motor or the sensor could be the wrong way • round.
To keep things simple I only want to switch the sensor connection not the • motor
connection.

To do this I need to be able to flip the direction "forward" in the code, • so if
the motor and sensor directions conflict I can correct this in software.

I tried to do this with a macro, but the compiler requires I use a • constant and
not a variable. But as the test is done within the program I have to use a
variable.

So basically I'm looking for a replacement for OnFwd();

Steve

Is there a way to get the absolute value of the rotation sensor count?

or you could do

x=current_position;

until (x==where_ever_you_want_to_go)
{
      if (rotationcount<0)
     {   x=rotationcount*-1;
      }
}
Hope this helps
Scott



Message is in Reply To:
  Switching Direction
 
I have a motor which drives a rack mechanism and I'm using a rotation sensor to index my position on the rack. When I program the motor (in NQC) to go forward I want the sensor to count up. If the sensor then actually goes down I want to test for (...) (21 years ago, 18-Jun-03, to lugnet.robotics)

4 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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