Teacup configuration for the CNC Control Panel project. More...
#include "config.h"
#include <stdint.h>
#include "temp.h"
#include "config.h"
#include <avr/io.h>
Go to the source code of this file.
Defines | |
#define | enable_heater() heater_set(0, 64) |
#define | disable_heater() heater_set(0, 0) |
#define | DEFINE_HEATER(name, pin) HEATER_ ## name, |
#define | HOST |
This is the motherboard, as opposed to the extruder. | |
#define | STEPS_PER_M_X 333333 |
#define | STEPS_PER_M_Y 333333 |
#define | STEPS_PER_M_Z 333333 |
#define | MAXIMUM_FEEDRATE_X 2000 |
used for G0 rapid moves and as a cap for all other feedrates | |
#define | MAXIMUM_FEEDRATE_Y 2000 |
#define | MAXIMUM_FEEDRATE_Z 2000 |
#define | SEARCH_FEEDRATE_X 60 |
used when searching endstops and as default feedrate | |
#define | SEARCH_FEEDRATE_Y 60 |
#define | SEARCH_FEEDRATE_Z 60 |
#define | X_MIN 0.0 |
Soft axis limits, in mm. | |
#define | X_MAX 720.0 |
#define | Y_MIN 0.0 |
#define | Y_MAX 420.0 |
#define | Z_MIN 0.0 |
#define | Z_MAX 110.0 |
#define | ACCELERATION_RAMPING |
acceleration and deceleration ramping. | |
#define | ACCELERATION 50. |
how fast to accelerate when using ACCELERATION_RAMPING. | |
#define | _READ(IO) (IO ## _RPORT & MASK(IO ## _PIN)) |
Read a pin. | |
#define | _WRITE(IO, v) do { if (v) { IO ## _WPORT |= MASK(IO ## _PIN); } else { IO ## _WPORT &= ~MASK(IO ## _PIN); }; } while (0) |
write to a pin | |
#define | _TOGGLE(IO) do { IO ## _RPORT = MASK(IO ## _PIN); } while (0) |
toggle a pin | |
#define | _SET_INPUT(IO) do { IO ## _DDR &= ~MASK(IO ## _PIN); } while (0) |
set pin as input | |
#define | _SET_OUTPUT(IO) do { IO ## _DDR |= MASK(IO ## _PIN); } while (0) |
set pin as output | |
#define | _GET_INPUT(IO) ((IO ## _DDR & MASK(IO ## _PIN)) == 0) |
check if pin is an input | |
#define | _GET_OUTPUT(IO) ((IO ## _DDR & MASK(IO ## _PIN)) != 0) |
check if pin is an output | |
#define | READ(IO) _READ(IO) |
Read a pin wrapper. | |
#define | WRITE(IO, v) _WRITE(IO, v) |
Write to a pin wrapper. | |
#define | TOGGLE(IO) _TOGGLE(IO) |
toggle a pin wrapper | |
#define | SET_INPUT(IO) _SET_INPUT(IO) |
set pin as input wrapper | |
#define | SET_OUTPUT(IO) _SET_OUTPUT(IO) |
set pin as output wrapper | |
#define | GET_INPUT(IO) _GET_INPUT(IO) |
check if pin is an input wrapper | |
#define | GET_OUTPUT(IO) _GET_OUTPUT(IO) |
check if pin is an output wrapper | |
#define | X_STEP_PIN AIO0 |
#define | X_DIR_PIN AIO1 |
#define | X_MIN_PIN AIO2 |
#define | X_INVERT_DIR 1 |
#define | X_INVERT_MIN 1 |
#define | Y_STEP_PIN AIO3 |
#define | Y_DIR_PIN AIO4 |
#define | Y_MIN_PIN AIO5 |
#define | Y_INVERT_MIN 1 |
#define | Z_STEP_PIN DIO2 |
#define | Z_DIR_PIN DIO4 |
#define | Z_MIN_PIN DIO7 |
#define | Z_INVERT_MIN 1 |
#define | CHARGEPUMP_PIN DIO3 |
#define | ESTOP_IN_PIN DIO8 |
#define | ESTOP_INVERT_IN 1 |
#define | BAUD 115200 |
Baud rate for the connection to the host. | |
#define | XONXOFF |
Xon/Xoff flow control. | |
#define | MOVEBUFFER_SIZE 8 |
move buffer size, in number of moves note that each move takes a fair chunk of ram (69 bytes as of this writing) so don't make the buffer too big - a bigger serial readbuffer may help more than increasing this unless your gcodes are more than 70 characters long on average. | |
#define | USE_WATCHDOG |
Teacup implements a watchdog, which has to be reset every 250ms or it will reboot the controller. | |
#define | STEP_INTERRUPT_INTERRUPTIBLE 0 |
this option makes the step interrupt interruptible (nested). | |
#define | ENDSTOP_STEPS 4 |
number of steps to run into the endstops intentionally As Endstops trigger false alarm sometimes, Teacup debounces them by counting a number of consecutive positives. | |
Enumerations | |
enum | heater_t |
Functions | |
void | heater_init (void) |
initialise heater subsystem Set directions, initialise PWM timers, read PID factors from eeprom, etc | |
void | heater_save_settings (void) |
Write PID factors to eeprom. | |
void | heater_set (heater_t index, uint8_t value) |
manually set PWM output | |
void | heater_tick (heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t target_temp) |
run heater PID algorithm | |
uint8_t | heaters_all_off (void) |
turn off all heaters | |
void | pid_set_p (heater_t index, int32_t p) |
set heater P factor | |
void | pid_set_i (heater_t index, int32_t i) |
set heater I factor | |
void | pid_set_d (heater_t index, int32_t d) |
set heater D factor | |
void | pid_set_i_limit (heater_t index, int32_t i_limit) |
set heater I limit | |
void | heater_print (uint16_t i) |
send heater debug info to host |
Teacup configuration for the CNC Control Panel project.
pin definitions and I/O macros
why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
#define ACCELERATION 50. |
how fast to accelerate when using ACCELERATION_RAMPING.
given in mm/s^2, decimal allowed, useful range 1. to 10'000. Start with 10. for milling (high precision) or 1000. for printing
#define ACCELERATION_RAMPING |
acceleration and deceleration ramping.
Each movement starts at (almost) no speed, linearly accelerates to target speed and decelerates just in time to smoothly stop at the target. alternative to ACCELERATION_REPRAP
#define BAUD 115200 |
Baud rate for the connection to the host.
Usually 115200, other common values are 19200, 38400 or 57600.
#define ENDSTOP_STEPS 4 |
number of steps to run into the endstops intentionally As Endstops trigger false alarm sometimes, Teacup debounces them by counting a number of consecutive positives.
Valid range is 1...255. Use 4 or less for reliable endstops, 8 or even more for flaky ones.
TODO: investigate removing this altogether. The S-720 has reed switch endstops that are also buffered on the Zero3, I don't expect it to send any false positives.
#define HOST |
This is the motherboard, as opposed to the extruder.
See extruder/ directory for GEN3 extruder firmware
#define MOVEBUFFER_SIZE 8 |
move buffer size, in number of moves note that each move takes a fair chunk of ram (69 bytes as of this writing) so don't make the buffer too big - a bigger serial readbuffer may help more than increasing this unless your gcodes are more than 70 characters long on average.
however, a larger movebuffer will probably help with lots of short consecutive moves, as each move takes a bunch of math (hence time) to set up so a longer buffer allows more of the math to be done during preceding longer moves
#define STEP_INTERRUPT_INTERRUPTIBLE 0 |
this option makes the step interrupt interruptible (nested).
this should help immensely with dropped serial characters, but may also make debugging infuriating due to the complexities arising from nested interrupts
#define USE_WATCHDOG |
Teacup implements a watchdog, which has to be reset every 250ms or it will reboot the controller.
As rebooting (and letting the GCode sending application trying to continue the build with a then different Home point) is probably even worse than just hanging, and there is no better restore code in place, this is disabled for now.
TODO: add reboot type check, if caused by watchdog send XOFF to the host and lock-up -- otherwise the above scenario applies and we don't want that on a metal-handling machine like this one.
#define X_MIN 0.0 |
Soft axis limits, in mm.
Define them to your machine's size relative to what your host considers to be the origin.
#define XONXOFF |
Xon/Xoff flow control.
Redundant when using RepRap Host for sending GCode, but mandatory when sending GCode files with a plain terminal emulator, like GtkTerm (Linux), CoolTerm (Mac) or HyperTerminal (Windows).
void heater_print | ( | uint16_t | i | ) |
send heater debug info to host
i | index of heater to send info for |
void heater_set | ( | heater_t | index, | |
uint8_t | value | |||
) |
manually set PWM output
index | the heater we're setting the output for | |
value | the PWM value to write |
anything done by this function is overwritten by heater_tick above if the heater has an associated temp sensor
Referenced by heater_tick().
void heater_tick | ( | heater_t | h, | |
temp_sensor_t | t, | |||
uint16_t | current_temp, | |||
uint16_t | target_temp | |||
) |
run heater PID algorithm
h | which heater we're running the loop for | |
t | which temp sensor this heater is attached to | |
current_temp | the temperature that the associated temp sensor is reporting | |
target_temp | the temperature we're trying to achieve |
Referenced by temp_sensor_tick().
uint8_t heaters_all_off | ( | void | ) |
turn off all heaters
for emergency stop
void pid_set_d | ( | heater_t | index, | |
int32_t | d | |||
) |
set heater D factor
index | heater to change D factor for | |
d | scaled D factor |
void pid_set_i | ( | heater_t | index, | |
int32_t | i | |||
) |
set heater I factor
index | heater to change I factor for | |
i | scaled I factor |
void pid_set_i_limit | ( | heater_t | index, | |
int32_t | i_limit | |||
) |
set heater I limit
index | heater to set I limit for | |
i_limit | scaled I limit |
void pid_set_p | ( | heater_t | index, | |
int32_t | p | |||
) |
set heater P factor
index | heater to change factor for | |
p | scaled P factor |