Welcome! Log In Create A New Profile

Advanced

Why high frequency PWM?

Posted by bryanandaimee 
Why high frequency PWM?
April 12, 2011 12:03AM
So I was on the Gen7 forum topic with Traumflug and we were both wondering why all the firmwares seem to be moving to high frequency PWM for heater control. This tends to make selection of FET's more difficult and more expensive, not to mention all the electrical noise you are injecting into the system using high power high frequency signals. So the question is what are the benefits to kHz PWM? Would PWM at a few tens of Hz accomplish the lions share of stabilizing temps without the baggage for the electronics designers?
Re: Why high frequency PWM?
April 12, 2011 03:27AM
We're reading the temp sensors at 100hz in teacup if you have thermistors, running the PWM at that frequency would impact the temperature readings significantly. Running it lower doesn't make any sense and would piss off the PID, the only sensible option is up. Above a few hundred hertz it becomes audibly annoying until we reach 30khz or so. Feel free to alter the clock initiations in mendel.c for 1khz pwm if you like, that should work fine if you can handle the noise smiling smiley


-----------------------------------------------
Wooden Mendel
Teacup Firmware
Re: Why high frequency PWM?
April 12, 2011 04:54AM
Thermistors have a time constant of a few seconds so not much point in reading at 100 Hz and certainly need no for high frequency PWM.

Edited 1 time(s). Last edit at 04/12/2011 05:58AM by nophead.


[www.hydraraptor.blogspot.com]
Re: Why high frequency PWM?
April 12, 2011 07:29PM
OK, so I understand that the PID function needs to be able to control the PWM each time it wants to change control output, so the PWM frequency must be at least equal to the PID control frequency (not necessarily equal to the sampling rate) and the PWM frequency should also be different than the sampling rate to minimize interference. From Nophead's comment, it seems that there are a few alternatives.

1. keep the 100 Hz sampling rate but time average the samples down to say a few Hz and run the PID at that frequency. The PWM could then be run at 10x that or a few tens of Hz.

2. Drop the sampling rate down to a few Hz and run 20 or 30Hz PWM.

comments?

Edited 1 time(s). Last edit at 04/12/2011 08:02PM by bryanandaimee.
Re: Why high frequency PWM?
April 12, 2011 08:02PM
bryanandaimee Wrote:
-------------------------------------------------------
> would it work to sample at say 1 or 2 Hz
> and then run the PWM at 10 or 20 Hz?

yep sure that should work fine, let us know how it goes smiling smiley


-----------------------------------------------
Wooden Mendel
Teacup Firmware
Re: Why high frequency PWM?
April 12, 2011 08:07PM
Sounds good, and is the PID control frequency also configurable, or would that be a firmware change?
Re: Why high frequency PWM?
April 12, 2011 09:04PM
PWM is set up in mendel.c line 145ff and heater_init() in heater.c. As far as I can see at a quick glance, the prescaler is unused, so PWM frequency is at the 62.5 kHz default. An ATmega reference manual will tell how low one can go with with the prescaler, or wether software-PWM is required for 10/100Hz.


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: Why high frequency PWM?
April 12, 2011 09:28PM
bryanandaimee Wrote:
-------------------------------------------------------
> Sounds good, and is the PID control frequency also
> configurable, or would that be a firmware change?

find next_read_time in temp.c:220. This controls how often sensors are polled, in 10ms units. It defaults to zero for thermistors. Set it to 100 for 1hz read. PID is calculated once every time the sensor is read, so this also controls PID frequency.


-----------------------------------------------
Wooden Mendel
Teacup Firmware
Re: Why high frequency PWM?
April 20, 2011 06:40PM
I use PWM (at 100Hz) on my heater output (including my modified Klimentkip) because I'm using a 19.5V Dell laptop PSU with a standard 6 ohm MakerGear heatcore (nichrome wire). I need to limit the total dissipation to 38% ( (12/19.5)^2 ). This is pretty easy to accomplish in FiveD and Teacup and it's why I had to add PWM to Klimentkip before I could try it.

100Hz cycling should not be a challenge to a FET.

BTW I also read the temp sensor at 100Hz but average it over 100 samples (1s) for M105 output. The PID runs at 100Hz because it's possible to choose reasonably scaled constants at that speed and the net effect averages out the noise in Gen6 just like using the averaged value but without feeling like I have to verify the stability of the double integrator.
Sorry, only registered users may post in this forum.

Click here to login