Browse Source

Merge pull request #482 from codexmas/Marlin_v1

servosupport
ErikZalm 12 years ago
parent
commit
64360164ad
6 changed files with 858 additions and 307 deletions
  1. 39
    22
      Marlin/Configuration.h
  2. 10
    10
      Marlin/Makefile
  3. 252
    192
      Marlin/Marlin_main.cpp
  4. 337
    0
      Marlin/Servo.cpp
  5. 132
    0
      Marlin/Servo.h
  6. 88
    83
      Marlin/pins.h

+ 39
- 22
Marlin/Configuration.h View File

@@ -2,7 +2,7 @@
2 2
 #define CONFIGURATION_H
3 3
 
4 4
 // This configurtion file contains the basic settings.
5
-// Advanced settings can be found in Configuration_adv.h 
5
+// Advanced settings can be found in Configuration_adv.h
6 6
 // BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration
7 7
 
8 8
 //User specified version info of this build to display in [Pronterface, etc] terminal window during startup.
@@ -78,7 +78,7 @@
78 78
 // 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
79 79
 // 10 is 100k RS thermistor 198-961 (4.7k pullup)
80 80
 //
81
-//    1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k 
81
+//    1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
82 82
 //                          (but gives greater accuracy and more stable PID)
83 83
 // 51 is 100k thermistor - EPCOS (1k pullup)
84 84
 // 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
@@ -95,7 +95,7 @@
95 95
 #define TEMP_WINDOW     1       // (degC) Window around target to start the recidency timer x degC early.
96 96
 
97 97
 // The minimal temperature defines the temperature below which the heater will not be enabled It is used
98
-// to check that the wiring to the thermistor is not broken. 
98
+// to check that the wiring to the thermistor is not broken.
99 99
 // Otherwise this would lead to the heater being powered on all the time.
100 100
 #define HEATER_0_MINTEMP 5
101 101
 #define HEATER_1_MINTEMP 5
@@ -121,7 +121,7 @@
121 121
 #define BANG_MAX 256 // limits current to nozzle while in bang-bang mode; 256=full current
122 122
 #define PID_MAX 256 // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 256=full current
123 123
 #ifdef PIDTEMP
124
-  //#define PID_DEBUG // Sends debug data to the serial port. 
124
+  //#define PID_DEBUG // Sends debug data to the serial port.
125 125
   //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
126 126
   #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
127 127
                                   // is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
@@ -132,15 +132,15 @@
132 132
 // If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
133 133
 // Ultimaker
134 134
     #define  DEFAULT_Kp 22.2
135
-    #define  DEFAULT_Ki 1.08  
136
-    #define  DEFAULT_Kd 114  
135
+    #define  DEFAULT_Ki 1.08
136
+    #define  DEFAULT_Kd 114
137 137
 
138 138
 // Makergear
139 139
 //    #define  DEFAULT_Kp 7.0
140
-//    #define  DEFAULT_Ki 0.1  
141
-//    #define  DEFAULT_Kd 12  
140
+//    #define  DEFAULT_Ki 0.1
141
+//    #define  DEFAULT_Kd 12
142 142
 
143
-// Mendel Parts V9 on 12V    
143
+// Mendel Parts V9 on 12V
144 144
 //    #define  DEFAULT_Kp 63.0
145 145
 //    #define  DEFAULT_Ki 2.25
146 146
 //    #define  DEFAULT_Kd 440
@@ -149,11 +149,11 @@
149 149
 // Bed Temperature Control
150 150
 // Select PID or bang-bang with PIDTEMPBED.  If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis
151 151
 //
152
-// uncomment this to enable PID on the bed.   It uses the same ferquency PWM as the extruder. 
152
+// uncomment this to enable PID on the bed.   It uses the same ferquency PWM as the extruder.
153 153
 // If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz,
154 154
 // which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
155
-// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. 
156
-// If your configuration is significantly different than this and you don't understand the issues involved, you proabaly 
155
+// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
156
+// If your configuration is significantly different than this and you don't understand the issues involved, you proabaly
157 157
 // shouldn't use bed PID until someone else verifies your hardware works.
158 158
 // If this is enabled, find your own PID constants below.
159 159
 //#define PIDTEMPBED
@@ -223,9 +223,9 @@
223 223
 #endif
224 224
 
225 225
 // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
226
-const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
227
-const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
228
-const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
226
+const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
227
+const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
228
+const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
229 229
 //#define DISABLE_MAX_ENDSTOPS
230 230
 
231 231
 // For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
@@ -280,13 +280,13 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
280 280
 #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
281 281
 #define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}  // set the homing speeds (mm/min)
282 282
 
283
-// default settings 
283
+// default settings
284 284
 
285 285
 #define DEFAULT_AXIS_STEPS_PER_UNIT   {78.7402,78.7402,200.0*8/3,760*1.1}  // default steps per unit for ultimaker
286 286
 #define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 25}    // (mm/sec)
287 287
 #define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
288 288
 
289
-#define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves 
289
+#define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves
290 290
 #define DEFAULT_RETRACT_ACCELERATION  3000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts
291 291
 
292 292
 // Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
@@ -307,7 +307,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
307 307
 // EEPROM
308 308
 // the microcontroller can store settings in the EEPROM, e.g. max velocity...
309 309
 // M500 - stores paramters in EEPROM
310
-// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
310
+// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
311 311
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
312 312
 //define this to enable eeprom support
313 313
 //#define EEPROM_SETTINGS
@@ -353,7 +353,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
353 353
 #if defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
354 354
  #define ULTIPANEL
355 355
  #define NEWPANEL
356
-#endif 
356
+#endif
357 357
 
358 358
 #if defined(REPRAPWORLD_KEYPAD)
359 359
   #define NEWPANEL
@@ -361,7 +361,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
361 361
 #endif
362 362
 
363 363
 // Preheat Constants
364
-#define PLA_PREHEAT_HOTEND_TEMP 180 
364
+#define PLA_PREHEAT_HOTEND_TEMP 180
365 365
 #define PLA_PREHEAT_HPB_TEMP 70
366 366
 #define PLA_PREHEAT_FAN_SPEED 255		// Insert Value between 0 and 255
367 367
 
@@ -381,7 +381,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
381 381
 		#define LCD_WIDTH 20
382 382
 		#define LCD_HEIGHT 4
383 383
 	#endif
384
-#else //no panel but just lcd 
384
+#else //no panel but just lcd
385 385
   #ifdef ULTRA_LCD
386 386
 	#ifdef DOGLCD	// Change number of lines to match the 128x64 graphics display
387 387
 		#define LCD_WIDTH 20
@@ -389,7 +389,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
389 389
 	#else
390 390
 		#define LCD_WIDTH 16
391 391
 		#define LCD_HEIGHT 2
392
-	#endif    
392
+	#endif
393 393
   #endif
394 394
 #endif
395 395
 
@@ -406,6 +406,23 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
406 406
 // Support for the BariCUDA Paste Extruder.
407 407
 //#define BARICUDA
408 408
 
409
+/*********************************************************************\
410
+*
411
+* R/C SERVO support
412
+*
413
+* Sponsored by TrinityLabs, Reworked by codexmas
414
+*
415
+**********************************************************************/
416
+
417
+// Number of servos
418
+//
419
+// If you select a configuration below, this will receive a default value and does not need to be set manually
420
+// set it manually if you have more servos than extruders and wish to manually control some
421
+// leaving it undefined or defining as 0 will disable the servo subsystem
422
+// If unsure, leave commented / disabled
423
+//
424
+// #define NUM_SERVOS 3
425
+
409 426
 #include "Configuration_adv.h"
410 427
 #include "thermistortables.h"
411 428
 

+ 10
- 10
Marlin/Makefile View File

@@ -1,12 +1,12 @@
1 1
 # Sprinter Arduino Project Makefile
2
-# 
2
+#
3 3
 # Makefile Based on:
4 4
 # Arduino 0011 Makefile
5 5
 # Arduino adaptation by mellis, eighthave, oli.keller
6 6
 # Marlin adaption by Daid
7 7
 #
8 8
 # This has been tested with Arduino 0022.
9
-# 
9
+#
10 10
 # This makefile allows you to build sketches from the command line
11 11
 # without the Arduino environment (or Java).
12 12
 #
@@ -21,7 +21,7 @@
21 21
 #     (e.g. UPLOAD_PORT = /dev/tty.USB0).  If the exact name of this file
22 22
 #     changes, you can use * as a wildcard (e.g. UPLOAD_PORT = /dev/tty.usb*).
23 23
 #
24
-#  3. Set the line containing "MCU" to match your board's processor. 
24
+#  3. Set the line containing "MCU" to match your board's processor.
25 25
 #     Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
26 26
 #     or Diecimila have the atmega168.  If you're using a LilyPad Arduino,
27 27
 #     change F_CPU to 8000000. If you are using Gen7 electronics, you
@@ -44,7 +44,7 @@ ARDUINO_INSTALL_DIR  ?= ../../arduino-0022
44 44
 ARDUINO_VERSION      ?= 22
45 45
 
46 46
 # You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
47
-AVR_TOOLS_PATH ?= 
47
+AVR_TOOLS_PATH ?=
48 48
 
49 49
 #Programmer configuration
50 50
 UPLOAD_RATE        ?= 115200
@@ -213,7 +213,7 @@ CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp	\
213 213
 	SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp		\
214 214
 	stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp \
215 215
 	watchdog.cpp
216
-CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp
216
+CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp Servo.cpp
217 217
 
218 218
 #Check for Arduino 1.0.0 or higher and use the correct sourcefiles for that version
219 219
 ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
@@ -317,19 +317,19 @@ endif
317 317
 # Default target.
318 318
 all: sizeafter
319 319
 
320
-build: $(BUILD_DIR) elf hex 
320
+build: $(BUILD_DIR) elf hex
321 321
 
322 322
 # Creates the object directory
323
-$(BUILD_DIR): 
323
+$(BUILD_DIR):
324 324
 	$P mkdir -p $(BUILD_DIR)
325 325
 
326 326
 elf: $(BUILD_DIR)/$(TARGET).elf
327 327
 hex: $(BUILD_DIR)/$(TARGET).hex
328 328
 eep: $(BUILD_DIR)/$(TARGET).eep
329
-lss: $(BUILD_DIR)/$(TARGET).lss 
329
+lss: $(BUILD_DIR)/$(TARGET).lss
330 330
 sym: $(BUILD_DIR)/$(TARGET).sym
331 331
 
332
-# Program the device.  
332
+# Program the device.
333 333
 # Do not try to reset an arduino if it's not one
334 334
 upload: $(BUILD_DIR)/$(TARGET).hex
335 335
 ifeq (${AVRDUDE_PROGRAMMER}, arduino)
@@ -356,7 +356,7 @@ COFFCONVERT=$(OBJCOPY) --debugging \
356 356
 	--change-section-address .data-0x800000 \
357 357
 	--change-section-address .bss-0x800000 \
358 358
 	--change-section-address .noinit-0x800000 \
359
-	--change-section-address .eeprom-0x810000 
359
+	--change-section-address .eeprom-0x810000
360 360
 
361 361
 
362 362
 coff: $(BUILD_DIR)/$(TARGET).elf

+ 252
- 192
Marlin/Marlin_main.cpp
File diff suppressed because it is too large
View File


+ 337
- 0
Marlin/Servo.cpp View File

@@ -0,0 +1,337 @@
1
+/*
2
+ Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
3
+ Copyright (c) 2009 Michael Margolis.  All right reserved.
4
+
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+ Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+ */
19
+
20
+/*
21
+
22
+ A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
23
+ The servos are pulsed in the background using the value most recently written using the write() method
24
+
25
+ Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
26
+ Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
27
+
28
+ The methods are:
29
+
30
+ Servo - Class for manipulating servo motors connected to Arduino pins.
31
+
32
+ attach(pin )  - Attaches a servo motor to an i/o pin.
33
+ attach(pin, min, max  ) - Attaches to a pin setting min and max values in microseconds
34
+ default min is 544, max is 2400
35
+
36
+ write()     - Sets the servo angle in degrees.  (invalid angle that is valid as pulse in microseconds is treated as microseconds)
37
+ writeMicroseconds() - Sets the servo pulse width in microseconds
38
+ read()      - Gets the last written servo pulse width as an angle between 0 and 180.
39
+ readMicroseconds()   - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
40
+ attached()  - Returns true if there is a servo attached.
41
+ detach()    - Stops an attached servos from pulsing its i/o pin.
42
+
43
+*/
44
+
45
+#include <avr/interrupt.h>
46
+#include <Arduino.h>
47
+
48
+#include "Servo.h"
49
+
50
+#define usToTicks(_us)    (( clockCyclesPerMicrosecond()* _us) / 8)     // converts microseconds to tick (assumes prescale of 8)  // 12 Aug 2009
51
+#define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds
52
+
53
+
54
+#define TRIM_DURATION       2                               // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009
55
+
56
+//#define NBR_TIMERS        (MAX_SERVOS / SERVOS_PER_TIMER)
57
+
58
+static servo_t servos[MAX_SERVOS];                          // static array of servo structures
59
+static volatile int8_t Channel[_Nbr_16timers ];             // counter for the servo being pulsed for each timer (or -1 if refresh interval)
60
+
61
+uint8_t ServoCount = 0;                                     // the total number of attached servos
62
+
63
+
64
+// convenience macros
65
+#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo
66
+#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER)       // returns the index of the servo on this timer
67
+#define SERVO_INDEX(_timer,_channel)  ((_timer*SERVOS_PER_TIMER) + _channel)     // macro to access servo index by timer and channel
68
+#define SERVO(_timer,_channel)  (servos[SERVO_INDEX(_timer,_channel)])            // macro to access servo class by timer and channel
69
+
70
+#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4)  // minimum value in uS for this servo
71
+#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4)  // maximum value in uS for this servo
72
+
73
+/************ static functions common to all instances ***********************/
74
+
75
+static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t* OCRnA)
76
+{
77
+  if( Channel[timer] < 0 )
78
+    *TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer
79
+  else{
80
+    if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive == true )
81
+      digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated
82
+  }
83
+
84
+  Channel[timer]++;    // increment to the next channel
85
+  if( SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
86
+    *OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks;
87
+    if(SERVO(timer,Channel[timer]).Pin.isActive == true)     // check if activated
88
+      digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high
89
+  }
90
+  else {
91
+    // finished all channels so wait for the refresh period to expire before starting over
92
+    if( ((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) )  // allow a few ticks to ensure the next OCR1A not missed
93
+      *OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL);
94
+    else
95
+      *OCRnA = *TCNTn + 4;  // at least REFRESH_INTERVAL has elapsed
96
+    Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
97
+  }
98
+}
99
+
100
+#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
101
+// Interrupt handlers for Arduino
102
+#if defined(_useTimer1)
103
+SIGNAL (TIMER1_COMPA_vect)
104
+{
105
+  handle_interrupts(_timer1, &TCNT1, &OCR1A);
106
+}
107
+#endif
108
+
109
+#if defined(_useTimer3)
110
+SIGNAL (TIMER3_COMPA_vect)
111
+{
112
+  handle_interrupts(_timer3, &TCNT3, &OCR3A);
113
+}
114
+#endif
115
+
116
+#if defined(_useTimer4)
117
+SIGNAL (TIMER4_COMPA_vect)
118
+{
119
+  handle_interrupts(_timer4, &TCNT4, &OCR4A);
120
+}
121
+#endif
122
+
123
+#if defined(_useTimer5)
124
+SIGNAL (TIMER5_COMPA_vect)
125
+{
126
+  handle_interrupts(_timer5, &TCNT5, &OCR5A);
127
+}
128
+#endif
129
+
130
+#elif defined WIRING
131
+// Interrupt handlers for Wiring
132
+#if defined(_useTimer1)
133
+void Timer1Service()
134
+{
135
+  handle_interrupts(_timer1, &TCNT1, &OCR1A);
136
+}
137
+#endif
138
+#if defined(_useTimer3)
139
+void Timer3Service()
140
+{
141
+  handle_interrupts(_timer3, &TCNT3, &OCR3A);
142
+}
143
+#endif
144
+#endif
145
+
146
+
147
+static void initISR(timer16_Sequence_t timer)
148
+{
149
+#if defined (_useTimer1)
150
+  if(timer == _timer1) {
151
+    TCCR1A = 0;             // normal counting mode
152
+    TCCR1B = _BV(CS11);     // set prescaler of 8
153
+    TCNT1 = 0;              // clear the timer count
154
+#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
155
+    TIFR |= _BV(OCF1A);      // clear any pending interrupts;
156
+    TIMSK |=  _BV(OCIE1A) ;  // enable the output compare interrupt
157
+#else
158
+    // here if not ATmega8 or ATmega128
159
+    TIFR1 |= _BV(OCF1A);     // clear any pending interrupts;
160
+    TIMSK1 |=  _BV(OCIE1A) ; // enable the output compare interrupt
161
+#endif
162
+#if defined(WIRING)
163
+    timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
164
+#endif
165
+  }
166
+#endif
167
+
168
+#if defined (_useTimer3)
169
+  if(timer == _timer3) {
170
+    TCCR3A = 0;             // normal counting mode
171
+    TCCR3B = _BV(CS31);     // set prescaler of 8
172
+    TCNT3 = 0;              // clear the timer count
173
+#if defined(__AVR_ATmega128__)
174
+    TIFR |= _BV(OCF3A);     // clear any pending interrupts;
175
+	ETIMSK |= _BV(OCIE3A);  // enable the output compare interrupt
176
+#else
177
+    TIFR3 = _BV(OCF3A);     // clear any pending interrupts;
178
+    TIMSK3 =  _BV(OCIE3A) ; // enable the output compare interrupt
179
+#endif
180
+#if defined(WIRING)
181
+    timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service);  // for Wiring platform only
182
+#endif
183
+  }
184
+#endif
185
+
186
+#if defined (_useTimer4)
187
+  if(timer == _timer4) {
188
+    TCCR4A = 0;             // normal counting mode
189
+    TCCR4B = _BV(CS41);     // set prescaler of 8
190
+    TCNT4 = 0;              // clear the timer count
191
+    TIFR4 = _BV(OCF4A);     // clear any pending interrupts;
192
+    TIMSK4 =  _BV(OCIE4A) ; // enable the output compare interrupt
193
+  }
194
+#endif
195
+
196
+#if defined (_useTimer5)
197
+  if(timer == _timer5) {
198
+    TCCR5A = 0;             // normal counting mode
199
+    TCCR5B = _BV(CS51);     // set prescaler of 8
200
+    TCNT5 = 0;              // clear the timer count
201
+    TIFR5 = _BV(OCF5A);     // clear any pending interrupts;
202
+    TIMSK5 =  _BV(OCIE5A) ; // enable the output compare interrupt
203
+  }
204
+#endif
205
+}
206
+
207
+static void finISR(timer16_Sequence_t timer)
208
+{
209
+    //disable use of the given timer
210
+#if defined WIRING   // Wiring
211
+  if(timer == _timer1) {
212
+    #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
213
+    TIMSK1 &=  ~_BV(OCIE1A) ;  // disable timer 1 output compare interrupt
214
+    #else
215
+    TIMSK &=  ~_BV(OCIE1A) ;  // disable timer 1 output compare interrupt
216
+    #endif
217
+    timerDetach(TIMER1OUTCOMPAREA_INT);
218
+  }
219
+  else if(timer == _timer3) {
220
+    #if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
221
+    TIMSK3 &= ~_BV(OCIE3A);    // disable the timer3 output compare A interrupt
222
+    #else
223
+    ETIMSK &= ~_BV(OCIE3A);    // disable the timer3 output compare A interrupt
224
+    #endif
225
+    timerDetach(TIMER3OUTCOMPAREA_INT);
226
+  }
227
+#else
228
+    //For arduino - in future: call here to a currently undefined function to reset the timer
229
+#endif
230
+}
231
+
232
+static boolean isTimerActive(timer16_Sequence_t timer)
233
+{
234
+  // returns true if any servo is active on this timer
235
+  for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) {
236
+    if(SERVO(timer,channel).Pin.isActive == true)
237
+      return true;
238
+  }
239
+  return false;
240
+}
241
+
242
+
243
+/****************** end of static functions ******************************/
244
+
245
+Servo::Servo()
246
+{
247
+  if( ServoCount < MAX_SERVOS) {
248
+    this->servoIndex = ServoCount++;                    // assign a servo index to this instance
249
+	servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);   // store default values  - 12 Aug 2009
250
+  }
251
+  else
252
+    this->servoIndex = INVALID_SERVO ;  // too many servos
253
+}
254
+
255
+uint8_t Servo::attach(int pin)
256
+{
257
+  return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
258
+}
259
+
260
+uint8_t Servo::attach(int pin, int min, int max)
261
+{
262
+  if(this->servoIndex < MAX_SERVOS ) {
263
+    pinMode( pin, OUTPUT) ;                                   // set servo pin to output
264
+    servos[this->servoIndex].Pin.nbr = pin;
265
+    // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
266
+    this->min  = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS
267
+    this->max  = (MAX_PULSE_WIDTH - max)/4;
268
+    // initialize the timer if it has not already been initialized
269
+    timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
270
+    if(isTimerActive(timer) == false)
271
+      initISR(timer);
272
+    servos[this->servoIndex].Pin.isActive = true;  // this must be set after the check for isTimerActive
273
+  }
274
+  return this->servoIndex ;
275
+}
276
+
277
+void Servo::detach()
278
+{
279
+  servos[this->servoIndex].Pin.isActive = false;
280
+  timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
281
+  if(isTimerActive(timer) == false) {
282
+    finISR(timer);
283
+  }
284
+}
285
+
286
+void Servo::write(int value)
287
+{
288
+  if(value < MIN_PULSE_WIDTH)
289
+  {  // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
290
+    if(value < 0) value = 0;
291
+    if(value > 180) value = 180;
292
+    value = map(value, 0, 180, SERVO_MIN(),  SERVO_MAX());
293
+  }
294
+  this->writeMicroseconds(value);
295
+}
296
+
297
+void Servo::writeMicroseconds(int value)
298
+{
299
+  // calculate and store the values for the given channel
300
+  byte channel = this->servoIndex;
301
+  if( (channel < MAX_SERVOS) )   // ensure channel is valid
302
+  {
303
+    if( value < SERVO_MIN() )          // ensure pulse width is valid
304
+      value = SERVO_MIN();
305
+    else if( value > SERVO_MAX() )
306
+      value = SERVO_MAX();
307
+
308
+  	value = value - TRIM_DURATION;
309
+    value = usToTicks(value);  // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
310
+
311
+    uint8_t oldSREG = SREG;
312
+    cli();
313
+    servos[channel].ticks = value;
314
+    SREG = oldSREG;
315
+  }
316
+}
317
+
318
+int Servo::read() // return the value as degrees
319
+{
320
+  return  map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
321
+}
322
+
323
+int Servo::readMicroseconds()
324
+{
325
+  unsigned int pulsewidth;
326
+  if( this->servoIndex != INVALID_SERVO )
327
+    pulsewidth = ticksToUs(servos[this->servoIndex].ticks)  + TRIM_DURATION ;   // 12 aug 2009
328
+  else
329
+    pulsewidth  = 0;
330
+
331
+  return pulsewidth;
332
+}
333
+
334
+bool Servo::attached()
335
+{
336
+  return servos[this->servoIndex].Pin.isActive ;
337
+}

+ 132
- 0
Marlin/Servo.h View File

@@ -0,0 +1,132 @@
1
+/*
2
+  Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
3
+  Copyright (c) 2009 Michael Margolis.  All right reserved.
4
+
5
+  This library is free software; you can redistribute it and/or
6
+  modify it under the terms of the GNU Lesser General Public
7
+  License as published by the Free Software Foundation; either
8
+  version 2.1 of the License, or (at your option) any later version.
9
+
10
+  This library is distributed in the hope that it will be useful,
11
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
+  Lesser General Public License for more details.
14
+
15
+  You should have received a copy of the GNU Lesser General Public
16
+  License along with this library; if not, write to the Free Software
17
+  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
+*/
19
+
20
+/*
21
+
22
+  A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
23
+  The servos are pulsed in the background using the value most recently written using the write() method
24
+
25
+  Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
26
+  Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
27
+  The sequence used to sieze timers is defined in timers.h
28
+
29
+  The methods are:
30
+
31
+   Servo - Class for manipulating servo motors connected to Arduino pins.
32
+
33
+   attach(pin )  - Attaches a servo motor to an i/o pin.
34
+   attach(pin, min, max  ) - Attaches to a pin setting min and max values in microseconds
35
+   default min is 544, max is 2400
36
+
37
+   write()     - Sets the servo angle in degrees.  (invalid angle that is valid as pulse in microseconds is treated as microseconds)
38
+   writeMicroseconds() - Sets the servo pulse width in microseconds
39
+   read()      - Gets the last written servo pulse width as an angle between 0 and 180.
40
+   readMicroseconds()   - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
41
+   attached()  - Returns true if there is a servo attached.
42
+   detach()    - Stops an attached servos from pulsing its i/o pin.
43
+ */
44
+
45
+#ifndef Servo_h
46
+#define Servo_h
47
+
48
+#include <inttypes.h>
49
+
50
+/*
51
+ * Defines for 16 bit timers used with  Servo library
52
+ *
53
+ * If _useTimerX is defined then TimerX is a 16 bit timer on the curent board
54
+ * timer16_Sequence_t enumerates the sequence that the timers should be allocated
55
+ * _Nbr_16timers indicates how many 16 bit timers are available.
56
+ *
57
+ */
58
+
59
+// Say which 16 bit timers can be used and in what order
60
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
61
+#define _useTimer5
62
+//#define _useTimer1
63
+#define _useTimer3
64
+#define _useTimer4
65
+//typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
66
+typedef enum { _timer5, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
67
+
68
+#elif defined(__AVR_ATmega32U4__)
69
+//#define _useTimer1
70
+#define _useTimer3
71
+//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
72
+typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
73
+
74
+#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
75
+#define _useTimer3
76
+//#define _useTimer1
77
+//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
78
+typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
79
+
80
+#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
81
+#define _useTimer3
82
+//#define _useTimer1
83
+//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
84
+typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
85
+
86
+#else  // everything else
87
+//#define _useTimer1
88
+//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
89
+typedef enum { _Nbr_16timers } timer16_Sequence_t ;
90
+#endif
91
+
92
+#define Servo_VERSION           2      // software version of this library
93
+
94
+#define MIN_PULSE_WIDTH       544     // the shortest pulse sent to a servo
95
+#define MAX_PULSE_WIDTH      2400     // the longest pulse sent to a servo
96
+#define DEFAULT_PULSE_WIDTH  1500     // default pulse width when servo is attached
97
+#define REFRESH_INTERVAL    20000     // minumim time to refresh servos in microseconds
98
+
99
+#define SERVOS_PER_TIMER       12     // the maximum number of servos controlled by one timer
100
+#define MAX_SERVOS   (_Nbr_16timers  * SERVOS_PER_TIMER)
101
+
102
+#define INVALID_SERVO         255     // flag indicating an invalid servo index
103
+
104
+typedef struct  {
105
+  uint8_t nbr        :6 ;             // a pin number from 0 to 63
106
+  uint8_t isActive   :1 ;             // true if this channel is enabled, pin not pulsed if false
107
+} ServoPin_t   ;
108
+
109
+typedef struct {
110
+  ServoPin_t Pin;
111
+  unsigned int ticks;
112
+} servo_t;
113
+
114
+class Servo
115
+{
116
+public:
117
+  Servo();
118
+  uint8_t attach(int pin);           // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
119
+  uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
120
+  void detach();
121
+  void write(int value);             // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
122
+  void writeMicroseconds(int value); // Write pulse width in microseconds
123
+  int read();                        // returns current pulse width as an angle between 0 and 180 degrees
124
+  int readMicroseconds();            // returns current pulse width in microseconds for this servo (was read_us() in first release)
125
+  bool attached();                   // return true if this servo is attached, otherwise false
126
+private:
127
+   uint8_t servoIndex;               // index into the channel data for this servo
128
+   int8_t min;                       // minimum is this value times 4 added to MIN_PULSE_WIDTH
129
+   int8_t max;                       // maximum is this value times 4 added to MAX_PULSE_WIDTH
130
+};
131
+
132
+#endif

+ 88
- 83
Marlin/pins.h View File

@@ -248,14 +248,14 @@
248 248
     #define E0_STEP_PIN      28
249 249
     #define E0_DIR_PIN       27
250 250
     #define E0_ENABLE_PIN    24
251
-    
251
+
252 252
     #define TEMP_0_PIN      2
253 253
     #define TEMP_1_PIN      -1
254 254
     #define TEMP_2_PIN      -1
255 255
     #define TEMP_BED_PIN        1   // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!! (pin 34 bed)
256
-     
256
+
257 257
     #define HEATER_0_PIN    4
258
-    #define HEATER_1_PIN    -1   
258
+    #define HEATER_1_PIN    -1
259 259
     #define HEATER_2_PIN    -1
260 260
     #define HEATER_BED_PIN      3  // (bed)
261 261
 
@@ -272,25 +272,25 @@
272 272
     //our RS485 pins
273 273
     //#define TX_ENABLE_PIN       12
274 274
     //#define RX_ENABLE_PIN       13
275
-    
276
-    #define BEEPER -1	
277
-	#define SDCARDDETECT -1 		
275
+
276
+    #define BEEPER -1
277
+	#define SDCARDDETECT -1
278 278
     #define SUICIDE_PIN -1						//has to be defined; otherwise Power_off doesn't work
279
-	
279
+
280 280
     #define KILL_PIN -1
281
-	//Pins for 4bit LCD Support 
282
-    #define LCD_PINS_RS 18 
281
+	//Pins for 4bit LCD Support
282
+    #define LCD_PINS_RS 18
283 283
     #define LCD_PINS_ENABLE 17
284 284
     #define LCD_PINS_D4 16
285
-    #define LCD_PINS_D5 15 
285
+    #define LCD_PINS_D5 15
286 286
     #define LCD_PINS_D6 13
287 287
     #define LCD_PINS_D7 14
288
-    
288
+
289 289
      //buttons are directly attached
290 290
     #define BTN_EN1 11
291 291
     #define BTN_EN2 10
292 292
     #define BTN_ENC 12  //the click
293
-    
293
+
294 294
     #define BLEN_C 2
295 295
     #define BLEN_B 1
296 296
     #define BLEN_A 0
@@ -376,13 +376,18 @@
376 376
 #else
377 377
 #define HEATER_1_PIN       9    // EXTRUDER 2 (FAN On Sprinter)
378 378
 #endif
379
-#define HEATER_2_PIN       -1   
379
+#define HEATER_2_PIN       -1
380 380
 #define TEMP_0_PIN         13   // ANALOG NUMBERING
381 381
 #define TEMP_1_PIN         15   // ANALOG NUMBERING
382 382
 #define TEMP_2_PIN         -1   // ANALOG NUMBERING
383 383
 #define HEATER_BED_PIN     8    // BED
384 384
 #define TEMP_BED_PIN       14   // ANALOG NUMBERING
385 385
 
386
+#define SERVO0_PIN         11
387
+#define SERVO1_PIN         6
388
+#define SERVO2_PIN         5
389
+#define SERVO3_PIN         4
390
+
386 391
 #ifdef ULTRA_LCD
387 392
 
388 393
   #ifdef NEWPANEL
@@ -396,13 +401,13 @@
396 401
     #define BLEN_B 1
397 402
     #define BLEN_C 2
398 403
 
399
-    #define LCD_PINS_RS 16 
404
+    #define LCD_PINS_RS 16
400 405
     #define LCD_PINS_ENABLE 17
401 406
     #define LCD_PINS_D4 23
402
-    #define LCD_PINS_D5 25 
407
+    #define LCD_PINS_D5 25
403 408
     #define LCD_PINS_D6 27
404 409
     #define LCD_PINS_D7 29
405
-    
410
+
406 411
     #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
407 412
       #define BEEPER 37
408 413
 
@@ -455,21 +460,21 @@
455 460
     //#define SHIFT_LD 42
456 461
     //#define SHIFT_OUT 40
457 462
     //#define SHIFT_EN 17
458
-    
459
-    #define LCD_PINS_RS 16 
463
+
464
+    #define LCD_PINS_RS 16
460 465
     #define LCD_PINS_ENABLE 17
461 466
     #define LCD_PINS_D4 23
462
-    #define LCD_PINS_D5 25 
467
+    #define LCD_PINS_D5 25
463 468
     #define LCD_PINS_D6 27
464 469
     #define LCD_PINS_D7 29
465
-    
470
+
466 471
     //encoder rotation values
467 472
     #define encrot0 0
468 473
     #define encrot1 2
469 474
     #define encrot2 3
470 475
     #define encrot3 1
471 476
 
472
-    
477
+
473 478
     //bits in the shift register that carry the buttons for:
474 479
     // left up center down right red
475 480
     #define BL_LE 7
@@ -481,7 +486,7 @@
481 486
 
482 487
     #define BLEN_B 1
483 488
     #define BLEN_A 0
484
-  #endif 
489
+  #endif
485 490
 #endif //ULTRA_LCD
486 491
 
487 492
 #else // RAMPS_V_1_1 or RAMPS_V_1_2 as default (MOTHERBOARD == 3)
@@ -526,15 +531,15 @@
526 531
 #define HEATER_1_PIN        -1
527 532
 #define HEATER_2_PIN        -1
528 533
 #define TEMP_0_PIN          2    // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
529
-#define TEMP_1_PIN          -1   
530
-#define TEMP_2_PIN          -1   
534
+#define TEMP_1_PIN          -1
535
+#define TEMP_2_PIN          -1
531 536
 #define TEMP_BED_PIN        1    // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
532 537
 #endif// MOTHERBOARD == 33 || MOTHERBOARD == 34
533 538
 
534
-// SPI for Max6675 Thermocouple 
539
+// SPI for Max6675 Thermocouple
535 540
 
536 541
 #ifndef SDSUPPORT
537
-// these pins are defined in the SD library if building with SD support  
542
+// these pins are defined in the SD library if building with SD support
538 543
   #define MAX_SCK_PIN          52
539 544
   #define MAX_MISO_PIN         50
540 545
   #define MAX_MOSI_PIN         51
@@ -586,8 +591,8 @@
586 591
 #define HEATER_1_PIN        -1
587 592
 #define HEATER_2_PIN        -1
588 593
 #define TEMP_0_PIN          0    // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
589
-#define TEMP_1_PIN          -1    
590
-#define TEMP_2_PIN          -1    
594
+#define TEMP_1_PIN          -1
595
+#define TEMP_2_PIN          -1
591 596
 #define HEATER_BED_PIN      -1
592 597
 #define TEMP_BED_PIN        -1
593 598
 
@@ -650,14 +655,14 @@
650 655
     #define PS_ON_PIN       -1    //changed @ rkoeppl 20110410
651 656
     #define KILL_PIN        -1    //changed @ drakelive 20120830
652 657
     //our pin for debugging.
653
-    
658
+
654 659
     #define DEBUG_PIN        0
655
-    
660
+
656 661
     //our RS485 pins
657 662
     #define TX_ENABLE_PIN	12
658 663
     #define RX_ENABLE_PIN	13
659 664
 
660
-    
665
+
661 666
 #endif
662 667
 
663 668
 /****************************************************************************************
@@ -673,7 +678,7 @@
673 678
 #if MOTHERBOARD == 62 || MOTHERBOARD == 63 || MOTHERBOARD == 64
674 679
 #undef MOTHERBOARD
675 680
 #define MOTHERBOARD 6
676
-#define SANGUINOLOLU_V_1_2 
681
+#define SANGUINOLOLU_V_1_2
677 682
 #endif
678 683
 #if MOTHERBOARD == 6
679 684
 #define KNOWN_BOARD 1
@@ -700,7 +705,7 @@
700 705
 
701 706
 #define LED_PIN            -1
702 707
 
703
-#define FAN_PIN            -1 
708
+#define FAN_PIN            -1
704 709
 #if FAN_PIN == 12 || FAN_PIN ==13
705 710
 #define FAN_SOFT_PWM
706 711
 #endif
@@ -779,21 +784,21 @@
779 784
      #define BTN_ENC 16  //the switch
780 785
      //not connected to a pin
781 786
      #define SDCARDDETECT -1
782
-     
787
+
783 788
      //from the same bit in the RAMPS Newpanel define
784 789
      //encoder rotation values
785 790
      #define encrot0 0
786 791
      #define encrot1 2
787 792
      #define encrot2 3
788 793
      #define encrot3 1
789
-     
794
+
790 795
      #define BLEN_C 2
791 796
      #define BLEN_B 1
792 797
      #define BLEN_A 0
793
-     
798
+
794 799
    #endif //Newpanel
795 800
  #endif //Ultipanel
796
- 
801
+
797 802
 #endif
798 803
 
799 804
 
@@ -823,17 +828,17 @@
823 828
 #define Y_MAX_PIN 28
824 829
 #define Y_ENABLE_PIN 29
825 830
 
826
-#define Z_STEP_PIN 37 
831
+#define Z_STEP_PIN 37
827 832
 #define Z_DIR_PIN 39
828 833
 #define Z_MIN_PIN 30
829 834
 #define Z_MAX_PIN 32
830 835
 #define Z_ENABLE_PIN 35
831 836
 
832
-#define HEATER_BED_PIN 4 
833
-#define TEMP_BED_PIN 10  
837
+#define HEATER_BED_PIN 4
838
+#define TEMP_BED_PIN 10
834 839
 
835 840
 #define HEATER_0_PIN  2
836
-#define TEMP_0_PIN 8   
841
+#define TEMP_0_PIN 8
837 842
 
838 843
 #define HEATER_1_PIN 3
839 844
 #define TEMP_1_PIN 9
@@ -863,24 +868,24 @@
863 868
   //arduino pin witch triggers an piezzo beeper
864 869
     #define BEEPER 18
865 870
 
866
-    #define LCD_PINS_RS 20 
871
+    #define LCD_PINS_RS 20
867 872
     #define LCD_PINS_ENABLE 17
868 873
     #define LCD_PINS_D4 16
869
-    #define LCD_PINS_D5 21 
874
+    #define LCD_PINS_D5 21
870 875
     #define LCD_PINS_D6 5
871 876
     #define LCD_PINS_D7 6
872
-    
877
+
873 878
     //buttons are directly attached
874 879
     #define BTN_EN1 40
875 880
     #define BTN_EN2 42
876 881
     #define BTN_ENC 19  //the click
877
-    
882
+
878 883
     #define BLEN_C 2
879 884
     #define BLEN_B 1
880 885
     #define BLEN_A 0
881
-    
886
+
882 887
     #define SDCARDDETECT 38
883
-    
888
+
884 889
       //encoder rotation values
885 890
     #define encrot0 0
886 891
     #define encrot1 2
@@ -895,14 +900,14 @@
895 900
     #define SHIFT_LD 42
896 901
     #define SHIFT_OUT 40
897 902
     #define SHIFT_EN 17
898
-    
899
-    #define LCD_PINS_RS 16 
903
+
904
+    #define LCD_PINS_RS 16
900 905
     #define LCD_PINS_ENABLE 5
901 906
     #define LCD_PINS_D4 6
902
-    #define LCD_PINS_D5 21 
907
+    #define LCD_PINS_D5 21
903 908
     #define LCD_PINS_D6 20
904 909
     #define LCD_PINS_D7 19
905
-    
910
+
906 911
     //encoder rotation values
907 912
     #ifndef ULTIMAKERCONTROLLER
908 913
      #define encrot0 0
@@ -929,7 +934,7 @@
929 934
 
930 935
     #define BLEN_B 1
931 936
     #define BLEN_A 0
932
-  #endif 
937
+  #endif
933 938
 #endif //ULTRA_LCD
934 939
 
935 940
 #endif
@@ -960,17 +965,17 @@
960 965
 #define Y_MAX_PIN 16
961 966
 #define Y_ENABLE_PIN 29
962 967
 
963
-#define Z_STEP_PIN 37 
968
+#define Z_STEP_PIN 37
964 969
 #define Z_DIR_PIN 39
965 970
 #define Z_MIN_PIN 19
966 971
 #define Z_MAX_PIN 18
967 972
 #define Z_ENABLE_PIN 35
968 973
 
969
-#define HEATER_BED_PIN -1 
970
-#define TEMP_BED_PIN -1  
974
+#define HEATER_BED_PIN -1
975
+#define TEMP_BED_PIN -1
971 976
 
972 977
 #define HEATER_0_PIN  2
973
-#define TEMP_0_PIN 8   
978
+#define TEMP_0_PIN 8
974 979
 
975 980
 #define HEATER_1_PIN 1
976 981
 #define TEMP_1_PIN 1
@@ -994,10 +999,10 @@
994 999
 #define KILL_PIN           -1
995 1000
 #define SUICIDE_PIN        -1  //PIN that has to be turned on right after start, to keep power flowing.
996 1001
 
997
-#define LCD_PINS_RS 24 
1002
+#define LCD_PINS_RS 24
998 1003
 #define LCD_PINS_ENABLE 22
999 1004
 #define LCD_PINS_D4 36
1000
-#define LCD_PINS_D5 34 
1005
+#define LCD_PINS_D5 34
1001 1006
 #define LCD_PINS_D6 32
1002 1007
 #define LCD_PINS_D7 30
1003 1008
 
@@ -1019,17 +1024,17 @@
1019 1024
 #define X_DIR_PIN          16
1020 1025
 #define X_ENABLE_PIN       48
1021 1026
 #define X_MIN_PIN          37
1022
-#define X_MAX_PIN          36 
1027
+#define X_MAX_PIN          36
1023 1028
 
1024 1029
 #define Y_STEP_PIN         54
1025
-#define Y_DIR_PIN          47 
1030
+#define Y_DIR_PIN          47
1026 1031
 #define Y_ENABLE_PIN       55
1027 1032
 #define Y_MIN_PIN          35
1028
-#define Y_MAX_PIN          34 
1033
+#define Y_MAX_PIN          34
1029 1034
 
1030
-#define Z_STEP_PIN         57 
1035
+#define Z_STEP_PIN         57
1031 1036
 #define Z_DIR_PIN          56
1032
-#define Z_ENABLE_PIN       62 
1037
+#define Z_ENABLE_PIN       62
1033 1038
 #define Z_MIN_PIN          33
1034 1039
 #define Z_MAX_PIN          32
1035 1040
 
@@ -1047,7 +1052,7 @@
1047 1052
 
1048 1053
 #define LED_PIN            13
1049 1054
 
1050
-#define FAN_PIN            7 
1055
+#define FAN_PIN            7
1051 1056
 //additional FAN1 PIN (e.g. useful for electronics fan or light on/off) on PIN 8
1052 1057
 
1053 1058
 #define PS_ON_PIN          45
@@ -1108,10 +1113,10 @@
1108 1113
 #define SDSS               53
1109 1114
 #define SDCARDDETECT       49
1110 1115
 #define BEEPER             44
1111
-#define LCD_PINS_RS        19 
1116
+#define LCD_PINS_RS        19
1112 1117
 #define LCD_PINS_ENABLE    42
1113 1118
 #define LCD_PINS_D4        18
1114
-#define LCD_PINS_D5        38 
1119
+#define LCD_PINS_D5        38
1115 1120
 #define LCD_PINS_D6        41
1116 1121
 #define LCD_PINS_D7        40
1117 1122
 #define BTN_EN1            11
@@ -1295,7 +1300,7 @@
1295 1300
 
1296 1301
 #define LED_PIN            -1
1297 1302
 
1298
-#define FAN_PIN            -1 
1303
+#define FAN_PIN            -1
1299 1304
 
1300 1305
 #define PS_ON_PIN         14
1301 1306
 #define KILL_PIN           -1
@@ -1334,7 +1339,7 @@
1334 1339
 *       MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D25)
1335 1340
 *        SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D24)
1336 1341
 *                  RST  9|        |32  AREF
1337
-*                  VCC 10|        |31  GND 
1342
+*                  VCC 10|        |31  GND
1338 1343
 *                  GND 11|        |30  AVCC
1339 1344
 *                XTAL2 12|        |29  PC7 (D 23)
1340 1345
 *                XTAL1 13|        |28  PC6 (D 22)
@@ -1391,7 +1396,7 @@
1391 1396
 #define KILL_PIN           -1
1392 1397
 
1393 1398
 #define HEATER_0_PIN       4
1394
-#define HEATER_1_PIN       -1 // 12 
1399
+#define HEATER_1_PIN       -1 // 12
1395 1400
 #define HEATER_2_PIN       -1 // 13
1396 1401
 #define TEMP_0_PIN          0 //D27   // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
1397 1402
 #define TEMP_1_PIN         -1 // 1
@@ -1453,11 +1458,11 @@
1453 1458
 #define KILL_PIN           -1
1454 1459
 
1455 1460
 #define HEATER_0_PIN        3 /*DONE PWM on RIGHT connector */
1456
-#define HEATER_1_PIN       -1 
1461
+#define HEATER_1_PIN       -1
1457 1462
 #define HEATER_2_PIN       -1
1458
-#define HEATER_1_PIN       -1 
1463
+#define HEATER_1_PIN       -1
1459 1464
 #define HEATER_2_PIN       -1
1460
-#define TEMP_0_PIN          0 // ANALOG INPUT NUMBERING 
1465
+#define TEMP_0_PIN          0 // ANALOG INPUT NUMBERING
1461 1466
 #define TEMP_1_PIN          1 // ANALOG
1462 1467
 #define TEMP_2_PIN         -1 // 2
1463 1468
 #define HEATER_BED_PIN      4
@@ -1505,7 +1510,7 @@
1505 1510
 #define Z_MS2_PIN 67
1506 1511
 
1507 1512
 #define HEATER_BED_PIN 3
1508
-#define TEMP_BED_PIN 2 
1513
+#define TEMP_BED_PIN 2
1509 1514
 
1510 1515
 #define HEATER_0_PIN  9
1511 1516
 #define TEMP_0_PIN 0
@@ -1598,9 +1603,9 @@
1598 1603
 
1599 1604
 #define HEATER_0_PIN       9    // EXTRUDER 1
1600 1605
 #define HEATER_1_PIN       8    // EXTRUDER 2 (FAN On Sprinter)
1601
-#define HEATER_2_PIN       -1  
1606
+#define HEATER_2_PIN       -1
1602 1607
 
1603
-#if TEMP_SENSOR_0 == -1 
1608
+#if TEMP_SENSOR_0 == -1
1604 1609
 #define TEMP_0_PIN         8   // ANALOG NUMBERING
1605 1610
 #else
1606 1611
 #define TEMP_0_PIN         13   // ANALOG NUMBERING
@@ -1619,25 +1624,25 @@
1619 1624
 
1620 1625
   #ifdef NEWPANEL
1621 1626
   //arduino pin which triggers an piezzo beeper
1622
-    
1623
-    #define LCD_PINS_RS 16 
1627
+
1628
+    #define LCD_PINS_RS 16
1624 1629
     #define LCD_PINS_ENABLE 17
1625 1630
     #define LCD_PINS_D4 23
1626
-    #define LCD_PINS_D5 25 
1631
+    #define LCD_PINS_D5 25
1627 1632
     #define LCD_PINS_D6 27
1628 1633
     #define LCD_PINS_D7 29
1629
-    
1634
+
1630 1635
     //buttons are directly attached using AUX-2
1631 1636
     #define BTN_EN1 59
1632 1637
     #define BTN_EN2 64
1633 1638
     #define BTN_ENC 43  //the click
1634
-    
1639
+
1635 1640
     #define BLEN_C 2
1636 1641
     #define BLEN_B 1
1637 1642
     #define BLEN_A 0
1638
-    
1643
+
1639 1644
     #define SDCARDDETECT -1		// Ramps does not use this port
1640
-    
1645
+
1641 1646
       //encoder rotation values
1642 1647
     #define encrot0 0
1643 1648
     #define encrot1 2
@@ -1653,7 +1658,7 @@
1653 1658
 #endif
1654 1659
 
1655 1660
 //List of pins which to ignore when asked to change by gcode, 0 and 1 are RX and TX, do not mess with those!
1656
-#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, HEATER_0_PIN, 
1661
+#define _E0_PINS E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, HEATER_0_PIN,
1657 1662
 #if EXTRUDERS > 1
1658 1663
   #define _E1_PINS E1_STEP_PIN, E1_DIR_PIN, E1_ENABLE_PIN, HEATER_1_PIN,
1659 1664
 #else

Loading…
Cancel
Save