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 / 145
144  |  146
Subject: 
Re: Rotation sensor bug found (maybe!)
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Sat, 17 Apr 1999 17:00:33 GMT
Viewed: 
1380 times
  
Mario Ferrari wrote:

I think I might have found a bug in the ds_rotation_handler (direct-sensor.c).
The problem arises when the STATE_0_VALUE is checked using the IN_RANGE macro.
As STATE_0_VALUE is 1023U<<6, which is about the max value for an unsigned,
adding to it the RANGE_SIZE to test the upper bound gets an unwanted result.
The value would be over the max possible unsigned value and the result of the
addition is 40U<<6 - 1.

You've got a point here.  What if we hardwire STATE_0_VALUE to the
following?

#define STATE_0_VALUE (ds_unscale(1023U)-RANGE_SIZE)

Or, for a more general approach:

#define MIN(a,b) (a<b?a:b)
#define MAX(a,b) (a>b?a:b)
#define STATE_VALUE(k) ( \
MIN( \
MAX(ds_unscale(k),RANGE_SIZE), \
ds_unscale(1023U)-RANGE_SIZE \
) \
)
#define STATE_0_VALUE (STATE_VALUE(1023U))
#define STATE_1_VALUE (STATE_VALUE( 833U))
#define STATE_2_VALUE (STATE_VALUE( 405U))
#define STATE_3_VALUE (STATE_VALUE( 623U))

This is off the top of my head, but it should handle arbitrary values,
and all of that math should be done in the compiler, resulting in
constants.


Second problem. I checked many values for my two rotation sensors, and as I
wrote yesterday they are different from the ones inside direct-sensor.c. In
some cases they are out of the range specified in legOS.

Well, I don't know where the current costants came from, but they are
probably just the values that one person got with their RCX.  They are
bound to be different between different RCXs, sensors, and wire lengths,
and yours appear to be just different enough to cause problems.  Perhaps
we should collect data from a number of people and try to arrive at
values for the state values and the range which accomodate all of them.
They are just constants, after all.

I don't have any rotation sensors.



Message has 2 Replies:
  Re: Rotation sensor bug found
 
Lou, thank you for your reply. (...) This should work. (...) This seems wrong to me because sets all the STATE_n_VALUE to k-RANGE_SIZE. For now I modified ds_rotation_handler() in this way (two occurrences): // if ( IN_RANGE ( STATE_0_VALUE ) ) { // (...) (26 years ago, 18-Apr-99, to lugnet.robotics.rcx.legos)
  Re: Rotation sensor bug found (maybe!)
 
(...) Exactly. I don't have rotation sensors, either. I think these values were originally gathered from Michael Nielsen's sensors. What's the current status? Is there a patch working for everybody, or do we need some calibration work? It would be (...) (26 years ago, 20-Apr-99, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Rotation sensor bug found (maybe!)
 
I think I might have found a bug in the ds_rotation_handler (direct-sensor.c). The problem arises when the STATE_0_VALUE is checked using the IN_RANGE macro. As STATE_0_VALUE is 1023U<<6, which is about the max value for an unsigned, adding to it (...) (26 years ago, 17-Apr-99, to lugnet.robotics.rcx.legos)

10 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