heaters: allow to disable PWM on PWM-able pins.

This is not only handy for debugging non-PWM mode, it may also
help those who run a heated bed attached to a solid state relay.

This way it was found out connecting heaters to non-PWM pins
works just fine and did so for a loooong time.

Not yet distributed to all the config.h templates.
This commit is contained in:
Markus Hitter 2012-10-12 02:25:40 +02:00
parent 5a2677f685
commit 8d91312991
3 changed files with 17 additions and 13 deletions

View File

@ -321,9 +321,6 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO1, THERMISTOR_EXTRUDER)
* *
* Define your heaters here. *
* *
* Currently, heaters work on PWM-able pins, only. See the end of this file *
* for PWM-able pin mappings. *
* *
* To attach a heater to a temp sensor above, simply use exactly the same *
* name - copy+paste is your friend. Some common names are 'extruder', *
* 'bed', 'fan', 'motor', ... names with special meaning can be found *
@ -336,18 +333,25 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO1, THERMISTOR_EXTRUDER)
* temperature sensor of TT_NONE, then you can control the spindle's rpm *
* via temperature commands. M104 S1..255 for spindle on, M104 S0 for off. *
* *
* Set 'pwm' to ... *
* 1 for using PWM on a PWM-able pin and on/off on other pins. *
* 0 for using on/off on a PWM-able pin, too. *
* Using PWM usually gives smoother temperature control but can conflict *
* with slow switches, like solid state relays. PWM frequency can be *
* influenced globally with FAST_PWM, see below. *
* *
\***************************************************************************/
#ifndef DEFINE_HEATER
#define DEFINE_HEATER(...)
#endif
// name port
DEFINE_HEATER(extruder, PB3)
DEFINE_HEATER(bed, PB4)
// DEFINE_HEATER(fan, PINB4)
// DEFINE_HEATER(chamber, PIND7)
// DEFINE_HEATER(motor, PIND6)
// name port pwm
DEFINE_HEATER(extruder, PB3, 1)
DEFINE_HEATER(bed, PB4, 1)
// DEFINE_HEATER(fan, PINB4, 1)
// DEFINE_HEATER(chamber, PIND7, 1)
// DEFINE_HEATER(motor, PIND6, 1)
/// and now because the c preprocessor isn't as smart as it could be,
/// uncomment the ones you've listed above and comment the rest.

View File

@ -27,8 +27,8 @@ typedef struct {
#undef DEFINE_HEATER
/// \brief helper macro to fill heater definition struct from config.h
// #define DEFINE_HEATER(name, port, pin, pwm) { &(port), (pin), &(pwm) },
#define DEFINE_HEATER(name, pin) { &(pin ## _WPORT), pin ## _PIN, (pin ## _PWM) },
#define DEFINE_HEATER(name, pin, pwm) { &(pin ## _WPORT), pin ## _PIN, \
pwm ? (pin ## _PWM) : NULL},
static const heater_definition_t heaters[NUM_HEATERS] =
{
#include "config.h"
@ -251,7 +251,7 @@ void heater_init() {
// set all heater pins to output
do {
#undef DEFINE_HEATER
#define DEFINE_HEATER(name, pin) WRITE(pin, 0); SET_OUTPUT(pin);
#define DEFINE_HEATER(name, pin, pwm) WRITE(pin, 0); SET_OUTPUT(pin);
#include "config.h"
#undef DEFINE_HEATER
} while (0);

View File

@ -6,7 +6,7 @@
#include "temp.h"
#undef DEFINE_HEATER
#define DEFINE_HEATER(name, pin) HEATER_ ## name,
#define DEFINE_HEATER(name, pin, pwm) HEATER_ ## name,
typedef enum
{
#include "config.h"