Browse Source

fixed pwm generation at pin D12 and D13 when one of them is used as FAN_PIN on Sanguino, added soft pwm entry for FAN_PIN in temperature.cpp

oni303 11 years ago
parent
commit
ab09fa4bbf
3 changed files with 22 additions and 0 deletions
  1. 3
    0
      Marlin/pins.h
  2. 4
    0
      Marlin/planner.cpp
  3. 15
    0
      Marlin/temperature.cpp

+ 3
- 0
Marlin/pins.h View File

@@ -709,6 +709,9 @@
709 709
 #define LED_PIN            -1
710 710
 
711 711
 #define FAN_PIN            -1 
712
+#if FAN_PIN == 12 || FAN_PIN ==13
713
+#define FAN_SOFT_PWM
714
+#endif
712 715
 
713 716
 #ifdef MELZI
714 717
 #define LED_PIN            28

+ 4
- 0
Marlin/planner.cpp View File

@@ -460,10 +460,12 @@ void check_axes_activity()
460 460
   else
461 461
   {
462 462
     #if FAN_PIN > -1
463
+    #ifndef FAN_SOFT_PWM
463 464
     if (fanSpeed != 0){
464 465
       analogWrite(FAN_PIN,fanSpeed); // If buffer is empty use current fan speed
465 466
     }
466 467
     #endif
468
+	#endif
467 469
   }
468 470
   if((DISABLE_X) && (x_active == 0)) disable_x();
469 471
   if((DISABLE_Y) && (y_active == 0)) disable_y();
@@ -475,6 +477,7 @@ void check_axes_activity()
475 477
     disable_e2(); 
476 478
   }
477 479
 #if FAN_PIN > -1
480
+  #ifndef FAN_SOFT_PWM
478 481
   if((fanSpeed == 0) && (fan_speed ==0))
479 482
   {
480 483
     analogWrite(FAN_PIN, 0);
@@ -484,6 +487,7 @@ void check_axes_activity()
484 487
   {
485 488
     analogWrite(FAN_PIN,tail_fan_speed);
486 489
   }
490
+  #endif
487 491
 #endif
488 492
 #ifdef AUTOTEMP
489 493
   getHighESpeed();

+ 15
- 0
Marlin/temperature.cpp View File

@@ -96,6 +96,11 @@ static volatile bool temp_meas_ready = false;
96 96
 #endif //PIDTEMPBED
97 97
   static unsigned char soft_pwm[EXTRUDERS];
98 98
   static unsigned char soft_pwm_bed;
99
+#ifdef FAN_SOFT_PWM
100
+  static unsigned char soft_pwm_fan;
101
+#endif
102
+
103
+
99 104
   
100 105
 #if EXTRUDERS > 3
101 106
 # error Unsupported number of extruders
@@ -597,6 +602,9 @@ void tp_init()
597 602
     #ifdef FAST_PWM_FAN
598 603
     setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
599 604
     #endif
605
+    #ifdef FAN_SOFT_PWM
606
+	soft_pwm_fan=(unsigned char)fanSpeed;
607
+	#endif
600 608
   #endif  
601 609
 
602 610
   #ifdef HEATER_0_USES_MAX6675
@@ -929,6 +937,10 @@ ISR(TIMER0_COMPB_vect)
929 937
     soft_pwm_b = soft_pwm_bed;
930 938
     if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1);
931 939
     #endif
940
+    #ifdef FAN_SOFT_PWM
941
+    soft_pwm_fan =(unsigned char) fanSpeed;
942
+    if(soft_pwm_fan > 0) WRITE(FAN_PIN,1);
943
+    #endif
932 944
   }
933 945
   if(soft_pwm_0 <= pwm_count) WRITE(HEATER_0_PIN,0);
934 946
   #if EXTRUDERS > 1
@@ -940,6 +952,9 @@ ISR(TIMER0_COMPB_vect)
940 952
   #if HEATER_BED_PIN > -1
941 953
   if(soft_pwm_b <= pwm_count) WRITE(HEATER_BED_PIN,0);
942 954
   #endif
955
+  #ifdef FAN_SOFT_PWM
956
+  if(soft_pwm_fan <= pwm_count) WRITE(FAN_PIN,0);
957
+  #endif
943 958
   
944 959
   pwm_count++;
945 960
   pwm_count &= 0x7f;

Loading…
Cancel
Save