public anonymous / config.h Created 2011-05-12

Configuration file for the reprap machine with teacup firmware on board and Gen3 electronics (including extruder controller so intercom used to control DC motor extruder).

config.h
C++
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 /* Notice to developers: this file is intentionally included twice. */ /** \file \brief Gen3 Electronics Sample Configuration*//* 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*/ //#error this config is marginally, and may be incorrect! please post in forum or via git any corrections /***************************************************************************\* ** 1. MECHANICAL/HARDWARE ** *\***************************************************************************/ /* 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 ! ( defined (__AVR_ATmega644P__) || defined (__AVR_ATmega644PA__) ) #error GEN3 has a 644P/644PA! set your cpu type in Makefile!#endif /** \def F_CPU CPU clock rate*/#ifndef F_CPU #define F_CPU 16000000L#endif /** \def HOST This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware*/#define HOST /* Values reflecting the gearing of your machine. All numbers are fixed point integers, so no more than 3 digits to the right of the decimal point, please :-)  calculate these values appropriate for your machine for threaded rods, this is (steps motor per turn) / (pitch of the thread) for belts, this is (steps per motor turn) / (number of gear teeth) / (belt module) half-stepping doubles the number, quarter stepping requires * 4, etc.*/#define STEPS_PER_MM_X 48.780 //320.000#define STEPS_PER_MM_Y 48.780 //320.000#define STEPS_PER_MM_Z 410.256 //200.000 /// http://blog.arcol.hu/?p=157 may help with this one#define STEPS_PER_MM_E 320.000  /* Values depending on the capabilities of your stepper motors and other mechanics. All numbers are integers, no decimals allowed.  Units are mm/min*/ /// used for G0 rapid moves and as a cap for all other feedrates#define MAXIMUM_FEEDRATE_X 2500 //200#define MAXIMUM_FEEDRATE_Y 2500 //200#define MAXIMUM_FEEDRATE_Z 250 //100#define MAXIMUM_FEEDRATE_E 200 /// used when searching endstops and as default feedrate#define SEARCH_FEEDRATE_X 1000 //50#define SEARCH_FEEDRATE_Y 1000 //50#define SEARCH_FEEDRATE_Z 100 //50// no SEARCH_FEEDRATE_E, as E can't be searched /// this is how many steps to suck back the filament by when we stop. set to zero to disable#define E_STARTSTOP_STEPS 0 //20  /** Soft axis limits, in mm undefine if you don't want to use them*/ /*#define X_MIN 0.0#define X_MAX 200.0 #define Y_MIN 0.0#define Y_MAX 200.0 #define Z_MIN 0.0#define Z_MAX 140.0 */ /***************************************************************************\* ** 2. ACCELERATION ** ** IMPORTANT: choose only one! These algorithms choose when to step, trying ** to use more than one will have undefined and probably ** disastrous results! ** *\***************************************************************************/ /** \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.*///#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*/#define ACCELERATION_RAMPING /// how fast to accelerate when using ACCELERATION_RAMPING/// smaller values give quicker acceleration/// valid range = 1 to 8,000,000; 500,000 is a good starting point#define ACCELERATION_STEEPNESS 120000 /** \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.  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.  \todo figure out how to add acceleration to this algorithm*/// #define ACCELERATION_TEMPORAL   /***************************************************************************\* ** 3. PINOUTS ** *\***************************************************************************/ /** 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" /** \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.*///#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 SD_CARD_DETECT DIO2#define SD_WRITE_PROTECT DIO3 #define PS_ON_PIN DIO14   /***************************************************************************\* ** 4. TEMPERATURE SENSORS ** *\***************************************************************************/ /** TEMP_HYSTERESIS: actual temperature must be target +/- hysteresis before target temperature can be achieved. Unit is degree Celsius.*/#define TEMP_HYSTERESIS 10 //5 /** TEMP_RESIDENCY_TIME: actual temperature must be close to target for this long before target is achieved  temperature is "achieved" for purposes of M109 and friends when actual temperature is within [hysteresis] of target for [residency] seconds*/#define TEMP_RESIDENCY_TIME 6 // which temperature sensors are you using? (intercom is the gen3-style separate extruder board)// #define TEMP_MAX6675// #define TEMP_THERMISTOR// #define TEMP_AD595// #define TEMP_PT100#define TEMP_INTERCOM /***************************************************************************\* ** Define your temperature sensors here ** ** for GEN3 set temp_type to TT_INTERCOM and temp_pin to 0 ** ** Types are same as TEMP_ list above- TT_MAX6675, TT_THERMISTOR, TT_AD595, ** TT_PT100, TT_INTERCOM. See list in temp.c. ** *\***************************************************************************/ #ifndef DEFINE_TEMP_SENSOR #define DEFINE_TEMP_SENSOR(...)#endif // name type pin additionalDEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, 0, 0)DEFINE_TEMP_SENSOR(bed, TT_INTERCOM, 1, 0) // bed has no heater attached#define HEATER_bed HEATER_noheater  /***************************************************************************\* ** 5. HEATERS ** *\***************************************************************************/ /** \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!*/// #define HEATER_SANITY_CHECK /***************************************************************************\* ** Define your heaters here ** ** \WARNING For GEN3, ONLY DEFINE HEATERS CONNECTED TO YOUR MOTHERBOARD HERE ** Heaters connected to your extruder controller belong in extruder/config.h ** ** If your heater isn't on a PWM-able pin, set heater_pwm to zero and we'll ** use bang-bang output. Note that PID will still be used ** ** See Appendix 8 at the end of this file for PWMable pin mappings ** ** If a heater isn't attached to a temperature sensor above, it can still be ** controlled by host but otherwise is ignored by firmware ** ** 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' ** *\***************************************************************************/ #ifndef DEFINE_HEATER #define DEFINE_HEATER(...)#endif // name port pin pwm// DEFINE_HEATER(extruder, PORTB, PINB3, OCR0A)// DEFINE_HEATER(bed, PORTB, PINB4, OCR0B)// DEFINE_HEATER(fan, PORTB, PINB4, OCR0B)// DEFINE_HEATER(chamber, PORTD, PIND7, OCR2A)// DEFINE_HEATER(motor, PORTD, PIND6, OCR2B) /** \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.*/ // #define HEATER_EXTRUDER HEATER_extruder // workaround for heated bed over intercom. HEATER_BED is the intercom temp channel number.#define HEATER_BED 1// #define HEATER_FAN HEATER_fan   /***************************************************************************\* ** 6. COMMUNICATION OPTIONS ** *\***************************************************************************/ /** \def REPRAP_HOST_COMPATIBILITY 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. See the discussion on the reprap-dev mailing list from 11 Oct. 2010.  Undefine it for best human readability, set it to an old date for compatibility with hosts before August 2010*/// #define REPRAP_HOST_COMPATIBILITY 19750101#define REPRAP_HOST_COMPATIBILITY 20100806// #define REPRAP_HOST_COMPATIBILITY  /** Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600.*/#define BAUD 19200//#define BAUD 115200 /** \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*/// #define XONXOFF   /***************************************************************************\* ** 7. MISCELLANEOUS OPTIONS ** *\***************************************************************************/ /** \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.*/#define DEBUG /** \def BANG_BANG 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'*//** \def BANG_BANG_OFF BANG_BANG_OFF PWM value for 'off'*/// #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*/#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*/// #define DC_EXTRUDER HEATER_motor// #define DC_EXTRUDER_PWM 180 #define DC_EXTRUDER_CONTROLLER /** \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.*/// #define USE_WATCHDOG /** analog subsystem stuff REFERENCE - which analog reference to use. see analog.h for choices*/#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*/#define STEP_INTERRUPT_INTERRUPTIBLE 0 /** 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 /// this is the scaling of internally stored PID values. 1024L is a good value#define PID_SCALE 1024L   /***************************************************************************\* ** 8. APPENDIX A - PWMABLE PINS AND MAPPINGS ** ** ** list of PWM-able pins and corresponding timers ** timer1 is used for step timing so don't use OC1A/OC1B ** they are omitted from this listing for that reason ** ** For the atmega168/328, timer/pin mappings are as follows ** ** OCR0A - PD6 - DIO6 ** OCR0B - PD5 - DIO5 ** OCR2A - PB3 - DIO11 ** OCR2B - PD3 - DIO3 ** ** For the atmega644, timer/pin mappings are as follows ** ** OCR0A - PB3 - DIO3 ** OCR0B - PB4 - DIO4 ** OCR2A - PD7 - DIO15 ** OCR2B - PD6 - DIO14 ** ** For the atmega1280, timer/pin mappings are as follows ** ** OCR0A - PB7 - DIO13 ** OCR0B - PG5 - DIO4 ** OCR2A - PB4 - DIO10 ** OCR2B - PH6 - DIO9 ** OCR3AL - PE3 - DIO5 ** OCR3BL - PE4 - DIO2 ** OCR3CL - PE5 - DIO3 ** OCR4AL - PH3 - DIO6 ** OCR4BL - PH4 - DIO7 ** OCR4CL - PH5 - DIO8 ** OCR5AL - PL3 - DIO46 ** OCR5BL - PL4 - DIO45 ** OCR5CL - PL5 - DIO44 ** *\***************************************************************************/