Skip to content
Newer
Older
100644 446 lines (360 sloc) 19.1 KB
694e3c4 @Traumflug Revert "Config templates: protect config.h against multiple inclusion."
Traumflug authored Feb 27, 2011
1 /* Notice to developers: this file is intentionally included twice. */
c61191d @Traumflug Config templates: protect config.h against multiple inclusion.
Traumflug authored Feb 24, 2011
2
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
3 /*
4 CONTENTS
5
6 1. Mechanical/Hardware
7 2. Acceleration settings
8 3. Pinouts
9 4. Temperature sensors
10 5. Heaters
11 6. Communication options
12 7. Miscellaneous
13 8. Appendix A - PWMable pins and mappings
14 */
15
16 /***************************************************************************\
17 * *
18 * 1. MECHANICAL/HARDWARE *
19 * *
20 \***************************************************************************/
21
22 /*
23 Set your microcontroller type in Makefile! atmega168/atmega328p/atmega644p/atmega1280
24
25 If you want to port this to a new chip, start off with arduino.h and see how you go.
26 */
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 9, 2011
27 #if ! ( defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__) )
28 #error RAMPS has 1280/2560! set your cpu type in Makefile!
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
29 #endif
30
31 /*
32 CPU clock rate
33 */
34 #ifndef F_CPU
35 #define F_CPU 16000000L
36 #endif
37
38 /*
39 This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware
40 */
41 #define HOST
42
43 /*
44 Values reflecting the gearing of your machine.
45 All numbers are fixed point integers, so no more than 3 digits to the right of the decimal point, please :-)
46 */
47
48 // calculate these values appropriate for your machine
49 // for threaded rods, this is (steps motor per turn) / (pitch of the thread)
50 // for belts, this is (steps per motor turn) / (number of gear teeth) / (belt module)
51 // half-stepping doubles the number, quarter stepping requires * 4, etc.
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
52 #define MICROSTEPPING_X 16.0
53 #define MICROSTEPPING_Y 16.0
54 #define MICROSTEPPING_Z 16.0
55 #define MICROSTEPPING_E 4.0
56
57 #define STEPS_PER_MM_X (5.023*MICROSTEPPING_X)
58 #define STEPS_PER_MM_Y (5.023*MICROSTEPPING_Y)
59 #define STEPS_PER_MM_Z (416.699*MICROSTEPPING_Z)
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
60
61 // http://blog.arcol.hu/?p=157 may help with this next one
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
62 #define STEPS_PER_MM_E (2.759*MICROSTEPPING_E)
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
63
64
65 /*
66 Values depending on the capabilities of your stepper motors and other mechanics.
67 All numbers are integers, no decimals allowed.
68
69 Units are mm/min
70 */
71
72 // used for G0 rapid moves and as a cap for all other feedrates
73 #define MAXIMUM_FEEDRATE_X 200
74 #define MAXIMUM_FEEDRATE_Y 200
75 #define MAXIMUM_FEEDRATE_Z 100
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
76 #define MAXIMUM_FEEDRATE_E 600
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
77
78 // used when searching endstops and as default feedrate
79 #define SEARCH_FEEDRATE_X 50
80 #define SEARCH_FEEDRATE_Y 50
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
81 #define SEARCH_FEEDRATE_Z 1
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
82 #define SEARCH_FEEDRATE_E 50
83
84 // this is how many steps to suck back the filament by when we stop. set to zero to disable
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
85 #define E_STARTSTOP_STEPS 0
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
86
87
8ebce94 @triffid add soft limits to configs
triffid authored Feb 8, 2011
88 /*
89 Soft axis limits, in mm
90 undefine if you don't want to use them
91 */
92
93 #define X_MIN 0.0
94 #define X_MAX 200.0
95
96 #define Y_MIN 0.0
97 #define Y_MAX 200.0
98
99 #define Z_MIN 0.0
100 #define Z_MAX 140.0
101
102
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
103
104 /***************************************************************************\
105 * *
106 * 2. ACCELERATION *
107 * *
108 * IMPORTANT: choose only one! These algorithms choose when to step, trying *
109 * to use more than one will have undefined and probably *
110 * disastrous results! *
111 * *
112 \***************************************************************************/
113
114
115 /*
116 acceleration, reprap style.
117 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.
118 */
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
119 #define ACCELERATION_REPRAP
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
120
121
122 /*
123 acceleration and deceleration ramping.
124 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
125 */
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
126 // #define ACCELERATION_RAMPING
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
127
128 // how fast to accelerate when using ACCELERATION_RAMPING
129 // smaller values give quicker acceleration
130 // valid range = 1 to 8,000,000; 500,000 is a good starting point
131 #define ACCELERATION_STEEPNESS 500000
132
133
134 /*
135 temporal step algorithm
136 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.
137
138 This algorithm is not a type of acceleration, and I haven't worked out how to integrate acceleration with it.
139 However it does control step timing, so acceleration algorithms seemed appropriate
140
141 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.
142 This algorithm instead calculates when a step occurs on any axis, and sets the timer to that value.
143
144 // TODO: figure out how to add acceleration to this algorithm
145 */
146 // #define ACCELERATION_TEMPORAL
147
148
149
150 /***************************************************************************\
151 * *
152 * 3. PINOUTS *
153 * *
154 \***************************************************************************/
155
156 /*
157 Machine Pin Definitions
158 - make sure to avoid duplicate usage of a pin
159 - comment out pins not in use, as this drops the corresponding code and makes operations faster
160 */
161
162 #include "arduino.h"
163
164 /*
b7afdda @Traumflug Make the use of the internal pullup resistors optional.
Traumflug authored Feb 24, 2011
165 internal pullup resistors
166 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.
167 */
168 //#define USE_INTERNAL_PULLUPS
169
170 /*
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
171 this is the ramps motherboard pinout
172 */
173
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
174 //#define TX_ENABLE_PIN DIO12
175 //#define RX_ENABLE_PIN DIO13
176
177 #define X_STEP_PIN DIO26
178 #define X_DIR_PIN DIO28
179 #define X_MIN_PIN DIO3
180 #define X_MAX_PIN DIO2
181 #define X_ENABLE_PIN DIO24
0d37270 @Traumflug Config templates: publish INVERT flags.
Traumflug authored Feb 23, 2011
182 //#define X_INVERT_DIR
183 //#define X_INVERT_MIN
184 //#define X_INVERT_MAX
185 //#define X_INVERT_ENABLE
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
186
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
187 #define Y_STEP_PIN DIO38
188 #define Y_DIR_PIN DIO40
189 #define Y_MIN_PIN DIO16
190 #define Y_MAX_PIN DIO17
191 #define Y_ENABLE_PIN DIO36
0d37270 @Traumflug Config templates: publish INVERT flags.
Traumflug authored Feb 23, 2011
192 //#define Y_INVERT_DIR
193 //#define Y_INVERT_MIN
194 //#define Y_INVERT_MAX
195 //#define Y_INVERT_ENABLE
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
196
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
197 #define Z_STEP_PIN DIO44
198 #define Z_DIR_PIN DIO46
199 #define Z_MIN_PIN DIO18
200 #define Z_MAX_PIN DIO19
201 #define Z_ENABLE_PIN DIO42
0d37270 @Traumflug Config templates: publish INVERT flags.
Traumflug authored Feb 23, 2011
202 //#define Z_INVERT_DIR
203 //#define Z_INVERT_MIN
204 //#define Z_INVERT_MAX
205 //#define Z_INVERT_ENABLE
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
206
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
207 #define E_STEP_PIN DIO32
208 #define E_DIR_PIN DIO34
209 #define E_ENABLE_PIN DIO30
0d37270 @Traumflug Config templates: publish INVERT flags.
Traumflug authored Feb 23, 2011
210 //#define E_INVERT_DIR
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
211
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
212 //#define SD_CARD_DETECT DIO2
213 //#define SD_WRITE_PROTECT DIO3
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
214
215
216
217 /***************************************************************************\
218 * *
219 * 4. TEMPERATURE SENSORS *
220 * *
221 \***************************************************************************/
222
223 /*
224 TEMP_HYSTERESIS: actual temperature must be target +/- hysteresis before target temperature can be achieved.
225 NOTE: format is 30.2 fixed point, so value of 20 actually means +/- 5 degrees
226
227 TEMP_RESIDENCY_TIME: actual temperature must be close to target for this long before target is achieved
228
229 temperature is "achieved" for purposes of M109 and friends when actual temperature is within [hysteresis] of target for [residency] seconds
230 */
231 #define TEMP_HYSTERESIS 20
232 #define TEMP_RESIDENCY_TIME 60
233
234 // which temperature sensors are you using? (intercom is the gen3-style separate extruder board)
235 // #define TEMP_MAX6675
236 #define TEMP_THERMISTOR
237 // #define TEMP_AD595
238 // #define TEMP_PT100
239 // #define TEMP_INTERCOM
240
241 /***************************************************************************\
242 * *
243 * Define your temperature sensors here *
244 * *
245 * for GEN3 set temp_type to TT_INTERCOM and temp_pin to 0 *
246 * *
247 * Types are same as TEMP_ list above- TT_MAX6675, TT_THERMISTOR, TT_AD595, *
248 * TT_PT100, TT_INTERCOM. See list in temp.c. *
249 * *
250 \***************************************************************************/
251
252 #ifndef DEFINE_TEMP_SENSOR
253 #define DEFINE_TEMP_SENSOR(...)
254 #endif
255
256 // name type pin
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
257 DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, AIO2_PIN)
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
258 DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO1_PIN)
259
260
261 /***************************************************************************\
262 * *
263 * 5. HEATERS *
264 * *
265 \***************************************************************************/
266
267 // check if heater responds to changes in target temperature, disable and spit errors if not
268 // largely untested, please comment in forum if this works, or doesn't work for you!
269 // #define HEATER_SANITY_CHECK
270
271 /***************************************************************************\
272 * *
273 * Define your heaters here *
274 * *
275 * If your heater isn't on a PWM-able pin, set heater_pwm to zero and we'll *
276 * use bang-bang output. Note that PID will still be used *
277 * *
278 * See Appendix 8 at the end of this file for PWMable pin mappings *
279 * *
280 * If a heater isn't attached to a temperature sensor above, it can still be *
281 * controlled by host but otherwise is ignored by firmware *
282 * *
283 * To attach a heater to a temp sensor above, simply use exactly the same *
284 * name - copy+paste is your friend *
285 * *
286 * Some common names are 'extruder', 'bed', 'fan', 'motor' *
287 * *
288 \***************************************************************************/
289
290 #ifndef DEFINE_HEATER
291 #define DEFINE_HEATER(...)
292 #endif
293
48fcffb @nrpatel Set the correct pins for RAMPS v1.1
nrpatel authored Feb 10, 2011
294 // NOTE: these pins are for RAMPS V1.1 and newer. V1.0 is different
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
295 // name port pin pwm
f80edea @triffid fix example heaters, add note to gen3 config clarifying that heaters …
triffid authored Feb 14, 2011
296 DEFINE_HEATER(extruder, PORTB, PINB4, OCR2A)
297 DEFINE_HEATER(bed, PORTH, PINH5, OCR4CL)
298 DEFINE_HEATER(fan, PORTH, PINH6, OCR2B)
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
299 // DEFINE_HEATER(chamber, PORTD, PIND7, OCR2A)
300 // DEFINE_HEATER(motor, PORTD, PIND6, OCR2B)
301
302 // and now because the c preprocessor isn't as smart as it could be,
303 // uncomment the ones you've listed above and comment the rest.
304 // 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!
305 // so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER
306 // 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.
307
308 #define HEATER_EXTRUDER HEATER_extruder
309 #define HEATER_BED HEATER_bed
310 // #define HEATER_FAN HEATER_fan
311
312 /***************************************************************************\
313 * *
314 * 6. COMMUNICATION OPTIONS *
315 * *
316 \***************************************************************************/
317
318 /*
319 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.
320 See the discussion on the reprap-dev mailing list from 11 Oct. 2010.
321
322 Undefine it for best human readability, set it to an old date for compatibility with hosts before August 2010
323 */
324 // #define REPRAP_HOST_COMPATIBILITY 19750101
325 #define REPRAP_HOST_COMPATIBILITY 20100806
326 // #define REPRAP_HOST_COMPATIBILITY <date of next RepRap Host compatibility break>
327
328 /*
329 Xon/Xoff flow control.
330 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).
331 Can also be set in Makefile
332 */
333 // #define XONXOFF
334
335
336
337 /***************************************************************************\
338 * *
339 * 7. MISCELLANEOUS OPTIONS *
340 * *
341 \***************************************************************************/
342
343 /*
344 DEBUG
345 enables /heaps/ of extra output, and some extra M-codes.
346 WARNING: this WILL break most host-side talkers that expect particular responses from firmware such as reprap host and replicatorG
347 use with serial terminal or other suitable talker only.
348 */
349 // #define DEBUG
350
351 /*
352 BANG_BANG
353 drops PID loop from heater control, reduces code size significantly (1300 bytes!)
354 may allow DEBUG on '168
355 BANG_BANG_ON
356 PWM value for 'on'
357 BANG_BANG_OFF
358 PWM value for 'off'
359 */
360 // #define BANG_BANG
361 // #define BANG_BANG_ON 200
362 // #define BANG_BANG_OFF 45
363
364 /*
365 move buffer size, in number of moves
366 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.
367 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
368 */
369 #define MOVEBUFFER_SIZE 8
370
371 /*
372 DC extruder
e688e8b @Traumflug Consequences of the stepping extruder now being optional.
Traumflug authored Mar 2, 2011
373 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
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
374 */
375 // #define DC_EXTRUDER HEATER_motor
376 // #define DC_EXTRUDER_PWM 180
377
378 /*
d705f46 @triffid more cleanup after name change
triffid authored Feb 24, 2011
379 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.
553f3a5 @triffid some config templates, also bang-bang heater support to reduce code size
triffid authored Feb 7, 2011
380 */
381 // #define USE_WATCHDOG
382
383 /*
384 analog subsystem stuff
385 REFERENCE - which analog reference to use. see analog.h for choices
386 */
387 #define REFERENCE REFERENCE_AVCC
388
389 /*
390 this option makes the step interrupt interruptible (nested).
391 this should help immensely with dropped serial characters, but may also make debugging infuriating due to the complexities arising from nested interrupts
392 */
393 #define STEP_INTERRUPT_INTERRUPTIBLE 1
394
395 /*
396 temperature history count. This is how many temperature readings to keep in order to calculate derivative in PID loop
397 higher values make PID derivative term more stable at the expense of reaction time
398 */
399 #define TH_COUNT 8
400
401 // this is the scaling of internally stored PID values. 1024L is a good value
402 #define PID_SCALE 1024L
403
404
405
406 /***************************************************************************\
407 * *
408 * 8. APPENDIX A - PWMABLE PINS AND MAPPINGS *
409 * *
410 * *
411 * list of PWM-able pins and corresponding timers *
412 * timer1 is used for step timing so don't use OC1A/OC1B *
413 * they are omitted from this listing for that reason *
414 * *
415 * For the atmega168/328, timer/pin mappings are as follows *
416 * *
417 * OCR0A - PD6 - DIO6 *
418 * OCR0B - PD5 - DIO5 *
419 * OCR2A - PB3 - DIO11 *
420 * OCR2B - PD3 - DIO3 *
421 * *
422 * For the atmega644, timer/pin mappings are as follows *
423 * *
424 * OCR0A - PB3 - DIO3 *
425 * OCR0B - PB4 - DIO4 *
426 * OCR2A - PD7 - DIO15 *
427 * OCR2B - PD6 - DIO14 *
428 * *
429 * For the atmega1280, timer/pin mappings are as follows *
430 * *
431 * OCR0A - PB7 - DIO13 *
432 * OCR0B - PG5 - DIO4 *
433 * OCR2A - PB4 - DIO10 *
434 * OCR2B - PH6 - DIO9 *
435 * OCR3AL - PE3 - DIO5 *
436 * OCR3BL - PE4 - DIO2 *
437 * OCR3CL - PE5 - DIO3 *
438 * OCR4AL - PH3 - DIO6 *
439 * OCR4BL - PH4 - DIO7 *
440 * OCR4CL - PH5 - DIO8 *
441 * OCR5AL - PL3 - DIO46 *
442 * OCR5BL - PL4 - DIO45 *
443 * OCR5CL - PL5 - DIO44 *
444 * *
445 \***************************************************************************/
Something went wrong with that request. Please try again.