-
Notifications
You must be signed in to change notification settings - Fork 0
/
CEB Press Test - Selection Switching
211 lines (175 loc) · 6.8 KB
/
CEB Press Test - Selection Switching
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/* Open Source Ecology CEB Press v19.01 with Arduino Uno or Mega as controller of choice.
CC-BY-SA, GPLv3, and OSE License for Distributive Economics
Use Mega to keep consistency with OSE D3D 3D Printer to minimize GVCS part count.
Switches FET's HIGH/LOW to control two hydraulic solenoids,
measures piston motion time relative to pressure sensor trigger,
and repeats cycle while auto calibrating timing from previous cycles and startup positions.
Extension time is measured. Orientation of machine is such that cylinder retracts to the right.
See sequence at http://bit.ly/2Hnuk6F
Faults should be self-resolving based on pressing sequence: pressure trigger reverses direction
at fault point and no block results. There is one likely place for faults to occur: soil load into chamber.
Uses HiLetgo Relay Shield 5V 4 Channel for Arduino:
https://www.amazon.com/HiLetgo-Relay-Shield-Channel-Arduino/dp/B07F7Y55Z7/ref=sr_1_2?ie=UTF8&qid=1547696929&sr=8-2&keywords=hiletgo+relay+shield
Note pins must be trimmed flat under Relay 1 connector and must be insulated to prevent shorts.
Relay 1 is controlled by digital pin 7
Relay 2 is controlled by digital pin 6
Relay 3 is controlled by digital pin 5
Relay 4 is controlled by digital pin 4
A high written to a pin turns the relay ON
A low written to a pin turns the relay OFF
Contributions by:
Abe Anderson
http://opensourceecology.org/wiki/AbeAnd_Log
Marcin Jakubowski
http://opensourceecology.org/wiki/Marcin_Log
Unfamiliar with code structures? See https://www.arduino.cc/en/Reference/HomePage
*/
//defines to make it easier for non-coders to make adjustments for troubleshooting and custom changes
#define SOLENOID_UP 7 //Extension. See pin mapping above.
#define SOLENOID_DOWN 6 //swap these pin numbers for wire inversion
#define SOLENOID_LEFT 5 //Extension.
#define SOLENOID_RIGHT 4 //swap these pin numbers for wire inversion
#define PRESSURE_SENSOR 13 //Needs pins adjacent to get 8-pin dupont housing for both selector and sensor
#define SELECTOR_QUARTER 12 //Second 8-pin Dupont housing for the solenoids
//Reset is the shutdown/initialization procedure. All procedures are selected by
#define SELECTOR_HALF 11 //the WHILE function. QUARTER to FULL refers to brick thickness.
#define SELECTOR_THREEQUARTER 10 //Secondary cylinder timing is measured only.
#define SELECTOR_FULL 9 //Primary cylinder thickness setting is based on secondary cylinder motion.
#define PRESSURE_SENSOR_DEBOUNCE 20 //milliseconds to delay for pressure sensor debounce
#define DELAY 500 // 1/2 sec extra to compress brick via main Cyl (default 500ms)
//custom function declarations
bool checkPressure(); //function to read pressure sensor
bool resetSelected(); //
//bool quarterSelected(); //
bool halfSelected(); //
bool threequarterSelected(); //
bool fullSelected(); //
//Global variables
unsigned long drawerExtTime = 0; //Time measurement for calibrating motion.
unsigned long previousMillis = 0; //time measurement for expansion
void setup() {
//initialize pin I/O Inputs and turn everything off to avoid startup glitches
pinMode(PRESSURE_SENSOR, INPUT_PULLUP);
pinMode(SELECTOR_HALF, INPUT_PULLUP);
pinMode(SELECTOR_THREEQUARTER, INPUT_PULLUP);
pinMode(SELECTOR_FULL, INPUT_PULLUP);
pinMode(SOLENOID_RIGHT, OUTPUT);
digitalWrite(SOLENOID_RIGHT, LOW);
pinMode(SOLENOID_LEFT, OUTPUT);
digitalWrite(SOLENOID_LEFT, LOW);
pinMode(SOLENOID_DOWN, OUTPUT);
digitalWrite(SOLENOID_DOWN, LOW);
pinMode(SOLENOID_UP, OUTPUT);
digitalWrite(SOLENOID_UP, LOW);
}
void loop() {
//Step 0 Reset/Initialize - Brick pressing sequence - http://bit.ly/2Hnuk6F
while (fullSelected() == true) { // happens when 8 is selected
digitalWrite(SOLENOID_UP, HIGH);
delay(1000);
digitalWrite(SOLENOID_UP, LOW);
delay(1000);
digitalWrite(SOLENOID_DOWN, HIGH);
delay(1000);
digitalWrite(SOLENOID_DOWN, LOW);
delay(1000);
digitalWrite(SOLENOID_LEFT, HIGH);
delay(1000);
digitalWrite(SOLENOID_LEFT, LOW);
delay(1000);
digitalWrite(SOLENOID_RIGHT, HIGH);
delay(1000);
digitalWrite(SOLENOID_RIGHT, LOW);
delay(1000);
if (checkPressure() == false) {
digitalWrite(SOLENOID_UP, HIGH);
delay(2000);
}
}
while (threequarterSelected() == true) { //happens when 9 is selected
digitalWrite(SOLENOID_UP, HIGH);
delay(500);
digitalWrite(SOLENOID_UP, LOW);
delay(500);
digitalWrite(SOLENOID_DOWN, HIGH);
delay(500);
digitalWrite(SOLENOID_DOWN, LOW);
delay(500);
digitalWrite(SOLENOID_LEFT, HIGH);
delay(500);
digitalWrite(SOLENOID_LEFT, LOW);
delay(500);
digitalWrite(SOLENOID_RIGHT, HIGH);
delay(500);
digitalWrite(SOLENOID_RIGHT, LOW);
delay(500);
}
if ( threequarterSelected() == false && fullSelected == false ) { //happens when nothing is selected
digitalWrite(SOLENOID_UP, HIGH);
delay(500);
digitalWrite(SOLENOID_UP, LOW);
delay(500);
}
} //end of loop
//custom function definitions
//reads pressure sensor state HIGH is false and LOW is true
bool checkPressure() {
if (digitalRead(PRESSURE_SENSOR) == HIGH) {
delay(PRESSURE_SENSOR_DEBOUNCE);
if (digitalRead(PRESSURE_SENSOR) == HIGH) {
return true;
}
else {
return false;
}
}
else {
return false;
}}
//reads selector - HIGH is false, LOW is true- SELECTOR_RESET, SELECTOR_QUARTER, SELECTOR_HALF, SELECTOR_3QUARTERS, SELECTOR_FULL,
bool resetSelected() {
if (threequarterSelected() == false && halfSelected() == false && fullSelected() == false) {
return true;
}
else {
return false;
}}
bool halfSelected() {
if (digitalRead(SELECTOR_HALF) == HIGH) {
delay(PRESSURE_SENSOR_DEBOUNCE);
if (digitalRead(SELECTOR_HALF) == HIGH) {
return false;
}
else {
return true;
}
}
else {
return true;
}}
bool threequarterSelected() {
if (digitalRead(SELECTOR_THREEQUARTER) == HIGH) {
delay(PRESSURE_SENSOR_DEBOUNCE);
if (digitalRead(SELECTOR_THREEQUARTER) == HIGH) {
return false;
}
else {
return true;
}
}
else {
return true;
}}
bool fullSelected() {
if (digitalRead(SELECTOR_FULL) == HIGH) {
delay(PRESSURE_SENSOR_DEBOUNCE);
if (digitalRead(SELECTOR_FULL) == HIGH) {
return false;
}
else {
return true;
}
}
else {
return true;
}}