00001 /* Notice to developers: this file is intentionally included twice. */ 00002 00003 /* 00004 CONTENTS 00005 00006 1. Mechanical/Hardware 00007 2. Acceleration settings 00008 3. Pinouts 00009 4. Temperature sensors 00010 5. Heaters 00011 6. Communication options 00012 7. Miscellaneous 00013 8. Appendix A - PWMable pins and mappings 00014 */ 00015 00016 /***************************************************************************\ 00017 * * 00018 * 1. MECHANICAL/HARDWARE * 00019 * * 00020 \***************************************************************************/ 00021 00022 /* 00023 Set your microcontroller type in Makefile! atmega168/atmega328p/atmega644p/atmega1280 00024 00025 If you want to port this to a new chip, start off with arduino.h and see how you go. 00026 */ 00027 #if ! ( defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__) ) 00028 #error RAMPS has 1280/2560! set your cpu type in Makefile! 00029 #endif 00030 00031 /* 00032 CPU clock rate 00033 */ 00034 #ifndef F_CPU 00035 #define F_CPU 16000000L 00036 #endif 00037 00038 /* 00039 This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware 00040 */ 00041 #define HOST 00042 00043 /* 00044 Values reflecting the gearing of your machine. 00045 All numbers are fixed point integers, so no more than 3 digits to the right of the decimal point, please :-) 00046 */ 00047 00048 // calculate these values appropriate for your machine 00049 // for threaded rods, this is (steps motor per turn) / (pitch of the thread) 00050 // for belts, this is (steps per motor turn) / (number of gear teeth) / (belt module) 00051 // half-stepping doubles the number, quarter stepping requires * 4, etc. 00052 #define MICROSTEPPING_X 16.0 00053 #define MICROSTEPPING_Y 16.0 00054 #define MICROSTEPPING_Z 16.0 00055 #define MICROSTEPPING_E 4.0 00056 00057 #define STEPS_PER_MM_X (5.023*MICROSTEPPING_X) 00058 #define STEPS_PER_MM_Y (5.023*MICROSTEPPING_Y) 00059 #define STEPS_PER_MM_Z (416.699*MICROSTEPPING_Z) 00060 00061 // http://blog.arcol.hu/?p=157 may help with this next one 00062 #define STEPS_PER_MM_E (2.759*MICROSTEPPING_E) 00063 00064 00065 /* 00066 Values depending on the capabilities of your stepper motors and other mechanics. 00067 All numbers are integers, no decimals allowed. 00068 00069 Units are mm/min 00070 */ 00071 00072 // used for G0 rapid moves and as a cap for all other feedrates 00073 #define MAXIMUM_FEEDRATE_X 200 00074 #define MAXIMUM_FEEDRATE_Y 200 00075 #define MAXIMUM_FEEDRATE_Z 100 00076 #define MAXIMUM_FEEDRATE_E 600 00077 00078 // used when searching endstops and as default feedrate 00079 #define SEARCH_FEEDRATE_X 50 00080 #define SEARCH_FEEDRATE_Y 50 00081 #define SEARCH_FEEDRATE_Z 1 00082 #define SEARCH_FEEDRATE_E 50 00083 00084 // this is how many steps to suck back the filament by when we stop. set to zero to disable 00085 #define E_STARTSTOP_STEPS 0 00086 00087 00088 /* 00089 Soft axis limits, in mm 00090 undefine if you don't want to use them 00091 */ 00092 00093 #define X_MIN 0.0 00094 #define X_MAX 200.0 00095 00096 #define Y_MIN 0.0 00097 #define Y_MAX 200.0 00098 00099 #define Z_MIN 0.0 00100 #define Z_MAX 140.0 00101 00102 00103 00104 /***************************************************************************\ 00105 * * 00106 * 2. ACCELERATION * 00107 * * 00108 * IMPORTANT: choose only one! These algorithms choose when to step, trying * 00109 * to use more than one will have undefined and probably * 00110 * disastrous results! * 00111 * * 00112 \***************************************************************************/ 00113 00114 00115 /* 00116 acceleration, reprap style. 00117 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. 00118 */ 00119 // #define ACCELERATION_REPRAP 00120 00121 00122 /* 00123 acceleration and deceleration ramping. 00124 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 00125 */ 00126 #define ACCELERATION_RAMPING 00127 00128 // how fast to accelerate when using ACCELERATION_RAMPING 00129 // smaller values give quicker acceleration 00130 // valid range = 1 to 8,000,000; 500,000 is a good starting point 00131 #define ACCELERATION_STEEPNESS 500000 00132 00133 00134 /* 00135 temporal step algorithm 00136 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. 00137 00138 This algorithm is not a type of acceleration, and I haven't worked out how to integrate acceleration with it. 00139 However it does control step timing, so acceleration algorithms seemed appropriate 00140 00141 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. 00142 This algorithm instead calculates when a step occurs on any axis, and sets the timer to that value. 00143 00144 // TODO: figure out how to add acceleration to this algorithm 00145 */ 00146 // #define ACCELERATION_TEMPORAL 00147 00148 00149 00150 /***************************************************************************\ 00151 * * 00152 * 3. PINOUTS * 00153 * * 00154 \***************************************************************************/ 00155 00156 /* 00157 Machine Pin Definitions 00158 - make sure to avoid duplicate usage of a pin 00159 - comment out pins not in use, as this drops the corresponding code and makes operations faster 00160 */ 00161 00162 #include "arduino.h" 00163 00164 /* 00165 internal pullup resistors 00166 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. 00167 */ 00168 //#define USE_INTERNAL_PULLUPS 00169 00170 /* 00171 this is the ramps motherboard pinout 00172 */ 00173 00174 //#define TX_ENABLE_PIN DIO12 00175 //#define RX_ENABLE_PIN DIO13 00176 00177 #define X_STEP_PIN DIO26 00178 #define X_DIR_PIN DIO28 00179 #define X_MIN_PIN DIO3 00180 #define X_MAX_PIN DIO2 00181 #define X_ENABLE_PIN DIO24 00182 //#define X_INVERT_DIR 00183 //#define X_INVERT_MIN 00184 //#define X_INVERT_MAX 00185 //#define X_INVERT_ENABLE 00186 00187 #define Y_STEP_PIN DIO38 00188 #define Y_DIR_PIN DIO40 00189 #define Y_MIN_PIN DIO16 00190 #define Y_MAX_PIN DIO17 00191 #define Y_ENABLE_PIN DIO36 00192 //#define Y_INVERT_DIR 00193 //#define Y_INVERT_MIN 00194 //#define Y_INVERT_MAX 00195 //#define Y_INVERT_ENABLE 00196 00197 #define Z_STEP_PIN DIO44 00198 #define Z_DIR_PIN DIO46 00199 #define Z_MIN_PIN DIO18 00200 #define Z_MAX_PIN DIO19 00201 #define Z_ENABLE_PIN DIO42 00202 //#define Z_INVERT_DIR 00203 //#define Z_INVERT_MIN 00204 //#define Z_INVERT_MAX 00205 //#define Z_INVERT_ENABLE 00206 00207 #define E_STEP_PIN DIO32 00208 #define E_DIR_PIN DIO34 00209 #define E_ENABLE_PIN DIO30 00210 //#define E_INVERT_DIR 00211 00212 //#define SD_CARD_DETECT DIO2 00213 //#define SD_WRITE_PROTECT DIO3 00214 00215 00216 00217 /***************************************************************************\ 00218 * * 00219 * 4. TEMPERATURE SENSORS * 00220 * * 00221 \***************************************************************************/ 00222 00223 /* 00224 TEMP_HYSTERESIS: actual temperature must be target +/- hysteresis before target temperature can be achieved. 00225 NOTE: format is 30.2 fixed point, so value of 20 actually means +/- 5 degrees 00226 00227 TEMP_RESIDENCY_TIME: actual temperature must be close to target for this long before target is achieved 00228 00229 temperature is "achieved" for purposes of M109 and friends when actual temperature is within [hysteresis] of target for [residency] seconds 00230 */ 00231 #define TEMP_HYSTERESIS 20 00232 #define TEMP_RESIDENCY_TIME 60 00233 00234 // which temperature sensors are you using? (intercom is the gen3-style separate extruder board) 00235 // #define TEMP_MAX6675 00236 #define TEMP_THERMISTOR 00237 // #define TEMP_AD595 00238 // #define TEMP_PT100 00239 // #define TEMP_INTERCOM 00240 00241 /***************************************************************************\ 00242 * * 00243 * Define your temperature sensors here * 00244 * * 00245 * for GEN3 set temp_type to TT_INTERCOM and temp_pin to 0 * 00246 * * 00247 * Types are same as TEMP_ list above- TT_MAX6675, TT_THERMISTOR, TT_AD595, * 00248 * TT_PT100, TT_INTERCOM. See list in temp.c. * 00249 * * 00250 \***************************************************************************/ 00251 00252 #ifndef DEFINE_TEMP_SENSOR 00253 #define DEFINE_TEMP_SENSOR(...) 00254 #endif 00255 00256 // name type pin 00257 DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, AIO2_PIN) 00258 DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO1_PIN) 00259 00260 00261 /***************************************************************************\ 00262 * * 00263 * 5. HEATERS * 00264 * * 00265 \***************************************************************************/ 00266 00267 // check if heater responds to changes in target temperature, disable and spit errors if not 00268 // largely untested, please comment in forum if this works, or doesn't work for you! 00269 // #define HEATER_SANITY_CHECK 00270 00271 /***************************************************************************\ 00272 * * 00273 * Define your heaters here * 00274 * * 00275 * If your heater isn't on a PWM-able pin, set heater_pwm to zero and we'll * 00276 * use bang-bang output. Note that PID will still be used * 00277 * * 00278 * See Appendix 8 at the end of this file for PWMable pin mappings * 00279 * * 00280 * If a heater isn't attached to a temperature sensor above, it can still be * 00281 * controlled by host but otherwise is ignored by firmware * 00282 * * 00283 * To attach a heater to a temp sensor above, simply use exactly the same * 00284 * name - copy+paste is your friend * 00285 * * 00286 * Some common names are 'extruder', 'bed', 'fan', 'motor' * 00287 * * 00288 \***************************************************************************/ 00289 00290 #ifndef DEFINE_HEATER 00291 #define DEFINE_HEATER(...) 00292 #endif 00293 00294 // NOTE: these pins are for RAMPS V1.1 and newer. V1.0 is different 00295 // name port pin pwm 00296 DEFINE_HEATER(extruder, PORTB, PINB4, OCR2A) 00297 DEFINE_HEATER(bed, PORTH, PINH5, OCR4CL) 00298 DEFINE_HEATER(fan, PORTH, PINH6, OCR2B) 00299 // DEFINE_HEATER(chamber, PORTD, PIND7, OCR2A) 00300 // DEFINE_HEATER(motor, PORTD, PIND6, OCR2B) 00301 00302 // and now because the c preprocessor isn't as smart as it could be, 00303 // uncomment the ones you've listed above and comment the rest. 00304 // 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! 00305 // so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER 00306 // 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. 00307 00308 #define HEATER_EXTRUDER HEATER_extruder 00309 #define HEATER_BED HEATER_bed 00310 // #define HEATER_FAN HEATER_fan 00311 00312 /***************************************************************************\ 00313 * * 00314 * 6. COMMUNICATION OPTIONS * 00315 * * 00316 \***************************************************************************/ 00317 00318 /* 00319 RepRap Host changes it's communications protocol from time to time and intentionally avoids backwards compatibility. Set this to the date the source code of your Host was fetched from RepRap's repository, which is likely also the build date. 00320 See the discussion on the reprap-dev mailing list from 11 Oct. 2010. 00321 00322 Undefine it for best human readability, set it to an old date for compatibility with hosts before August 2010 00323 */ 00324 // #define REPRAP_HOST_COMPATIBILITY 19750101 00325 #define REPRAP_HOST_COMPATIBILITY 20100806 00326 // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break> 00327 00328 /* 00329 Xon/Xoff flow control. 00330 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). 00331 Can also be set in Makefile 00332 */ 00333 // #define XONXOFF 00334 00335 00336 00337 /***************************************************************************\ 00338 * * 00339 * 7. MISCELLANEOUS OPTIONS * 00340 * * 00341 \***************************************************************************/ 00342 00343 /* 00344 DEBUG 00345 enables /heaps/ of extra output, and some extra M-codes. 00346 WARNING: this WILL break most host-side talkers that expect particular responses from firmware such as reprap host and replicatorG 00347 use with serial terminal or other suitable talker only. 00348 */ 00349 // #define DEBUG 00350 00351 /* 00352 BANG_BANG 00353 drops PID loop from heater control, reduces code size significantly (1300 bytes!) 00354 may allow DEBUG on '168 00355 BANG_BANG_ON 00356 PWM value for 'on' 00357 BANG_BANG_OFF 00358 PWM value for 'off' 00359 */ 00360 // #define BANG_BANG 00361 // #define BANG_BANG_ON 200 00362 // #define BANG_BANG_OFF 45 00363 00364 /* 00365 move buffer size, in number of moves 00366 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. 00367 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 00368 */ 00369 #define MOVEBUFFER_SIZE 8 00370 00371 /* 00372 DC extruder 00373 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 00374 */ 00375 // #define DC_EXTRUDER HEATER_motor 00376 // #define DC_EXTRUDER_PWM 180 00377 00378 /* 00379 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. 00380 */ 00381 // #define USE_WATCHDOG 00382 00383 /* 00384 analog subsystem stuff 00385 REFERENCE - which analog reference to use. see analog.h for choices 00386 */ 00387 #define REFERENCE REFERENCE_AVCC 00388 00389 /* 00390 this option makes the step interrupt interruptible (nested). 00391 this should help immensely with dropped serial characters, but may also make debugging infuriating due to the complexities arising from nested interrupts 00392 */ 00393 #define STEP_INTERRUPT_INTERRUPTIBLE 1 00394 00395 /* 00396 temperature history count. This is how many temperature readings to keep in order to calculate derivative in PID loop 00397 higher values make PID derivative term more stable at the expense of reaction time 00398 */ 00399 #define TH_COUNT 8 00400 00401 // this is the scaling of internally stored PID values. 1024L is a good value 00402 #define PID_SCALE 1024L 00403 00404 00405 00406 /***************************************************************************\ 00407 * * 00408 * 8. APPENDIX A - PWMABLE PINS AND MAPPINGS * 00409 * * 00410 * * 00411 * list of PWM-able pins and corresponding timers * 00412 * timer1 is used for step timing so don't use OC1A/OC1B * 00413 * they are omitted from this listing for that reason * 00414 * * 00415 * For the atmega168/328, timer/pin mappings are as follows * 00416 * * 00417 * OCR0A - PD6 - DIO6 * 00418 * OCR0B - PD5 - DIO5 * 00419 * OCR2A - PB3 - DIO11 * 00420 * OCR2B - PD3 - DIO3 * 00421 * * 00422 * For the atmega644, timer/pin mappings are as follows * 00423 * * 00424 * OCR0A - PB3 - DIO3 * 00425 * OCR0B - PB4 - DIO4 * 00426 * OCR2A - PD7 - DIO15 * 00427 * OCR2B - PD6 - DIO14 * 00428 * * 00429 * For the atmega1280, timer/pin mappings are as follows * 00430 * * 00431 * OCR0A - PB7 - DIO13 * 00432 * OCR0B - PG5 - DIO4 * 00433 * OCR2A - PB4 - DIO10 * 00434 * OCR2B - PH6 - DIO9 * 00435 * OCR3AL - PE3 - DIO5 * 00436 * OCR3BL - PE4 - DIO2 * 00437 * OCR3CL - PE5 - DIO3 * 00438 * OCR4AL - PH3 - DIO6 * 00439 * OCR4BL - PH4 - DIO7 * 00440 * OCR4CL - PH5 - DIO8 * 00441 * OCR5AL - PL3 - DIO46 * 00442 * OCR5BL - PL4 - DIO45 * 00443 * OCR5CL - PL5 - DIO44 * 00444 * * 00445 \***************************************************************************/