PWM not functioning as expected #226
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the bug
When using PWM to control a fan nothing happens. neither manual nor linked to temperature
To Reproduce
Fan mos module hooked up to 3v3 and gnd, sig to BCM pin 13 (wpi 23).
Expected behavior
fan to speed up or slow down according to manual or automatic controls. currently nothing happens,
Additional context



rPi 3 B.
manually writing the pin up works fine. as does restarting with the correct settings, then it works until any setting is changed.
setting fan to gpio mode also allows fan to work, also setting it as a cooler works to link with temperature.
Settings (manual)
Settings (temp linked):
$gpio readall:
log shows options being changed.
`
2019-03-26 13:49:42,933 - octoprint.plugins.enclosure - INFO - Setting GPIO pin 13 as OUTPUT with initial value: 0
2019-03-26 13:49:51,147 - octoprint.plugins.enclosure - INFO - Turning gpio to control temperature on.
2019-03-26 13:50:53,976 - octoprint.plugins.enclosure - INFO - Setting GPIO pin 13 as PWM
`
tab shows that fan should be at 63%

It appears the PWM object is not correctly cleared initialized when settings are changed.
I am working on a fix
as a temporary fix I am trying using pwm_instance.start() instead of ChangeDutyCycle() as this ensures it is always properly started. its not pretty but I cant work out where an uninitialized instance is getting through