Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Jerry Jackson
#25968 Is there a way to change PWM frequency to something other than 1000 Hz using Arduino IDE ?

Something in the range of 4 to 20kHz would probably be perfect for my application
User avatar
By Jerry Jackson
#26397 Thanks for directing me to analogWriteFreq()

It mostly works great for my needs. I am directly driving the gate on some logic level MOSFETs and noticed something strange:

At some frequency threshold above around 4.5 to 5 kHz it does not appear to have a solid level of control of the PWM pulse stream. For example, at 10% pulse width I was seeing very brief and random 100% on periods which was causing my MOSFET controlled LED lighting to go to 100% (like a camera flash) then settle back at 20% and randomly continue with the 100% spikes. It made no difference with or without the MOSFET gate connected. I could easily see these 100% periods with my oscilloscope.

I finally settled on 4 kHz as it appears to be stable there.

Otherwise, I am happy that it seems more than capable of supplying enough current to charge my MOSFET gate very quickly (around 16 nanoseconds rise time) after experimenting with several different MOSFET choices to hopefully give me the least amount of heating problems.
User avatar
By Phil Price
#28765 I noticed this also. I was hoping to be able to generate a 38Khz carrier for an IR project but unfortunately I don't think it will be possible with the sporadic 100% I'm seeing on PWM. Not sure if this can be fixed in software or if it is a hardware limitation (i.e interrupts getting delayed to deal with network stuff).

Also the frequency did not seem to be correct either, appeared to be around 45Khz - but that could just be me not using the scope properly...