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 / 154
153  |  155
Subject: 
Re: Rotation sensor bug found
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Mon, 19 Apr 1999 02:04:08 GMT
Viewed: 
1074 times
  
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.



Message has 1 Reply:
  Re: Rotation sensor bug found
 
(...) 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 (25 years ago, 19-Apr-99, to lugnet.robotics.rcx.legos)

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