GetEOPD
Reads the current value of the HiTechnic EOPD sensor
Contents
Syntax
[calcedDist rawVal] = GetEOPD(port)
[calcedDist rawVal] = GetEOPD(port, handle)
Description
This function returns both a calculated distance and the measured raw value from the HiTechnic EOPD sensor.
The given port number specifies the connection port. The value port can be addressed by the symbolic constants SENSOR_1, SENSOR_2, SENSOR_3 and SENSOR_4 analog to the labeling on the NXT Brick.
Returned raw values are always between 0 and 1023 and indicate reflected light intensity. In 'SHORT' range mode, the values are usually very low, i.e. < 100 or < 200. For increased sensitivity ('LONG' range mode), they can also be higher. This mostly depends on the target surface material.
The rawVal output argument is always valid. calcedDist however will only have a meaningful value if the sensor is correctly calibrated using CalibrateEOPD. Otherwise values might not make sense or are NaN. If rawVal is 0, calcedDist will be set to Inf.
More on how to interpret the EOPD sensor values, and a detailed explanation of the calibration formula can be found here: http://www.hitechnic.com/blog/eopd-sensor/eopd-how-to-measure-distance/#more-178
The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call COM_SetDefaultNXT to set one).
Example
port = SENSOR_2; OpenEOPD(port, 'SHORT'); % set calibration matrix calibMatrix = [3 91; 9 19]; CalibrateEOPD(port, 'SETMATRIX', calibMatrix); % now the sensor can be used [dist raw] = GetEOPD(port); % clean up, as usual. LED stays on anyway CloseSensor(port);
See also
OpenEOPD, CalibrateEOPD, CloseSensor, NXT_SetInputMode, NXT_GetInputValues,
Signature
- Author: Linus Atorf (see AUTHORS)
- Date: 2010/09/17
- Copyright: 2007-2010, RWTH Aachen University