Enabling GPIO pins not listed in klippy.log mcu section

Printer Model: Flsun V400
MCU / Printerboard: stm32f103xe/MKS Robin Nano 2.1
klippy(5).log (173.2 KB)

This is my first post - thanks for any assistance and apologies for any faux pas. I’m attempting to add a CPAP fan using the bltouch sensor pin. Wiring to the fan is 24v direct from PSU and dupont connector on the bltouch sensor pin, PA8. I can confirm functionality by switching this lead to bltouch 5v pin. I get no output when attempting to control using macros/console, and reviewing klippy.log the only mention of PA8 is in my own fan config. I’m assuming I need to enable this pin somewhere, however I wasn’t able to find what I needed from past posts or the knowledge base.

I’ve been working off of Guiouz’s v400 config from github (can only post one link) as a baseline config for the machine. This is the schematic I’ve been using for pinouts. Below is my config change, with the factory fans optioned out (These do allow manual control).

#[fan]
#pin: PB1

[fan]
pin: PA8
kick_start_time: 0.1
off_below: 0.2
cycle_time: 0.005
max_power: 1
hardware_pwm: False

Seems correct, what you are doing. Have you tried M106 S255?
SET_FAN_SPEED as seen in your log is only applicable to fan_generic

Yes, thank you. That SET_FAN_SPEED was sort of a ditch attempt, having read that it only works with fan_generic and knowing I’m not using that parameter. I should have been more specific - M106 S255 and M106 S0 - or any speed in between - had on effect via console. I believe that’s what the screen macro uses w the ‘slider’ interface as well, but still no luck there either.

As a bit of an afterthought, this does make me wonder what pin(s) I could use for generic fan speed control as well… I’m currently using multiple added aux fans, one of which I’ve resorted to a PWM modulel to quiet a bit. Maybe that warrants its own post.

ETA: Is the fact that the PA8 pin isn’t called out in the log an issue?

Some general remarks

  • A regular fan can only be driven by a pin that is backed-up by a MOSFET
  • Any free pin can be used to drive a TTL electronic board via 3.3V, e.g. your CPAP blower electronic
  • Depending on the schematic a pull-up (^), pull-down (~) or an invert (!) may be needed before the pin, e.g. ^PA8
  • Any pin can be used for PWM as long as you do not define hardware_pwm: true. For hardware PWM a PWM-capable pin is needed. I’d stick with software PWM, i.e. hardware_pwm: false

Try any other pin, e.g. one of your free endstop pins, or experiment with the pull-up stuff.
Pin numbers are not mentioned in the logs.

Thanks again. I wasn’t able to get any pull-up methods to work without errors such as this. I believe it’s just a syntax issue however the error’s example didn’t provide much help:


.

That said, I was able to use another pin successfully.

#[fan]
#pin: PB1

[fan]
pin: PC2
kick_start_time: 0.1
off_below: 0.2
cycle_time: 0.005
max_power: 1
hardware_pwm: False

This is a case where you need to read the error message.

You cannot specify the pulldown modifier (~) to your pin - only ! (signal invert) is allowed.

As a rule of thumb, the pullup (^) or pulldown (~) pin modifiers aren’t necessary as they are generally ineffectual as most 32bit microcontrollers have buffers on the output and specifying a pullup or pulldown on the IO pin will not get passed to the peripheral device. The reason for this is because 32 MCUs (like the STM32F used in your Robin Nano 2) run at 3.3V and the standard interface logic voltage used in 3D printers is 5V. If a pull up or pulldown is required then you need to consult the schematic of the controller board to see whether or not they are already there for the IO pin you want to use. Most controller IO pins that are normally used for output have a pull up built into the board.

If you’re working an Arduino (8bit) based controller board, which has a processor running at 5V, the pullup and pulldown modifiers should work and may be required.

1 Like