PWM support for M42
-
Unlike the current Duet boards that only support digital on/off, adding PWM support to output pins via M42 would be handy! I assume the upgraded µC on the DuetWifi could hopefully support this? Having used this ability in Smoothieware, this is one feature I really miss with my current Duet.
W3DRK
-
In fact the firmware does allow PWM to be specified with M42. However, all the PWM pins are allocated to heaters and fans (including the heater pins on the expansion connector). If you use M42 to setup PWM on an unused heater output, the PID controller will turn it off (high) after a short time. Maybe we need an M command to specify how many heaters are connected, so that heater outputs beyond that can be used as general I/O pins.
-
That would be fantastic!
It's nice to be able to control LEDs and things this way and I usually prefer to use my own galvanically isolated mosfets so I can use devices with various voltage requirements (for example 5V and 12V fans/LEDs on a 24V system) without any risk of ground loops and to protect the uC. So having direct access to multiple unused PWM capable I/O pins would be a nice touch.
I also see there is thermostatic control available for the 2nd fan output. Is it possible to independently configure more than one I/O for thermostatic control, each with different temperature thresholds?
I'm certainly looking forward to getting my DuetWifi. Very nice work! To be honest I'm a die-hard fan of Smoothieware and how flexible their firmware is, but once I started tinkering with a Duet v0.6 it's really been growing on me….
Cheers!
DieterIn fact the firmware does allow PWM to be specified with M42. However, all the PWM pins are allocated to heaters and fans (including the heater pins on the expansion connector). If you use M42 to setup PWM on an unused heater output, the PID controller will turn it off (high) after a short time. Maybe we need an M command to specify how many heaters are connected, so that heater outputs beyond that can be used as general I/O pins.
-
Another option would be to add software PWM to any unused GPIO pin that can currently be used by M42 depending on the PWM frequency wanted this could add too much overhead though.
Regarding deciding if a heater output is used or not, rather than a new M code, why not just allow all heaters that are not added to a tool to be used as PWM?
-
Another option would be to add software PWM to any unused GPIO pin that can currently be used by M42 depending on the PWM frequency wanted this could add too much overhead though.
The overhead would be high unless the PWM resolution were limited to 1ms or the timing were done in the step ISR, which I would rather avoid because of the impact on maximum step generation speed.
Regarding deciding if a heater output is used or not, rather than a new M code, why not just allow all heaters that are not added to a tool to be used as PWM?
For safety reasons I would rather the user made a definite statement that there is no heater attached to the pin. But perhaps we don't need a new M code, we could add an option to M305 instead.