Changeset 296
- Timestamp:
- 09/25/08 13:47:33 (5 years ago)
- Location:
- branches/atorf/RWTHMindstormsNXT
- Files:
-
- 2 modified
-
GetUltrasonic.m (modified) (3 diffs)
-
OpenUltrasonic.m (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/atorf/RWTHMindstormsNXT/GetUltrasonic.m
r275 r296 1 function [DistanceCM] = GetUltrasonic( f_sensorport)1 function [DistanceCM] = GetUltrasonic(port) 2 2 % Reads the current value of the NXT ultrasonic sensor 3 3 % … … 45 45 46 46 % also accept strings as input 47 if ischar( f_sensorport)48 f_sensorport = str2double(f_sensorport);47 if ischar(port) 48 port = str2double(port); 49 49 end%if 50 50 … … 56 56 57 57 % retrieve 1 byte from device 0x02, register 0x42 58 data = COM_ReadI2C( f_sensorport, 1, uint8(2), uint8(66));58 data = COM_ReadI2C(port, 1, uint8(2), uint8(66)); 59 59 60 60 if isempty(data) -
branches/atorf/RWTHMindstormsNXT/OpenUltrasonic.m
r291 r296 1 function [] = OpenUltrasonic( f_sensorport, varargin)1 function [] = OpenUltrasonic(port, varargin) 2 2 % Initializes and sets the mode of the NXT ultrasonic sensor 3 3 % … … 65 65 %% Parameter check 66 66 % also accept strings as input 67 if ischar( f_sensorport)68 f_sensorport = str2double(f_sensorport);67 if ischar(port) 68 port = str2double(port); 69 69 end%if 70 70 … … 78 78 79 79 80 NXT_SetInputMode( f_sensorport, 'LOWSPEED_9V', 'RAWMODE', 'dontreply');80 NXT_SetInputMode(port, 'LOWSPEED_9V', 'RAWMODE', 'dontreply'); 81 81 82 82 … … 94 94 I2Cdata(3) = hex2dec('01'); % SINGLE_SHOT 95 95 96 NXT_LSWrite( f_sensorport, RequestLen, I2Cdata, 'dontreply');96 NXT_LSWrite(port, RequestLen, I2Cdata, 'dontreply'); 97 97 98 98 else … … 104 104 I2Cdata(3) = hex2dec('02'); % CONTINUOUS_MEASUREMENT 105 105 106 NXT_LSWrite( f_sensorport, RequestLen, I2Cdata, 'dontreply');106 NXT_LSWrite(port, RequestLen, I2Cdata, 'dontreply'); 107 107 end%if 108 108 … … 114 114 % the following command sequence is not clearly documented but was 115 115 % found to work well! 116 NXT_LSGetStatus( f_sensorport); % flush out data with Poll116 NXT_LSGetStatus(port); % flush out data with Poll 117 117 % we request the status-byte so that it doesn't get checked. 118 118 % errors that can occur here are: … … 120 120 %Packet (reply to LSREAD) contains error message 224: "Specified 121 121 %channel/connection not configured or busy" 122 [a b c] = NXT_LSRead( f_sensorport); % flush out data with Poll?122 [a b c] = NXT_LSRead(port); % flush out data with Poll? 123 123 124 124 end%function
