Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto power : ENABLE_POWER_ON_STARTUP == 2 only turn on power pin when heat required #639

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ArduinoDUE/Repetier/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,9 @@ to activate the quadratic term. Only adds lots of computations and storage usage
/**
Some boards like Gen7 have a power on pin, to enable the ATX power supply. If this is defined,
the power will be turned on without the need to call M80 if initially started.
0 = Do not power on
1 = Power on startup
2 = Only power on when heaters / heatbed target temp >= 20 and power off again when heaters & heatbed all off (or on sensor defect)
*/
#define ENABLE_POWER_ON_STARTUP 1

Expand Down
21 changes: 21 additions & 0 deletions src/ArduinoDUE/Repetier/Extruder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ void Extruder::manageTemperatures()
#ifdef RED_BLUE_STATUS_LEDS
bool hot = false;
#endif
#if defined(ENABLE_POWER_ON_STARTUP) && ENABLE_POWER_ON_STARTUP == 2 && (PS_ON_PIN>-1)
bool haveHeatDemand = false;
#endif // ENABLE_POWER_ON_STARTUP == 2
bool newDefectFound = false;
millis_t time = HAL::timeInMilliseconds(); // compare time for decouple tests
#if NUM_TEMPERATURE_LOOPS > 0
Expand All @@ -78,6 +81,9 @@ void Extruder::manageTemperatures()
TemperatureController *act = tempController[controller];
// Get Temperature
act->updateCurrentTemperature();
#if defined(ENABLE_POWER_ON_STARTUP) && ENABLE_POWER_ON_STARTUP == 2 && (PS_ON_PIN>-1)
haveHeatDemand |= (act->targetTemperatureC >= 20); //PID defines off as < 20
#endif // ENABLE_POWER_ON_STARTUP == 2
#if FAN_THERMO_PIN > -1
// Special case thermistor controlled fan
if(act == &thermoController) {
Expand Down Expand Up @@ -356,6 +362,21 @@ void Extruder::manageTemperatures()
} // any sensor defect
#endif // NUM_TEMPERATURE_LOOPS

#if defined(ENABLE_POWER_ON_STARTUP) && ENABLE_POWER_ON_STARTUP == 2 && (PS_ON_PIN>-1)
if(haveHeatDemand && !Printer::isAnyTempsensorDefect()){
if(!Printer::isPowerOn()) {
GCode gc; //not fully initialised but processMCode only needs M set for commands 80/81
gc.M=80;
Commands::processMCode(&gc);
}
}
else if(Printer::isPowerOn()) {
GCode gc; //not fully initialised but processMCode only needs M set for commands 80/81
gc.M=81;
Commands::processMCode(&gc);
}
#endif //ENABLE_POWER_ON_STARTUP == 2

// Report temperatures every second, so we do not need to send M105
if(Printer::isAutoreportTemp()) {
millis_t now = HAL::timeInMilliseconds();
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoDUE/Repetier/Printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ void Printer::setup()
#endif
#endif

#if defined(ENABLE_POWER_ON_STARTUP) && ENABLE_POWER_ON_STARTUP && (PS_ON_PIN>-1)
#if defined(ENABLE_POWER_ON_STARTUP) && ENABLE_POWER_ON_STARTUP == 1 && (PS_ON_PIN>-1)
SET_OUTPUT(PS_ON_PIN); //GND
WRITE(PS_ON_PIN, (POWER_INVERTING ? HIGH : LOW));
Printer::setPowerOn(true);
Expand Down