RacingtoMars
Member
Hi everyone,
I've been hanging around "back stage" for a while now, reading and learning. I wanted to bring something to the table before asking for help, and I noticed that there are a fair few posts (and loads of questions on the web) regarding PWM control of computer-type fans.
What I discovered after my first prototype didn't work — and now it seems obvious — is that the DC brushless motor in the fan has its own electronics which, don't like being switched on and off rapidly!! From what I understand, the ONLY way to do this (aside from having a very, very low PWM rate) is to use a 4-pin fan, where the 4th connection is a PWM input to the fan's own electronics.
I have created some code, which is a little messy, but it does work.
The part that I am really struggling with is the "boost" (I've heard the term 'goose' also) to overcome the starting inertia from being stationary. I don't know how to set parameters so that the boost kicks in if the speed is to increase, but not if the speed is to decrease. Would I have to use two registers to do this?
Thanks & kind regards,
Craig.
About Me as I'm new:
I'm late 30's and getting back into hobby electronics after a career change into photography for 16 years (I was initially a systems apprentice). I was put off 'micros' at college after spending HOURS typing in machine-code to achieve almost nothing, and always tending to stick to analogue electronics after that!
I'm currently studying Physics with the Open University, working part-time, and looking after the home & kids — so Picaxe fits into the small pockets of time that I manage to steal here and there..!
I've been hanging around "back stage" for a while now, reading and learning. I wanted to bring something to the table before asking for help, and I noticed that there are a fair few posts (and loads of questions on the web) regarding PWM control of computer-type fans.
What I discovered after my first prototype didn't work — and now it seems obvious — is that the DC brushless motor in the fan has its own electronics which, don't like being switched on and off rapidly!! From what I understand, the ONLY way to do this (aside from having a very, very low PWM rate) is to use a 4-pin fan, where the 4th connection is a PWM input to the fan's own electronics.
I have created some code, which is a little messy, but it does work.
The part that I am really struggling with is the "boost" (I've heard the term 'goose' also) to overcome the starting inertia from being stationary. I don't know how to set parameters so that the boost kicks in if the speed is to increase, but not if the speed is to decrease. Would I have to use two registers to do this?
Thanks & kind regards,
Craig.
Code:
' Temperature sensitive fan-speed controller for 4-pin brushless DC type fan
' serout C.0,N2400,(254,1) 'clear screen
' serout C.0,N2400,(254,192,"Temp ",#b1,%11010010,"C ") ; transmit value in b1 to serial OLED
symbol fan = C.2 ; Pin 5 - the only PWM output on the 08M2 chip
symbol LED = C.1 ; Pin 6
gosub blast ; ensures the fan starts spinning until the temp is determined to be low enough
main: ; set an appropriate PWM value according to temperature
gosub howhot ; read the temperature from the DS18B20 into b1
gosub display ; output the temp to serial display for testing purposes
select case b1 ; use the value of the temperature in b1
case <20 ; if temp is less than 20ºC
goto offFan ; switch fan off off
case 20 to 24 ; temperature range
;gosub blast ; kickstarts the fan from still, BUT unfortunately also boosts when reducing the PWM level :(
goto fiftyFan ; quiet at 50%
case 25 to 29 ; temperature range
goto sixtysixFan ; low vibration at 60% - try 66%
case 30 to 34 ; temperature range
goto seventysevenFan ; little noisy at 77% - try 85% noise but no vibe, too blowy though
case 35 to 39 ; temperature range
goto ninetyfan ; 90% duty mostly wind noise
case >= 40 ; temperature limit
goto alarm ; max output fan with audible & visible alerts
Else
high fan ; fan on full
endselect
blast:
pwmout 2, 39, 160 ; fan at full power briefly to break inertia
pause 250 ; the shortness of the brieflyness
return
howhot:
pause 750 ; provide enough time to initialise and also pause between temp reads
readtemp C.4,b1 ;read temperature value from Pin 3 into b1
return
display:
serout C.0,N2400,(254,1) ;Pin 7 clear screen
pause 30
serout C.0,N2400,(254,192,"Temp ",#b1,%11010010,"C ")
; transmit value to serial OLED with binary code for º symbol
return
offFan:
pwmout 2, 39, 0 ; fan off for such cases as the temp being below minimum
goto main
fiftyFan: ; pwm duty output
pwmout 2, 39, 80
goto main
sixtysixFan: ; pwm duty output
pwmout 2, 39, 106
goto main
seventysevenFan: ; pwm duty output
pwmout 2, 39, 123
goto main
eightyfiveFan: ; pwm duty output
pwmout 2, 39, 136
goto main
eightyeightFan: ; pwm duty output
pwmout 2, 39, 141
goto main
ninetyFan: ; pwm duty output
pwmout 2, 39, 144
goto main
fullFan: ; pwm FULL duty output
pwmout 2, 39, 160
goto main
alarm: ; maximum temperature reached!
;sound C.4, (100, 100) ; Pin 3 freq100, length 100 for future use
pwmout 2, 39, 160 ; fan on FULL
high LED ; switch the LED on C.1 high
pause 250 ; wait 0.25 sec
low LED ; switch off the LED
pause 100 ; wait 0.10 sec
high LED ; switch LED back on
pause 250 ; wait 0.25 sec
low LED ; switch off the LED
pause 400 ; wait 0.40 sec
goto main ; will stay at max until the temperature drops
interrupt: return ; helps with download errors
I'm late 30's and getting back into hobby electronics after a career change into photography for 16 years (I was initially a systems apprentice). I was put off 'micros' at college after spending HOURS typing in machine-code to achieve almost nothing, and always tending to stick to analogue electronics after that!
I'm currently studying Physics with the Open University, working part-time, and looking after the home & kids — so Picaxe fits into the small pockets of time that I manage to steal here and there..!