Kaynağa Gözat

Fix for stepper microstepping

Cameron Lai 10 yıl önce
ebeveyn
işleme
eea3ba5588
1 değiştirilmiş dosya ile 39 ekleme ve 16 silme
  1. 39
    16
      Marlin/stepper.cpp

+ 39
- 16
Marlin/stepper.cpp Dosyayı Görüntüle

@@ -1228,34 +1228,55 @@ void digipot_current(uint8_t driver, int current)
1228 1228
 
1229 1229
 void microstep_init()
1230 1230
 {
1231
+  #if defined(Y_MS1_PIN) && Y_MS1_PIN > -1
1232
+  SET_OUTPUT(Y_MS1_PIN);
1233
+  SET_OUTPUT(Y_MS2_PIN);
1234
+  #endif
1235
+  #if defined(Z_MS1_PIN) && Z_MS1_PIN > -1
1236
+  SET_OUTPUT(Z_MS1_PIN);
1237
+  SET_OUTPUT(Z_MS2_PIN);
1238
+  #endif
1239
+
1240
+  #if defined(E0_MS1_PIN) && E0_MS1_PIN > -1
1241
+  SET_OUTPUT(E0_MS1_PIN);
1242
+  SET_OUTPUT(E0_MS2_PIN);
1243
+  #endif
1244
+  
1245
+  #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
1246
+  SET_OUTPUT(E1_MS1_PIN);
1247
+  SET_OUTPUT(E1_MS2_PIN);
1248
+  #endif
1249
+  
1231 1250
   #if defined(X_MS1_PIN) && X_MS1_PIN > -1
1251
+  SET_OUTPUT(X_MS1_PIN);
1252
+  SET_OUTPUT(X_MS2_PIN);
1253
+  
1232 1254
   const uint8_t microstep_modes[] = MICROSTEP_MODES;
1233
-  pinMode(X_MS2_PIN,OUTPUT);
1234
-  pinMode(Y_MS2_PIN,OUTPUT);
1235
-  pinMode(Z_MS2_PIN,OUTPUT);
1236
-  pinMode(E0_MS2_PIN,OUTPUT);
1237
-  pinMode(E1_MS2_PIN,OUTPUT);
1238 1255
   for(int i=0;i<=4;i++) microstep_mode(i,microstep_modes[i]);
1239
-  #endif
1256
+  #endif  
1240 1257
 }
1241 1258
 
1242 1259
 void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2)
1243 1260
 {
1244 1261
   if(ms1 > -1) switch(driver)
1245 1262
   {
1246
-    case 0: digitalWrite( X_MS1_PIN,ms1); break;
1247
-    case 1: digitalWrite( Y_MS1_PIN,ms1); break;
1248
-    case 2: digitalWrite( Z_MS1_PIN,ms1); break;
1249
-    case 3: digitalWrite(E0_MS1_PIN,ms1); break;
1250
-    case 4: digitalWrite(E1_MS1_PIN,ms1); break;
1263
+    case 0: WRITE( X_MS1_PIN,ms1); break;
1264
+    case 1: WRITE( Y_MS1_PIN,ms1); break;
1265
+    case 2: WRITE( Z_MS1_PIN,ms1); break;
1266
+    case 3: WRITE(E0_MS1_PIN,ms1); break;
1267
+    #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
1268
+    case 4: WRITE(E1_MS1_PIN,ms1); break;
1269
+    #endif
1251 1270
   }
1252 1271
   if(ms2 > -1) switch(driver)
1253 1272
   {
1254
-    case 0: digitalWrite( X_MS2_PIN,ms2); break;
1255
-    case 1: digitalWrite( Y_MS2_PIN,ms2); break;
1256
-    case 2: digitalWrite( Z_MS2_PIN,ms2); break;
1257
-    case 3: digitalWrite(E0_MS2_PIN,ms2); break;
1258
-    case 4: digitalWrite(E1_MS2_PIN,ms2); break;
1273
+    case 0: WRITE( X_MS2_PIN,ms2); break;
1274
+    case 1: WRITE( Y_MS2_PIN,ms2); break;
1275
+    case 2: WRITE( Z_MS2_PIN,ms2); break;
1276
+    case 3: WRITE(E0_MS2_PIN,ms2); break;
1277
+    #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
1278
+    case 4: WRITE(E1_MS2_PIN,ms2); break;
1279
+    #endif
1259 1280
   }
1260 1281
 }
1261 1282
 
@@ -1286,8 +1307,10 @@ void microstep_readings()
1286 1307
       SERIAL_PROTOCOLPGM("E0: ");
1287 1308
       SERIAL_PROTOCOL(   digitalRead(E0_MS1_PIN));
1288 1309
       SERIAL_PROTOCOLLN( digitalRead(E0_MS2_PIN));
1310
+      #if defined(E1_MS1_PIN) && E1_MS1_PIN > -1
1289 1311
       SERIAL_PROTOCOLPGM("E1: ");
1290 1312
       SERIAL_PROTOCOL(   digitalRead(E1_MS1_PIN));
1291 1313
       SERIAL_PROTOCOLLN( digitalRead(E1_MS2_PIN));
1314
+      #endif
1292 1315
 }
1293 1316
 

Loading…
İptal
Kaydet