Changeset 293
- Timestamp:
- 09/25/08 09:32:43 (5 years ago)
- Location:
- branches/atorf/RWTHMindstormsNXT
- Files:
-
- 3 modified
-
COM_ReadI2C.m (modified) (1 diff)
-
USGetSnapshotResults.m (modified) (3 diffs)
-
USMakeSnapshot.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/atorf/RWTHMindstormsNXT/COM_ReadI2C.m
r288 r293 28 28 % Default value is 0x02 (2 in decimal). Finally, |RegisterAddress| is 29 29 % the address where you want to read data from. For the ultrasound and 30 % many other sensors, the "data section" starts at 0x 24(66 in decimal).30 % many other sensors, the "data section" starts at 0x42 (66 in decimal). 31 31 % 32 32 % As last argument you can pass a valid NXT-handle to be used from this -
branches/atorf/RWTHMindstormsNXT/USGetSnapshotResults.m
r275 r293 1 function snaps = USGetSnapshotResults( f_sensorport)1 function snaps = USGetSnapshotResults(port) 2 2 % Retrieves up to eight echos (distances) stored inside the US sensor 3 3 % … … 65 65 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 … … 75 75 %I2Cdata(1) = hex2dec('02'); % the default I2C address for a port. 76 76 %I2Cdata(2) = hex2dec('42'); % READ! 77 %NXT_LSWrite( f_sensorport, RequestLen, I2Cdata, 'dontreply');77 %NXT_LSWrite(port, RequestLen, I2Cdata, 'dontreply'); 78 78 79 79 % retrieve 8 bytes from device 0x02, register 0x42 80 data = COM_ReadI2C( f_sensorport, 8, uint8(2), uint8(66));80 data = COM_ReadI2C(port, 8, uint8(2), uint8(66)); 81 81 82 82 if ~isempty(data) -
branches/atorf/RWTHMindstormsNXT/USMakeSnapshot.m
r153 r293 1 function USMakeSnapshot( f_sensorport)1 function USMakeSnapshot(port) 2 2 % Causes the ultrasonic sensor to send one snapshot ("ping") and record the echos 3 3 % … … 54 54 55 55 % also accept strings as input 56 if ischar( f_sensorport)57 f_sensorport = str2double(f_sensorport);56 if ischar(port) 57 port = str2double(port); 58 58 end%if 59 59 … … 71 71 I2Cdata(3) = hex2dec('01'); % SINGLE_SHOT 72 72 73 NXT_LSWrite( f_sensorport, RequestLen, I2Cdata, 'dontreply');73 NXT_LSWrite(port, RequestLen, I2Cdata, 'dontreply'); 74 74 75 75
