-
Notifications
You must be signed in to change notification settings - Fork 2
/
simulation.m
64 lines (48 loc) · 1.72 KB
/
simulation.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
MAX_SPEED = 40e3;
stepper_resolution = 1.8/16.0;
steps_in_angle = round(1/stepper_resolution);
% observe steps drift with more resolution
64/1.8
32/1.8
16/1.8
4/1.8
2/1.8
1/1.8
% simulate deg/sec
desired = [0:400];
stepper_resolution = 1.8/4;
real = MAX_SPEED.*stepper_resolution./round(MAX_SPEED./(desired./stepper_resolution));
figure(1);
plot(desired, real, desired,desired);
title('Actual vs Desired speed with 1/4 micro-stepping');
legend({'actual','desired'},'Location','southeast');
ylabel('Speed in Degrees/sec') ;
stepper_resolution = 1.8/16;
real = MAX_SPEED.*stepper_resolution./round(MAX_SPEED./(desired./stepper_resolution));
figure(2);
plot(desired, real, desired,desired);
title('Actual vs Desired speed with 1/16 micro-stepping');
legend({'actual','desired'},'Location','southeast');
ylabel('Speed in Degrees/sec') ;
stepper_resolution = 1.8/32;
real = MAX_SPEED.*stepper_resolution./round(MAX_SPEED./(desired./stepper_resolution));
figure(3)
plot(desired, real, desired,desired);
title('Actual vs Desired speed with 1/32 micro-stepping');
legend({'actual','desired'},'Location','southeast');
ylabel('Speed in Degrees/sec') ;
stepper_resolution = 1.8/64;
real = MAX_SPEED.*stepper_resolution./round(MAX_SPEED./(desired./stepper_resolution));
figure(4)
plot(desired, real, desired,desired);
title('Actual vs Desired speed with 1/64 micro-stepping');
legend({'actual','desired'},'Location','southeast');
ylabel('Speed in Degrees/sec') ;
% this simulates steps/sec instead of dergrees/sec
desired = [0:3000];
real = MAX_SPEED./round(MAX_SPEED./desired);
figure(5)
plot(desired, real, desired, desired)
title('Actual vs Desired speed in Steps/sec ');
legend({'actual','desired'},'Location','southeast');
ylabel('Speed in Step/sec') ;