From: Bernhard Tittelbach Date: Mon, 5 Aug 2013 00:59:50 +0000 (+0000) Subject: reprap settins X-Git-Url: https://git.realraum.at/?p=reprap_mendel_prusa.git;a=commitdiff_plain;h=4b729bea491ba060ae83f070aa2e9dc43ccfba58 reprap settins --- diff --git a/teacup_firmware/config.h b/teacup_firmware/config.h index 1c685a3..3be215a 100644 --- a/teacup_firmware/config.h +++ b/teacup_firmware/config.h @@ -1,20 +1,20 @@ /* Notice to developers: this file is intentionally included twice. */ /** \file - \brief Gen3 Electronics Sample Configuration + \brief Gen3 Electronics Sample Configuration */ /* - CONTENTS + CONTENTS - 1. Mechanical/Hardware - 2. Acceleration settings - 3. Pinouts - 4. Temperature sensors - 5. Heaters - 6. Communication options - 7. Miscellaneous - 8. Appendix A - PWMable pins and mappings + 1. Mechanical/Hardware + 2. Acceleration settings + 3. Pinouts + 4. Temperature sensors + 5. Heaters + 6. Communication options + 7. Miscellaneous + 8. Appendix A - PWMable pins and mappings */ /***************************************************************************\ @@ -24,60 +24,60 @@ \***************************************************************************/ /* - Set your microcontroller type in Makefile! atmega168/atmega328p/atmega644p/atmega1280 + Set your microcontroller type in Makefile! atmega168/atmega328p/atmega644p/atmega1280 - If you want to port this to a new chip, start off with arduino.h and see how you go. + If you want to port this to a new chip, start off with arduino.h and see how you go. */ #if ! ( defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__) ) - #error GEN3 has a 644P/644PA! set your cpu type in Makefile! + #error GEN3 has a 644P/644PA! set your cpu type in Makefile! #endif /** \def F_CPU - CPU clock rate + CPU clock rate */ -#ifndef F_CPU - #define F_CPU 16000000UL +#ifndef F_CPU + #define F_CPU 16000000UL #endif /** \def MOTHERBOARD - This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware + This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware */ -#define MOTHERBOARD +#define MOTHERBOARD /** \def STEPS_PER_M - steps per meter ( = steps per mm * 1000 ) + steps per meter ( = steps per mm * 1000 ) - calculate these values appropriate for your machine + calculate these values appropriate for your machine - for threaded rods, this is - (steps motor per turn) / (pitch of the thread) * 1000 + for threaded rods, this is + (steps motor per turn) / (pitch of the thread) * 1000 - for belts, this is - (steps per motor turn) / (number of gear teeth) / (belt module) * 1000 + for belts, this is + (steps per motor turn) / (number of gear teeth) / (belt module) * 1000 - half-stepping doubles the number, quarter stepping requires * 4, etc. + half-stepping doubles the number, quarter stepping requires * 4, etc. - valid range = 20 to 4'0960'000 (0.02 to 40960 steps/mm) + valid range = 20 to 4'0960'000 (0.02 to 40960 steps/mm) - all numbers are integers, so no decimal point, please :-) + all numbers are integers, so no decimal point, please :-) */ -//#define STEPS_PER_M_X 10047 -//#define STEPS_PER_M_X 8000 +//#define STEPS_PER_M_X 10047 +//#define STEPS_PER_M_X 8000 //rechnerisch 8000, experimentell auf der X-Achse 8963.59 //rechnerisch 8000, experimentell auf der X-Achse 8075.67 -#define STEPS_PER_M_X 8050 +#define STEPS_PER_M_X 8200 // 200 steps / 20 gearteeth / 2.5mm (abtsand zahnriemen-zähne) -//#define STEPS_PER_M_Y 10047 -//#define STEPS_PER_M_Y 8000 +//#define STEPS_PER_M_Y 10047 +//#define STEPS_PER_M_Y 8000 //rechnerisch 8000, experimentell auf der Y-Achse 8164.0 -#define STEPS_PER_M_Y 8164 +#define STEPS_PER_M_Y 7950 //160000 für single step mit M8 Muttern, 320000 für half-step mit M8 Muttern //200 steps / 1.25 * 1000 * 2 -#define STEPS_PER_M_Z 320000 +#define STEPS_PER_M_Z 320000 /// http://blog.arcol.hu/?p=157 may help with this one -//#define STEPS_PER_M_E 35200 +//#define STEPS_PER_M_E 35200 // Extruder gear ratio Gr = 14.0 / 43.0 // Extruder nozzle diameter = 0.5mm (bzw 0.35mm mit unserer anderen Düse) // Filament Width = 3mm @@ -88,59 +88,59 @@ // motor_steps for 1 circumfence = 200 // Extruder gear ratio Gr = 14.0 / 43.0 // STEPS_PER_M_E = 1m / (Gr * u_schraube) * motor_steps ¨~= 27933 -//#define STEPS_PER_M_E 27933 +//#define STEPS_PER_M_E 27933 //experimentell (ohne Düse): 99455 previousvalue *(200.0mm software/194.0mm echt) = 102530.93 -#define STEPS_PER_M_E 102531 +#define STEPS_PER_M_E 102531 /* - Values depending on the capabilities of your stepper motors and other mechanics. - All numbers are integers, no decimals allowed. + Values depending on the capabilities of your stepper motors and other mechanics. + All numbers are integers, no decimals allowed. - Units are mm/min + Units are mm/min */ /// used for G0 rapid moves and as a cap for all other feedrates -#define MAXIMUM_FEEDRATE_X 5000 -#define MAXIMUM_FEEDRATE_Y 5000 -#define MAXIMUM_FEEDRATE_Z 100 -#define MAXIMUM_FEEDRATE_E 200 +#define MAXIMUM_FEEDRATE_X 5000 +#define MAXIMUM_FEEDRATE_Y 5000 +#define MAXIMUM_FEEDRATE_Z 100 +#define MAXIMUM_FEEDRATE_E 200 /// used when searching endstops and as default feedrate -#define SEARCH_FEEDRATE_X 50 -#define SEARCH_FEEDRATE_Y 50 -#define SEARCH_FEEDRATE_Z 50 +#define SEARCH_FEEDRATE_X 50 +#define SEARCH_FEEDRATE_Y 50 +#define SEARCH_FEEDRATE_Z 50 // no SEARCH_FEEDRATE_E, as E can't be searched /** \def SLOW_HOMING - wether to search the home point slowly - With some endstop configurations, like when probing for the surface of a PCB, you can't deal with overrunning the endstop. In such a case, uncomment this definition. + wether to search the home point slowly + With some endstop configurations, like when probing for the surface of a PCB, you can't deal with overrunning the endstop. In such a case, uncomment this definition. */ -// #define SLOW_HOMING +// #define SLOW_HOMING /// this is how many steps to suck back the filament by when we stop. set to zero to disable -#define E_STARTSTOP_STEPS 20 +#define E_STARTSTOP_STEPS 20 /** - Soft axis limits, in mm. - Define them to your machine's size relative to what your host considers to be the origin. + Soft axis limits, in mm. + Define them to your machine's size relative to what your host considers to be the origin. */ -#define X_MIN 0.0 +#define X_MIN 0.0 // eigentlich 184mm, aber wir lassen uns ein bisschen Sicherheitsabstand -//#define X_MAX 184.0 -#define X_MAX 177.0 +//#define X_MAX 184.0 +#define X_MAX 177.0 -#define Y_MIN 0.0 -#define Y_MAX 195.0 +#define Y_MIN 0.0 +#define Y_MAX 195.0 -#define Z_MIN 0.0 -#define Z_MAX 125.0 +#define Z_MIN 0.0 +#define Z_MAX 125.0 -/** \def E_ABSOLUTE - Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. +/** \def E_ABSOLUTE + Some G-Code creators produce relative length commands for the extruder, others absolute ones. G-Code using absolute lengths can be recognized when there are G92 E0 commands from time to time. If you have G92 E0 in your G-Code, define this flag. - This is the startup default and can be changed with M82/M83 while running. + This is the startup default and can be changed with M82/M83 while running. */ #define E_ABSOLUTE @@ -157,35 +157,35 @@ \***************************************************************************/ /** \def ACCELERATION_REPRAP - acceleration, reprap style. - Each movement starts at the speed of the previous command and accelerates or decelerates linearly to reach target speed at the end of the movement. + acceleration, reprap style. + Each movement starts at the speed of the previous command and accelerates or decelerates linearly to reach target speed at the end of the movement. */ // #define ACCELERATION_REPRAP /** \def 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 + 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 ACCELERATION_RAMPING /** \def ACCELERATION - 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 + 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 1000. /** \def ACCELERATION_TEMPORAL - temporal step algorithm - This algorithm causes the timer to fire when any axis needs to step, instead of synchronising to the axis with the most steps ala bresenham. + temporal step algorithm + This algorithm causes the timer to fire when any axis needs to step, instead of synchronising to the axis with the most steps ala bresenham. - This algorithm is not a type of acceleration, and I haven't worked out how to integrate acceleration with it. - However it does control step timing, so acceleration algorithms seemed appropriate + This algorithm is not a type of acceleration, and I haven't worked out how to integrate acceleration with it. + However it does control step timing, so acceleration algorithms seemed appropriate - The Bresenham algorithm is great for drawing lines, but not so good for steppers - In the case where X steps 3 times to Y's two, Y experiences massive jitter as it steps in sync with X every 2 out of 3 X steps. This is a worst-case, but the problem exists for most non-45/90 degree moves. At higher speeds, the jitter /will/ cause position loss and unnecessary vibration. - This algorithm instead calculates when a step occurs on any axis, and sets the timer to that value. + The Bresenham algorithm is great for drawing lines, but not so good for steppers - In the case where X steps 3 times to Y's two, Y experiences massive jitter as it steps in sync with X every 2 out of 3 X steps. This is a worst-case, but the problem exists for most non-45/90 degree moves. At higher speeds, the jitter /will/ cause position loss and unnecessary vibration. + This algorithm instead calculates when a step occurs on any axis, and sets the timer to that value. - \todo figure out how to add acceleration to this algorithm + \todo figure out how to add acceleration to this algorithm */ // #define ACCELERATION_TEMPORAL @@ -198,68 +198,68 @@ \***************************************************************************/ /** - Machine Pin Definitions - - make sure to avoid duplicate usage of a pin - - comment out pins not in use, as this drops the corresponding code and makes operations faster + Machine Pin Definitions + - make sure to avoid duplicate usage of a pin + - comment out pins not in use, as this drops the corresponding code and makes operations faster */ -#include "arduino.h" +#include "arduino.h" /** \def USE_INTERNAL_PULLUPS - internal pullup resistors - the ATmega has internal pullup resistors on it's input pins which are counterproductive with the commonly used eletronic endstops, so they should be switched off. For other endstops, like mechanical ones, you may want to uncomment this. + internal pullup resistors + the ATmega has internal pullup resistors on it's input pins which are counterproductive with the commonly used eletronic endstops, so they should be switched off. For other endstops, like mechanical ones, you may want to uncomment this. */ //#define USE_INTERNAL_PULLUPS /** - this is the official gen3 reprap motherboard pinout -*/ -#define TX_ENABLE_PIN DIO12 -#define RX_ENABLE_PIN DIO13 - -#define X_STEP_PIN DIO15 -#define X_DIR_PIN DIO18 -//~ #define X_MIN_PIN DIO20 -#define X_MAX_PIN DIO21 -#define X_ENABLE_PIN DIO19 -//#define X_INVERT_DIR -//~ #define X_INVERT_MIN -//~ #define X_INVERT_MAX -#define X_INVERT_ENABLE - -#define Y_STEP_PIN DIO23 -#define Y_DIR_PIN DIO22 -#define Y_MIN_PIN AIO6 -//~ #define Y_MAX_PIN AIO5 -#define Y_ENABLE_PIN AIO7 -//#define Y_INVERT_DIR -//~ #define Y_INVERT_MIN -//~ #define Y_INVERT_MAX -#define Y_INVERT_ENABLE - -#define Z_STEP_PIN AIO4 -#define Z_DIR_PIN AIO3 -#define Z_MIN_PIN AIO1 -//~ #define Z_MAX_PIN AIO0 -#define Z_ENABLE_PIN AIO2 -//#define Z_INVERT_DIR -//~ #define Z_INVERT_MIN -//~ #define Z_INVERT_MAX -#define Z_INVERT_ENABLE - -#define E_STEP_PIN DIO17 -#define E_DIR_PIN DIO16 -//#define E_ENABLE_PIN xxxx -//#define E_INVERT_DIR -//#define E_INVERT_ENABLE - -#define SD_CARD_DETECT DIO2 -#define SD_WRITE_PROTECT DIO3 - -//#define PS_ON_PIN DIO14 -#define PS_ON_PIN PB5 // on TechZoneComm Motherboard, SPI Port: MOSI -//#define STEPPER_ENABLE_PIN xxxx -//#define STEPPER_INVERT_ENABLE + this is the official gen3 reprap motherboard pinout +*/ +#define TX_ENABLE_PIN DIO12 +#define RX_ENABLE_PIN DIO13 + +#define X_STEP_PIN DIO15 +#define X_DIR_PIN DIO18 +//~ #define X_MIN_PIN DIO20 +#define X_MAX_PIN DIO21 +#define X_ENABLE_PIN DIO19 +//#define X_INVERT_DIR +//~ #define X_INVERT_MIN +//~ #define X_INVERT_MAX +#define X_INVERT_ENABLE + +#define Y_STEP_PIN DIO23 +#define Y_DIR_PIN DIO22 +#define Y_MIN_PIN AIO6 +//~ #define Y_MAX_PIN AIO5 +#define Y_ENABLE_PIN AIO7 +//#define Y_INVERT_DIR +//~ #define Y_INVERT_MIN +//~ #define Y_INVERT_MAX +#define Y_INVERT_ENABLE + +#define Z_STEP_PIN AIO4 +#define Z_DIR_PIN AIO3 +#define Z_MIN_PIN AIO1 +//~ #define Z_MAX_PIN AIO0 +#define Z_ENABLE_PIN AIO2 +//#define Z_INVERT_DIR +//~ #define Z_INVERT_MIN +//~ #define Z_INVERT_MAX +#define Z_INVERT_ENABLE + +#define E_STEP_PIN DIO17 +#define E_DIR_PIN DIO16 +//#define E_ENABLE_PIN xxxx +//#define E_INVERT_DIR +//#define E_INVERT_ENABLE + +#define SD_CARD_DETECT DIO2 +#define SD_WRITE_PROTECT DIO3 + +//#define PS_ON_PIN DIO14 +#define PS_ON_PIN PB5 // on TechZoneComm Motherboard, SPI Port: MOSI +//#define STEPPER_ENABLE_PIN xxxx +//#define STEPPER_INVERT_ENABLE @@ -270,17 +270,17 @@ \***************************************************************************/ /** - TEMP_HYSTERESIS: actual temperature must be target +/- hysteresis before target temperature can be achieved. - Unit is degree Celsius. + TEMP_HYSTERESIS: actual temperature must be target +/- hysteresis before target temperature can be achieved. + Unit is degree Celsius. */ -#define TEMP_HYSTERESIS 5 +#define TEMP_HYSTERESIS 5 /** - TEMP_RESIDENCY_TIME: actual temperature must be close to target (within - set temperature +- TEMP_HYSTERESIS) for this long before target is achieved - (and a M116 succeeds). Unit is seconds. + TEMP_RESIDENCY_TIME: actual temperature must be close to target (within + set temperature +- TEMP_HYSTERESIS) for this long before target is achieved + (and a M116 succeeds). Unit is seconds. */ -#define TEMP_RESIDENCY_TIME 30 +#define TEMP_RESIDENCY_TIME 30 /** TEMP_EWMA: Smooth noisy temperature sensors. Good hardware shouldn't be @@ -296,11 +296,11 @@ #define TEMP_EWMA 0.1 /// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board. -// #define TEMP_MAX6675 -// #define TEMP_THERMISTOR -// #define TEMP_AD595 -// #define TEMP_PT100 -#define TEMP_INTERCOM +// #define TEMP_MAX6675 +// #define TEMP_THERMISTOR +// #define TEMP_AD595 +// #define TEMP_PT100 +#define TEMP_INTERCOM /***************************************************************************\ * * @@ -321,12 +321,12 @@ \***************************************************************************/ #ifndef DEFINE_TEMP_SENSOR - #define DEFINE_TEMP_SENSOR(...) + #define DEFINE_TEMP_SENSOR(...) #endif // name type pin additional DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, AIO0, 0) -//DEFINE_TEMP_SENSOR(bed, TT_INTERCOM, AIO1, 0) +DEFINE_TEMP_SENSOR(bed, TT_INTERCOM, AIO1, 0) // bed has no heater attached #define HEATER_bed HEATER_noheater @@ -339,10 +339,10 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, AIO0, 0) \***************************************************************************/ /** \def HEATER_SANITY_CHECK - check if heater responds to changes in target temperature, disable and spit errors if not - largely untested, please comment in forum if this works, or doesn't work for you! + check if heater responds to changes in target temperature, disable and spit errors if not + largely untested, please comment in forum if this works, or doesn't work for you! */ -// #define HEATER_SANITY_CHECK +// #define HEATER_SANITY_CHECK /***************************************************************************\ * * @@ -375,7 +375,7 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, AIO0, 0) \***************************************************************************/ #ifndef DEFINE_HEATER - #define DEFINE_HEATER(...) + #define DEFINE_HEATER(...) #endif // name port pwm @@ -383,18 +383,18 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, AIO0, 0) // DEFINE_HEATER(bed, PINB4, 1) /** \def HEATER_EXTRUDER - \def HEATER_BED - \def HEATER_FAN - 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. - \NOTE these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! - so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER - I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. + \def HEATER_BED + \def HEATER_FAN + 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. + \NOTE these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! + so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER + I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. */ // workaround for heated bed over intercom. HEATER_EXTRUDER, HEATER_BED are the intercom temp channel numbers. -#define HEATER_EXTRUDER 0 -//~ #define HEATER_BED 1 +#define HEATER_EXTRUDER 0 +#define HEATER_BED 1 #define HEATER_FAN 2 @@ -419,11 +419,11 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, AIO0, 0) // #define USB_SERIAL /** \def 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). - Can also be set in Makefile + 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). + Can also be set in Makefile */ -// #define XONXOFF +// #define XONXOFF @@ -443,86 +443,86 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, AIO0, 0) #define EECONFIG /** \def DEBUG - DEBUG - enables /heaps/ of extra output, and some extra M-codes. - WARNING: this WILL break most host-side talkers that expect particular responses from firmware such as reprap host and replicatorG - use with serial terminal or other suitable talker only. + DEBUG + enables /heaps/ of extra output, and some extra M-codes. + WARNING: this WILL break most host-side talkers that expect particular responses from firmware such as reprap host and replicatorG + use with serial terminal or other suitable talker only. */ -// #define DEBUG +// #define DEBUG /** \def BANG_BANG - BANG_BANG - drops PID loop from heater control, reduces code size significantly (1300 bytes!) - may allow DEBUG on '168 + BANG_BANG + drops PID loop from heater control, reduces code size significantly (1300 bytes!) + may allow DEBUG on '168 *//** \def BANG_BANG_ON - BANG_BANG_ON - PWM value for 'on' + BANG_BANG_ON + PWM value for 'on' *//** \def BANG_BANG_OFF - BANG_BANG_OFF - PWM value for 'off' + BANG_BANG_OFF + PWM value for 'off' */ -// #define BANG_BANG -// #define BANG_BANG_ON 200 -// #define BANG_BANG_OFF 45 +// #define BANG_BANG +// #define BANG_BANG_ON 200 +// #define BANG_BANG_OFF 45 /** - 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 + 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 MOVEBUFFER_SIZE 8 +#define MOVEBUFFER_SIZE 8 /** \def DC_EXTRUDER - DC extruder - If you have a DC motor extruder, configure it as a "heater" above and define this value as the index or name. You probably also want to comment out E_STEP_PIN and E_DIR_PIN in the Pinouts section above. + DC extruder + If you have a DC motor extruder, configure it as a "heater" above and define this value as the index or name. You probably also want to comment out E_STEP_PIN and E_DIR_PIN in the Pinouts section above. */ -// #define DC_EXTRUDER HEATER_motor -// #define DC_EXTRUDER_PWM 180 +// #define DC_EXTRUDER HEATER_motor +// #define DC_EXTRUDER_PWM 180 /** \def 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. + 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. */ // #define USE_WATCHDOG /** - analog subsystem stuff - REFERENCE - which analog reference to use. see analog.h for choices + analog subsystem stuff + REFERENCE - which analog reference to use. see analog.h for choices */ -#define REFERENCE REFERENCE_AVCC +#define REFERENCE REFERENCE_AVCC /** \def STEP_INTERRUPT_INTERRUPTIBLE - 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 + 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 STEP_INTERRUPT_INTERRUPTIBLE 1 +#define STEP_INTERRUPT_INTERRUPTIBLE 1 /** - temperature history count. This is how many temperature readings to keep in order to calculate derivative in PID loop - higher values make PID derivative term more stable at the expense of reaction time + temperature history count. This is how many temperature readings to keep in order to calculate derivative in PID loop + higher values make PID derivative term more stable at the expense of reaction time */ -#define TH_COUNT 8 +#define TH_COUNT 8 /** \def FAST_PWM - Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a - 20(16) MHz electronics. The slower one is the default, as it's the safer - choice. Drawback is, in a quiet environment you might notice the heaters - and your power supply humming. + Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a + 20(16) MHz electronics. The slower one is the default, as it's the safer + choice. Drawback is, in a quiet environment you might notice the heaters + and your power supply humming. - Uncomment this option if you want to get rid of this humming or want - faster PWM for other reasons. + Uncomment this option if you want to get rid of this humming or want + faster PWM for other reasons. - See also: http://reprap.org/wiki/Gen7_Research#MOSFET_heat_and_PWM + See also: http://reprap.org/wiki/Gen7_Research#MOSFET_heat_and_PWM */ -// #define FAST_PWM +// #define FAST_PWM /// this is the scaling of internally stored PID values. 1024L is a good value -#define PID_SCALE 1024L +#define PID_SCALE 1024L /** \def ENDSTOP_STEPS - 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. + 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. */ -#define ENDSTOP_STEPS 4 +#define ENDSTOP_STEPS 4 diff --git a/teacup_firmware/extruder/config.h b/teacup_firmware/extruder/config.h index a531d43..474b971 100644 --- a/teacup_firmware/extruder/config.h +++ b/teacup_firmware/extruder/config.h @@ -1,22 +1,22 @@ /* Notice to developers: this file is intentionally included twice. */ /* - CPU clock rate + CPU clock rate */ -#ifndef F_CPU - #define F_CPU 16000000L +#ifndef F_CPU + #define F_CPU 16000000L #endif /* - other fallbacks for the Arduino IDE + other fallbacks for the Arduino IDE */ #define EXTRUDER #define GEN3 -#include "arduino.h" +#include "arduino.h" // controller index- bus is multidrop after all -#define THIS_CONTROLLER_NUM 0 +#define THIS_CONTROLLER_NUM 0 //RS485 Interface pins #define RX_ENABLE_PIN DIO4 @@ -49,56 +49,61 @@ #define TEMP_BED_PIN AIO6 #define TEMP_BED_PIN_CHANNEL 6 +//Read digital temperature from DS18B20 +#define ONEWIRE_PIN DIO2 -#define REFERENCE REFERENCE_AVCC +#define REFERENCE REFERENCE_AVCC -#define TEMP_THERMISTOR +#define TEMP_THERMISTOR +#define TEMP_DS1820 //e.e.: TechZoneRemix Gen3 Extruder Board: // 12V screw terminal C: DIO12 // 12V screw terminal B: DIO11 // 12V screw terminal A: AIO1 -#define HEATER_PIN DIO12 -#define BED_PIN AIO1 -#define FAN_PIN DIO11 +#define HEATER_PIN DIO12 +#define BED_PIN AIO1 +#define FAN_PIN DIO11 // extruder settings -#define TEMP_HYSTERESIS 5 -#define TEMP_RESIDENCY_TIME 60 - -#ifdef DEFINE_TEMP_SENSOR -DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, TEMP_PIN_CHANNEL, THERMISTOR_EXTRUDER) -DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, TEMP_BED_PIN_CHANNEL, THERMISTOR_EXTRUDER) +#define TEMP_HYSTERESIS 5 +#define TEMP_RESIDENCY_TIME 60 + +#ifdef DEFINE_TEMP_SENSOR +DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, TEMP_PIN_CHANNEL, THERMISTOR_EXTRUDER) +//DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, TEMP_BED_PIN_CHANNEL, THERMISTOR_EXTRUDER) + //9 bits accuracy for faster conversion time +DEFINE_TEMP_SENSOR(bed, TT_ONEWIRE, 0, 9) // dummy temp sensor so analog_mask includes trim pot -DEFINE_TEMP_SENSOR(noheater, TT_THERMISTOR, TRIM_POT_CHANNEL, 0) +DEFINE_TEMP_SENSOR(noheater, TT_THERMISTOR, TRIM_POT_CHANNEL, 0) #endif // DEFINE_HEATER(, , ) // fan startup threshold: FANs usually take more power to start spinning than to keep spinning, // so, below a given pwm value we start the fan with full power and after // 50ms lower the output to the requested value. -#ifdef DEFINE_HEATER -DEFINE_HEATER(extruder, DIO12, 0) -DEFINE_HEATER(bed, AIO1, 0) -DEFINE_HEATER(fan, DIO11, 150) +#ifdef DEFINE_HEATER +DEFINE_HEATER(extruder, DIO12, 0, 0) +DEFINE_HEATER(bed, AIO1, 1, 0) +DEFINE_HEATER(fan, DIO11, 0, 150) #endif // list of PWM-able pins and corresponding timers // timer1 is used for step timing so don't use OC1A/OC1B (DIO9/DIO10) -// OC0A DIO6 -// OC0B DIO5 -// OC1A DIO9 -// OC1B DIO10 -// OC2A DIO11 -// OC2B DIO3 +// OC0A DIO6 +// OC0B DIO5 +// OC1A DIO9 +// OC1B DIO10 +// OC2A DIO11 +// OC2B DIO3 -#define TH_COUNT 8 -#define PID_SCALE 1024L +#define TH_COUNT 8 +#define PID_SCALE 1024L /* - Motors + Motors */ -#define enable_motors() do { TCCR0A |= MASK(COM0A1) | MASK(COM0B1); } while (0) -#define disable_motors() do { TCCR0A &= ~MASK(COM0A1) & ~MASK(COM0B1); } while (0) +#define enable_motors() do { TCCR0A |= MASK(COM0A1) | MASK(COM0B1); } while (0) +#define disable_motors() do { TCCR0A &= ~MASK(COM0A1) & ~MASK(COM0B1); } while (0) diff --git a/teacup_firmware/extruder/extruder.c b/teacup_firmware/extruder/extruder.c deleted file mode 100644 index b9a5f50..0000000 --- a/teacup_firmware/extruder/extruder.c +++ /dev/null @@ -1,250 +0,0 @@ -#include -#include - -#include - -#include "intercom.h" -#include "analog.h" -#include "config.h" -#include "watchdog.h" -#include "heater.h" -#include "temp.h" -#include "timer.h" - -static uint8_t motor_pwm; -static uint8_t motor_idle_counter; - -void io_init(void) { - // setup I/O pins - WRITE(DEBUG_LED, 0); SET_OUTPUT(DEBUG_LED); - WRITE(H1D,0); SET_OUTPUT(H1D); - WRITE(H1E,0); SET_OUTPUT(H1E); - WRITE(H2D,0); SET_OUTPUT(H2D); - WRITE(H2E,0); SET_OUTPUT(H2E); - - SET_INPUT(TRIM_POT); - SET_INPUT(TEMP_PIN); - SET_INPUT(TEMP_BED_PIN); - SET_INPUT(E_STEP_PIN); - SET_INPUT(E_DIR_PIN); - - // use pull up resistors to avoid noise - WRITE(E_STEP_PIN, 1); - WRITE(E_DIR_PIN, 1); - - //Enable the RS485 transceiver - SET_OUTPUT(RX_ENABLE_PIN); - SET_OUTPUT(TX_ENABLE_PIN); - WRITE(RX_ENABLE_PIN,0); - disable_transmit(); - - #ifdef HEATER_PIN - WRITE(HEATER_PIN, 0); SET_OUTPUT(HEATER_PIN); - #endif - - #ifdef BED_PIN - WRITE(BED_PIN, 0); SET_OUTPUT(BED_PIN); - #endif - - #ifdef FAN_PIN - WRITE(FAN_PIN, 0); SET_OUTPUT(FAN_PIN); - #endif - -// #if defined(HEATER_PWM) || defined(FAN_PWM) || defined(BED_PWM) - // setup PWM timer: fast PWM, no prescaler - TCCR2A = MASK(WGM21) | MASK(WGM20); - TCCR2B = MASK(CS22); - TIMSK2 = 0; - OCR2A = 0; - OCR2B = 0; -// #endif - - #if defined(H1E_PWM) && defined(H2E_PWM) - TCCR0A = MASK(WGM01) | MASK(WGM00); - TCCR0B = MASK(CS20); - TIMSK0 = 0; - OCR0A = 0; - OCR0B = 0; - #endif -} - -void motor_init(void) { - //Enable an interrupt to be triggered when the step pin changes - //This will be PCIE0 - motor_idle_counter = 0; - PCICR = MASK(PCIE0); - PCMSK0 = MASK(PCINT2); -} - -ISR(PCINT0_vect) { - static uint8_t coil_pos, pwm; - - //if the step pin is high, we advance the motor - if (READ(E_STEP_PIN)) { - - //Turn on motors only on first tick to save power I guess - enable_motors(); - - //Set motor idle counter to zero - motor_idle_counter = 0; - - //Advance the coil position - if (READ(E_DIR_PIN)) - coil_pos++; - else - coil_pos--; - - coil_pos &= 7; - - //Grab the latest motor power to use - pwm = motor_pwm; - - switch(coil_pos) { - case 0: - WRITE(H1D, 0); - WRITE(H2D, 0); - H1E_PWM = 0; - H2E_PWM = pwm; - break; - case 1: - WRITE(H1D, 1); - WRITE(H2D, 0); - H1E_PWM = pwm; - H2E_PWM = pwm; - break; - case 2: - WRITE(H1D, 1); - WRITE(H2D, 0); - H1E_PWM = pwm; - H2E_PWM = 0; - break; - case 3: - WRITE(H1D, 1); - WRITE(H2D, 1); - H1E_PWM = pwm; - H2E_PWM = pwm; - break; - case 4: - WRITE(H1D, 1); - WRITE(H2D, 1); - H1E_PWM = 0; - H2E_PWM = pwm; - break; - case 5: - WRITE(H1D, 0); - WRITE(H2D, 1); - H1E_PWM = pwm; - H2E_PWM = pwm; - break; - case 6: - WRITE(H1D, 0); - WRITE(H2D, 1); - H1E_PWM = pwm; - H2E_PWM = 0; - break; - case 7: - WRITE(H1D, 0); - WRITE(H2D, 0); - H1E_PWM = pwm; - H2E_PWM = pwm; - break; - } - } -} - -void init(void) { - // set up watchdog - wd_init(); - - // setup analog reading - analog_init(); - - // set up serial - intercom_init(); - - // set up inputs and outputs - io_init(); - - // temp sensor - temp_init(); - - // heater - heater_init(); - - // set up extruder motor driver - motor_init(); - - // set up clock - timer_init(); - - // enable interrupts - sei(); - - // reset watchdog - wd_reset(); -} - -uint8_t writebuff[11]; -int main (void) -{ - init(); - - enable_heater(); - - // main loop - for (;;) - { - wd_reset(); - - //Read motor PWM - motor_pwm = analog_read(TRIM_POT_CHANNEL) >> 2; - - ifclock(CLOCK_FLAG_10MS) { - // check temperatures and manage heaters - temp_sensor_tick(); - } - ifclock(CLOCK_FLAG_250MS) { - // this is of course bad code, since the interupt routine setting motor_idle_counter to 0 can be run at any time during this code. Worst case, it runs while disable_motors() is halfway in progress - motor_idle_counter++; - if (motor_idle_counter > 3) - disable_motors(); - } - - // check if we've had a new intercom packet - if (intercom_flags & FLAG_NEW_RX) { - intercom_flags &= ~FLAG_NEW_RX; - - switch (rx.packet.control_word) { - // M105- read temperatures - case 105: - send_temperature(0, temp_get(0)); - temp_set(0, read_temperature(0)); - send_temperature(1, temp_get(1)); - temp_set(1, read_temperature(1)); - start_send(); - break; - // M130 - set PID P factor - case 130: - pid_set_p(rx.packet.control_index, rx.packet.control_data_int32); - // M131 - set PID I factor - case 131: - pid_set_i(rx.packet.control_index, rx.packet.control_data_int32); - // M132 - set PID D factor - case 132: - pid_set_d(rx.packet.control_index, rx.packet.control_data_int32); - // M133 - set PID I limit - case 133: - pid_set_i_limit(rx.packet.control_index, rx.packet.control_data_int32); - // M134 - save PID values to eeprom - case 134: - heater_save_settings(); - break; - } - } - - if (intercom_flags & FLAG_TX_FINISHED) { - WRITE(TX_ENABLE_PIN,0); - } - - } -}