PWM fan speed control with a 12F683


Results 1 to 18 of 18

Threaded View

  1. #1
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305

    Default PWM fan speed control with a 12F683

    Ladies and Gents,
    I'm trying to use a 12F683 to control a fan motor. I want to be able to push a button and have the fan cycle through speeds from off to high in 3 steps.

    The problem is I can't figure out how to use PWM indefinitely.

    This is my program. I've got the push button on GPIO.3 and the fan currently on GPIO.5. It works kinda but the selected speed only lasts for the length of time PWM is set. During that time you can't select another speed.

    Your thoughts would be appreciated.

    clear
    define osc 4
    @ device mclr_off 'the input will be through GPIO.3
    ansel = 0 'all ports digital
    cmcon0 = 7 'turn off comparators
    adcon0 = 0

    touchnumber var byte 'count the number of touches
    outTOfan var gpio.5 'LED symbolizing fan speed
    trisio = %001111
    touchnumber = 0

    starthere:
    outtofan = 0
    If gpio.3 = 1 then goto main
    goto starthere
    main:
    touchnumber = touchnumber + 1
    if touchnumber =4 then touchnumber = 0
    select case touchnumber
    case 0
    gpio.5 = 0
    case 1
    pwm gpio.5, 60,1000
    case 2
    pwm gpio.5,150, 1000
    case 3
    pwm gpio.5, 255, 1000
    end select
    goto starthere

    end
    Last edited by AvionicsMaster1; - 30th June 2011 at 19:55. Reason: add tags

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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