From 1daf677154f501b819e4473f0174f3a1b4cbfcc0 Mon Sep 17 00:00:00 2001
From: Tim Stadtmann <tim.stadtmann@rwth-aachen.de>
Date: Tue, 16 Aug 2016 14:56:09 +0200
Subject: [PATCH] Add and fix examples

---
 examples/distancePlotting.m | 39 +++++++++++++++++++++++++++++++++++++
 examples/testConnSpeed.m    |  2 +-
 examples/testToolbox.m      |  7 ++++---
 3 files changed, 44 insertions(+), 4 deletions(-)
 create mode 100644 examples/distancePlotting.m

diff --git a/examples/distancePlotting.m b/examples/distancePlotting.m
new file mode 100644
index 0000000..416e8a5
--- /dev/null
+++ b/examples/distancePlotting.m
@@ -0,0 +1,39 @@
+b = EV3('debug', 0);
+b.connect('usb');
+
+s = b.sensor4;
+if s.type ~= DeviceType.UltraSonic
+    error('Connect US-sensor to port 4');
+end
+s.mode = DeviceMode.UltraSonic.DistCM;
+
+readings = [];
+time = [];
+
+tic
+hold on;
+while toc < 20
+    readings = [readings, s.value];
+    time = [time, toc];
+%     plot(time, readings)
+%     drawnow
+end
+hold off;
+
+fprintf('\nSensor readings per sec: %f\n', length(readings)/time(length(time)));
+
+b.disconnect();
+
+%% Results
+%   Bluetooth
+% debug=2, sensor-typ-kontrolle an: 7.5 Readings/sec   % worst case
+% debug=1, sensor-typ-kontrolle an: 9.3 readings/sec   
+% debug=0, sensor-typ-kontrolle an: 9.6 readings/sec 
+% debug=0, sensor-typ-kontrolle aus: 16.5 readings/sec 
+% debug=0, sensor-typ-kontrolle aus, plotting aus: 22.5 readings/sec   % best case
+% debug=0, sensor-typ-kontrolle an, plotting aus: 10
+%   USB
+% debug=2, sensor-typ-kontrolle an: 16.5 readings/sec   % worst case 
+% debug=0, sensor-typ-kontrolle aus, plotting aus: 100 readings/sec   % best case
+%
+%       -> NOTIZ AN MICH: TYP KONTROLLE ÜBERDENKEN
diff --git a/examples/testConnSpeed.m b/examples/testConnSpeed.m
index c2e38ef..c0a3630 100644
--- a/examples/testConnSpeed.m
+++ b/examples/testConnSpeed.m
@@ -19,7 +19,7 @@ function testConnSpeed(ioType, serPort, it, withResponse)
     end
     
     m = b.motorB;
-    m.setProperties('power', 10, 'tachoLimitMode', 'Time', 'tachoLimit', 15000);
+    m.setProperties('power', 10, 'limitMode', 'Time', 'limitValue', 15000);
     m.resetTachoCount();
     
     if withResponse
diff --git a/examples/testToolbox.m b/examples/testToolbox.m
index 003cfad..a04346e 100644
--- a/examples/testToolbox.m
+++ b/examples/testToolbox.m
@@ -5,8 +5,8 @@ b.sensor4.mode = DeviceMode.UltraSonic.DistCM;
 tic;
 t = 0;
 
-b.motorA.setProperties('power', 50, 'speedRegulation', 'on', 'smoothStart', 10, 'tachoLimitMode', ...
-    'Time', 'tachoLimit', 3000);
+b.motorA.setProperties('power', 50, 'speedRegulation', 'on', 'smoothStart', 10, 'limitMode', ...
+    'Time', 'limitValue', 3000);
 b.motorA.start();
 
 pause(0.5);
@@ -17,12 +17,13 @@ while b.motorA.isRunning()
 end
 
 b.motorB.power = 50;
-b.motorB.tachoLimit = 4*360;
+b.motorB.limitValue = 4*360;
 b.motorB.start();
 b.motorB.waitFor();
 b.beep();
 
 b.motorA.speedRegulation = false;
+pause(1);
 b.motorA.syncedStart(b.motorB, 'turnRatio', 200);
 b.motorA.waitFor();
 
-- 
GitLab