Kaynağa Gözat

Added support for the Rambo reprap electronics board. Added Mcodes to set

motor current and microstepping pins.
tonokip 11 yıl önce
ebeveyn
işleme
1c1fddc7ac
6 değiştirilmiş dosya ile 261 ekleme ve 3 silme
  1. 2
    1
      Marlin/Configuration.h
  2. 14
    0
      Marlin/Configuration_adv.h
  3. 53
    1
      Marlin/Marlin.pde
  4. 82
    0
      Marlin/pins.h
  5. 101
    1
      Marlin/stepper.cpp
  6. 9
    0
      Marlin/stepper.h

+ 2
- 1
Marlin/Configuration.h Dosyayı Görüntüle

@@ -30,9 +30,10 @@
30 30
 // Ultimaker = 7
31 31
 // Teensylu = 8
32 32
 // Gen3+ =9
33
+// Rambo = 301
33 34
 
34 35
 #ifndef MOTHERBOARD
35
-#define MOTHERBOARD 7
36
+#define MOTHERBOARD 301
36 37
 #endif
37 38
 
38 39
 

+ 14
- 0
Marlin/Configuration_adv.h Dosyayı Görüntüle

@@ -128,6 +128,20 @@
128 128
 // if unwanted behavior is observed on a user's machine when running at very slow speeds.
129 129
 #define MINIMUM_PLANNER_SPEED 0.05// (mm/sec)
130 130
 
131
+// MS1 MS2 Stepper Driver Microstepping mode table
132
+#define MICROSTEP1 LOW,LOW
133
+#define MICROSTEP2 HIGH,LOW
134
+#define MICROSTEP4 LOW,HIGH
135
+#define MICROSTEP8 HIGH,HIGH
136
+#define MICROSTEP16 HIGH,HIGH
137
+
138
+// Microstep setting (Only functional when stepper driver microstep pins are connected to MCU.
139
+#define MICROSTEP_MODES {16,16,16,16,16} // [1,2,4,8,16]
140
+
141
+// Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards)
142
+#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
143
+
144
+
131 145
 //===========================================================================
132 146
 //=============================Additional Features===========================
133 147
 //===========================================================================

+ 53
- 1
Marlin/Marlin.pde Dosyayı Görüntüle

@@ -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"
@@ -120,6 +120,10 @@
120 120
 // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
121 121
 // M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
122 122
 // M503 - print the current settings (from memory not from eeprom)
123
+// M907 - Set digital trimpot motor current using axis codes.
124
+// M908 - Control digital trimpot directly.
125
+// M350 - Set microstepping mode.
126
+// M351 - Toggle MS1 MS2 pins directly.
123 127
 // M999 - Restart after being stopped by error
124 128
 
125 129
 //Stepper Movement Variables
@@ -309,6 +313,8 @@ void setup()
309 313
       SERIAL_ECHOPGM(STRING_VERSION_CONFIG_H);
310 314
       SERIAL_ECHOPGM(MSG_AUTHOR);
311 315
       SERIAL_ECHOLNPGM(STRING_CONFIG_H_AUTHOR);
316
+      SERIAL_ECHOPGM("Compiled: ");
317
+      SERIAL_ECHOLNPGM(__DATE__);
312 318
     #endif
313 319
   #endif
314 320
   SERIAL_ECHO_START;
@@ -1466,6 +1472,52 @@ void process_commands()
1466 1472
       EEPROM_printSettings();
1467 1473
     }
1468 1474
     break;
1475
+    case 907: // Set digital trimpot motor current using axis codes.
1476
+    {
1477
+      #if DIGIPOTSS_PIN > -1
1478
+        for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) digipot_current(i,code_value());
1479
+        if(code_seen('B')) digipot_current(4,code_value());
1480
+        if(code_seen('S')) for(int i=0;i<=4;i++) digipot_current(i,code_value());
1481
+      #endif
1482
+    }
1483
+    case 908: // Control digital trimpot directly.
1484
+    {
1485
+      #if DIGIPOTSS_PIN > -1
1486
+        uint8_t channel,current;
1487
+        if(code_seen('P')) channel=code_value();
1488
+        if(code_seen('S')) current=code_value();
1489
+        digitalPotWrite(channel, current);
1490
+      #endif
1491
+    }
1492
+    break;
1493
+    case 350: // Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
1494
+    {
1495
+      #if X_MS1_PIN > -1
1496
+        if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value()); 
1497
+        for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
1498
+        if(code_seen('B')) microstep_mode(4,code_value());
1499
+        microstep_readings();
1500
+      #endif
1501
+    }
1502
+    break;
1503
+    case 351: // Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
1504
+    {
1505
+      #if X_MS1_PIN > -1
1506
+      if(code_seen('S')) switch((int)code_value())
1507
+      {
1508
+        case 1:
1509
+          for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,code_value(),-1);
1510
+          if(code_seen('B')) microstep_ms(4,code_value(),-1);
1511
+          break;
1512
+        case 2:
1513
+          for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,-1,code_value());
1514
+          if(code_seen('B')) microstep_ms(4,-1,code_value());
1515
+          break;
1516
+      }
1517
+      microstep_readings();
1518
+      #endif
1519
+    }
1520
+    break;
1469 1521
     case 999: // Restart after being stopped
1470 1522
       Stopped = false;
1471 1523
       gcode_LastN = Stopped_gcode_LastN;

+ 82
- 0
Marlin/pins.h Dosyayı Görüntüle

@@ -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
 
@@ -1128,6 +1140,76 @@
1128 1140
 
1129 1141
 #endif
1130 1142
 
1143
+#if MOTHERBOARD == 301
1144
+#define KNOWN_BOARD
1145
+/*****************************************************************
1146
+* Rambo Pin Assignments
1147
+******************************************************************/
1148
+
1149
+#ifndef __AVR_ATmega2560__
1150
+#error Oops!  Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu.
1151
+#endif
1152
+
1153
+#define X_STEP_PIN 37
1154
+#define X_DIR_PIN 48
1155
+#define X_MIN_PIN 12
1156
+#define X_MAX_PIN 19
1157
+#define X_ENABLE_PIN 29
1158
+#define X_MS1_PIN 40
1159
+#define X_MS2_PIN 41
1160
+
1161
+#define Y_STEP_PIN 36
1162
+#define Y_DIR_PIN 49
1163
+#define Y_MIN_PIN 11
1164
+#define Y_MAX_PIN 18
1165
+#define Y_ENABLE_PIN 28
1166
+#define Y_MS1_PIN 69
1167
+#define Y_MS2_PIN 39
1168
+
1169
+#define Z_STEP_PIN 35
1170
+#define Z_DIR_PIN 47
1171
+#define Z_MIN_PIN 10
1172
+#define Z_MAX_PIN 15
1173
+#define Z_ENABLE_PIN 27
1174
+#define Z_MS1_PIN 68
1175
+#define Z_MS2_PIN 67
1176
+
1177
+#define HEATER_BED_PIN 3
1178
+#define TEMP_BED_PIN 2 
1179
+
1180
+#define HEATER_0_PIN  9
1181
+#define TEMP_0_PIN 0
1182
+
1183
+#define HEATER_1_PIN 7
1184
+#define TEMP_1_PIN 1
1185
+
1186
+#define HEATER_2_PIN -1
1187
+#define TEMP_2_PIN -1
1188
+
1189
+#define E0_STEP_PIN         34
1190
+#define E0_DIR_PIN          43
1191
+#define E0_ENABLE_PIN       26
1192
+#define E0_MS1_PIN 65
1193
+#define E0_MS2_PIN 66
1194
+
1195
+#define E1_STEP_PIN         33
1196
+#define E1_DIR_PIN          42
1197
+#define E1_ENABLE_PIN       25
1198
+#define E1_MS1_PIN 63
1199
+#define E1_MS2_PIN 64
1200
+
1201
+#define DIGIPOTSS_PIN 38
1202
+#define DIGIPOT_CHANNELS {4,5,3,0,1} // X Y Z E0 E1 digipot channels to stepper driver mapping
1203
+
1204
+#define SDPOWER            -1
1205
+#define SDSS               53
1206
+#define LED_PIN            13
1207
+#define FAN_PIN            8
1208
+#define PS_ON_PIN          4
1209
+#define KILL_PIN           -1
1210
+#define SUICIDE_PIN        -1  //PIN that has to be turned on right after start, to keep power flowing.
1211
+
1212
+#endif
1131 1213
 
1132 1214
 #ifndef KNOWN_BOARD
1133 1215
 #error Unknown MOTHERBOARD value in configuration.h

+ 101
- 1
Marlin/stepper.cpp Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

@@ -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…
İptal
Kaydet