RCX: Sensors

Provides processes and constants for manipulating sensors connected to the RCX's three input ports.

Index

Declarations

Data type SENSOR.TYPE

DATA TYPE SENSOR.TYPE

Used for the 4 main types of LEGO sensors to initialise the read mode and activity appropriately, along with a 'raw' unconfigured mode.

Group SENSOR.TYPE

Different sensor types that may be connected to the input ports of the RCX.

Constant SENSOR.RAW

VAL SENSOR.TYPE SENSOR.RAW

Raw sensor, useful for custom RCX sensors or where the mode of the sensor being inferred is not desirable.

Constant SENSOR.TOUCH

VAL SENSOR.TYPE SENSOR.TOUCH

Touch (bump) sensor.

Constant SENSOR.TEMP

VAL SENSOR.TYPE SENSOR.TEMP

Temperature sensor.

Constant SENSOR.LIGHT

VAL SENSOR.TYPE SENSOR.LIGHT

Light sensor.

Constant SENSOR.ROTATION

VAL SENSOR.TYPE SENSOR.ROTATION

Rotation sensor.

Data type SENSOR.MODE

DATA TYPE SENSOR.MODE

Sensor mode Defines the kind of values received from the sensor.

Group SENSOR.MODE

The sensor read mode to be used with a specific sensor.

Constant SENSOR.MODE.RAW

VAL SENSOR.MODE SENSOR.MODE.RAW

Raw values.

Constant SENSOR.MODE.BOOL

VAL SENSOR.MODE SENSOR.MODE.BOOL

Boolean

Constant SENSOR.MODE.EDGE

VAL SENSOR.MODE SENSOR.MODE.EDGE

Edge, every transition.

Constant SENSOR.MODE.PULSE

VAL SENSOR.MODE SENSOR.MODE.PULSE

Pulse, only on -ve transition.

Constant SENSOR.MODE.PERCENT

VAL SENSOR.MODE SENSOR.MODE.PERCENT

Percentage

Constant SENSOR.MODE.CELSIUS

VAL SENSOR.MODE SENSOR.MODE.CELSIUS

Degrees Celsius.

Constant SENSOR.MODE.FARENHEIT

VAL SENSOR.MODE SENSOR.MODE.FARENHEIT

Degrees Farenheit.

Constant SENSOR.MODE.ANGLE

VAL SENSOR.MODE SENSOR.MODE.ANGLE

Angle (rotation)

Group SENSOR

Sensor numbers

Constant SENSOR.1

VAL INT SENSOR.1

Sensor port 1.

Constant SENSOR.2

VAL INT SENSOR.2

Sensor port 2.

Constant SENSOR.3

VAL INT SENSOR.3

Sensor port 3.

Constant sensor.addr

VAL [3]INT sensor.addr

Sensor memory addresses

Process sensor.active

PROC sensor.active (VAL INT sensor.num)

Set the sensor to 'active' mode, with power (sensor dependant).

Parameters:

VAL INT sensor.num Number of the sensor port to set passive.

Process sensor.passive

PROC sensor.passive (VAL INT sensor.num)

Set the sensor to 'passive' mode, without power (sensor dependant).

Parameters:

VAL INT sensor.num Number of the sensor port to set active.

Group SENSOR

Types for sensor value readings.

Data type SENSOR.VAL

DATA TYPE SENSOR.VAL

Sensor values formatted as per the 'mode'.

Data type SENSOR.RAW

DATA TYPE SENSOR.RAW

Raw values

Data type SENSOR.BOOL

DATA TYPE SENSOR.BOOL

Boolean

Record SENSOR.T

DATA TYPE SENSOR.T

A sensor reading.

Variable type

SENSOR.TYPE type

Type of the sensor

Variable mode

SENSOR.MODE mode

Read mode (see SENSOR.MODE constants)

Variable raw

SENSOR.VAL raw

Raw sensor value.

Variable value

SENSOR.VAL value

Value according to read mode.

Variable boolean

SENSOR.BOOL boolean

Boolean value.

Process read.sensor

PROC read.sensor (VAL INT num, RESULT SENSOR.T reading)

Direct read value from a sensor This process is used for low-level reading, for normal use use the sensor process.

Parameters:

VAL INT num The sensor port number
RESULT SENSOR.T reading The type and mode of the sensor, returned with raw, value and boolean completed.

Process sensor

PROC sensor (VAL INT num, VAL INT delay, VAL SENSOR.TYPE type, VAL SENSOR.MODE mode, CHAN SENSOR.VAL out!)

Read from a sensor to a channel This process will read values from the sensor at the time interval specified in the delay to the output channel.

Parameters:

VAL INT num The sensor port number
VAL INT delay The delay between reads from the sensor.
VAL SENSOR.TYPE type The sensor type
VAL SENSOR.MODE mode The value read mode of the sensor.
CHAN SENSOR.VAL out The channel that outputs are written to.