Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
B
brew
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
João Lino
brew
Commits
94938f90
Commit
94938f90
authored
Feb 14, 2018
by
João Lino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrated code for Pump
parent
ed255e4e
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
267 additions
and
30 deletions
+267
-30
brew.h
brew.h
+2
-1
brew.ino
brew.ino
+59
-22
config.h
config.h
+2
-6
src/HeatingElement/HeatingElement.h
src/HeatingElement/HeatingElement.h
+1
-1
src/Pump/Pump.cpp
src/Pump/Pump.cpp
+148
-0
src/Pump/Pump.h
src/Pump/Pump.h
+55
-0
src/Temperature/Temperature.cpp
src/Temperature/Temperature.cpp
+0
-0
src/Temperature/Temperature.h
src/Temperature/Temperature.h
+0
-0
No files found.
brew.h
View file @
94938f90
...
...
@@ -27,11 +27,12 @@ void runSettingsSelection();
#include "config.h"
#include "src/Temperature/Temperature.h"
#include "src/HeatingElement/HeatingElement.h"
#include "src/Pump/Pump.h"
#include "Melody.h"
#include "Display.h"
#include "Temperature.h"
#include "Profiles.h"
// ++++++++++++++++++++++++ FUNCTIONS +++++++++++++++++++++++++++++++++
...
...
brew.ino
View file @
94938f90
This diff is collapsed.
Click to expand it.
config.h
View file @
94938f90
...
...
@@ -47,14 +47,10 @@
// ++++++++++++++++++++++++ Pump ++++++++++++++++++++++++
#define PUMP_PIN 6
#define PUMP_TEMPERATURE_MAX_OPERATION 90
#define PUMP_
SPEED_STOP
0
#define PUMP_
PRIMING_TIME_IN_SECONDS 1
0
#define PUMP_SPEED_STOP_MOSFET 255
#define PUMP_SPEED_SLOW 64
#define PUMP_SPEED_AVERAGE 128
#define PUMP_SPEED_FAST 192
#define PUMP_SPEED_MAX_MOSFET 0
#define PUMP_SPEED_MAX 255
#define PUMP_SPEED_DEFAULT 0
#define PUMP_SPEED_DEFAULT PUMP_SPEED_MAX_MOSFET
// ++++++++++++++++++++++++ Rotary Encoder ++++++++++++++++++++++++
#define ROTARY_ENCODER_INTERRUPT_NUMBER 1 // On Mega2560 boards, interrupt 1 is on pin 3
...
...
src/HeatingElement/HeatingElement.h
View file @
94938f90
...
...
@@ -35,8 +35,8 @@ class HeatingElement
double
ulWattToWindowTime
(
double
ulAppliedWatts
);
int
_iOutputPin
;
int
_uiOnValue
;
int
_uiOffValue
;
int
_uiOnValue
;
boolean
_bStatusElement
;
int
_iWindowSize
;
// Time frame to operate in
unsigned
long
_windowStartTime
;
...
...
src/Pump/Pump.cpp
0 → 100644
View file @
94938f90
#include "Pump.h"
Pump
::
Pump
(
int
iOutputPin
,
int
iOffValue
,
int
iMaxValue
)
{
Pump
(
iOutputPin
,
iOffValue
,
iMaxValue
,
DEFAULT_PUMP_MAX_OPETATION_TEMPERARTURE
,
DEFAULT_PUMP_PRIMING_TIME_IN_SECONDS
);
}
Pump
::
Pump
(
int
iOutputPin
,
int
iOffValue
,
int
iMaxValue
,
int
iMaxTemperature
,
int
iPrimingTimeInSeconds
)
{
_iOutputPin
=
iOutputPin
;
_iOffValue
=
iOffValue
;
_iMaxValue
=
iMaxValue
;
_iMaxTemperature
=
iMaxTemperature
;
_iPrimingTimeInSeconds
=
iPrimingTimeInSeconds
;
_iActualPumpSpeed
=
_iOffValue
;
// Time frame to operate in
_iTargetPumpSpeed
=
_iOffValue
;
_temperature
=
NULL
;
_selfPrimingMode
=
false
;
_hasBeenPrimedSinceStartup
=
false
;
pinMode
(
_iOutputPin
,
OUTPUT
);
// sets the pin as output
analogWrite
(
_iOutputPin
,
_iOffValue
);
// analogWrite values from 0 to 255
}
void
Pump
::
shutDown
()
{
_iActualPumpSpeed
=
_iOffValue
;
// Time frame to operate in
_iTargetPumpSpeed
=
_iOffValue
;
_selfPrimingMode
=
false
;
// Turn off gracefully
process
();
}
bool
Pump
::
process
()
{
if
(
_temperature
!=
NULL
)
{
// Operate pump if its operating temperature is bellow the maximum operating temperature
float
currentTemperature
=
_temperature
->
getCurrentTemperature
();
if
(
currentTemperature
<=
_iMaxTemperature
)
{
// Self prime on first use
if
(
!
_hasBeenPrimedSinceStartup
&&
_iTargetPumpSpeed
!=
_iOffValue
)
{
_hasBeenPrimedSinceStartup
=
true
;
_selfPrimingMode
=
true
;
_millisAtPrimingStart
=
millis
();
}
// Process end of self priming mode
if
(
millis
()
-
_millisAtPrimingStart
>
_iPrimingTimeInSeconds
*
1000
)
{
_selfPrimingMode
=
false
;
}
// Control speed for self priming mode of operation
if
(
_selfPrimingMode
)
{
// Alternate speed
if
(
((
millis
()
/
1000
)
%
2
)
==
0
)
{
_iActualPumpSpeed
=
_iMaxValue
;
}
else
{
_iActualPumpSpeed
=
_iOffValue
;
}
}
// Set target speed in normal mode of operation
else
{
_iActualPumpSpeed
=
_iTargetPumpSpeed
;
}
}
// Turn pump off if its operating temperature exceeds the maximum operating temperature
else
{
_iActualPumpSpeed
=
_iOffValue
;
}
}
else
{
// The pump will remain off until temperature feedback is provided
_iActualPumpSpeed
=
_iOffValue
;
}
// Set pump speed
analogWrite
(
_iOutputPin
,
_iActualPumpSpeed
);
// analogWrite values from 0 to 255
return
_iActualPumpSpeed
;
}
bool
Pump
::
process
(
int
iTargetPumpSpeed
)
{
setTargetPumpSpeed
(
iTargetPumpSpeed
);
return
process
();
}
void
Pump
::
forcePumpSelfPrime
()
{
_selfPrimingMode
=
true
;
_millisAtPrimingStart
=
millis
();
}
// Getter and setters
bool
Pump
::
isPumpOn
()
{
return
_iActualPumpSpeed
!=
_iOffValue
;
}
void
Pump
::
setCheckTemperatureFunction
(
Temperature
*
temperature
)
{
_temperature
=
temperature
;
}
int
Pump
::
getTargetPumpSpeed
()
{
return
_iTargetPumpSpeed
;
}
void
Pump
::
setTargetPumpSpeed
(
int
iTargetPumpSpeed
)
{
_iTargetPumpSpeed
=
iTargetPumpSpeed
;
}
// Power Increments
int
Pump
::
getNullSpeed
()
{
return
_iOffValue
;
}
int
Pump
::
getOneSixthSpeed
()
{
return
calculateSpeedFraction
(
1.0
/
6.0
);
}
int
Pump
::
getOneThirdSpeed
()
{
return
calculateSpeedFraction
(
1.0
/
3.0
);
}
int
Pump
::
getHalfSpeed
()
{
return
calculateSpeedFraction
(
1.0
/
2.0
);
}
int
Pump
::
getTwoThirdSpeed
()
{
return
calculateSpeedFraction
(
2.0
/
3.0
);
}
int
Pump
::
getMaxSpeed
()
{
return
_iMaxValue
;
}
// Private functions
int
Pump
::
calculateSpeedFraction
(
double
fraction
)
{
int
ret
;
if
(
_iMaxValue
>=
_iOffValue
)
{
ret
=
_iMaxValue
*
fraction
;
}
else
{
ret
=
_iOffValue
*
((
1.0
-
fraction
)
*
-
1.0
);
}
return
ret
;
}
\ No newline at end of file
src/Pump/Pump.h
0 → 100644
View file @
94938f90
#ifndef Pump_h
#define Pump_h
#include "Arduino.h"
#include "../Temperature/Temperature.h"
#define DEFAULT_PUMP_MAX_OPETATION_TEMPERARTURE 90
#define DEFAULT_PUMP_PRIMING_TIME_IN_SECONDS 10
//#define HEATING_ELEMENT_MAX_HEAT_PWM_INTEGER 5
//#define HEATING_ELEMENT_MAX_HEAT_PWM_FLOAT 5.0
class
Pump
{
public:
Pump
(
int
iOutputPin
,
int
iOffValue
,
int
iMaxValue
,
int
iMaxTemperature
,
int
iPrimingTimeInSeconds
);
Pump
(
int
iOutputPin
,
int
iOffValue
,
int
iMaxValue
);
void
shutDown
();
void
forcePumpSelfPrime
();
bool
process
();
bool
process
(
int
iTargetPumpSpeed
);
bool
isPumpOn
();
void
setCheckTemperatureFunction
(
Temperature
*
temperature
);
int
getTargetPumpSpeed
();
void
setTargetPumpSpeed
(
int
iTargetPumpSpeed
);
int
getNullSpeed
();
int
getOneSixthSpeed
();
int
getOneThirdSpeed
();
int
getHalfSpeed
();
int
getTwoThirdSpeed
();
int
getMaxSpeed
();
private:
int
_iOutputPin
;
int
_iOffValue
;
int
_iMaxValue
;
boolean
_selfPrimingMode
;
boolean
_hasBeenPrimedSinceStartup
;
unsigned
long
_millisAtPrimingStart
;
int
_iPrimingTimeInSeconds
;
int
_iMaxTemperature
;
int
_iActualPumpSpeed
;
// Time frame to operate in
int
_iTargetPumpSpeed
;
Temperature
*
_temperature
;
// Private functions
int
calculateSpeedFraction
(
double
fraction
);
};
#endif
\ No newline at end of file
Temperature.cpp
→
src/Temperature/
Temperature.cpp
View file @
94938f90
File moved
Temperature.h
→
src/Temperature/
Temperature.h
View file @
94938f90
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment