Subject:
|
Re: Rotation sensor bug found
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Sun, 18 Apr 1999 07:30:22 GMT
|
Viewed:
|
1386 times
|
| |
| |
Lou, thank you for your reply.
> 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)
This should work.
> 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 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 ) ) { // Original code
if ( raw > ( STATE_0_VALUE - RANGE_SIZE) ) { // Mario
and the defines with my central values:
#define RANGE_SIZE (40U<<6)
#define STATE_0_VALUE (1023U<<6)
#define STATE_1_VALUE (857U<<6)
#define STATE_2_VALUE (444U<<6)
#define STATE_3_VALUE (658U<<6)
Everything worrks fine! The demo/rotation-sensor program performs well.
I understand Markus is very deep in his studies at present moment. Anyway I'll
send him a message then he will decide how to modify the code to keep it as
general as possible.
> > 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.
We might ask in the robotics newsgroup to all the owners of rotation sensors
what their sensor actually read. So to fine tune both the values and the range.
Mario
|
|
Message has 1 Reply: | | Re: Rotation sensor bug found
|
| (...) It wouldn't, though. First it gets the maximum of the given value or RANGE_SIZE. That is done to prevent a similar overflow at the low end, even though, with current values, that won't happen. Then, that value is compared against the safe (...) (26 years ago, 19-Apr-99, to lugnet.robotics.rcx.legos)
|
Message is in Reply To:
| | Re: Rotation sensor bug found (maybe!)
|
| (...) 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) ( \ (...) (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
|
|
|
|