Proportional fan control. I suck at math!


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    brookfield, ct, usa
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    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

  2. #2
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    I think Malcolm had it... it's about 8.5 PWM steps per degree, over a 30 degree span.

    So, something like this?


    Code:
    If temp < 90 then 
    	duty = 0
    else
    	duty = (temp - 90)  * 85 /10   'subtract 90 from temp, and multiply * 8.5
    endif


    steve

Similar Threads

  1. How do I give a radio control car autonomous control
    By Kenjones1935 in forum General
    Replies: 190
    Last Post: - 17th January 2010, 16:40
  2. Transistor selection, PWM fan control
    By 124C41 in forum Schematics
    Replies: 5
    Last Post: - 22nd December 2008, 16:33
  3. Control RC servo via Parallax Servo Control
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th September 2005, 09:18
  4. Replies: 9
    Last Post: - 30th August 2005, 07:33

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts