Sensor types and modes
[Input module constants]

Constants that are used for defining sensor types and modes. More...


 NBC sensor type constants

Use sensor type constants to configure an input port for a specific type of sensor.

 NBC sensor mode constants

Use sensor mode constants to configure an input port for the desired sensor mode.

Detailed Description

Constants that are used for defining sensor types and modes.

The sensor ports on the NXT are capable of interfacing to a variety of different sensors. It is up to the program to tell the NXT what kind of sensor is attached to each port. Calling SetSensorType configures a sensor's type. There are 16 sensor types, each corresponding to a specific type of LEGO RCX or NXT sensor. Two of these types are for NXT I2C digital sensors, either 9V powered or unpowered, and a third is used to configure port IN_4 as a high-speed RS-485 serial port. A seventeenth type (IN_TYPE_CUSTOM) is for use with custom analog sensors. And an eighteenth type (IN_TYPE_NO_SENSOR) is used to indicate that no sensor has been configured, effectively turning off the specified port.

In general, a program should configure the type to match the actual sensor. If a sensor port is configured as the wrong type, the NXT may not be able to read it accurately. Use the NBC sensor type constants.

The NXT allows a sensor to be configured in different modes. The sensor mode determines how a sensor's raw value is processed. Some modes only make sense for certain types of sensors, for example IN_MODE_ANGLESTEP is useful only with rotation sensors. Call SetSensorMode to set the sensor mode. The possible modes are shown below. Use the NBC sensor mode constants.

The NXT provides a boolean conversion for all sensors - not just touch sensors. This boolean conversion is normally based on preset thresholds for the raw value. A "low" value (less than 460) is a boolean value of 1. A high value (greater than 562) is a boolean value of 0. This conversion can be modified: a slope value between 0 and 31 may be added to a sensor's mode when calling SetSensorMode. If the sensor's value changes more than the slope value during a certain time (3ms), then the sensor's boolean state will change. This allows the boolean state to reflect rapid changes in the raw value. A rapid increase will result in a boolean value of 0, a rapid decrease is a boolean value of 1.

Even when a sensor is configured for some other mode (i.e. IN_MODE_PCTFULLSCALE), the boolean conversion will still be carried out.

Generated by  doxygen 1.6.2