Skip to content

Commit

Permalink
Cleaned up the new multi-temperature code
Browse files Browse the repository at this point in the history
The temperature of heater elements is now controlled
by new class "Heater".
Instances of this class encapsulate all temperature
management of the respective heater.
Depending on the configuration, the firmware instanciates
a Heater object for the extruder and the build
platform  (Configuration.h HAS_HEATED_BUILD_PLATFORM)
  • Loading branch information
zaggo committed Nov 19, 2009
1 parent 8df4fa5 commit f3779ab
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 325 deletions.
9 changes: 6 additions & 3 deletions ArduinoSlaveExtruder/ArduinoSlaveExtruder.pde
Expand Up @@ -33,7 +33,6 @@
#include "PacketProcessor.h"
#include "Extruder.h"
#include "Heater.h"
#include "BuildPlatform.h"

void init_serial();
void initialize();
Expand Down Expand Up @@ -80,8 +79,12 @@ void loop()
//manage our extruder stuff.
if (!is_tool_paused)
{
manage_extruder_temperature();
manage_platform_temperature();
extruder_heater.manage_temperature();

#ifdef HAS_HEATED_BUILD_PLATFORM
platform_heater.manage_temperature();
#endif

}
}

Expand Down
162 changes: 0 additions & 162 deletions ArduinoSlaveExtruder/BuildPlatform.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions ArduinoSlaveExtruder/BuildPlatform.h

This file was deleted.

20 changes: 16 additions & 4 deletions ArduinoSlaveExtruder/Configuration.h.dist
Expand Up @@ -31,6 +31,12 @@
#define MOTOR_REVERSE_DURATION 300
#define MOTOR_FORWARD_DURATION 300

/****************************************************************************************
* Is there a heated build platform?
****************************************************************************************/

#define HAS_HEATED_BUILD_PLATFORM 1

/****************************************************************************************
* Define the PID behavior for the heater
****************************************************************************************/
Expand Down Expand Up @@ -84,11 +90,17 @@
#define SERVO1_PIN 9
#define SERVO2_PIN 10

#define HEATER_PIN 11
#define FAN_PIN 12
#define VALVE_PIN 15
#define EXTRUDER_HEATER_PIN 11
#define EXTRUDER_THERMISTOR_PIN 3

#define THERMISTOR_PIN 3
#ifdef HAS_HEATED_BUILD_PLATFORM
#define PLATFORM_HEATER_PIN 15
#define PLATFORM_THERMISTOR_PIN 6
#else
#define VALVE_PIN 15
#endif

#define FAN_PIN 12

#define DEBUG_PIN 13

Expand Down
66 changes: 33 additions & 33 deletions ArduinoSlaveExtruder/Extruder.cpp
@@ -1,7 +1,6 @@
#include "Configuration.h"
#include "Extruder.h"
#include "Heater.h"
#include "BuildPlatform.h"
#include "Variables.h"
#include "Timer1.h"
#include "PacketProcessor.h"
Expand Down Expand Up @@ -36,27 +35,18 @@ void init_extruder()
iGain = SPEED_INITIAL_IGAIN;
dGain = SPEED_INITIAL_DGAIN;

// Two Temp Zones
// 1. Extruder
extruder_temp_control_enabled = true;
#if TEMP_PID
extruder_temp_iState = 0;
extruder_temp_dState = 0;
extruder_temp_pGain = TEMP_PID_PGAIN;
extruder_temp_iGain = TEMP_PID_IGAIN;
extruder_temp_dGain = TEMP_PID_DGAIN;
extruder_temp_pid_update_windup();
#endif

// 2. Plateform
platform_temp_control_enabled = true;
#if TEMP_PID
platform_temp_iState = 0;
platform_temp_dState = 0;
platform_temp_pGain = TEMP_PID_PGAIN;
platform_temp_iGain = TEMP_PID_IGAIN;
platform_temp_dGain = TEMP_PID_DGAIN;
platform_temp_pid_update_windup();
#ifdef EXTRUDER_THERMOCOUPLER_PIN
extruder_heater.init(EXTRUDER_THERMOCOUPLER_PIN, EXTRUDER_HEATER_PIN, true);
#else
extruder_heater.init(EXTRUDER_THERMISTOR_PIN, EXTRUDER_HEATER_PIN, false);
#endif

#ifdef HAS_HEATED_BUILD_PLATFORM
#ifdef PLATFORM_THERMOCOUPLER_PIN
platform_heater.init(PLATFORM_THERMOCOUPLER_PIN, PLATFORM_HEATER_PIN, true);
#else
platform_heater.init(PLATFORM_THERMISTOR_PIN, PLATFORM_HEATER_PIN, false);
#endif
#endif

//encoder pins are for reading.
Expand All @@ -83,26 +73,34 @@ void init_extruder()
digitalWrite(MOTOR_2_DIR_PIN, HIGH);

//setup our various accessory pins.
pinMode(HEATER_PIN, OUTPUT);
pinMode(EXTRUDER_HEATER_PIN, OUTPUT);
pinMode(FAN_PIN, OUTPUT);
//pinMode(VALVE_PIN, OUTPUT);
pinMode(PLATFORMHEATER_PIN, OUTPUT);
#ifdef HAS_HEATED_BUILD_PLATFORM
pinMode(PLATFORM_HEATER_PIN, OUTPUT);
#else
pinMode(VALVE_PIN, OUTPUT);
#endif

//turn them all off
digitalWrite(HEATER_PIN, LOW);
digitalWrite(EXTRUDER_HEATER_PIN, LOW);
digitalWrite(FAN_PIN, LOW);
// digitalWrite(VALVE_PIN, LOW);
digitalWrite(PLATFORMHEATER_PIN, LOW);
#ifdef HAS_HEATED_BUILD_PLATFORM
digitalWrite(PLATFORM_HEATER_PIN, LOW);
#else
digitalWrite(VALVE_PIN, LOW);
#endif

//setup our debug pin.
pinMode(DEBUG_PIN, OUTPUT);
digitalWrite(DEBUG_PIN, LOW);

//default to zero.
set_extruder_temperature(0);
extruder_heater.set_target_temperature(0);

#ifdef HAS_HEATED_BUILD_PLATFORM
//default build platform to 60 C
set_platform_temperature(60);
platform_heater.set_target_temperature(60);
#endif

setupTimer1Interrupt();
}
Expand Down Expand Up @@ -284,20 +282,22 @@ void disable_fan()
digitalWrite(FAN_PIN, LOW);
}

#ifndef HAS_HEATED_BUILD_PLATFORM
void open_valve()
{
//digitalWrite(VALVE_PIN, HIGH);
digitalWrite(VALVE_PIN, HIGH);
}

void close_valve()
{
//digitalWrite(VALVE_PIN, LOW);
digitalWrite(VALVE_PIN, LOW);
}
#endif

byte is_tool_ready()
{
//are we within 5% of the temperature?
if (extruder_current_temperature > (int)(extruder_target_temperature * 0.95))
if (extruder_heater.hasReachedTargetTemperature())
return 1;
else
return 0;
Expand Down
2 changes: 2 additions & 0 deletions ArduinoSlaveExtruder/Extruder.h
Expand Up @@ -19,8 +19,10 @@ void disable_motor_2();
void enable_fan();
void disable_fan();

#ifndef HAS_HEATED_BUILD_PLATFORM
void open_valve();
void close_valve();
#endif

byte is_tool_ready();

Expand Down

0 comments on commit f3779ab

Please sign in to comment.