Browse Source

Merge remote-tracking branch 'tonokip/Marlin_v1' into Marlin_v1

Conflicts:
	Marlin/Configuration.h
Erik vd Zalm 11 years ago
parent
commit
f934d0ef5b
8 changed files with 265 additions and 1872 deletions
  1. 1
    0
      Marlin/Configuration.h
  2. 14
    0
      Marlin/Configuration_adv.h
  3. 5
    1834
      Marlin/Marlin.pde
  4. 0
    36
      Marlin/Marlin.pde.tmp.pde
  5. 53
    1
      Marlin/Marlin_main.cpp
  6. 82
    0
      Marlin/pins.h
  7. 101
    1
      Marlin/stepper.cpp
  8. 9
    0
      Marlin/stepper.h

+ 1
- 0
Marlin/Configuration.h View File

@@ -41,6 +41,7 @@
41 41
 // 70 = Megatronics
42 42
 // 90 = Alpha OMCA board
43 43
 // 91 = Final OMCA board
44
+// Rambo = 301
44 45
 
45 46
 #ifndef MOTHERBOARD
46 47
 #define MOTHERBOARD 7

+ 14
- 0
Marlin/Configuration_adv.h View File

@@ -173,6 +173,20 @@
173 173
 // if unwanted behavior is observed on a user's machine when running at very slow speeds.
174 174
 #define MINIMUM_PLANNER_SPEED 0.05// (mm/sec)
175 175
 
176
+// MS1 MS2 Stepper Driver Microstepping mode table
177
+#define MICROSTEP1 LOW,LOW
178
+#define MICROSTEP2 HIGH,LOW
179
+#define MICROSTEP4 LOW,HIGH
180
+#define MICROSTEP8 HIGH,HIGH
181
+#define MICROSTEP16 HIGH,HIGH
182
+
183
+// Microstep setting (Only functional when stepper driver microstep pins are connected to MCU.
184
+#define MICROSTEP_MODES {16,16,16,16,16} // [1,2,4,8,16]
185
+
186
+// Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards)
187
+#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
188
+
189
+
176 190
 //===========================================================================
177 191
 //=============================Additional Features===========================
178 192
 //===========================================================================

+ 5
- 1834
Marlin/Marlin.pde
File diff suppressed because it is too large
View File


+ 0
- 36
Marlin/Marlin.pde.tmp.pde View File

@@ -1,36 +0,0 @@
1
-/* -*- c++ -*- */
2
-
3
-/*
4
-    Reprap firmware based on Sprinter and grbl.
5
- Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
6
- 
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
- 
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
- GNU General Public License for more details.
16
- 
17
- You should have received a copy of the GNU General Public License
18
- along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
- */
20
-
21
-/*
22
- This firmware is a mashup between Sprinter and grbl.
23
-  (https://github.com/kliment/Sprinter)
24
-  (https://github.com/simen/grbl/tree)
25
- 
26
- It has preliminary support for Matthew Roberts advance algorithm 
27
-    http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
28
- */
29
-
30
-/* All the implementation is done in *.cpp files to get better compatibility with avr-gcc without the Arduino IDE */
31
-/* Use this file to help the Arduino IDE find which Arduino libraries are needed and to keep documentation on GCode */
32
-
33
-#include "Configuration.h"
34
-#ifdef ULTRA_LCD
35
-#include <LiquidCrystal.h>
36
-#endif

+ 53
- 1
Marlin/Marlin_main.cpp View File

@@ -26,7 +26,7 @@
26 26
  It has preliminary support for Matthew Roberts advance algorithm 
27 27
     http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
28 28
  */
29
-
29
+#include <SPI.h>
30 30
 #include "Marlin.h"
31 31
 
32 32
 #include "ultralcd.h"
@@ -121,6 +121,10 @@
121 121
 // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
122 122
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
123 123
 // M503 - print the current settings (from memory not from eeprom)
124
+// M907 - Set digital trimpot motor current using axis codes.
125
+// M908 - Control digital trimpot directly.
126
+// M350 - Set microstepping mode.
127
+// M351 - Toggle MS1 MS2 pins directly.
124 128
 // M999 - Restart after being stopped by error
125 129
 
126 130
 //Stepper Movement Variables
@@ -310,6 +314,8 @@ void setup()
310 314
       SERIAL_ECHOPGM(STRING_VERSION_CONFIG_H);
311 315
       SERIAL_ECHOPGM(MSG_AUTHOR);
312 316
       SERIAL_ECHOLNPGM(STRING_CONFIG_H_AUTHOR);
317
+      SERIAL_ECHOPGM("Compiled: ");
318
+      SERIAL_ECHOLNPGM(__DATE__);
313 319
     #endif
314 320
   #endif
315 321
   SERIAL_ECHO_START;
@@ -1475,6 +1481,52 @@ void process_commands()
1475 1481
         Config_PrintSettings();
1476 1482
     }
1477 1483
     break;
1484
+    case 907: // Set digital trimpot motor current using axis codes.
1485
+    {
1486
+      #if DIGIPOTSS_PIN > -1
1487
+        for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) digipot_current(i,code_value());
1488
+        if(code_seen('B')) digipot_current(4,code_value());
1489
+        if(code_seen('S')) for(int i=0;i<=4;i++) digipot_current(i,code_value());
1490
+      #endif
1491
+    }
1492
+    case 908: // Control digital trimpot directly.
1493
+    {
1494
+      #if DIGIPOTSS_PIN > -1
1495
+        uint8_t channel,current;
1496
+        if(code_seen('P')) channel=code_value();
1497
+        if(code_seen('S')) current=code_value();
1498
+        digitalPotWrite(channel, current);
1499
+      #endif
1500
+    }
1501
+    break;
1502
+    case 350: // Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
1503
+    {
1504
+      #if X_MS1_PIN > -1
1505
+        if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value()); 
1506
+        for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
1507
+        if(code_seen('B')) microstep_mode(4,code_value());
1508
+        microstep_readings();
1509
+      #endif
1510
+    }
1511
+    break;
1512
+    case 351: // Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
1513
+    {
1514
+      #if X_MS1_PIN > -1
1515
+      if(code_seen('S')) switch((int)code_value())
1516
+      {
1517
+        case 1:
1518
+          for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,code_value(),-1);
1519
+          if(code_seen('B')) microstep_ms(4,code_value(),-1);
1520
+          break;
1521
+        case 2:
1522
+          for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,-1,code_value());
1523
+          if(code_seen('B')) microstep_ms(4,-1,code_value());
1524
+          break;
1525
+      }
1526
+      microstep_readings();
1527
+      #endif
1528
+    }
1529
+    break;
1478 1530
     case 999: // Restart after being stopped
1479 1531
       Stopped = false;
1480 1532
       gcode_LastN = Stopped_gcode_LastN;

+ 82
- 0
Marlin/pins.h View File

@@ -1,6 +1,18 @@
1 1
 #ifndef PINS_H
2 2
 #define PINS_H
3 3
 
4
+#define X_MS1_PIN -1
5
+#define X_MS2_PIN -1
6
+#define Y_MS1_PIN -1
7
+#define Y_MS2_PIN -1
8
+#define Z_MS1_PIN -1
9
+#define Z_MS2_PIN -1
10
+#define E0_MS1_PIN -1
11
+#define E0_MS2_PIN -1
12
+#define E1_MS1_PIN -1
13
+#define E1_MS2_PIN -1
14
+#define DIGIPOTSS_PIN -1
15
+
4 16
 #if MOTHERBOARD == 99
5 17
 #define	KNOWN_BOARD 1
6 18
 
@@ -1215,6 +1227,76 @@
1215 1227
 
1216 1228
 #endif
1217 1229
 
1230
+#if MOTHERBOARD == 301
1231
+#define KNOWN_BOARD
1232
+/*****************************************************************
1233
+* Rambo Pin Assignments
1234
+******************************************************************/
1235
+
1236
+#ifndef __AVR_ATmega2560__
1237
+#error Oops!  Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu.
1238
+#endif
1239
+
1240
+#define X_STEP_PIN 37
1241
+#define X_DIR_PIN 48
1242
+#define X_MIN_PIN 12
1243
+#define X_MAX_PIN 24
1244
+#define X_ENABLE_PIN 29
1245
+#define X_MS1_PIN 40
1246
+#define X_MS2_PIN 41
1247
+
1248
+#define Y_STEP_PIN 36
1249
+#define Y_DIR_PIN 49
1250
+#define Y_MIN_PIN 11
1251
+#define Y_MAX_PIN 23
1252
+#define Y_ENABLE_PIN 28
1253
+#define Y_MS1_PIN 69
1254
+#define Y_MS2_PIN 39
1255
+
1256
+#define Z_STEP_PIN 35
1257
+#define Z_DIR_PIN 47
1258
+#define Z_MIN_PIN 10
1259
+#define Z_MAX_PIN 30
1260
+#define Z_ENABLE_PIN 27
1261
+#define Z_MS1_PIN 68
1262
+#define Z_MS2_PIN 67
1263
+
1264
+#define HEATER_BED_PIN 3
1265
+#define TEMP_BED_PIN 2 
1266
+
1267
+#define HEATER_0_PIN  9
1268
+#define TEMP_0_PIN 0
1269
+
1270
+#define HEATER_1_PIN 7
1271
+#define TEMP_1_PIN 1
1272
+
1273
+#define HEATER_2_PIN -1
1274
+#define TEMP_2_PIN -1
1275
+
1276
+#define E0_STEP_PIN         34
1277
+#define E0_DIR_PIN          43
1278
+#define E0_ENABLE_PIN       26
1279
+#define E0_MS1_PIN 65
1280
+#define E0_MS2_PIN 66
1281
+
1282
+#define E1_STEP_PIN         33
1283
+#define E1_DIR_PIN          42
1284
+#define E1_ENABLE_PIN       25
1285
+#define E1_MS1_PIN 63
1286
+#define E1_MS2_PIN 64
1287
+
1288
+#define DIGIPOTSS_PIN 38
1289
+#define DIGIPOT_CHANNELS {4,5,3,0,1} // X Y Z E0 E1 digipot channels to stepper driver mapping
1290
+
1291
+#define SDPOWER            -1
1292
+#define SDSS               53
1293
+#define LED_PIN            13
1294
+#define FAN_PIN            8
1295
+#define PS_ON_PIN          4
1296
+#define KILL_PIN           -1
1297
+#define SUICIDE_PIN        -1  //PIN that has to be turned on right after start, to keep power flowing.
1298
+
1299
+#endif
1218 1300
 
1219 1301
 /****************************************************************************************
1220 1302
 * MegaTronics

+ 101
- 1
Marlin/stepper.cpp View File

@@ -28,7 +28,7 @@
28 28
 #include "ultralcd.h"
29 29
 #include "language.h"
30 30
 #include "speed_lookuptable.h"
31
-
31
+#include <SPI.h>
32 32
 
33 33
 
34 34
 //===========================================================================
@@ -714,6 +714,9 @@ ISR(TIMER1_COMPA_vect)
714 714
 
715 715
 void st_init()
716 716
 {
717
+  digipot_init(); //Initialize Digipot Motor Current
718
+  microstep_init(); //Initialize Microstepping Pins
719
+  
717 720
   //Initialize Dir Pins
718 721
   #if X_DIR_PIN > -1
719 722
     SET_OUTPUT(X_DIR_PIN);
@@ -951,3 +954,100 @@ void quickStop()
951 954
   ENABLE_STEPPER_DRIVER_INTERRUPT();
952 955
 }
953 956
 
957
+int digitalPotWrite(int address, int value) // From Arduino DigitalPotControl example
958
+{
959
+  #if DIGIPOTSS_PIN > -1
960
+    digitalWrite(DIGIPOTSS_PIN,LOW); // take the SS pin low to select the chip
961
+    SPI.transfer(address); //  send in the address and value via SPI:
962
+    SPI.transfer(value);
963
+    digitalWrite(DIGIPOTSS_PIN,HIGH); // take the SS pin high to de-select the chip:
964
+    //delay(10);
965
+  #endif
966
+}
967
+
968
+void digipot_init() //Initialize Digipot Motor Current
969
+{
970
+  #if DIGIPOTSS_PIN > -1
971
+    const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
972
+    
973
+    SPI.begin(); 
974
+    pinMode(DIGIPOTSS_PIN, OUTPUT);    
975
+    for(int i=0;i<=4;i++) 
976
+      //digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
977
+      digipot_current(i,digipot_motor_current[i]);
978
+  #endif
979
+}
980
+
981
+void digipot_current(uint8_t driver, int current)
982
+{
983
+  #if DIGIPOTSS_PIN > -1
984
+    const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
985
+    digitalPotWrite(digipot_ch[driver], current);
986
+  #endif
987
+}
988
+
989
+void microstep_init()
990
+{
991
+  #if X_MS1_PIN > -1
992
+  const uint8_t microstep_modes[] = MICROSTEP_MODES;
993
+  pinMode(X_MS2_PIN,OUTPUT);
994
+  pinMode(Y_MS2_PIN,OUTPUT);
995
+  pinMode(Z_MS2_PIN,OUTPUT);
996
+  pinMode(E0_MS2_PIN,OUTPUT);
997
+  pinMode(E1_MS2_PIN,OUTPUT);
998
+  for(int i=0;i<=4;i++) microstep_mode(i,microstep_modes[i]);
999
+  #endif
1000
+}
1001
+
1002
+void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2)
1003
+{
1004
+  if(ms1 > -1) switch(driver)
1005
+  {
1006
+    case 0: digitalWrite( X_MS1_PIN,ms1); break;
1007
+    case 1: digitalWrite( Y_MS1_PIN,ms1); break;
1008
+    case 2: digitalWrite( Z_MS1_PIN,ms1); break;
1009
+    case 3: digitalWrite(E0_MS1_PIN,ms1); break;
1010
+    case 4: digitalWrite(E1_MS1_PIN,ms1); break;
1011
+  }
1012
+  if(ms2 > -1) switch(driver)
1013
+  {
1014
+    case 0: digitalWrite( X_MS2_PIN,ms2); break;
1015
+    case 1: digitalWrite( Y_MS2_PIN,ms2); break;
1016
+    case 2: digitalWrite( Z_MS2_PIN,ms2); break;
1017
+    case 3: digitalWrite(E0_MS2_PIN,ms2); break;
1018
+    case 4: digitalWrite(E1_MS2_PIN,ms2); break;
1019
+  }
1020
+}
1021
+
1022
+void microstep_mode(uint8_t driver, uint8_t stepping_mode)
1023
+{
1024
+  switch(stepping_mode)
1025
+  {
1026
+    case 1: microstep_ms(driver,MICROSTEP1); break;
1027
+    case 2: microstep_ms(driver,MICROSTEP2); break;
1028
+    case 4: microstep_ms(driver,MICROSTEP4); break;
1029
+    case 8: microstep_ms(driver,MICROSTEP8); break;
1030
+    case 16: microstep_ms(driver,MICROSTEP16); break;
1031
+  }
1032
+}
1033
+
1034
+void microstep_readings()
1035
+{
1036
+      SERIAL_PROTOCOLPGM("MS1,MS2 Pins\n");
1037
+      SERIAL_PROTOCOLPGM("X: ");
1038
+      SERIAL_PROTOCOL(   digitalRead(X_MS1_PIN));
1039
+      SERIAL_PROTOCOLLN( digitalRead(X_MS2_PIN));
1040
+      SERIAL_PROTOCOLPGM("Y: ");
1041
+      SERIAL_PROTOCOL(   digitalRead(Y_MS1_PIN));
1042
+      SERIAL_PROTOCOLLN( digitalRead(Y_MS2_PIN));
1043
+      SERIAL_PROTOCOLPGM("Z: ");
1044
+      SERIAL_PROTOCOL(   digitalRead(Z_MS1_PIN));
1045
+      SERIAL_PROTOCOLLN( digitalRead(Z_MS2_PIN));
1046
+      SERIAL_PROTOCOLPGM("E0: ");
1047
+      SERIAL_PROTOCOL(   digitalRead(E0_MS1_PIN));
1048
+      SERIAL_PROTOCOLLN( digitalRead(E0_MS2_PIN));
1049
+      SERIAL_PROTOCOLPGM("E1: ");
1050
+      SERIAL_PROTOCOL(   digitalRead(E1_MS1_PIN));
1051
+      SERIAL_PROTOCOLLN( digitalRead(E1_MS2_PIN));
1052
+}
1053
+

+ 9
- 0
Marlin/stepper.h View File

@@ -68,4 +68,13 @@ void finishAndDisableSteppers();
68 68
 extern block_t *current_block;  // A pointer to the block currently being traced
69 69
 
70 70
 void quickStop();
71
+
72
+int digitalPotWrite(int address, int value);
73
+void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
74
+void microstep_mode(uint8_t driver, uint8_t stepping);
75
+void digipot_init();
76
+void digipot_current(uint8_t driver, int current);
77
+void microstep_init();
78
+void microstep_readings();
79
+
71 80
 #endif

Loading…
Cancel
Save