Welcome! Log In Create A New Profile

Advanced

Fan configuration - what am I missing?

Posted by xC0000005 
Fan configuration - what am I missing?
October 26, 2017 12:16PM
The printer I'm compiling Marlin for has two sofware controlled fans. One is on the extruder, and I have it set as E0_AUTO_FAN_PIN.
The other is a part cooling fan, and I'd like it to come on whenever the slicer has set it to (like, I'm printing in PLA).
I have it defined as FAN_PIN.

However, the fan pin never comes on, no matter how what commands I issue (manually testing). The auto fan does come on when the extruder temp is > 50 degrees, and if I swap pin definitions, the part fan comes on, so I've got my pin definitions "right."

What am I missing to have the extruder fan automatically come on and the part fan controlled by the M106 command? Since M106 controlled the extruder cooling fan before I set it to auto, I would expect to be able to do M106 P1 S255 and have the part cooling fan come on, but I must have something misconfigured.
Re: Fan configuration - what am I missing?
October 26, 2017 12:43PM
I would turn on PIN DEBUGGING... And using M42 and M43 see if I can turn on the fan. If the fan isn't wired up to the 'correct' pin, you'll have problems turning it on.

Also... M43 is pretty smart. You can put it in a mode where it tells you what pins changed.
So you can unplug your fan from where ever it is plugged in, and ground that pin.
And M43 should be able to report which pin's status changed.
Re: Fan configuration - what am I missing?
October 26, 2017 02:28PM
Since swapping pin assignments auto-turns on the part cooling fan, I'm near certain I have the pin definitions right. My suspicion is that the macros for HAS_FAN_0 and HAS_FAN_1 are setting it so there's only a single fan defined when E0_AUTO_FAN is defined to one value and FAN_PIN (which is labeled as the cooling fan in the comments) is defined differently. The macros seem to handle three fans just fine, but I bet the number of fans defined is still 1 in this case, and the pin is E0_AUTO_FAN. I'll test and find out tonight.
Re: Fan configuration - what am I missing?
October 26, 2017 02:28PM
Since swapping pin assignments auto-turns on the part cooling fan, I'm near certain I have the pin definitions right. My suspicion is that the macros for HAS_FAN_0 and HAS_FAN_1 are setting it so there's only a single fan defined when E0_AUTO_FAN is defined to one value and FAN_PIN (which is labeled as the cooling fan in the comments) is defined differently. The macros seem to handle three fans just fine, but I bet the number of fans defined is still 1 in this case, and the pin is E0_AUTO_FAN. I'll test and find out tonight.
Re: Fan configuration - what am I missing?
October 26, 2017 02:39PM
I may have figured this out. Thanks for the help, and I'll report back if it's still borked once I fix my definitions to match what the macros expect.
Re: Fan configuration - what am I missing?
October 27, 2017 12:32PM
Well, my best theories are busted.

I don't know if this is something specific to 32bit or not.

In my pins configuration file, I have

#define FAN1_PIN PB3 // FAN1 header on board - PRINT FAN

in configuration_adv.h, I have
#define E0_AUTO_FAN_PIN PB8

Marlin thinks I have zero fans (I modified the output of M42 to spew a bunch of info).
I tracked it down the a macro in conditionals_post.h, and for the life of me, I don't understand what it's doing.

#define HAS_FAN1 (PIN_EXISTS(FAN1) && CONTROLLER_FAN_PIN != FAN1_PIN && E0_AUTO_FAN_PIN != FAN1_PIN && E1_AUTO_FAN_PIN != FAN1_PIN && E2_AUTO_FAN_PIN != FAN1_PIN && E3_AUTO_FAN_PIN != FAN1_PIN)

In english, this is "If fan1 is definied, and it's not the controller fan, E0, 1, 2, or 3 auto fan pins, we have FAN1"
So I level by level checked it, and the one that makes this macro return false is E0_AUTO_FAN_PIN != FAN1_PIN.

So I added in this file some code to spew a pragma with the values...and what I get is confusing.

// **********
/* definition to expand macro then apply to pragma message */
#define VALUE_TO_STRING(x) #x
#define VALUE(x) VALUE_TO_STRING(x)
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)

#if E0_AUTO_FAN_PIN != FAN1_PIN
#error "Not Equal!"
#else
#pragma message(VAR_NAME_VALUE(E0_AUTO_FAN_PIN))
#pragma message(VAR_NAME_VALUE(FAN1_PIN))
#error "E0AFPFP"
#endif
// *********

When I compile, I correctly get the spew from the pragmas -
Marlin/src/HAL/HAL_LPC1768/../../inc/Conditionals_post.h:650:52: note: #pragma message: E0_AUTO_FAN_PIN=PB8
#pragma message(VAR_NAME_VALUE(E0_AUTO_FAN_PIN))
^
Marlin/src/HAL/HAL_LPC1768/../../inc/Conditionals_post.h:651:45: note: #pragma message: FAN1_PIN=PB3
#pragma message(VAR_NAME_VALUE(FAN1_PIN))

So...PB3 has somehow evaluated equal to PB8? (PB3 is an enum with a value of 19, PB8 has a value of 24).

Is there something I'm doing wrong here thatI can change to fix this?
Re: Fan configuration - what am I missing?
October 27, 2017 01:25PM
This is probably caused by the STM32 arduino board defintions.
[gcc.gnu.org]

says that enums are not expanded, and STM32 uses enums for pin definitions. I've switched my local copy to #defines, and it is at least evaluating as expected.
Sorry, only registered users may post in this forum.

Click here to login