PWM case light

Hi all,

the printer I'm currently working on has some caselights. Since they're LEDS I want to PWM them. I adapted the M355 command to use analogwrites: analogWrite(11, com->S) (CASE_LIGHTS_PIN = 11). This actually worked but the printer goes into full fail mode. It says busy processing and never responds to a command anymore. Then I figured I should probably use the native M-command to do this: M42 P11 S100. Same problem!

I then added a new gcode command in the same way M106 works (setting fan power). This makes the case light flicker on and off since it doesn't use the internal PWM timers.

How to work around this problem? PWM apparently kills the printer and the timers in HAL.cpp don't switch fast enough.

Comments

  • The main problem is that firmware requires several timers for timings, so these can not be used as pwm timers. Unfortunately timers and pins are bound so you can only use pins using timer 3-5 on a AVR board. There M42 would work.

  • Cool, I will let the leds be controlled in a binary way then. Might connect a custom mosfet circuit to a pin on timer 3 - 5 or just connect a big capacitor to the current situation in the future.
Sign In or Register to comment.