Skip to content

Commit

Permalink
Merge pull request #3757 from thinkyhead/rc_fix_auto_fans
Browse files Browse the repository at this point in the history
Don't try to enable unused auto fans
  • Loading branch information
thinkyhead committed May 14, 2016
2 parents a713043 + 4d6bb52 commit e01e529
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Marlin/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ int Temperature::getHeaterPower(int heater) {
#if HAS_AUTO_FAN

void Temperature::checkExtruderAutoFans() {
const uint8_t fanPin[] = { EXTRUDER_0_AUTO_FAN_PIN, EXTRUDER_1_AUTO_FAN_PIN, EXTRUDER_2_AUTO_FAN_PIN, EXTRUDER_3_AUTO_FAN_PIN };
const int8_t fanPin[] = { EXTRUDER_0_AUTO_FAN_PIN, EXTRUDER_1_AUTO_FAN_PIN, EXTRUDER_2_AUTO_FAN_PIN, EXTRUDER_3_AUTO_FAN_PIN };
const int fanBit[] = { 0,
EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN ? 0 : 1,
EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN ? 0 :
Expand All @@ -347,10 +347,13 @@ int Temperature::getHeaterPower(int heater) {
SBI(fanState, fanBit[f]);
}
for (int f = 0; f <= 3; f++) {
unsigned char newFanSpeed = TEST(fanState, f) ? EXTRUDER_AUTO_FAN_SPEED : 0;
// this idiom allows both digital and PWM fan outputs (see M42 handling).
digitalWrite(fanPin[f], newFanSpeed);
analogWrite(fanPin[f], newFanSpeed);
int8_t pin = fanPin[f];
if (pin >= 0) {
unsigned char newFanSpeed = TEST(fanState, f) ? EXTRUDER_AUTO_FAN_SPEED : 0;
// this idiom allows both digital and PWM fan outputs (see M42 handling).
digitalWrite(pin, newFanSpeed);
analogWrite(pin, newFanSpeed);
}
}
}

Expand Down

3 comments on commit e01e529

@jakehenak
Copy link

@jakehenak jakehenak commented on e01e529 May 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm testing this out and it doesn't appear to work for my configuration. Voltage measures 300mv off the pwm pins. Works with same pins in RC 4.

In my case auto extruder 1 and 2 are both set to the same pin while 3 and 4 are -1. I have 2 extruders, only the first is active.

I see you have a loop that automatically sets the fan, could the below scenario be occurring?

The routine looks at extruder 1, turns on the fan when the temp is higher.
then looks at extruder 2, turns the fan off because the temp is lower.

Since they are on the same pin it appears as if nothing is happening.

I do see random voltage spikes off my multimeter which would indicate something is happening.

++ I have confirmed that by removing the pin from auto extruder 2 that the fans start up.

@thinkyhead
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. It should be setting only bit 0 in the first loop, then using that to turn on the first auto fan. I will re-examine the logic and see where it might be errant.

@thinkyhead
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, should be all patched up now!

Please sign in to comment.