How to use a potentiometer resistor to control speed of motor fan manually?Thanks


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    mengckid's Avatar
    mengckid Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by markedwards
    Hi Mengckid,

    You did't mention which PIC you were using or what application.
    Here is code that I use with hardware pwm (HPWM).
    My application requires 5 speeds and a 60% minimum speed setting.
    You can add more comparisons or calculate speed settings based on AD1.
    There are 2 lines that control acceleration & de-acceleration
    I like the hardware pwm best, it runs consistent speed
    while your program executes other code. It will work with PWM if you change the last line.

    ADCIN 1,AD1 'read channel 1...AN1
    AD1 = AD1 >> 6 'justify data

    ADJUSTFAN:
    IF AD1 < 2 then FANSPEED = 153 '60% min speed
    IF AD1 >= 3 then SPEED = 178 '70%
    IF AD1 >= 5 then SPEED = 204 '80%
    IF AD1 >= 7 then SPEED = 229 '90%
    IF AD1 >= 9 then SPEED = 255 '100%
    IF SPEED > SPD THEN SPD = SPD + 1 'accelerate
    IF SPEED < SPD THEN SPD = SPD - 1 'de-accelerate
    hpwm 2,SPD,32760 ' PWM 20,000 Hz

    Mark
    Thanks u,anyway... you are so great,ur code help me much,thanks u

    The PIC i am using is PIC16F874A, and the application is used the single turn 10k potentiometer to increase or decrease the speed of motor fan in another pin in PIC. Meaning,i will use a N-channel MOSFET to drive the current to motor fan.

    Sorry for that, if I willing to use PWM command to control speed of motor fan, meaning accelerate or de-accelerate it, can I do that?

    Hopefully, you can help me, thanks a million

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    if I willing to use PWM command to control speed of motor fan, meaning accelerate or de-accelerate it, can I do that?
    If you mean PWM instead of HPWM you'll be disapointed, PWM do only few cycle and don't run in background. AND MORE, the signal generated is quite poor. This is really not what you need.

    If your PIC don't have any PWM module, you can still use timer interrupt to generate the PWM signal.

    HPWM is the way to go. It could be as simple as...
    Code:
    START:
        ADCIN 0,MotorSpeed
        HPWM MotorSpeed
            '
            ' Other code here
            '
        GOTO START
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    I have to agree with Mr E, HPWM is definitely the way to go. Once you set it it keeps on running until PWM which needs to be refresh all the time. We use an op-amp with high input impedence along with a small capacitor attached to the IO so that we can do other things with out having to refresh all the time. It's not a smooth an output as the HPWM but it does work. The capacitor slowly discharges through the op-amp.

Similar Threads

  1. brushless speed control
    By jetpr in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 24th December 2009, 15:23
  2. Replies: 14
    Last Post: - 26th September 2007, 05:41
  3. Speed Control (help Idea)
    By jetpr in forum General
    Replies: 0
    Last Post: - 1st November 2005, 01:51
  4. speed control
    By Kees Reedijk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st March 2005, 23:07
  5. Electronic speed control
    By actionplus in forum Schematics
    Replies: 10
    Last Post: - 21st June 2004, 19:01

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