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 / 156
155  |  157
Subject: 
Re: Rotation sensor bug found
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Mon, 19 Apr 1999 04:43:43 GMT
Viewed: 
1045 times
  
In lugnet.robotics.rcx.legos, Lou Sortman writes:
Mario Ferrari wrote:

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.

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 high-end value of 1023U<<6-RANGE_SIZE and
the mininum is returned.  In most cases, you get out exactly what you
put in.

OK. I was wrong. I should have better analyzed your code... This definitively
prove how long still is my way to get my hands on C :)

BTW, I wrote an e-mail to Markus but got it bounced back.

Mario



Message is in Reply To:
  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 (...) (25 years ago, 19-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
    

Custom Search

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