Welcome! Log In Create A New Profile

Advanced

PWM frequency of fan only about 4Hz

Posted by rbrakhya 
PWM frequency of fan only about 4Hz
August 24, 2012 02:48PM
Hi!
I upgraded from FW 0.54 to 0.6 a while ago and i got some problems with the fan PWM frequency. It's only about 4Hz and it sound really annoying. The fan speed control works (at 100% it runs continuously) and all other functions seem to work.
Reflashed to other newer versions, but it made no difference. Flashing with 0.54 fixes it.

I have:
RAMPS 1.4
Mega 2560
Running Repetier host 0.7

Is there any solution to this?
Re: PWM frequency of fan only about 4Hz
August 24, 2012 06:20PM
The current version 0.71 has a frequency of 7.62Hz. Not sure if it is better. With 0.54 you had hardware PWM which is now replaced by software PWM to remove problems with available timers. With a little change you can increase this to 15Hz. All you need to do is change Repetier.pde function ISR(PWM_TIMER_VECTOR)

Replace:
  if(pwm_count==0) {
#if EXT0_HEATER_PIN>-1
    if((pwm_pos_set[0] = pwm_pos[0])>0) WRITE(EXT0_HEATER_PIN,1);
#endif
#if defined(EXT1_HEATER_PIN) && EXT1_HEATER_PIN>-1
    if((pwm_pos_set[1] = pwm_pos[1])>0) WRITE(EXT1_HEATER_PIN,1);
#endif
#if defined(EXT2_HEATER_PIN) && EXT2_HEATER_PIN>-1
    if((pwm_pos_set[2] = pwm_pos[2])>0) WRITE(EXT2_HEATER_PIN,1);
#endif
#if FAN_PIN>-1
    if((pwm_pos_set[3] = pwm_pos[3])>0) WRITE(FAN_PIN,1);
#endif
  }
#if EXT0_HEATER_PIN>-1
  if(pwm_pos_set[0] == pwm_count) WRITE(EXT0_HEATER_PIN,0);
#endif
#if defined(EXT1_HEATER_PIN) && EXT1_HEATER_PIN>-1
    if(pwm_pos_set[1] == pwm_count) WRITE(EXT1_HEATER_PIN,0);
#endif
#if defined(EXT2_HEATER_PIN) && EXT2_HEATER_PIN>-1
    if(pwm_pos_set[2] == pwm_count) WRITE(EXT2_HEATER_PIN,0);
#endif
#if FAN_PIN>-1
    if(pwm_pos_set[3] == pwm_count) WRITE(FAN_PIN,0);
#endif

with

if(pwm_count==0) {
#if EXT0_HEATER_PIN>-1
if((pwm_pos_set[0] = pwm_pos[0])>0) WRITE(EXT0_HEATER_PIN,1);
#endif
#if defined(EXT1_HEATER_PIN) && EXT1_HEATER_PIN>-1
if((pwm_pos_set[1] = pwm_pos[1])>0) WRITE(EXT1_HEATER_PIN,1);
#endif
#if defined(EXT2_HEATER_PIN) && EXT2_HEATER_PIN>-1
if((pwm_pos_set[2] = pwm_pos[2])>0) WRITE(EXT2_HEATER_PIN,1);
#endif
}
#if FAN_PIN>-1
if((pwm_count & 128)==0) {
if((pwm_pos_set[3] = (pwm_pos[3]>>1))>0) WRITE(FAN_PIN,1);
}
#endif

#if EXT0_HEATER_PIN>-1
if(pwm_pos_set[0] == pwm_count) WRITE(EXT0_HEATER_PIN,0);
#endif
#if defined(EXT1_HEATER_PIN) && EXT1_HEATER_PIN>-1
if(pwm_pos_set[1] == pwm_count) WRITE(EXT1_HEATER_PIN,0);
#endif
#if defined(EXT2_HEATER_PIN) && EXT2_HEATER_PIN>-1
if(pwm_pos_set[2] == pwm_count) WRITE(EXT2_HEATER_PIN,0);
#endif
#if FAN_PIN>-1
if(pwm_pos_set[3] == (pwm_count & 127)) WRITE(FAN_PIN,0);
#endif

The code is untested, but should work.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: PWM frequency of fan only about 4Hz
August 24, 2012 06:47PM
Thank you!
I'll test it first thing in the morning!
Does this effectively lower the resolution to 7 bits?
If its possible to increase the frequency even more at the cost of resolution? I think i could do with 4-5bits for the fan..
Thanks for your great FW and SW!
Best regards,
Ronny
Re: PWM frequency of fan only about 4Hz
August 25, 2012 02:50AM
Yes, it lowered the resultion with pwm_pos[3]>>1 to 7 bits. Combined with & 128 and &127. This can be reduced to any other resolution increasing fan pwm. Normal hardware PWM has 50Hz I think.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: PWM frequency of fan only about 4Hz
January 12, 2014 05:06AM
Hi ,

I´m running Repetier host 0.83 and I´m searching a way to increase the PWM Frequency of the FAN from the 16Hz today to something above 200Hz....
I`m running a 2.5W Diode Laser on my modified printer for cutting and engraving. This Laser can be TTL modulated with up to 1kHz to adjust the power.
I´m using the Extruder heater for the Power and the Fan Signal for the TTL modulation. This is working fine as long as I use 90-100% power.
For engraving I will need to reduce the Power but all below 90% is just cutting or perforating every now and then due to the low PWM frequency of the Fan.
I tried to modify the ISR of V 0.83 and 0.91 like posted above but with no success....

Thank you very much in advance,
Best regards,
Tim
Re: PWM frequency of fan only about 4Hz
January 12, 2014 05:18AM
That ISR is meant to simulate many outputs with PWM. So save performance is is not very fast, which is ok for the normal printer usage.

What you need is a hardware PWM output that you can use. Simply use the Arduino PWM functions for this, but make sure the pin is not controlled by timer 0-2, which are already in use and using them would destroy functionality. That way you have no computation penalty and can get very high frequencies.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: PWM frequency of fan only about 4Hz
January 12, 2014 12:51PM
Hi repetier,

Thank you. I have changed the Pin 9 to Pin 7 which is a unused PWM PIN on Timer 4.
I took the Fan control out of the ISR and got it working by putting a simple analog write into the set_fan_speed() routine in the Commands.cpp
Working fine at 490Hz, so perfect, and I could not see any negative influences elsewhere so far, but one might implemented it in a better place? Do you have any recommendation where to put the analogWrite??

Thank you very much!
Best regards,
Tim
Re: PWM frequency of fan only about 4Hz
January 12, 2014 12:57PM
set_fan_speed is perfect for it. That's the fine thing about hardware pwm - fire and forget. So setting it where it gets changed is perfectly fine.


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Sorry, only registered users may post in this forum.

Click here to login