Skr pro, fan pins

So I was thinking of using fan0 to turn on a relay that turns on the router and vacuum, and fan1 and fan2 to run to 40mm fans over controller. Is this possible?

And then have Gcode autogenerated on all projects at start to turn fan0(relay for router/vacuum) on and gcode at end to turn fan0(relay for router/vacuum) off.

Also want fan1 to turn on at boot up and remain on, and fan2 to turn on after 5min when fan0(relay for router/vacuum)is on and also turn off 5 minutes after fan0(relay for router/vacuum) is off.
Can this all be done? If so anyone advise on what gcode I need and where to input it using repetier host?

Ps. I’m a newbie so still learning the ropes.

Also want fan1 to turn on at boot up and remain on

Usually, when people want a fan on all the time, it is easier to just use VCC at the terminals rather than deal with turning on the fan pins. But if you really want to use fan pins, you can put g-code in an auto start file on your SD card in your TFT, and it will be executed at the boot of your control board. This solution depends on you having the SD card in the slot when the electronics are booted.

fan2 to turn on after 5min when fan0(relay for router)is on and also turn off 5 minutes after fan0(relay for router) is off.

The 5-minute delays are a problem. Marlin g-code executes in a single sequence. You can add delays in the sequence, but nothing else will be done during the delay. If you put a pause at the beginning of the file, then none of your job will be executed until the pause is over. At the end, the job will not be completed until the pause is over.

To turn fan pins on/off, use M106 and M107 g-codes. I use fan2 on my Rambo board with M106 and M107 inserted at the beginning and end of my code to turn my router on/off.

In Repetier-Host, go to Config/Printer Settings/Scripts. Use the drop down to select when you want it to be run (Start Code and End Code probably), and insert the g-code you want in each section.

Most CAM tools have a similar ability to insert start and end g-code. I do it at CAM time so that I can run the g-code file off an SD card as well as a g-code sender like Repetier-Host.

As for turning your router/vacuum on/off, I go through some choices in this post. If you go with a mechanical relay solution, then I would use a 5V pin and M42 rather than fan pins and fan g-codes.

If you consider the delays important and are willing to put in some work to make it happen, it is possible to use an Arduino or similar and a relay module to make it happen. Your g-code would signal the start of the timers, and the control board would signal the Arduino to start timing and then to turn the fans on/off.

use M106and M107 g-code. How do I know which fan output is getting turned on with that code. Skr has 3 fan outputs? Sorry newbie question

Marlin/Configuration.h

// Set number of user-controlled fans. Disable to use all board-defined fans.
// :[1,2,3,4,5,6,7,8]
//#define NUM_M106_FANS 1

By default NUM_M106_FANS is disabled in Configuration.h so M106 should turn on all fans outputs. But for controlling a relay fans are not the best choice :

You specify which fan and the speed using parameters. So, if I want fan 2 on full, you would do:

M106 P2 S255  ; Turn on fan 2 to speed 255 (full)

The S parameter (speed) goes for 0 to 255. The value 255 is fully on. I think if you leave the S parameter off when running the g-code, you get full on (255).

Turning fans off is similar:

M107 P2  ; Turn off fan 2
1 Like

Ok so using dual endstop firmware,
If I type M106 P0 it turns on fan1,
M106 P1 doesn’t seem to turn on fan 2
M106 P2 turns fan 3 on.
Why isn’t P1 working however?

I don’t have an answer for you, and, since I don’t run an SKR Pro, I cannot test to verify your results. First, M106 not M107 turns on fan pins. Second, it must be a capital ‘M’. It must be M106, not m106. I’m not sure if either of these issues factor into your problem.

Since I don’t have an SKR Pro 1.2 board, all I can do is take a look at the code. According to the pinout, the fans are defined as follows:

image

So, fans are numbered 0, 1, and 2 just like the ‘P’ numbers in the M106 and M107 commands.

The code that assigns the pins to the fans is found in pins_BTT_SKR_PRO_common.h:

//
// Fans
//
#define FAN_PIN                             PC8   // Fan0
#define FAN1_PIN                            PE5   // Fan1

#ifndef E0_AUTO_FAN_PIN
  #define E0_AUTO_FAN_PIN               FAN1_PIN
#endif

#if !defined(CONTROLLER_FAN_PIN) && ENABLED(USE_CONTROLLER_FAN) && HOTENDS < 2
  #define CONTROLLER_FAN_PIN                PE6   // Fan2
#else
  #define FAN2_PIN                          PE6   // Fan2
#endif

While I cannot trace the entire logic to see how this is getting compiled, it appears that Fan 1 (middle fan connection) is assigned to E0_AUTO_FAN_PIN. This assignment attaches the fan to the extruder so that it comes on and off as needed by the extruder. I’m guessing this assignment is why your fan pin for P1 is not changing the Fan 1 state. You can probably change this define to enable the functionality for Fan1, but I’m reluctant to give you what I think the changes could be since I cannot test them.

Anyway. I would expect P0 to turn on the fan labeled Fan 0 which is the first fan connection. I would expect that P2 would turn on Fan 2 which is the third fan connection. I’m not surprised that P1 does not work, but if it is important enough for something you are doing, then it probably can be made to work by changing the firmware, recompiling, and re-flashing.

1 Like

Ahh ok.
Well silly question now.
Can I download my current firmware that loaded on the skr and edit these and then recompile it?

Is there a way I can just recompile and load the pins_BTT_SKR_PRO_common.h file.

I ask as I’ve saved eeprom settings and made changes etc. so was wondering if there is a way to edit what I have and reload it?

No, you cannot download the firmware from your board and edit it. You must start from a full source as provided by V1, load that source into VS and PlatformIO, compile that source, and re-flash your firmware.

But, saved EEPROM settings are not overwritten when you re-flash your firmware.

Just curious, why do you need three functioning fan ports? If all you need is to turn pins on and off, M42 will manipulate arbitrary, free pins.

Well I’m using them to control relays. 3 relays but only really need 2.
And as I’m not familiar with the compiling firmware etc. I was trying to avoid that.
But at the same time, doing it might be a way of beginning to learn on how to do it for future edits etc.

Will the m42 command still work with standard v1 firmware?
How does the m42 command work and on which pins?

M42 will work on any available pin, and no firmware changes are required. I think there are some pins Marlin protects from this command, but they likely will already be in use. You will find a pinout diagram here.

I believe all the pins on Extension 1 and Extension 2 are available for M42, and I think these are all 5V pins. You should check the voltage since you will want to match the relay to the voltage of the pin. When checking voltage, I’m very careful not to short pins. I use Dupont wire connectors, and only change pins when the board is powered down. I even place tape over any exposed connections to the multimeter. If you ever plan on putting a laser module on your machine, avoid using pin PC9 for your relays. PC9 is the designated laser PWM pin.

I’m not sure of the Marlin pin naming for the SKR Pro, but I believe the following is the syntax:

M42 PC4 S255  ; Turn the pin on full
M42 PC4 S0    ; Turn the pin off

An aside: unlike most of the rest of the pins on the SKR Pro board, Fan pins are ground-side switching. When you use M106 to set the value of the fan, you are setting the PWM value of the ground pin. This means 1) fan pin pairs don’t play well with some devices (though they should work fine with a relay), and 2) if can select a different VCC pin of a different voltage. For example, if you use the fan ground pin and then use a 5V pin elsewhere on your board, you can control a 5V relay.