Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

software PWM

Status
Not open for further replies.

large_ghostman

Well-Known Member
Most Helpful Member
just checking i am on the right path, i need to control a number of small fans with pwm, so far the frequency looks like being around the 3kHz range. i am thinking software pwm with two timers, i dont need huge resolution probaly 10 settings between 70% and 100% should do it, am i correct in thinking i need to set first timer as the frequency, so as it rolls over i turn all fans on the second acts as duty cycle so i set it for a period that equals 1oth of the main clock and switch off any fans that match the number of times the timer has rolled over?
hmmm i think i have confused it all there but i kind of know what i mean :D
 
With anything mechanical like fans I would use a frequency that's not audible, either below 20Hz or above 20kHz. For resolution it would be easiest to do the full 100% range. Therefore, I'd choose something like 15Hz and 100 steps which gives an interrupt frequency of 1500 times per second. Assuming a 4MHz oscillator and a pic, you can use timer 2 with prescaler=4, PR2 = 166 and this will give you 1500 interrupt per second. In your interrupt have a counter that goes from 0 to 99 and when it wraps set all outputs that don't have PWM=0 high. Then each subsequent interrupt check all PWMs against the counter and set the ports of any that match low.

If you use a higher crystal frequency then prescaler=16 may help or use timer1 (16 bit) with the PWM special event trigger to generate the interrupt.

Have fun,

Mike.
 
thanks pommie i will try that. not 100% sure the clk yet as i have to check something first. i will go with 15Hz, i tried 1K upto 20K and anything above about 3.5 didnt seem to work too well, these are ex pc fans and i think they are BDLC with the controllers inside, they sure didnt like me winding them right up :D so i will try the lower frequency, i did try and make them scream or whine but none of them made much noise :(
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top