-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfiguration.h
274 lines (237 loc) · 12.6 KB
/
configuration.h
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
//configuration.h
// Menu system, mode selection and state machine variables
// Available Pull Modes:
#define MANUAL_PULL 0 // Manual PWM set by paddle/pot. FLB OFF until PWM exceeds FLBThresholdPWM value
#define AUTO_PWM_PROFILE_PULL 1 // Not recommended
#define AUTO_PRESSURE_PROFILE_PULL 2 // Not recommended
#define AUTO_FLOW_PROFILE_PULL 3 // Not recommended
#define SLAYER_LIKE_PULL 4 // Single speed pump - low-flow PI by FLB-OFF for set time followed by FLB ON
#define LEVER_LIKE_PULL 5 // Not currently implemented
#define SLAYER_LIKE_PI_PRESSURE_PROFILE 6 // Low flow PI (FLB OFF) until pressure reaches 4 bar aand then manual pressure profiling
#define FLOW_PRESSURE_PROFILE 7 // FP: PID Flow (left side of paddle) up to unionThreshold. Then PP PID Pressure (right side of paddle)
#define FLUSH 10
// 3d5 buttons - choose the numerical code above to change the pull modes
#define BUTTON_1 4 // Leftmost button (single shot)
#define BUTTON_2 6 // Second button (double shot)
#define BUTTON_3 7 // Third button (single mug)
#define BUTTON_4 0 // 4th button (double mug)
// For debugging, this sends the entire EEPROM content to the serial monitor
// May be activated in the serial console by pressing Z
//#define EEPROM_SERIAL_DOWNLOAD
// Define MQTT channel
//#define MQTT
// Megunolink telemetry
// For use over an ESP8266 also needs the com0com com2tcp adapter. See https://hackaday.io/page/1304-virtual-serial-port-tunnel-to-use-with-esp-link.
#define MEGUNOLINK
// If the output relay inverts (like some modules do) uncomment the next line
#define INVERT_FLB_OUTPUT
// If using Otto Controls HTWF-1A12A22A Hall Effect 0-5V paddle control instead of potentiometer (same connections)
// Aligns center indent of paddle with FLB control and Preinfusion
#define OTTO_HTWF
// Allows measuring of weight using a Lunar
// From https://github.com/npouvesle/ACAIAScale_Arduino
#define ACAIA_LUNAR_INTEGRATION
#define DEFAULT_DOSE_FOR_EBF 18.0
#define EMPTY_PORTAFILTER_WEIGHT 537.1
// In device_HM10.h please set the proper scale MAC address as below
// const char * mac = "001C971267DF";
// #define ACAIA_SCALE_MAC "001C971267DF"
//Flowmeter Selection
//#define GICAR_FLOWMETER
#define DIGMESA_FLOWMETER // #9NB-0100/01A http://www.digmesa.com/wp-content/uploads/9NB-01xx_01_x_GB.pdf
#ifdef GICAR_FLOWMETER
float mlPerFlowMeterPulse = 0.48f; // 0.42f;// ml/pulse
float mlPerFlowMeterPulsePreInfusion = 0.34f; // 0.42f;// ml/pulse
#endif
#ifdef DIGMESA_FLOWMETER
float mlPerFlowMeterPulse = 0.0240f; // Calibrated values.... Spec is 0.025ml/pulse
float mlPerFlowMeterPulsePreInfusion = 0.0230f;
#endif
//#define SINGLE_PUMP // Used if the gear pump is also used for autofill
//*******************************************************************************
// Calibrate boiler pressure readings
//********************************************************************************
// The CALIBRATE_PRESSURE directive displays the 10-bit reading on the analog pressure input pin
// (instead of the 12 bar scale). Assuming the pressure sensor is sufficiently linear, we will need
// two points to calibrate the readings (to pressure in bars):
// A low range pressure input and its associated reading, and a high pressure source and its
// associated reading.
// So for calibration of the pressure measurement loop enable the line below.
// Use manual pull mode and a blind basket to:
// 1. Set a constant 3 bar, and write down the displayed A/D value (between 0 to 1023)
// 2. Do the same for 9 bar and write down the displayed value.
//
// Notes:
// 1. Some espresso machine manometers are not very accurate. A Scace device or a Fluke
// pressure gauge are usually more accurate.
// 2. Wait for the pressure to stabilize. if pressure exceeds the intended pressure it may
// not be possible to reduce the pressure so if that happens run a new pull.
// 3. It is recommended to run the test a few times to ensure consistency of the results.
// 4. Pressure sensors (like all resistive bridge based transducers) have a high tempco. Some, but not all,
// are accurately compensated for temperature. Recommended to wait for the machine to heat up and for the
// sensor temperature to stabilize before calibration.
//
//#define CALIBRATE_PRESSURE
// Write the low end calibration figure below
#define LOW_CALIBRATION_PRESSURE_READING 290 // 10-bit AD reading when low (3.0 bar) pressure is applied (between 0-1023)
//#define LOW_CALIBRATION_PRESSURE_READING 320 // (blown Mega) 10-bit AD reading when low (3.0 bar) pressure is applied (between 0-1023)
// Write the high end Calibration figure below
#define HIGH_CALIBRATION_PRESSURE_READING 788 // 10-bit AD reading when high (9.0 bar) pressure is applied (between 0-1023)
//#define HIGH_CALIBRATION_PRESSURE_READING 891 // (blown MEGA) 10-bit AD reading when high (9.0 bar) pressure is applied (between 0-1023)
// If your calibration point are different than 3.0 and 9.0 bar - set the relevant pressures below
// Note: This setting is provided for sensors that are linear within a narrower pressure range - so calibration
// can be performed within the linear range of the transducer; or if your reference transducer supports different
// reading points (e.g. a maximum of 8 bar).
#define LOW_CALIBRATION_PRESSURE 30 // x10 in bar - so for 3.0 bar write 30
#define HIGH_CALIBRATION_PRESSURE 90 // x10 in bar - so for 9.0 bar write 90
//***********************************************************************
// Touchpad driver
//***********************************************************************
#define TFT_TOUCH // A simple XPT2046 library for Arduino https://github.com/Bodmer/TFT_Touch
//#define TS_STMPE //The Adafruit STMPE610 library
//***********************************************************************
// Graphics Drivers
//***********************************************************************
#define MCUFRIEND //MCU Friend allows 16 bit parallel: https://github.com/prenticedavid/MCUFRIEND_kbv
/*
If parallel like ITEAD 3.2" MEGA shield pinout using MCUFRIEND is as follows. Remember to configure MCUFRIEND properly using special.h file.
D2 - T_IRQ - Disconnected
D3 - T_DOUT - Modified to pin 44
D4 - T_DIN - Modified to pin 46
D5 - T_CS - Modified to pin 8
D6 - T_CLK - Modified to pin 48
D22 DB8
D23 DB9
D24 DB10
D25 DB11
D26 DB12
D27 DB13
D28 DB14
D29 DB15
D30 DB7
D31 DB6
D32 DB5
D33 DB4
D34 DB3
D35 DB2
D36 DB1
D37 DB0
D38 RS
D39 WR
D40 CS
D41 RST
D50 SD_MISO
D51 SD_MOSI
D52 SD_SCK
D53 SD_NSS
*/
//#define ADAFRUIT_ILI9341
/*
#define LCD_CS 38 // Chip Select goes to Analog 3
#define LCD_CD 39 // Command/Data goes to Analog 2
#define LCD_WR 40 // LCD Write goes to Analog 1
#define LCD_RD 41 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
*/
#define DISPLAY_ROTATION
//***********************************************************************
// PINS: Global Parameters and Variables & Arduino Mega R3 Pins
//***********************************************************************
#define CS1 A0 // A0 - VNH5019 Motor driver current default
#define CONTROL_POT A1 // A1 - Control potentiometer is on analog pin 1
#define PRESSURE_SENSOR_INPUT A2 // A2 - 0-5V Pressure Input
// Pins D0 and D1 are serial port
#define FLOW_COUNT_INPUT 2 // D2 - INT0 Flow counter interrupt pin
#define GROUP_SOLENOID 3 // D3 - INT1 Group solenoid 220v detector is on pin 3 (an interrupt pin)
#define INB1 4 // D4 - VNH5019 Motor driver default
#ifndef SINGLE_PUMP
#define RED_LED 5 // D5 - LED lights RED during standby
#endif
#define EN1DIAG1 6 // D6 - VNH5019 Motor driver default
#define GREEN_LED 7 // D7 - LED lights GREEN during a pull
// _PWM1 = 11 // D11 - VNH5019 Motor driver default set in VNH5019MotorShieldMega.h file
#define INA1 12 // VNH5019 Motor driver - Move INA1 from D2 to D12 to allow pin 2 (INT0) use as an interrupt for the flow meter
#define FLOW_LIMIT_BYPASS 13 // D13 - Digital output to flow control bypass solenoid (0V - flow limited; 5V - bypass enabled)
#define STROBE_RELAY 10 // D10 - Will simulate a 3d5 button push
#ifdef SINGLE_PUMP
#define PUMP_RELAY 5 // Pump on detection to control filling of tank and tea water
#define RED_LED 22 // D22 - LED lights RED during standby (TH: changed from 5 to 22 to release one pin for pump on detection)
#endif
#ifdef TS_STMPE
#define TS_CS 8 // D8 - TouchScreen CS
#endif
#ifdef TFT_TOUCH
// These are the pins used to interface between the 2046 touch controller and Arduino Mega
#define DOUT 44 // 3 /* Data out pin (T_DO) of touch screen */
#define DIN 46 //4 /* Data in pin (T_DIN) of touch screen */
#define DCS 8 /* Chip select pin (T_CS) of touch screen */
#define DCLK 48 //6 /* Clock pin (T_CLK) of touch screen */
#endif
#ifdef ADAFRUIT_ILI9341
#define TFT_DC 9 // D9 - Adafruit TFT DC
#define TFT_CS 10 // D10 - Adafruit TFT CS
#endif
#ifdef TFT_TOUCH
// These are the default min and maximum values, set to 0 and 4095 to test the screen
#define HMIN 0
#define HMAX 4095
#define VMIN 0
#define VMAX 4095
#define XYSWAP 0 // 0 or 1
// This is the screen size for the raw to coordinate transformation
// width and height specified for landscape orientation
#define HRES 320 /* Default screen resulution for X axis */
#define VRES 320 /* Default screen resulution for Y axis */
#endif
// define Graph Size (note graph requires 11 more pixels undreneath the graph)
#define GRAPH_X_0 3
#define GRAPH_Y_0 309
#define GRAPH_X_SPAN 237
#define GRAPH_Y_SPAN 194
#define GRAPH_PWM_SPAN 400 // in PWM - (0 - x)% for VNH5019 driver usually 0-400
#define GRAPH_PRESSURE_SPAN 10 //in bar: 0-x bar usually 0-10 bar
#define GRAPH_FLOW_VOLUME_SPAN 100 //in ml/min usually 0-90ml
#define GRAPH_FLOW_RATE_SPAN 400 //in ml/min usually 0-400ml/min
//***********************************************************************
// Defaults for system parameters
// NOTE: These are default parameters that are only used for new Arduinos (in which case they get written into the EEPROM as defaults).
// Once the system is in operation they will get overwritten by readSWParametersfromEEPROM()
// To overwrite and force parameter rewrite from code unquote the following line
//***********************************************************************
//#define OVERWRITE_EEPROM_WITH_DEFAULTS
byte debounceCount = 3, slayerPIPeriod = 15, slayerPIFlowRate = 5;
double unionThreshold = 4.0d; // in bar - at this point the system will switch from FP to PP
//************************************************************************
// PID parameters
//************************************************************************
const uint16_t PIDSampleTime = 25; // in mSec
#define PRESSURE_AVERAGES 4
#define FLOW_AVERAGES_DIGMESA 100 // There are 20 Digmesa pulses for each Gicar pulse....
#define FLOW_AVERAGES_GICAR 5
// Pressure PID loop (pressure profiling)
double Kpp = 60, Kpi = 20, Kpd = 3;
#define PID_MIN_PRESSURE 4.0
#define PID_MAX_PRESSURE 10.0
#define PRESSURE_PID_MIN_PWM 0
#define PRESSURE_PID_MAX_PWM 220
// Flow PID loop (flow profiling)
double Kfp = 5, Kfi = 5, Kfd = 1;
#define PID_MIN_FLOW 0
#define PID_MAX_FLOW 150 // maximum debit in ml/min while in PI
#define FLOW_PID_MIN_PWM 10
#define FLOW_PID_MAX_PWM 150
#define STALL_FLOW_RATE 20 //ml/min
//***********************************************************************
// Pump Speeds (in PWM)
// 0-400 correlates to 0-100% PWM
// PWM speed is from -400 to 400. Pumps cannot be driven in reverse, so from 0-400.
//***********************************************************************
uint16_t pumpMaxPWM = 220, pumpMinPWM = 0, FLBThresholdPWM = 60, slayerMainPWM = 160;
const uint16_t slayerMaxPWM = 190,flushPWM = 168; // Maximum - minimum pump PWM (0-400)
#define MAX_PROFILE_INDEX 250 ////Safety timer - after 120 seconds turn off pull... GS3 LU1.16 sets the maximum time at 120 seconds....
// Removed FP and PP can correct up to y percent lower than profile PWM (double)
//#define PWM_TRACK_UPPER_BOUND 15.0 // FP and PP can correct up to x percent higher than profile PWM (double)
//#define PWM_TRACK_LOWER_BOUND 90.0 // FP and PP can correct up to y percent lower than profile PWM (double)
// Lunar MAC address is defined in device_HM10.h file.
// Programming with ESP8266:
// bash -c "/mnt/d/Users/assaf.HOME/Documents/ESP8266/esp-link-3.2.47.alpha/megaflash.sh 192.168.200.55 /mnt/d/Users/assaf.HOME/Documents/Arduino/GS3_Transformer/GS3_Transformer.ino.mega.hex"