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
a1f074de
Commit
a1f074de
authored
May 11, 2016
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fast PWM for cooler
parent
9947f434
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
23 deletions
+48
-23
temperature.cpp
MK/module/temperature/temperature.cpp
+48
-23
No files found.
MK/module/temperature/temperature.cpp
View file @
a1f074de
...
...
@@ -99,6 +99,10 @@ float current_temperature_cooler = 0.0;
unsigned
char
soft_pwm_bed
;
unsigned
char
soft_pwm_cooler
;
void
setPwmCooler
(
unsigned
char
pwm
);
unsigned
char
getPwmCooler
(
bool
soft
=
true
);
#if ENABLED(BABYSTEPPING)
volatile
int
babystepsTodo
[
3
]
=
{
0
};
#endif
...
...
@@ -266,6 +270,25 @@ static void updateTemperaturesFromRawValues();
//================================ Functions ================================
//===========================================================================
void
setPwmCooler
(
unsigned
char
pwm
)
{
soft_pwm_cooler
=
pwm
>>
1
;
#if ENABLED(FAST_PWM_COOLER)
analogWrite
(
COOLER_PIN
,
pwm
);
#endif
}
unsigned
char
getPwmCooler
(
bool
soft
=
true
)
{
if
(
soft
)
return
soft_pwm_cooler
;
#if ENABLED(FAST_PWM_COOLER)
return
analogRead
(
COOLER_PIN
);
#else
return
soft_pwm_cooler
*
2
;
#endif
}
void
autotempShutdown
()
{
#if ENABLED(AUTOTEMP)
if
(
autotemp_enabled
)
{
...
...
@@ -325,8 +348,10 @@ void autotempShutdown() {
if
(
temp_controller
==
-
1
)
soft_pwm_bed
=
bias
=
d
=
MAX_BED_POWER
/
2
;
else
if
(
temp_controller
<
-
1
)
soft_pwm_cooler
=
bias
=
d
=
MAX_COOLER_POWER
/
2
;
else
if
(
temp_controller
<
-
1
)
{
bias
=
d
=
MAX_COOLER_POWER
/
2
;
setPwmCooler
(
MAX_COOLER_POWER
);
}
else
soft_pwm
[
temp_controller
]
=
bias
=
d
=
PID_MAX
/
2
;
...
...
@@ -358,8 +383,8 @@ void autotempShutdown() {
if
(
running
&&
((
input
>
temp
&&
temp_controller
>=
-
1
)
||
(
input
<
temp
&&
temp_controller
<
-
1
)))
{
if
(
ms
>
t2
+
5000UL
)
{
running
=
false
;
if
(
temp_controller
<
-
1
)
soft_pwm_cooler
=
(
bias
-
d
)
>>
1
;
if
(
temp_controller
<
-
1
)
setPwmCooler
((
bias
-
d
))
;
else
if
(
temp_controller
<
0
)
soft_pwm_bed
=
(
bias
-
d
)
>>
1
;
else
...
...
@@ -420,7 +445,7 @@ void autotempShutdown() {
#endif
#if ENABLED(PIDTEMPCOOLER)
if
(
temp_controller
<
-
1
)
s
oft_pwm_cooler
=
(
bias
+
d
)
>>
1
;
s
etPwmCooler
((
bias
+
d
))
;
#endif
cycles
++
;
if
(
temp_controller
<
-
1
)
...
...
@@ -975,27 +1000,27 @@ void manage_temp_controller() {
#if ENABLED(PIDTEMPCOOLER)
float
pid_output
=
get_pid_output_cooler
();
s
oft_pwm_cooler
=
current_temperature_cooler
>
COOLER_MINTEMP
&&
current_temperature_cooler
<
COOLER_MAXTEMP
?
(
int
)
pid_output
>>
1
:
0
;
s
etPwmCooler
(
current_temperature_cooler
>
COOLER_MINTEMP
&&
current_temperature_cooler
<
COOLER_MAXTEMP
?
(
int
)
pid_output
:
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
)
s
oft_pwm_cooler
=
MAX_COOLER_POWER
>>
1
;
s
etPwmCooler
(
MAX_COOLER_POWER
)
;
else
if
(
current_temperature_cooler
<=
target_temperature_cooler
-
COOLER_HYSTERESIS
)
s
oft_pwm_cooler
=
0
;
s
etPwmCooler
(
0
)
;
}
else
{
// NEXTIME XXX here we have to manage hw pwm?
s
oft_pwm_cooler
=
0
;
else
{
s
etPwmCooler
(
0
)
;
WRITE_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
)
{
s
oft_pwm_cooler
=
current_temperature_cooler
>
target_temperature_cooler
?
MAX_COOLER_POWER
>>
1
:
0
;
s
etPwmCooler
(
current_temperature_cooler
>
target_temperature_cooler
?
MAX_COOLER_POWER
:
0
)
}
else
{
s
oft_pwm_cooler
=
0
;
s
etPwmCooler
(
0
)
;
WRITE_COOLER
(
LOW
);
}
#endif
...
...
@@ -1631,8 +1656,8 @@ void disable_all_coolers() {
#if HAS(TEMP_COOLER)
target_temperature_cooler
=
0
;
s
oft_pwm_cooler
=
0
;
#if HAS(COOLER_DEV)
s
etPwmCooler
(
0
)
;
#if HAS(COOLER_DEV)
&& !ENABLED(FAST_PWM_COOLER)
WRITE_COOLER
(
LOW
);
#endif
#endif
...
...
@@ -1790,7 +1815,7 @@ ISR(TIMER0_COMPB_vect) {
#if HAS(HEATER_BED)
ISR_STATICS
(
BED
);
#endif
#if HAS(COOLER_DEV)
#if HAS(COOLER_DEV)
&& !ENABLED(FAST_PWM_COOLER)
ISR_STATICS
(
COOLER_DEV
);
#endif
...
...
@@ -1826,9 +1851,9 @@ ISR(TIMER0_COMPB_vect) {
soft_pwm_BED
=
soft_pwm_bed
;
WRITE_HEATER_BED
(
soft_pwm_BED
>
0
?
1
:
0
);
#endif
#if HAS(COOLER_DEV)
soft_pwm_
cooler
=
soft_pwm_cooler
;
WRITE_COOLER
(
soft_pwm_
cooler
>
0
?
1
:
0
);
#if HAS(COOLER_DEV)
&& !ENABLED(FAST_PWM_COOLER)
soft_pwm_
COOLER_DEV
=
soft_pwm_cooler
;
WRITE_COOLER
(
soft_pwm_
COOLER_DEV
>
0
?
1
:
0
);
#endif
#if ENABLED(FAN_SOFT_PWM)
soft_pwm_fan
=
fanSpeedSoftPwm
/
2
;
...
...
@@ -1869,8 +1894,8 @@ ISR(TIMER0_COMPB_vect) {
#if HAS(HEATER_BED)
if
(
soft_pwm_BED
<
pwm_count
)
WRITE_HEATER_BED
(
0
);
#endif
#if HAS(COOLER_DEV)
if
(
soft_pwm_
cooler
<
pwm_count
)
WRITE_COOLER
(
0
);
#if HAS(COOLER_DEV)
&& !ENABLED(FAST_PWM_COOLER)
if
(
soft_pwm_
COOLER_DEV
<
pwm_count
)
WRITE_COOLER
(
0
);
#endif
#if ENABLED(FAN_SOFT_PWM)
...
...
@@ -1953,7 +1978,7 @@ ISR(TIMER0_COMPB_vect) {
#if HAS(HEATER_BED)
_SLOW_PWM_ROUTINE
(
BED
,
soft_pwm_bed
);
// BED
#endif
#if HAS(COOLER_DEV)
#if HAS(COOLER_DEV)
&& !ENABLED(FAST_PWM_COOLER)
_SLOW_PWM_SOURINT
(
COOLER_DEV
,
soft_pwm_cooler
);
// COOLER
#endif
...
...
@@ -1972,7 +1997,7 @@ ISR(TIMER0_COMPB_vect) {
#if HAS(HEATER_BED)
PWM_OFF_ROUTINE
(
BED
);
// BED
#endif
#if HAS(COOLER_DEV)
#if HAS(COOLER_DEV)
&& !ENABLED(FAST_PWM_COOLER)
PWM_OFF_ROUTINE
(
COOLER_DEV
);
// COOLER
#endif
...
...
@@ -2044,7 +2069,7 @@ ISR(TIMER0_COMPB_vect) {
#if HAS(HEATER_BED)
if
(
state_timer_heater_BED
>
0
)
state_timer_heater_BED
--
;
#endif
#if HAS(COOLER_DEV)
#if HAS(COOLER_DEV)
&& !ENABLED(FAST_PWM_COOLER)
if
(
state_timer_heater_COOLER_DEV
>
0
)
state_timer_heater_COOLER_DEV
--
;
#endif
}
// (pwm_count % 64) == 0
...
...
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