Skip to content
Snippets Groups Projects
Commit 44785c76 authored by Tim Stadtmann's avatar Tim Stadtmann
Browse files

Update example-scripts

parent f83ac476
Branches
Tags
No related merge requests found
b = EV3('debug', 2);
b.connect('bt', 'serPort', '/dev/rfcomm0');
m = b.motorA;
sl = b.motorB;
m.tachoLimit = 1000;
m.brakeMode = 'Coast';
counts = [];
power = [60, 65, 70, 75, 80, 85, 90, 95, 100];
for i=1:length(power)
m.resetTachoCount;
m.reset;
m.power = power(i);
m.syncedStart(sl);
m.waitFor();
counts = [counts, m.tachoCount];
b.beep;
b.debug = false;
end
\ No newline at end of file
% This script has two purposes:
% * Plotting distance to ultrasonic sensor (for fun and as an example)
% * Analyse runtime of sensor readings (comment out marked part of code to get useful
% results)
% Necessary:
% * USB-connection
% * UltraSonic-Sensor at Port 4
clear all
b = EV3('debug', 0);
b.connect('usb');
......@@ -15,8 +24,11 @@ hold on;
while toc < 20
readings = [readings, s.value];
time = [time, toc];
% plot(time, readings)
% drawnow
%% Plotting
% Should be commented out if you analyse latency of sensor readings
plot(time, readings)
drawnow
end
hold off;
......@@ -24,6 +36,8 @@ fprintf('\nSensor readings per sec: %f\n', length(readings)/time(length(time)));
b.disconnect();
clear all
%% Results
% Bluetooth
% debug=2, sensor-typ-kontrolle an: 7.5 Readings/sec % worst case
......
% In order to generally examine the runtime-distribution, start this script
% with the 'Run and Time'-Button in MATLAB.
% Necessary:
% * USB-connection
% * Motor at Port A
clear all
b = EV3();
b.connect('usb');
ma = b.motorA;
ma.setProperties('Power', 50, 'LimitValue', 2000);
t = 0;
flag = 0;
tacho = 0;
tic;
ma.start();
while(toc < 7)
flag = [flag, ma.isRunning];
tacho = [tacho, ma.tachoCount];
end
clear all
\ No newline at end of file
b = EV3();
b.connect('bt', 'serPort', '/dev/rfcomm0');
b.sensor3.mode = DeviceMode.Color.Col;
b.sensor4.mode = DeviceMode.UltraSonic.DistCM;
tic;
t = 0;
b.motorA.setProperties('power', 50, 'speedRegulation', 'on', 'smoothStart', 10, 'limitMode', ...
'Time', 'limitValue', 3000);
b.motorA.start();
pause(0.5);
while b.motorA.isRunning()
b.sensor3.value
b.sensor4.value
b.motorA.tachoCount
end
b.motorB.power = 50;
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();
for i=1:10
b.sensor3.value
b.motorA.tachoCount
b.sensor3.reset
b.motorA.tachoCount
end
b.beep
b.beep
b.disconnect
b.delete
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment