Fan PWM duty issue

Discussion in 'Embedded Systems and Microcontrollers' started by markdem, Mar 8, 2015.

  1. markdem

    Thread Starter Member

    Jul 31, 2013
    73
    38
    Hi All.

    I am working on a fan controller. Nice and easy, I read a temperature and change the PWM duty when things get too hot. Here is the bazaar issue. All goes well until I try a duty between 90 and 93%. If I use them the PWM output from the PIC will go to 0 after about .5 - 1 seconds. If I disconnect the fan, it will run fine. The pic still runs as I can send it commands to change duties. As soon as I move away from that range, everything works again.
    I am using a frequency of 25khz and the issue seems to change slightly if I change the frequency to 20kHz (the non working duty changes to 88-90%).

    Question is, what could be causing this??

    Below is my circuit. Any comments welcome.

    Thanks

    FAN.png
     
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    What PIC are you using?

    There is typically a section on maximum PWM frequency and resolution in the datasheet.

    Edit: OP changed post after I asked this...
     
    Last edited: Mar 8, 2015
  3. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,515
    2,369
    Did you try a lamp in place of the motor to get an exact visual of when the output stops?
    Microchip suggest a low end PWM frequency of 4-5Khz for motor control.
    I would also have been inclined to use a logic mosfet in place of bi-polar.
    Max.
     
  4. John P

    AAC Fanatic!

    Oct 14, 2008
    1,632
    224
    I wish you could post a description of exactly how you're setting up the timer and PWM in your code. Which registers get loaded with what values?

    And you said "If I disconnect the fan, it will run fine". What's that, the fan, or the processor in the absence of the fan? But I don't see how the fan can run at all if it's disconnected (we don't allow discussion of perpetual motion machines here, ha ha) and if it's the processor, do you mean you've looked at the output with a scope? It would certainly be a puzzle if the presence or absence of the fan makes the processor behave differently, given that the fan's power supply is a 12V input that doesn't connect to the processor.
     
  5. markdem

    Thread Starter Member

    Jul 31, 2013
    73
    38
    Thanks for the reply guys.
    Just to clear some things up. I don't think I am hitting some max frequency of the pic as if I set the duty at higher then 93% it will work. It is just at 90,91,92 and 93% that it fails. Lower the 90% and higher then 93% the fan works fine. I can't use 4-5Khz as we would get the fan making buzzing sounds. I might, just as a test, make the frequency that low and see what happens.
    I am using a PIC18F2580 like in the drawing above. I did not have a MOSFET on hand but the selected darlington should work ok. I am nowhere near the max current, I am only pulling about 500mA.
    I will try a 12v lamp later today to see if the load makes a difference. I have a scope connected so I can already see when the PWM is working and when it stops.
    And yes, when I disconnect the fan I mean the PWM output will work, the fan does not :). I can post the code later today (don't have it with me now) but I don't see how it could be a coding issue as it works fine when the fan is not connected.

    Thanks
     
    Last edited: Mar 8, 2015
  6. markdem

    Thread Starter Member

    Jul 31, 2013
    73
    38
    A little more playing and I made it work.
    If I connect a 12v lamp, it works fine. If I change the frequency to 5, 10, 15, 20 or 30kHz it works fine. If I make the frequency 25kHz and lower the fan voltage to <10 volts it works fine. It is just at 25Khz and 12V for duties between 90 and 93%.....

    In the end I just made the frequency 20kHz. Still to high to hear the frequency from the fan and it works fine.

    Still would love to know what was going on. It must be some kind of ringing or oscillating somewhere. I had a look at the 5v rail with my scope, nice and clean. If I look at the 12v rail I can see the EMF when the PWM is at zero, but it is only 200mV peak to peak. I can't see anything wrong with the PWM output at 89% (1 before it fails), it just looks like a normal square wave like it should.
     
  7. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,781
    1,103
    Fussy fan? Have you tried with a different fan?
     
  8. markdem

    Thread Starter Member

    Jul 31, 2013
    73
    38
    Yes, I have tried two different fans form different manufactures. Both different current ratings too.

    This one has me baffled..

    Thanks
     
  9. markdem

    Thread Starter Member

    Jul 31, 2013
    73
    38
    Hi Again,

    Back on this project and hit yet another wall. All is fine if I only have one fan but for this I need to connect two.
    If I connect the second fan the oscillator on the pic stops... If I disconnect the second fan the pic start working after about 1-2 seconds.
    This is not a current issue as I have tried a bigger fan (by it self) pulling 800mA and it works fine. The two fans are only 200mA each. Also, at 100% duty the two fans will work fine. It is just if I start to use PWM to control the speeds.
    I guess the first question is, can I use more then one fan on the same transistor? Will the back EMF effect the other fan? Why is the pic oscillator been effected?
    Is there something else that I am doing wrong here? It seems like such a simple thing to do yet I just can't make it work.

    Thanks
     
    Last edited: Mar 14, 2015
  10. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,515
    2,369
    Could it it be a noise spike causing a Pic MRST? Chassis/GND plane fault?
    Can you parallel two Mosfets for each fan?
    Max.
     
  11. markdem

    Thread Starter Member

    Jul 31, 2013
    73
    38
    I thought it might be a ground issue so I have the emitter connected via it own wire to the power supply now, did not help.
    I was hoping not to have to rebuild the board, but I guess I have no option...
    In general, should there be any issue driving two fans from the same transistor\MOSFET?

    Thanks
     
  12. geoffers

    Active Member

    Oct 25, 2010
    239
    6
    Might be barking (up the wrong tree)! But are there nice big capacitors on the fan motor leads? Could be a spike reseting pic, may be to quick to see on a scope
    Good luck cheers geoff
     
  13. geoffers

    Active Member

    Oct 25, 2010
    239
    6
    Or if there is could the winding / cap be resonant at the bad pwm frequency ? There's not a decoupling cap shown on your schematic I assume there's one on your board? The babys gone to sleep now so am I!
    Cheers geoff
     
Loading...