Subject:
|
Re: Switching Direction
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Thu, 19 Jun 2003 02:26:33 GMT
|
Original-From:
|
scott davis <rcx2man@NOSPAMhotmail.com>
|
Viewed:
|
783 times
|
| |
![Post a public reply to this message](/news/icon-reply.gif) | |
----- 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:
![](/news/x.gif) | | 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 (...) (22 years ago, 18-Jun-03, to lugnet.robotics)
|
4 Messages in This Thread: ![Switching Direction -Steven Lane (18-Jun-03 to lugnet.robotics)](/news/x.gif) ![](/news/246.gif) ![Re: Switching Direction -Philippe Hurbain (18-Jun-03 to lugnet.robotics)](/news/x.gif) ![](/news/46.gif) ![Re: Switching Direction -Steven Lane (19-Jun-03 to lugnet.robotics)](/news/x.gif)
![](/news/x.gif) ![](/news/68.gif) ![You are here](/news/here.gif)
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|