Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MarlinKimbra
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
MarlinKimbra
Commits
f9edd3ec
Commit
f9edd3ec
authored
May 10, 2016
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cooler support progression...
parent
cb03b10e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
9 deletions
+106
-9
MK_Main.cpp
MK/module/MK_Main.cpp
+2
-2
temperature.cpp
MK/module/temperature/temperature.cpp
+99
-6
temperature.h
MK/module/temperature/temperature.h
+5
-1
No files found.
MK/module/MK_Main.cpp
View file @
f9edd3ec
...
@@ -7412,7 +7412,7 @@ inline void gcode_M503() {
...
@@ -7412,7 +7412,7 @@ inline void gcode_M503() {
codenum
+=
millis
();
// keep track of when we started waiting
codenum
+=
millis
();
// keep track of when we started waiting
previous_millis_cmd
=
millis
();
previous_millis_cmd
=
millis
();
while
(
millis
()
<
codenum
){
while
(
millis
()
<
codenum
){
manage_
heat
er
();
manage_
temp_controll
er
();
manage_inactivity
();
manage_inactivity
();
lcd_update
();
lcd_update
();
}
}
...
@@ -9036,7 +9036,7 @@ void idle(
...
@@ -9036,7 +9036,7 @@ void idle(
bool
no_stepper_sleep
/*=false*/
bool
no_stepper_sleep
/*=false*/
#endif
#endif
)
{
)
{
manage_
heat
er
();
manage_
temp_controll
er
();
manage_inactivity
(
manage_inactivity
(
#if ENABLED(FILAMENTCHANGEENABLE)
#if ENABLED(FILAMENTCHANGEENABLE)
no_stepper_sleep
no_stepper_sleep
...
...
MK/module/temperature/temperature.cpp
View file @
f9edd3ec
...
@@ -237,6 +237,11 @@ static void updateTemperaturesFromRawValues();
...
@@ -237,6 +237,11 @@ static void updateTemperaturesFromRawValues();
millis_t
watch_heater_next_ms
[
HOTENDS
]
=
{
0
};
millis_t
watch_heater_next_ms
[
HOTENDS
]
=
{
0
};
#endif
#endif
#if ENABLED(THERMAL_PROTECTION_COOLERS)
int
watch_target_temp_cooler
=
0
;
millis_t
watch_cooler_next_ms
=
0
;
#endif
#if DISABLED(SOFT_PWM_SCALE)
#if DISABLED(SOFT_PWM_SCALE)
#define SOFT_PWM_SCALE 0
#define SOFT_PWM_SCALE 0
#endif
#endif
...
@@ -813,7 +818,7 @@ float get_pid_output(int h) {
...
@@ -813,7 +818,7 @@ float get_pid_output(int h) {
* - Apply filament width to the extrusion rate (may move)
* - Apply filament width to the extrusion rate (may move)
* - Update the heated bed PID output value
* - Update the heated bed PID output value
*/
*/
void
manage_
heater
()
{
// NEXTIME cambia nome GUARDA TUTTA LA FUNZIONE
void
manage_
temp_controller
()
{
if
(
!
temp_meas_ready
)
return
;
if
(
!
temp_meas_ready
)
return
;
...
@@ -825,7 +830,7 @@ void manage_heater() { // NEXTIME cambia nome GUARDA TUTTA LA FUNZIONE
...
@@ -825,7 +830,7 @@ void manage_heater() { // NEXTIME cambia nome GUARDA TUTTA LA FUNZIONE
if
(
ct
<
max
(
HEATER_0_MINTEMP
,
0.01
))
min_temp_error
(
0
);
if
(
ct
<
max
(
HEATER_0_MINTEMP
,
0.01
))
min_temp_error
(
0
);
#endif
#endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || DISABLED(PIDTEMPBED) || HAS(AUTO_FAN)
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || DISABLED(PIDTEMPBED) ||
DISABLED(PIDTEMPCOOLER) ||
HAS(AUTO_FAN)
millis_t
ms
=
millis
();
millis_t
ms
=
millis
();
#endif
#endif
...
@@ -894,6 +899,11 @@ void manage_heater() { // NEXTIME cambia nome GUARDA TUTTA LA FUNZIONE
...
@@ -894,6 +899,11 @@ void manage_heater() { // NEXTIME cambia nome GUARDA TUTTA LA FUNZIONE
next_bed_check_ms
=
ms
+
BED_CHECK_INTERVAL
;
next_bed_check_ms
=
ms
+
BED_CHECK_INTERVAL
;
#endif
#endif
#if DISABLED(PIDTEMPCOOLER)
if
(
ms
<
next_cooler_check_ms
)
return
;
next_cooler_check_ms
=
ms
+
BED_COOLER_INTERVAL
;
#endif
#if TEMP_SENSOR_BED != 0
#if TEMP_SENSOR_BED != 0
#if ENABLED(THERMAL_PROTECTION_BED)
#if ENABLED(THERMAL_PROTECTION_BED)
...
@@ -928,6 +938,42 @@ void manage_heater() { // NEXTIME cambia nome GUARDA TUTTA LA FUNZIONE
...
@@ -928,6 +938,42 @@ void manage_heater() { // NEXTIME cambia nome GUARDA TUTTA LA FUNZIONE
}
}
#endif
#endif
#endif // TEMP_SENSOR_BED != 0
#endif // TEMP_SENSOR_BED != 0
#if TEMP_SENSOR_COOLER != 0
#if ENABLED(THERMAL_PROTECTION_COOLER)
thermal_runaway_protection
(
&
thermal_runaway_cooler_state_machine
,
&
thermal_runaway_cooler_timer
,
current_temperature_cooler
,
target_temperature_cooler
,
-
2
,
THERMAL_PROTECTION_COOLER_PERIOD
,
THERMAL_PROTECTION_COOLER_HYSTERESIS
);
#endif
#if ENABLED(PIDTEMPCOOLER)
float
pid_output
=
get_pid_output_cooler
();
soft_pwm_cooler
=
current_temperature_cooler
>
COOLER_MINTEMP
&&
current_temperature_cooler
<
COOLER_MAXTEMP
?
(
int
)
pid_output
>>
1
:
0
;
#elif ENABLED(COOLER_LIMIT_SWITCHING)
// Check if temperature is within the correct band
if
(
current_temperature_cooler
>
COOLER_MINTEMP
&&
current_temperature_cooler
<
COOLER_MAXTEMP
)
{
if
(
current_temperature_cooler
>=
target_temperature_cooler
+
COOLER_HYSTERESIS
)
soft_pwm_cooler
=
MAX_COOLER_POWER
>>
1
;
else
if
(
current_temperature_cooler
<=
target_temperature_cooler
-
COOLER_HYSTERESIS
)
soft_pwm_cooler
=
0
;
}
else
{
// NEXTIME XXX here we have to manage hw pwm?
soft_pwm_cooler
=
0
;
WRITE_HEATER_COOLER
(
LOW
);
}
#else // COOLER_LIMIT_SWITCHING
// Check if temperature is within the correct range
if
(
current_temperature_cooler
>
COOLER_MINTEMP
&&
current_temperature_cooler
<
COOLER_MAXTEMP
)
{
soft_pwm_cooler
=
current_temperature_cooler
>
target_temperature_cooler
?
MAX_COOLER_POWER
>>
1
:
0
;
}
else
{
soft_pwm_cooler
=
0
;
WRITE_HEATER_COOLER
(
LOW
);
}
#endif
#endif // TEMP_SENSOR_COOLER != 0
}
}
#define PGM_RD_W(x) (short)pgm_read_word(&x)
#define PGM_RD_W(x) (short)pgm_read_word(&x)
...
@@ -1156,7 +1202,7 @@ static void updateTemperaturesFromRawValues() {
...
@@ -1156,7 +1202,7 @@ static void updateTemperaturesFromRawValues() {
/**
/**
* Initialize the temperature manager
* Initialize the temperature manager
* The manager is implemented by periodic calls to manage_
heat
er()
* The manager is implemented by periodic calls to manage_
temp_controll
er()
*/
*/
void
tp_init
()
{
void
tp_init
()
{
#if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)||(TEMP_SENSOR_COOLER==-1)
#if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)||(TEMP_SENSOR_COOLER==-1)
...
@@ -1406,7 +1452,7 @@ void tp_init() {
...
@@ -1406,7 +1452,7 @@ void tp_init() {
}
}
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
// NEXTIME this has be done even for cooler, but cooler uses M140? or anything else?
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
/**
/**
* Start Heating Sanity Check for hotends that are below
* Start Heating Sanity Check for hotends that are below
* their target temperature by a configurable margin.
* their target temperature by a configurable margin.
...
@@ -1422,6 +1468,23 @@ void tp_init() {
...
@@ -1422,6 +1468,23 @@ void tp_init() {
}
}
#endif
#endif
#if ENABLED(THERMAL_PROTECTION_COOLERS)
/**
* Start Cooling Sanity Check for hotends that are below
* their target temperature by a configurable margin.
* This is called when the temperature is set. (M141)
*/
void
start_watching_cooler
(
void
)
{
if
(
degCooler
()
<
degTargetCooler
()
-
(
WATCH_TEMP_COOLER_INCREASE
+
TEMP_COOLER_HYSTERESIS
+
1
))
{
watch_target_temp_cooler
=
degCooler
()
+
WATCH_COOLER_TEMP_INCREASE
;
watch_cooler_next_ms
=
millis
()
+
WATCH_TEMP_COOLER_PERIOD
*
1000UL
;
}
else
watch_cooler_next_ms
=
0
;
}
#endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || ENABLED(THERMAL_PROTECTION_BED) || ENABLED(THERMAL_PROTECTION_COOLER)
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || ENABLED(THERMAL_PROTECTION_BED) || ENABLED(THERMAL_PROTECTION_COOLER)
void
thermal_runaway_protection
(
TRState
*
state
,
millis_t
*
timer
,
float
temperature
,
float
target_temperature
,
int
temp_controller_id
,
int
period_seconds
,
int
hysteresis_degc
)
{
void
thermal_runaway_protection
(
TRState
*
state
,
millis_t
*
timer
,
float
temperature
,
float
target_temperature
,
int
temp_controller_id
,
int
period_seconds
,
int
hysteresis_degc
)
{
...
@@ -1642,12 +1705,12 @@ static void set_current_temp_raw() {
...
@@ -1642,12 +1705,12 @@ static void set_current_temp_raw() {
/**
/**
* Timer 0 is shared with millies
* Timer 0 is shared with millies
* - Manage PWM to all the heaters and fan
* - Manage PWM to all the heaters
, coolers
and fan
* - Update the raw temperature values
* - Update the raw temperature values
* - Check new temperature values for MIN/MAX errors
* - Check new temperature values for MIN/MAX errors
* - Step the babysteps value for each axis towards 0
* - Step the babysteps value for each axis towards 0
*/
*/
ISR
(
TIMER0_COMPB_vect
)
{
// NEXTIME tutta la funzione
ISR
(
TIMER0_COMPB_vect
)
{
static
unsigned
char
temp_count
=
0
;
static
unsigned
char
temp_count
=
0
;
static
TempState
temp_state
=
StartupDelay
;
static
TempState
temp_state
=
StartupDelay
;
...
@@ -1678,6 +1741,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
...
@@ -1678,6 +1741,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
#if HAS(HEATER_BED)
#if HAS(HEATER_BED)
ISR_STATICS
(
BED
);
ISR_STATICS
(
BED
);
#endif
#endif
#if HAS(COOLER)
ISR_STATICS
(
COOLER_DEVICE
);
#endif
#if HAS(FILAMENT_SENSOR)
#if HAS(FILAMENT_SENSOR)
static
unsigned
long
raw_filwidth_value
=
0
;
static
unsigned
long
raw_filwidth_value
=
0
;
...
@@ -1711,6 +1777,10 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
...
@@ -1711,6 +1777,10 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
soft_pwm_BED
=
soft_pwm_bed
;
soft_pwm_BED
=
soft_pwm_bed
;
WRITE_HEATER_BED
(
soft_pwm_BED
>
0
?
1
:
0
);
WRITE_HEATER_BED
(
soft_pwm_BED
>
0
?
1
:
0
);
#endif
#endif
#if HAS(COOLER)
soft_pwm_COOLER_DEVICE
=
soft_pwm_cooler
;
WRITE_COOLER
(
soft_pwm_COOLER_DEVICE
>
0
?
1
:
0
);
#endif
#if ENABLED(FAN_SOFT_PWM)
#if ENABLED(FAN_SOFT_PWM)
soft_pwm_fan
=
fanSpeedSoftPwm
/
2
;
soft_pwm_fan
=
fanSpeedSoftPwm
/
2
;
#if HAS(CONTROLLERFAN)
#if HAS(CONTROLLERFAN)
...
@@ -1750,6 +1820,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
...
@@ -1750,6 +1820,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
#if HAS(HEATER_BED)
#if HAS(HEATER_BED)
if
(
soft_pwm_BED
<
pwm_count
)
WRITE_HEATER_BED
(
0
);
if
(
soft_pwm_BED
<
pwm_count
)
WRITE_HEATER_BED
(
0
);
#endif
#endif
#if HAS(COOLER)
if
(
soft_pwm_COOLER_DEVICE
<
pwm_count
)
WRITE_COOLER
(
0
);
#endif
#if ENABLED(FAN_SOFT_PWM)
#if ENABLED(FAN_SOFT_PWM)
if
(
soft_pwm_fan
<
pwm_count
)
WRITE_FAN
(
0
);
if
(
soft_pwm_fan
<
pwm_count
)
WRITE_FAN
(
0
);
...
@@ -1831,6 +1904,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
...
@@ -1831,6 +1904,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
#if HAS(HEATER_BED)
#if HAS(HEATER_BED)
_SLOW_PWM_ROUTINE
(
BED
,
soft_pwm_bed
);
// BED
_SLOW_PWM_ROUTINE
(
BED
,
soft_pwm_bed
);
// BED
#endif
#endif
#if HAS(COOLER)
_SLOW_PWM_SOURINT
(
COOLER_DEVICE
,
soft_pwm_cooler
);
// COOLER
#endif
}
// slow_pwm_count == 0
}
// slow_pwm_count == 0
...
@@ -1847,6 +1923,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
...
@@ -1847,6 +1923,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
#if HAS(HEATER_BED)
#if HAS(HEATER_BED)
PWM_OFF_ROUTINE
(
BED
);
// BED
PWM_OFF_ROUTINE
(
BED
);
// BED
#endif
#endif
#if HAS(COOLER)
PWM_OFF_ROUTINE
(
COOLER_DEVICE
);
// COOLER
#endif
#if ENABLED(FAN_SOFT_PWM)
#if ENABLED(FAN_SOFT_PWM)
if
(
pwm_count
==
0
)
{
if
(
pwm_count
==
0
)
{
...
@@ -1916,6 +1995,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
...
@@ -1916,6 +1995,9 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
#if HAS(HEATER_BED)
#if HAS(HEATER_BED)
if
(
state_timer_heater_BED
>
0
)
state_timer_heater_BED
--
;
if
(
state_timer_heater_BED
>
0
)
state_timer_heater_BED
--
;
#endif
#endif
#if HAS(COOLER)
if
(
state_timer_heater_COOLER_DEVICE
>
0
)
state_timer_heater_COOLER_DEVICE
--
;
#endif
}
// (pwm_count % 64) == 0
}
// (pwm_count % 64) == 0
#endif // SLOW_PWM_HEATERS
#endif // SLOW_PWM_HEATERS
...
@@ -2119,6 +2201,17 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
...
@@ -2119,6 +2201,17 @@ ISR(TIMER0_COMPB_vect) { // NEXTIME tutta la funzione
if
(
current_temperature_bed_raw
GEBED
bed_maxttemp_raw
)
_temp_error
(
-
1
,
PSTR
(
SERIAL_T_MAXTEMP
),
PSTR
(
MSG_ERR_MAXTEMP_BED
));
if
(
current_temperature_bed_raw
GEBED
bed_maxttemp_raw
)
_temp_error
(
-
1
,
PSTR
(
SERIAL_T_MAXTEMP
),
PSTR
(
MSG_ERR_MAXTEMP_BED
));
if
(
bed_minttemp_raw
GEBED
current_temperature_bed_raw
)
_temp_error
(
-
1
,
PSTR
(
SERIAL_T_MINTEMP
),
PSTR
(
MSG_ERR_MINTEMP_BED
));
if
(
bed_minttemp_raw
GEBED
current_temperature_bed_raw
)
_temp_error
(
-
1
,
PSTR
(
SERIAL_T_MINTEMP
),
PSTR
(
MSG_ERR_MINTEMP_BED
));
#endif
#endif
#if HAS(TEMP_COOLER)
#if COOLER_RAW_LO_TEMP > COOLER_RAW_HI_TEMP
#define GECOOLER <=
#else
#define GECOOLER >=
#endif
if
(
current_temperature_cooler_raw
GECOOLER
cooler_maxttemp_raw
)
_temp_error
(
-
1
,
PSTR
(
SERIAL_T_MAXTEMP
),
PSTR
(
MSG_ERR_MAXTEMP_COOLER
));
if
(
cooler_minttemp_raw
GECOOLER
current_temperature_cooler_raw
)
_temp_error
(
-
1
,
PSTR
(
SERIAL_T_MINTEMP
),
PSTR
(
MSG_ERR_MINTEMP_COOLER
));
#endif
}
// temp_count >= OVERSAMPLENR
}
// temp_count >= OVERSAMPLENR
...
...
MK/module/temperature/temperature.h
View file @
f9edd3ec
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
// public functions
// public functions
void
tp_init
();
//initialize the heating
void
tp_init
();
//initialize the heating
void
manage_
heat
er
();
//it is critical that this is called periodically.
void
manage_
temp_controll
er
();
//it is critical that this is called periodically.
#if ENABLED(FILAMENT_SENSOR)
#if ENABLED(FILAMENT_SENSOR)
// For converting raw Filament Width to milimeters
// For converting raw Filament Width to milimeters
...
@@ -137,6 +137,10 @@ FORCE_INLINE float degTargetCooler() { return target_temperature_cooler; }
...
@@ -137,6 +137,10 @@ FORCE_INLINE float degTargetCooler() { return target_temperature_cooler; }
void
start_watching_heater
(
int
h
=
0
);
void
start_watching_heater
(
int
h
=
0
);
#endif
#endif
#if ENABLED(THERMAL_PROTECTION_COOLERS)
void
start_watching_cooler
(
void
);
#endif
FORCE_INLINE
void
setTargetHotend
(
const
float
&
celsius
,
uint8_t
hotend
)
{
FORCE_INLINE
void
setTargetHotend
(
const
float
&
celsius
,
uint8_t
hotend
)
{
target_temperature
[
HOTEND_ARG
]
=
celsius
;
target_temperature
[
HOTEND_ARG
]
=
celsius
;
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
...
...
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