To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.javaOpen lugnet.robotics.rcx.java in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / Java / 130
129  |  131
Subject: 
Light sensor initialization time?
Newsgroups: 
lugnet.robotics.rcx.java
Date: 
Thu, 27 Sep 2001 20:28:19 GMT
Viewed: 
2577 times
  
Hellow!

Here a little fact: the first reading on the light sensor
_just_ after you have activated it is too high. It seems
like one has to wait a little after activating the sensor.
The following program shows it rather nicely:
____START OF CODE____
import josx.platform.rcx.*;

public final class WeirdLight implements SensorConstants {

    public static void main( String[] args ) {
Sensor.S2.setTypeAndMode( SENSOR_TYPE_LIGHT,
SENSOR_MODE_PCT );
  Sensor.S2.activate();

// Uncomment the following to make it behave as expected
//try { Thread.sleep( 500 ); } catch ( Exception e ) {}

int val = Sensor.S2.readValue();

LCD.showNumber( val );
try { Thread.sleep( 1500 ); } catch ( Exception e ) {}

  Sensor.S2.passivate();
    } // main
} // WeirdLight
____END OF CODE____

If you include the first sleep command the value is as
expected.
When I ran the program I got the following results: 79-80
_without_ the sleep, and 33-35 (black tape) with the sleep.

Regards,
Martin E. Nielsen



Message has 1 Reply:
  Re: Light sensor initialization time?
 
I suspect this is due to the fact that the first sample from the sensor is actually being obtained while the sensor's reservoir capacitor is still charging. Why don't you try a simple test, actually two tests; 1. Initialise as passive sensor Wait 1 (...) (23 years ago, 27-Sep-01, to lugnet.robotics.rcx.java)

3 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