To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1163
1162  |  1164
Subject: 
Re: rotation sensor problem, again...
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Thu, 15 Jun 2000 02:18:07 GMT
Viewed: 
1039 times
  
Luis Villa  <liv@duke.edu> wrote:
Just when you thought it was all fixed. I use the following code:

ds_active(&SENSOR_2);
ds_rotation_on(&SENSOR_2);
ds_rotation_set(&SENSOR_2, 0);

to setup a rotation sensor. Immediately after calling ds_rotation_set(),
and /without moving the sensor/, the value read is not 0 (as it should be)
but 1. If I call ds_rotation_set(&SENSOR_2,2), then the code is
initialized not to 2, but to 3. Or, after downloading a new kernel, I get
the same behavior except with -1 or -2. There was a similar problem in the
old code that would occasionally initialize the rotation sensors to
whatever they were set to, plus 2. Anyone have any clues on why this is
happening? I knew the old code inside and out, but never could track down
the bug... is it going to be the same this time?
Luis

That you see values -1, 2, and 1 sounds like the current state of the
rotation sensor is not considered when when the sensor is reset, like it is
reset to a state of 0 when it should be reset to the current state of the
sensor, like 0, 1, 2, or 3 depending on the current sensor position.  It is
likely that ds_rotation_on sets the state of the sensor to 0, then you set
the rotation count to 0 using ds_rotation_set, then some fraction of a
second later the first A/D conversion completes, the current state is
determined, and the sensor position is updated accordingly, possibly
bumping the count up or down a bit.  By this reasoning, you should see a
bogus value 3/4 of the time, assuming you twist the rotation sensor to a
random position each time you test for a bogus value.

Not that this is necessarily the problem, but if I had a list of possible
problems to check for, this would be the first one I'd investigate.

If you want an easy test, and possibly a cheesy fix, try to sleep for 10 ms
or so between ds_rotation_on and ds_rotation_set.  If this fixes things,
you can be almost sure the problem I mentioned is the problem you are
seeing.  Hopefully, ds_rotation_set only sets the sensor count and does not
reset the sensor state!

-Kekoa



Message has 1 Reply:
  Re: rotation sensor problem, again...
 
(...) On second thought, this need not be the case. Maybe the initial sensor state starts out at whatever value it normally starts out at after bootup (probably zero), and simply never gets set (or reset) to the state indicated by looking at the (...) (24 years ago, 15-Jun-00, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  rotation sensor problem, again...
 
Just when you thought it was all fixed. I use the following code: ds_active(&SENSOR_2); ds_rotation_on(&SENSOR_2); ds_rotation_set(&SENSOR_2, 0); to setup a rotation sensor. Immediately after calling ds_rotation_set(), and /without moving the (...) (24 years ago, 14-Jun-00, to lugnet.robotics.rcx.legos)

4 Messages in This Thread:


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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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