Hi Polymer
try this - I used a 12F683
Take care
Alec


'************************************************* ***************
'* Name : fan controller_forum *
'* Author : Alec Noble *
'* Notice : Copyright (c) 2010 Alec Noble *
'* : All Rights Reserved *
'* Date :1/3/2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
@DEVICE=PIC12F683
define OSC 8
OSCCON = %01110001 ' Internal 8MHz osc
CMCON0 = 7 ' Comparators off
WPU = 0 ' Internal pull-ups = off
'GPIO = %00000000 ' All outputs = 0 on boot
TRISIO = %000000001 ' GPIO.0=data in, GPIO.2=PWMout, GPIO,1,3,4,5 unused

'******************** set up ADC ************************************
ANSEL = %00010001 'gpio.0 analog, others digital, ADC clock fosc/8
DEFINE ADC_BITS 10 ' ADCIN resolution (Bits)
DEFINE ADC_CLOCK 1 ' ADC clock source (Fosc/8)
DEFINE ADC_SAMPLEUS 11 ' ADC sampling time (uSec)
adcon0.7 = 1

'********************* define variables *******************************
sensor var word
temp var word
span var byte
duty var word
'********************** intitialize variables *************************
duty = 0
temp = 0
span = 0

'********************** Program starts here **************************
main:
HPWM 1, duty, 5000 'set PWM output
adcin 0, sensor 'read temperature sensor
sensor = sensor * 500
temp = div32 1023 'convert ADC to degrees
span = temp - 90 'get range above 90 degrees

if temp < 90 then 'less than 90 degrees PWM off
duty = 0
endif

if temp > 90 and temp < 120 then
duty = 130 + (span * 4) 'between 90 and 120 start with 50% and linearly
endif 'raise rate up to 120 degrees

if temp > 120 then 'above 120 degrees 100%
duty = 255
endif

pause 100 'pause to avoind to frequent cycling
goto main 'do it again