Skip to content
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
13 changes: 13 additions & 0 deletions config.h.dist
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@

#define STEPPER_ENABLE_PIN DIO9

/*
If your endstops are inverted, change this to a zero
*/
#define ENDSTOP_OK_VALUE 1

/*
* list of PWM-able pins and corresponding timers
* timer1 is used for step timing so don't use OC1A/OC1B
Expand Down Expand Up @@ -226,6 +231,14 @@
#define FAN_PIN DIO5
#define FAN_PWM OCR0B

/*
Define this to disable PID and use bang-bang instead.
If you do this, you must also comment out "HEATER_PWM" above.
Otherwise it won't work correctly. Using bang-bang takes MUCH less
space.
*/
//#define BANG_BANG

// --------------------------------------------------------------------------
// you shouldn't need to edit anything below this line

Expand Down
2 changes: 2 additions & 0 deletions gcode_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ void process_gcode_command() {
break;

#ifdef HEATER_PIN
#ifndef BANG_BANG
// M130- heater P factor
case 130:
if (next_target.seen_S)
Expand All @@ -288,6 +289,7 @@ void process_gcode_command() {
case 134:
heater_save_settings();
break;
#endif /* BANG_BANG */
#endif /* HEATER_PIN */

// M190- power on
Expand Down
12 changes: 10 additions & 2 deletions heater.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "heater.h"

#ifdef HEATER_PIN
#ifndef BANG_BANG

#ifndef SIMULATION
#include <avr/eeprom.h>
Expand Down Expand Up @@ -105,5 +106,12 @@ void heater_tick(int16_t current_temp, int16_t target_temp) {
disable_heater();
#endif
}

#endif /* HEATER_PIN */
#else /* BANG_BANG */
void heater_tick(int16_t current_temp, int16_t target_temp) {
if ( current_temp < target_temp )
enable_heater();
else
disable_heater();
}
#endif /* BANG_BANG */
#endif /* HEATER_PIN */
49 changes: 46 additions & 3 deletions mendel.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,54 @@ void io_init(void) {
// setup I/O pins
WRITE(X_STEP_PIN, 0); SET_OUTPUT(X_STEP_PIN);
WRITE(X_DIR_PIN, 0); SET_OUTPUT(X_DIR_PIN);
WRITE(X_MIN_PIN, 1); SET_INPUT(X_MIN_PIN);
#ifdef X_MIN_PIN
#if ENDSTOP_OK_VALUE == 0
WRITE(X_MIN_PIN, 0); SET_INPUT(X_MIN_PIN);
#else
WRITE(X_MIN_PIN, 1); SET_INPUT(X_MIN_PIN);
#endif
#endif
#ifdef X_MAX_PIN
#if ENDSTOP_OK_VALUE == 0
WRITE(X_MAX_PIN, 0); SET_INPUT(X_MAX_PIN);
#else
WRITE(X_MAX_PIN, 1); SET_INPUT(X_MAX_PIN);
#endif
#endif

WRITE(Y_STEP_PIN, 0); SET_OUTPUT(Y_STEP_PIN);
WRITE(Y_DIR_PIN, 0); SET_OUTPUT(Y_DIR_PIN);
WRITE(Y_MIN_PIN, 1); SET_INPUT(Y_MIN_PIN);
#ifdef Y_MIN_PIN
#if ENDSTOP_OK_VALUE == 0
WRITE(Y_MIN_PIN, 0); SET_INPUT(Y_MIN_PIN);
#else
WRITE(Y_MIN_PIN, 1); SET_INPUT(Y_MIN_PIN);
#endif
#endif
#ifdef Y_MAX_PIN
#if ENDSTOP_OK_VALUE == 0
WRITE(Y_MAX_PIN, 0); SET_INPUT(Y_MAX_PIN);
#else
WRITE(Y_MAX_PIN, 1); SET_INPUT(Y_MAX_PIN);
#endif
#endif

WRITE(Z_STEP_PIN, 0); SET_OUTPUT(Z_STEP_PIN);
WRITE(Z_DIR_PIN, 0); SET_OUTPUT(Z_DIR_PIN);
WRITE(Z_MIN_PIN, 1); SET_INPUT(Z_MIN_PIN);
#ifdef Z_MIN_PIN
#if ENDSTOP_OK_VALUE == 0
WRITE(Z_MIN_PIN, 0); SET_INPUT(Z_MIN_PIN);
#else
WRITE(Z_MIN_PIN, 1); SET_INPUT(Z_MIN_PIN);
#endif
#endif
#ifdef Z_MAX_PIN
#if ENDSTOP_OK_VALUE == 0
WRITE(Z_MAX_PIN, 0); SET_INPUT(Z_MAX_PIN);
#else
WRITE(Z_MAX_PIN, 1); SET_INPUT(Z_MAX_PIN);
#endif
#endif

WRITE(E_STEP_PIN, 0); SET_OUTPUT(E_STEP_PIN);
WRITE(E_DIR_PIN, 0); SET_OUTPUT(E_DIR_PIN);
Expand Down Expand Up @@ -95,7 +134,11 @@ void init(void) {
clock_setup();

// read PID settings from EEPROM
#ifdef HEATER_PIN
#ifndef BANG_BANG
heater_init();
#endif
#endif

// set up default feedrate
current_position.F = startpoint.F = next_target.target.F = SEARCH_FEEDRATE_Z;
Expand Down