-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.h
More file actions
138 lines (114 loc) · 4.26 KB
/
config.h
File metadata and controls
138 lines (114 loc) · 4.26 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef CONFIG_H
#define CONFIG_H
#include "console_helper_functions.h"
#include "sauter_helper_functions.h"
#include "motor_helper_functions.h"
// Sauter config data
byte pin_direction = 12;
byte pin_step = 13;
// GeckoDrive microstep data
float angle_per_step = 0.18; // 1.8 divided by 10, microstepping
int steps_per_rev = (int) 360.0/angle_per_step;
float millimeters_per_rev = 54.0;
float millimeters_per_step = millimeters_per_rev/steps_per_rev;
// Force limits
float FORCE_MAX_ABSOLUTE = 20.;
float FORCE_MAX = 15.0;
float FORCE_LIM = 8.0;
float FORCE_ZERO = 1.0;
float X_MIN = 5.0;
// Other options
int n_force_measures = 1;
int steps_initial = 3;
int steps_test = 1;
int steps_final = 3;
int pulse_period = 10; // milliseconds
float pulse_dutycycle = 0.20;
bool wait_between_stages = false;
void change_config(){
char strBuff[2000];
int option = 0;
while(true){
Serial.println("----------------------------------------------------");
Serial.println("Options:");
Serial.print("1) Force max (for security) = "); Serial.println(FORCE_MAX);
Serial.print("2) Force limit (define when to start and stop tests) = "); Serial.println(FORCE_LIM);
Serial.print("3) Force stop (close to zero, to know when to stop to rest) = "); Serial.println(FORCE_ZERO);
Serial.print("4) Length min (minimal displacement before stopping if force = Force limit) = "); Serial.println(X_MIN);
Serial.print("5) Number of measures (force measure will be a mean of multiple measures) = "); Serial.println(n_force_measures);
Serial.print("6) Initial steps (number of steps per loop when finding the start of test) = "); Serial.println(steps_initial);
Serial.print("7) Test steps (number of steps per loop while doing tests) = "); Serial.println(steps_test);
Serial.print("8) Final steps (number of steps per loop when finding the rest position at the end) = "); Serial.println(steps_final);
Serial.print("9) Stepper motor pulse period (in milliseconds) = "); Serial.println(pulse_period);
Serial.print("10) Stepper motor pulse dutycycle (from 0 to 100) = "); Serial.println((int)100*pulse_dutycycle);
Serial.print("11) Wait between stages? (0 for false, 1 for true) = "); Serial.println(wait_between_stages? 1 : 0);
Serial.println("12) Quit to main menu");
Serial.println("----------------------------------------------------");
Serial.print("Choose option: ");
option = get_int();
Serial.println(option);
if (option == 12) break;
else if (option < 0 or option > 13)
Serial.println("Invalid option");
else {
Serial.print("Enter new value: ");
float value = get_float();
Serial.println(value);
switch (option) {
case 1:
if (value > 0 and value < FORCE_MAX_ABSOLUTE)
FORCE_MAX = value;
else
{Serial.print("Invalid value, must be between 0 and "); Serial.println(FORCE_MAX_ABSOLUTE);}
break;
case 2:
if (value > 0 and value < FORCE_MAX_ABSOLUTE)
FORCE_LIM = value;
else
{Serial.print("Invalid value, must be between 0 and "); Serial.println(FORCE_MAX_ABSOLUTE);}
break;
case 3:
if (value > 0 and value < FORCE_MAX_ABSOLUTE)
FORCE_ZERO = value;
else
{Serial.print("Invalid value, must be between 0 and "); Serial.println(FORCE_MAX_ABSOLUTE);}
break;
case 4:
X_MIN = value;
break;
case 5:
n_force_measures = (int) value;
break;
case 6:
steps_initial = (int) value;
break;
case 7:
steps_test = (int) value;
break;
case 8:
steps_final = (int) value;
break;
case 9:
pulse_period = value;
break;
case 10:
if (value > 0 and value < 100)
pulse_dutycycle = value/100;
else
Serial.println("Invalid value");
break;
case 11:
if (value == 0)
wait_between_stages = false;
else if (value == 1)
wait_between_stages = true;
else
Serial.println("Invalid value");
break;
default:
Serial.println("Invalid option");
}
}
}
}
#endif /* CONFIG_H */