|
@@ -345,12 +345,31 @@ ISR(TIMER1_COMPA_vect)
|
345
|
345
|
// Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt
|
346
|
346
|
out_bits = current_block->direction_bits;
|
347
|
347
|
|
|
348
|
+
|
|
349
|
+ // Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY)
|
|
350
|
+ if((out_bits & (1<<X_AXIS))!=0){
|
|
351
|
+ WRITE(X_DIR_PIN, INVERT_X_DIR);
|
|
352
|
+ count_direction[X_AXIS]=-1;
|
|
353
|
+ }
|
|
354
|
+ else{
|
|
355
|
+ WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
|
356
|
+ count_direction[X_AXIS]=1;
|
|
357
|
+ }
|
|
358
|
+ if((out_bits & (1<<Y_AXIS))!=0){
|
|
359
|
+ WRITE(Y_DIR_PIN, INVERT_Y_DIR);
|
|
360
|
+ count_direction[Y_AXIS]=-1;
|
|
361
|
+ }
|
|
362
|
+ else{
|
|
363
|
+ WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
|
|
364
|
+ count_direction[Y_AXIS]=1;
|
|
365
|
+ }
|
|
366
|
+
|
348
|
367
|
// Set direction en check limit switches
|
|
368
|
+ #ifndef COREXY
|
349
|
369
|
if ((out_bits & (1<<X_AXIS)) != 0) { // stepping along -X axis
|
350
|
|
- #if !defined COREXY //NOT COREXY
|
351
|
|
- WRITE(X_DIR_PIN, INVERT_X_DIR);
|
352
|
|
- #endif
|
353
|
|
- count_direction[X_AXIS]=-1;
|
|
370
|
+ #else
|
|
371
|
+ if ((((out_bits & (1<<X_AXIS)) != 0)&&(out_bits & (1<<Y_AXIS)) != 0)) { //-X occurs for -A and -B
|
|
372
|
+ #endif
|
354
|
373
|
CHECK_ENDSTOPS
|
355
|
374
|
{
|
356
|
375
|
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
|
|
@@ -365,11 +384,6 @@ ISR(TIMER1_COMPA_vect)
|
365
|
384
|
}
|
366
|
385
|
}
|
367
|
386
|
else { // +direction
|
368
|
|
- #if !defined COREXY //NOT COREXY
|
369
|
|
- WRITE(X_DIR_PIN,!INVERT_X_DIR);
|
370
|
|
- #endif
|
371
|
|
-
|
372
|
|
- count_direction[X_AXIS]=1;
|
373
|
387
|
CHECK_ENDSTOPS
|
374
|
388
|
{
|
375
|
389
|
#if defined(X_MAX_PIN) && X_MAX_PIN > -1
|
|
@@ -384,11 +398,11 @@ ISR(TIMER1_COMPA_vect)
|
384
|
398
|
}
|
385
|
399
|
}
|
386
|
400
|
|
|
401
|
+ #ifndef COREXY
|
387
|
402
|
if ((out_bits & (1<<Y_AXIS)) != 0) { // -direction
|
388
|
|
- #if !defined COREXY //NOT COREXY
|
389
|
|
- WRITE(Y_DIR_PIN,INVERT_Y_DIR);
|
390
|
|
- #endif
|
391
|
|
- count_direction[Y_AXIS]=-1;
|
|
403
|
+ #else
|
|
404
|
+ if ((((out_bits & (1<<X_AXIS)) != 0)&&(out_bits & (1<<Y_AXIS)) == 0)) { // -Y occurs for -A and +B
|
|
405
|
+ #endif
|
392
|
406
|
CHECK_ENDSTOPS
|
393
|
407
|
{
|
394
|
408
|
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
|
|
@@ -403,10 +417,6 @@ ISR(TIMER1_COMPA_vect)
|
403
|
417
|
}
|
404
|
418
|
}
|
405
|
419
|
else { // +direction
|
406
|
|
- #if !defined COREXY //NOT COREXY
|
407
|
|
- WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
|
408
|
|
- #endif
|
409
|
|
- count_direction[Y_AXIS]=1;
|
410
|
420
|
CHECK_ENDSTOPS
|
411
|
421
|
{
|
412
|
422
|
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
|
|
@@ -420,28 +430,7 @@ ISR(TIMER1_COMPA_vect)
|
420
|
430
|
#endif
|
421
|
431
|
}
|
422
|
432
|
}
|
423
|
|
-
|
424
|
|
-
|
425
|
|
- #ifdef COREXY //coreXY kinematics defined
|
426
|
|
- if((current_block->steps_x >= current_block->steps_y)&&((out_bits & (1<<X_AXIS)) == 0)){ //+X is major axis
|
427
|
|
- WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
428
|
|
- WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
|
429
|
|
- }
|
430
|
|
- if((current_block->steps_x >= current_block->steps_y)&&((out_bits & (1<<X_AXIS)) != 0)){ //-X is major axis
|
431
|
|
- WRITE(X_DIR_PIN, INVERT_X_DIR);
|
432
|
|
- WRITE(Y_DIR_PIN, INVERT_Y_DIR);
|
433
|
|
- }
|
434
|
|
- if((current_block->steps_y > current_block->steps_x)&&((out_bits & (1<<Y_AXIS)) == 0)){ //+Y is major axis
|
435
|
|
- WRITE(X_DIR_PIN, !INVERT_X_DIR);
|
436
|
|
- WRITE(Y_DIR_PIN, INVERT_Y_DIR);
|
437
|
|
- }
|
438
|
|
- if((current_block->steps_y > current_block->steps_x)&&((out_bits & (1<<Y_AXIS)) != 0)){ //-Y is major axis
|
439
|
|
- WRITE(X_DIR_PIN, INVERT_X_DIR);
|
440
|
|
- WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
|
441
|
|
- }
|
442
|
|
- #endif //coreXY
|
443
|
|
-
|
444
|
|
-
|
|
433
|
+
|
445
|
434
|
if ((out_bits & (1<<Z_AXIS)) != 0) { // -direction
|
446
|
435
|
WRITE(Z_DIR_PIN,INVERT_Z_DIR);
|
447
|
436
|
|
|
@@ -516,7 +505,6 @@ ISR(TIMER1_COMPA_vect)
|
516
|
505
|
}
|
517
|
506
|
#endif //ADVANCE
|
518
|
507
|
|
519
|
|
- #if !defined COREXY
|
520
|
508
|
counter_x += current_block->steps_x;
|
521
|
509
|
if (counter_x > 0) {
|
522
|
510
|
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
|
@@ -532,56 +520,7 @@ ISR(TIMER1_COMPA_vect)
|
532
|
520
|
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
533
|
521
|
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
534
|
522
|
}
|
535
|
|
- #endif
|
536
|
523
|
|
537
|
|
- #ifdef COREXY
|
538
|
|
- counter_x += current_block->steps_x;
|
539
|
|
- counter_y += current_block->steps_y;
|
540
|
|
-
|
541
|
|
- if ((counter_x > 0)&&!(counter_y>0)){ //X step only
|
542
|
|
- WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
543
|
|
- WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
544
|
|
- counter_x -= current_block->step_event_count;
|
545
|
|
- count_position[X_AXIS]+=count_direction[X_AXIS];
|
546
|
|
- WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
547
|
|
- WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
548
|
|
- }
|
549
|
|
-
|
550
|
|
- if (!(counter_x > 0)&&(counter_y>0)){ //Y step only
|
551
|
|
- WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
552
|
|
- WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
553
|
|
- counter_y -= current_block->step_event_count;
|
554
|
|
- count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
555
|
|
- WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
556
|
|
- WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
557
|
|
- }
|
558
|
|
-
|
559
|
|
- if ((counter_x > 0)&&(counter_y>0)){ //step in both axes
|
560
|
|
- if (((out_bits & (1<<X_AXIS)) == 0)^((out_bits & (1<<Y_AXIS)) == 0)){ //X and Y in different directions
|
561
|
|
- WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
562
|
|
- counter_x -= current_block->step_event_count;
|
563
|
|
- WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
564
|
|
- step_wait();
|
565
|
|
- count_position[X_AXIS]+=count_direction[X_AXIS];
|
566
|
|
- count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
567
|
|
- WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
568
|
|
- counter_y -= current_block->step_event_count;
|
569
|
|
- WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
570
|
|
- }
|
571
|
|
- else{ //X and Y in same direction
|
572
|
|
- WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
573
|
|
- counter_x -= current_block->step_event_count;
|
574
|
|
- WRITE(X_STEP_PIN, INVERT_X_STEP_PIN) ;
|
575
|
|
- step_wait();
|
576
|
|
- count_position[X_AXIS]+=count_direction[X_AXIS];
|
577
|
|
- count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
578
|
|
- WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
579
|
|
- counter_y -= current_block->step_event_count;
|
580
|
|
- WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
581
|
|
- }
|
582
|
|
- }
|
583
|
|
- #endif //corexy
|
584
|
|
-
|
585
|
524
|
counter_z += current_block->steps_z;
|
586
|
525
|
if (counter_z > 0) {
|
587
|
526
|
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
|