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 / 330
329  |  331
Subject: 
Re: Rotation sensors?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 20 Jul 1999 17:41:12 GMT
Viewed: 
1099 times
  
Yep, others have reported having these problems.  Here's a fix I came up
with, but has also only been tested on my system.  There have been
reports that the existing code works for some, and not for others, so
you may need to customize this.

just replace the existing definitions in direct-sensor.c

hope this helps

mark

! A/D values for the rotation sensor states
//
#define STATE_0_VALUE (0x0f000)
#define STATE_1_VALUE (0x0d000)
#define STATE_2_VALUE (0x07000)
#define STATE_3_VALUE (0x0a000)

//! rotation sensor range matching function
//
#define IN_RANGE( val ) ((raw & 0x0f000) == val)

void ds_rotation_set(unsigned* const sensor,int pos) {
  unsigned channel=(unsigned) (sensor-&AD_A);
  unsigned raw = (*sensor);
  RotationState state;

    if(sensor>=&AD_A && sensor<=&AD_C) {    // catch range violations


      //determine initial position
      if(IN_RANGE(STATE_0_VALUE))
        state=STATE_0;
      if(IN_RANGE(STATE_1_VALUE))
        state=STATE_1;
      if(IN_RANGE(STATE_2_VALUE))
        state=STATE_2;
      if(IN_RANGE(STATE_3_VALUE))
        state=STATE_3;


    rotation_state[channel]=state;
    ds_rotations[channel]=pos;            // reset counter
    }
}


Jonathan Knudsen wrote:

Hello,

Rotation sensors appear to be broken in the 990330
snapshot. Here's part of the code I'm using:

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

  while (!PRESSED(button_state(), BUTTON_VIEW)) {
    lcd_int(ROTATION_3);
    lcd_refresh();
    msleep(20);
  }

Is this a known problem?

Thanks,
Jonathan



Message has 2 Replies:
  Re: Rotation sensors?
 
(...) [snip...] If you want to have more info about the sotry of this problem search this newsgruop for "rotation sensor bug found". Mario (URL) (25 years ago, 21-Jul-99, to lugnet.robotics.rcx.legos)
  Re: Rotation sensors?
 
Thanks Mark, those changes got rotation-sensor.c working for me. (...) (25 years ago, 22-Jul-99, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Rotation sensors?
 
Hello, Rotation sensors appear to be broken in the 990330 snapshot. Here's part of the code I'm using: ds_active(&SENSOR_3); ds_rotation_on(&SENSOR_3); ds_rotation_set(&SENSOR_3, 0); while (!PRESSED(button_state(), BUTTON_VIEW)) { (...) (25 years ago, 20-Jul-99, 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