Browse Source

Add support for Arduino DUE Shield Kit (#12950)

lanserge 5 years ago
parent
commit
c2cf8ffa82
4 changed files with 247 additions and 6 deletions
  1. 1
    0
      Marlin/src/core/boards.h
  2. 37
    6
      Marlin/src/lcd/ultralcd.cpp
  3. 2
    0
      Marlin/src/pins/pins.h
  4. 207
    0
      Marlin/src/pins/pins_ADSK.h

+ 1
- 0
Marlin/src/core/boards.h View File

@@ -221,6 +221,7 @@
221 221
 #define BOARD_ARCHIM1          1591   // UltiMachine Archim1 (with DRV8825 drivers)
222 222
 #define BOARD_ARCHIM2          1592   // UltiMachine Archim2 (with TMC2130 drivers)
223 223
 #define BOARD_ALLIGATOR        1602   // Alligator Board R2
224
+#define BOARD_ADSK             1610   // Arduino DUE Shield Kit (ADSK)
224 225
 
225 226
 //
226 227
 // STM32 ARM Cortex-M3

+ 37
- 6
Marlin/src/lcd/ultralcd.cpp View File

@@ -930,16 +930,46 @@ void MarlinUI::update() {
930 930
     uint8_t  ADCKeyNo;
931 931
   } _stADCKeypadTable_;
932 932
 
933
+  #ifndef ADC_BUTTONS_VALUE_SCALE
934
+    #define ADC_BUTTONS_VALUE_SCALE       1.0  // for the power voltage equal to the reference voltage
935
+  #endif
936
+  #ifndef ADC_BUTTONS_R_PULLUP
937
+    #define ADC_BUTTONS_R_PULLUP          4.7  // common pull-up resistor in the voltage divider
938
+  #endif
939
+  #ifndef ADC_BUTTONS_LEFT_R_PULLDOWN
940
+    #define ADC_BUTTONS_LEFT_R_PULLDOWN   0.47 // pull-down resistor for LEFT button voltage divider
941
+  #endif
942
+  #ifndef ADC_BUTTONS_RIGHT_R_PULLDOWN
943
+    #define ADC_BUTTONS_RIGHT_R_PULLDOWN  4.7  // pull-down resistor for RIGHT button voltage divider
944
+  #endif
945
+  #ifndef ADC_BUTTONS_UP_R_PULLDOWN
946
+    #define ADC_BUTTONS_UP_R_PULLDOWN     1.0  // pull-down resistor for UP button voltage divider
947
+  #endif
948
+  #ifndef ADC_BUTTONS_DOWN_R_PULLDOWN
949
+    #define ADC_BUTTONS_DOWN_R_PULLDOWN   10.0 // pull-down resistor for DOWN button voltage divider
950
+  #endif
951
+  #ifndef ADC_BUTTONS_MIDDLE_R_PULLDOWN
952
+    #define ADC_BUTTONS_MIDDLE_R_PULLDOWN 2.2  // pull-down resistor for MIDDLE button voltage divider
953
+  #endif
954
+
955
+  // Calculate the ADC value for the voltage divider with specified pull-down resistor value
956
+  #define ADC_BUTTON_VALUE(r)  (int(4096.0 * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)))
957
+
933 958
   static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = {
934 959
     // VALUE_MIN, VALUE_MAX, KEY
935 960
     { 4000, 4096, 1 + BLEN_KEYPAD_F1     }, // F1
936 961
     { 4000, 4096, 1 + BLEN_KEYPAD_F2     }, // F2
937 962
     { 4000, 4096, 1 + BLEN_KEYPAD_F3     }, // F3
938
-    {  300,  500, 1 + BLEN_KEYPAD_LEFT   }, // LEFT
939
-    { 1900, 2200, 1 + BLEN_KEYPAD_RIGHT  }, // RIGHT
940
-    {  570,  870, 1 + BLEN_KEYPAD_UP     }, // UP
941
-    { 2670, 2870, 1 + BLEN_KEYPAD_DOWN   }, // DOWN
942
-    { 1150, 1450, 1 + BLEN_KEYPAD_MIDDLE }, // ENTER
963
+    {  ADC_BUTTON_VALUE(ADC_BUTTONS_LEFT_R_PULLDOWN)   - 100,
964
+       ADC_BUTTON_VALUE(ADC_BUTTONS_LEFT_R_PULLDOWN)   + 100, 1 + BLEN_KEYPAD_LEFT   }, // LEFT  ( 272 ...  472)
965
+    {  ADC_BUTTON_VALUE(ADC_BUTTONS_RIGHT_R_PULLDOWN)  - 100,
966
+       ADC_BUTTON_VALUE(ADC_BUTTONS_RIGHT_R_PULLDOWN)  + 100, 1 + BLEN_KEYPAD_RIGHT  }, // RIGHT (1948 ... 2148)
967
+    {  ADC_BUTTON_VALUE(ADC_BUTTONS_UP_R_PULLDOWN)     - 100,
968
+       ADC_BUTTON_VALUE(ADC_BUTTONS_UP_R_PULLDOWN)     + 100, 1 + BLEN_KEYPAD_UP     }, // UP    ( 618 ...  818)
969
+    {  ADC_BUTTON_VALUE(ADC_BUTTONS_DOWN_R_PULLDOWN)   - 100,
970
+       ADC_BUTTON_VALUE(ADC_BUTTONS_DOWN_R_PULLDOWN)   + 100, 1 + BLEN_KEYPAD_DOWN   }, // DOWN  (2686 ... 2886)
971
+    {  ADC_BUTTON_VALUE(ADC_BUTTONS_MIDDLE_R_PULLDOWN) - 100,
972
+       ADC_BUTTON_VALUE(ADC_BUTTONS_MIDDLE_R_PULLDOWN) + 100, 1 + BLEN_KEYPAD_MIDDLE }, // ENTER (1205 ... 1405)
943 973
   };
944 974
 
945 975
   uint8_t get_ADC_keyValue(void) {
@@ -956,7 +986,8 @@ void MarlinUI::update() {
956 986
     }
957 987
     return 0;
958 988
   }
959
-#endif
989
+
990
+#endif // HAS_ADC_BUTTONS
960 991
 
961 992
 #if HAS_ENCODER_ACTION
962 993
 

+ 2
- 0
Marlin/src/pins/pins.h View File

@@ -387,6 +387,8 @@
387 387
   #include "pins_ARCHIM2.h"           // SAM3X8E                                    env:DUE env:DUE_debug
388 388
 #elif MB(ALLIGATOR)
389 389
   #include "pins_ALLIGATOR_R2.h"      // SAM3X8E                                    env:DUE env:DUE_debug
390
+#elif MB(ADSK)
391
+  #include "pins_ADSK.h"              // SAM3X8E                                    env:DUE env:DUE_debug
390 392
 
391 393
 //
392 394
 // STM32 ARM Cortex-M3

+ 207
- 0
Marlin/src/pins/pins_ADSK.h View File

@@ -0,0 +1,207 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Arduino DUE Shield Kit (ADSK) pin assignments
25
+ */
26
+
27
+#define BOARD_NAME "ADSK"
28
+
29
+#if !defined(__SAM3X8E__) && !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__)
30
+  #error "Oops! Select 'Arduino Due or Mega' in 'Tools > Board.'"
31
+#endif
32
+
33
+/* CNC shield modifications:
34
+FROM THE BOTTOM CUT THE 5V PIN THAT GOES TO ARDUINO!!!
35
+On the top put jumper between 5V and 3V3 pins,
36
+    jumper between D12 and A.STEP, jumper between D13 and A.DIR
37
+*/
38
+
39
+/* CNC shield 3D printer connections:
40
+X,Y,Z steppers as normal
41
+A stepper for E0 extruder
42
+(X-)&(GND) - X limit
43
+(Y-)&(GND) - Y limit
44
+(Z-)&(GND) - Z limit
45
+(Abort)&(GND) - Extruder thermistor (also require pullup resistor 4.7K between "Abort" and
46
+                                      Vcc (now "5V" on the board but actual 3.3V because of jumper))
47
+(Hold)&(GND) - Bed thermistor (also require pullup resistor 4.7K between "Hold" and
48
+                                 Vcc (now "5V" on the board but actual 3.3V because of jumper))
49
+(CoolEn) - 3.3v signal to controll extruder heater MOSFET
50
+(Resume) - 3.3v signal to control heatbed MOSFET
51
+(SDA) - 3.3v signal to controll extruder fan
52
+(SCL) - 3.3v signal to controll extruder cooling fan
53
+*/
54
+
55
+/* CNC Shield pinout
56
+"Name on the board": DUE pin
57
+"Abort":    Analog pin 0 or Digital pin 54
58
+"Hold":     Analog pin 1 or Digital pin 55
59
+"Resume":   Analog pin 2 or Digital pin 56
60
+"CoolEn":   Analog pin 3 or Digital pin 57
61
+"SDA":      Analog pin 4 or Digital pin 58
62
+"SCL":      Analog pin 5 or Digital pin 59
63
+"E-STOP":   Reset pin
64
+"RX":       Digital pin 0
65
+"TX":       Digital pin 1
66
+"X.STEP":   Digital pin 2
67
+"Y.STEP":   Digital pin 3
68
+"Z.STEP":   Digital pin 4
69
+"X.DIR":    Digital pin 5
70
+"Y.DIR":    Digital pin 6
71
+"Z.DIR":    Digital pin 7
72
+"EN":       Digital pin 8
73
+"X+","X-":  Digital pin 9
74
+"Y+","Y-":  Digital pin 10
75
+"Z+","Z-":  Digital pin 11
76
+"SpinEn":   Digital pin 12 -> will be connected to A.STEP with jumper
77
+"SpinDir":  Digital pin 13 -> will be connected to A.DIR with jumper
78
+*/
79
+
80
+//
81
+// Servos
82
+//
83
+#define SERVO0_PIN         61   // Analog pin 7, Digital pin 61
84
+
85
+//
86
+// Limit Switches
87
+//
88
+#define X_MIN_PIN           9
89
+#define Y_MIN_PIN          10
90
+#define Z_MIN_PIN          11
91
+
92
+#define Z_MIN_PROBE_PIN    62   // Analog pin 8, Digital pin 62
93
+
94
+//
95
+// Steppers
96
+//
97
+#define X_STEP_PIN          2
98
+#define X_DIR_PIN           5
99
+#define X_ENABLE_PIN        8
100
+    
101
+#define Y_STEP_PIN          3
102
+#define Y_DIR_PIN           6
103
+#define Y_ENABLE_PIN        8
104
+
105
+#define Z_STEP_PIN          4
106
+#define Z_DIR_PIN           7
107
+#define Z_ENABLE_PIN        8
108
+
109
+#define E0_STEP_PIN        12
110
+#define E0_DIR_PIN         13
111
+#define E0_ENABLE_PIN       8
112
+
113
+//
114
+// Heaters / Fans
115
+//
116
+#define HEATER_0_PIN       55   // "Hold":   Analog pin 1, Digital pin 55
117
+#define HEATER_BED_PIN     57   // "CoolEn": Analog pin 3, Digital pin 57
118
+#define FAN_PIN            54   // "Abort":  Analog pin 0, Digital pin 54
119
+#undef E0_AUTO_FAN_PIN
120
+#define E0_AUTO_FAN_PIN    56   // "Resume": Analog pin 2, Digital pin 56
121
+
122
+//
123
+// Temperature Sensors
124
+//
125
+#define TEMP_0_PIN          4   // "SDA":    Analog pin 4, Digital pin 58
126
+#define TEMP_BED_PIN        5   // "SCL":    Analog pin 5, Digital pin 59
127
+
128
+//
129
+// Misc. Functions
130
+//
131
+#define SDSS               52
132
+
133
+#if ENABLED(ZONESTAR_LCD)
134
+
135
+  /**
136
+   * The 2004 LCD should be powered with 5V.
137
+   * The next LCD pins RS,D4,D5,D6,D7 have internal pull-ups to 5V and as result the 5V will be on these pins.
138
+   * Luckily these internal pull-ups have really high resistance and adding 33K pull-down resistors will create
139
+   * simple voltage divider that will bring the voltage down just slightly bellow 3.3V.
140
+   * 
141
+   * This LCD also has buttons that connected to the same ADC pin with different voltage divider combinations.
142
+   * On the LCD panel there is internal pull-up resistor of the 4.7K connected to 5V.
143
+   * Connecting another 4.7K pull-down resistor between ADC pin and the GND
144
+   *   will result in scaled values for voltage dividers and will bring them down to be always below 3.3V.
145
+   * 
146
+   * For 2004 LCD to work with 3.3V board like Arduino DUE the next required:
147
+   * Pull-down resistors of 33K between each of LCD pins RS,D4,D5,D6,D7 and the GND.
148
+   * Pull-down resistor of 4.7K between ADC_KEYPAD_PIN and the GND
149
+   * 
150
+   * All these modifications will still work with 5V based boards but require proper scaled ADC values
151
+   */
152
+
153
+  #ifdef __SAM3X8E__
154
+    #define AREF_VOLTS 3.3
155
+  #else
156
+    #define AREF_VOLTS 5.0
157
+  #endif
158
+
159
+  //
160
+  // LCD / Controller
161
+  //
162
+  #define LCD_PINS_ENABLE  14
163
+  #define LCD_PINS_RS      15
164
+  #define LCD_PINS_D4      16
165
+  #define LCD_PINS_D5      17
166
+  #define LCD_PINS_D6      18
167
+  #define LCD_PINS_D7      19
168
+  #define ADC_KEYPAD_PIN    6   //60 // Analog pin 6, Digital pin 60
169
+
170
+  /** 
171
+   * The below defines will scale all the values to work properly on both
172
+   * 5V (Mega) and 3.3V (DUE) boards with all pull-up resistors added for 3.3V
173
+   */
174
+
175
+  #define ADC_BUTTONS_VALUE_SCALE         (5.0/AREF_VOLTS) // The LCD module pullup voltage is 5.0V but ADC reference voltage is 3.3V
176
+
177
+  #define ADC_BUTTONS_R_PULLDOWN          4.7  // Moves voltage down to be bellow 3.3V instead of 5V
178
+  // the resistors values will be scaled because of 4.7K pulldown parallel resistor 
179
+  #define _ADC_BUTTONS_R_SCALED(R)        ((R) * (ADC_BUTTONS_R_PULLDOWN) / ((R) + ADC_BUTTONS_R_PULLDOWN))
180
+
181
+  // buttons pullup resistor
182
+  #define ADC_BUTTONS_R_PULLUP            4.7 // the resistor on the 2004 LCD panel
183
+  // buttons resistors with scaled values because of parallel pulldown resistor
184
+  #define ADC_BUTTONS_LEFT_R_PULLDOWN     _ADC_BUTTONS_R_SCALED(0.47)
185
+  #define ADC_BUTTONS_RIGHT_R_PULLDOWN    _ADC_BUTTONS_R_SCALED(4.7)
186
+  #define ADC_BUTTONS_UP_R_PULLDOWN       _ADC_BUTTONS_R_SCALED(1.0)
187
+  #define ADC_BUTTONS_DOWN_R_PULLDOWN     _ADC_BUTTONS_R_SCALED(10.0)
188
+  #define ADC_BUTTONS_MIDDLE_R_PULLDOWN   _ADC_BUTTONS_R_SCALED(2.2)
189
+
190
+#endif // ZONESTAR_LCD
191
+
192
+/**
193
+ * RJ45 8 pins extruder connector
194
+ * 
195
+ * 1 - GND (Please do not connect to the same GND as extruder heater to prevent ground offset voltage)
196
+ * 2 - thermistor
197
+ * 3 - SERVO PWM
198
+ * 4 - extruder heater
199
+ * 5 - FAN (print cooling)
200
+ * 6 - FAN (extruder cooling)
201
+ * 7 - Probe signal
202
+ * 8 - 5V
203
+ * 
204
+ * Standard ethernet pairs: 1&2, 3&6, 4&5, 7&8
205
+ * Use CAT7 cable to have all pairs shielded
206
+ * 
207
+ */

Loading…
Cancel
Save