-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevdawg.ino
298 lines (268 loc) · 5.69 KB
/
devdawg.ino
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/* DevDawg
*
* Open Source Arduino-Based Rotary Film Development Controller.
* by Tim Soderstrom
*
* Licensed under the GPLv3 (see LICENSE for more information)
*/
/**********
* Defines
**********/
#define VERSION "v0.04"
#define BANNER_DELAY_MS 1000
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
#define LCD_COLUMNS 16
#define LCD_ROWS 2
#define SECONDS_MS 1000
#define FORWARD 0
#define REVERSE 1
#define ON 1
#define OFF 0
// Menu Options
#define MAIN_MENU 0
#define DEVELOP_FILM 1
#define PREHEAT 2
#define RUN_MOTOR 3
#define MAX_OPTION 3
// Tunable Defines
// Maximum number of dev steps a particular Dev Process can have.
#define MAX_DEV_STEPS 8
// How often to check the temperature probe
#define TEMP_UPDATE_INTERVAL 10
// Default Preheat Temperature (C)
#define DEFAULT_PREHEAT_TEMP 39
// Manual Temperature Adjustment Steps
#define TEMP_ADJUSTMENT_PRECISION 0.5
// Specified Motor RPM
#define MOTOR_RPM 45
// Slowet Motor Will Turn
#define MOTOR_MIN_RPM 24
// PID Parameters
//#define KP 2
//#define KI 5
//#define KD 1
#define KP 4
#define KI 5
#define KD 2
/***********
* Includes
***********/
// Maybe for the future for storing and easily transferring development processes
// Might be simpler to use I2C and an EEPROM but then there needs to be a mechanicsm
// to add/remove development options
// #include <SPI.h>
// #include <SD.h>
#include <PID_v1.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_RGBLCDShield.h>
#include "structs.h"
/*******
* Pins
*******/
const byte temperatureProbes = 2;
const byte buzzer = 3;
const byte heater = 4;
const byte motorSpeed = 5;
const byte motorX = 6;
const byte motorY = 7;
const byte recircPump = 8;
/************
* Variables
************/
byte pickedProcess = 0;
byte button = 0;
byte mode = 0;
byte option = 0;
double pidOutput;
double currentTemperature = 0;
double targetTemperature = DEFAULT_PREHEAT_TEMP;
unsigned long pidWindowStartTime;
unsigned int pidWindowSizeMS = 10000;
bool heaterState = OFF;
unsigned long previousMotorMillis = 0;
bool motorDirection = FORWARD;
/**********
* Objects
**********/
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(temperatureProbes);
DallasTemperature sensors(&oneWire);
DeviceAddress thermometer;
// PID Object
PID pid(¤tTemperature, &pidOutput, &targetTemperature, KP, KI, KD, DIRECT);
/******************************
* Development Process Structs
******************************/
// Dev Processes (These can eventually be in the EEPROM)
const byte processCount = 3;
// Dev Processes
const DevProcess process[] =
{
{
"Test",
255,
10,
24,
5,
{
{"Develop", 30, RED},
{"Blix", 35, VIOLET},
{"Wash 1", 36, BLUE},
{"Wash 2", 37, TEAL},
{"Stabilizer", 40, WHITE}
}
},
{
"C41",
255,
10,
38,
5,
{
{"Develop", 195, RED},
{"Blix", 195, VIOLET},
{"Wash 1", 360, BLUE},
{"Wash 2", 120, TEAL},
{"Stabilizer", 60, WHITE}
}
},
{
"Dlta100 DDX 1+4",
255,
10,
20,
3,
{
{"Develop", 720, BLUE},
{"Stop", 60, RED},
{"Fix", 300, WHITE}
}
}
};
DevProcess currentProcess;
/*******
* Code
********/
void setup()
{
pinMode(buzzer, OUTPUT);
pinMode(heater, OUTPUT);
pinMode(motorSpeed, OUTPUT);
pinMode(motorX, OUTPUT);
pinMode(motorY, OUTPUT);
pinMode(recircPump, OUTPUT);
digitalWrite(buzzer, LOW);
digitalWrite(heater, LOW);
analogWrite(motorSpeed, 0);
digitalWrite(motorX, LOW);
digitalWrite(motorY, LOW);
digitalWrite(recircPump, LOW);
Serial.begin(9600);
lcd.begin(LCD_COLUMNS, LCD_ROWS);
/* Print Title and Version */
lcd.setBacklight(YELLOW);
lcd.setCursor(0,0);
lcd.print(F("DevDawg"));
lcd.setCursor(0,1);
lcd.print(VERSION);
delay(BANNER_DELAY_MS);
/* Setup PID */
pidWindowStartTime = millis();
pid.SetOutputLimits(0, pidWindowSizeMS);
pid.SetMode(AUTOMATIC);
currentTemperature = collectTemperatures();
}
void loop()
{
/* Menu Functions */
switch(mode)
{
case PREHEAT:
{
preheat();
mode = 0;
break;
}
case DEVELOP_FILM:
{
developFilm();
mode = 0;
break;
}
case RUN_MOTOR:
{
runMotor();
mode = 0;
break;
}
// Main Menu
default:
{
switch(option)
{
case DEVELOP_FILM:
{
button = wait("Select Mode", "Develop Film");
break;
}
case PREHEAT:
{
button = wait("Select Mode", "Preheat");
break;
}
case RUN_MOTOR:
{
button = wait("Select Mode", "Turn Rotary");
break;
}
default:
{
button = wait("Main Menu","");
break;
}
}
delay(250);
switch(button)
{
case BUTTON_UP:
{
++option;
if(option > 2)
option = 0;
Serial.println(F("Button Up"));
Serial.print(F("Option: "));
Serial.println(option);
break;
}
case BUTTON_DOWN:
{
--option;
if(option > 2)
option = MAX_OPTION;
Serial.println(F("Button Down"));
Serial.print(F("Option: "));
Serial.println(option);
break;
}
case BUTTON_SELECT:
{
Serial.println(F("Button Select"));
mode = option;
option = 0;
break;
}
}
}
}
// Reset back to main menu
button = 0;
}