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
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    a range from 0-32!!

    if you use a 10Bit resolution
    Code:
    Adcin 0,Initial
    Final=Initial>>5
    change 5 for 3 if you use a 8 bit resolution.

    32= 2^5 or 5 bit resolution

    Im i still mixed in my head... maybe, as now, it looks good to me.

    10 bit resolution = range of 1024
    8 bit resolution = range of 256

    1024/32 =>32
    256/32 =>8

    and blah blah blah... i feel like a pre-school teacher today
    Last edited by mister_e; - 28th August 2005 at 16:11.
    Steve

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

  2. #2
    mengckid's Avatar
    mengckid Guest


    Did you find this post helpful? Yes | No

    Default

    Hi...I need some helps here...once again,i will post my Pic Basic Pro Code below,hopefully somebody will help me fixed my code, bcoz i just cant get the result that i want...

    The Code:

    include "modedefs.bas"
    DEFINE OSC 4

    ' Define ADCIN parameters
    DEFINE ADC_BITS 8 ' Set number of bits in result
    DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 10 ' Set sampling time in microseconds

    B0 var BYTE ' Create B0 to store result

    TRISB = %10000000 ' set output for led portb.0
    TRISC = %11111000 ' set output for pwm portc.2
    TRISA = %111111 ' Set PORTA to all input

    CCP1CON = %00001100 ' Set CCP1 to PWM
    ADCON1 = 0 ' for 10-bit ADC and Set all PORTA is analog

    HIGH PORTB.0

    GOSUB GETMBAT 'read voltage variable
    main:

    ADCIN 0,B0 ' Read channel 0 to B0
    B0 = B0 >> 3 'justify data

    if (B0>0) and (B0<5) THEN
    PWM PORTC.1,10,100
    endif
    if (B0>5) and (B0<10) THEN
    PWM PORTC.1,30,100
    endif
    if (B0>10) and (B0<15) THEN
    PWM PORTC.1,60,100
    endif
    IF (B0>15) AND (B0<20) THEN
    PWM PORTC.1,100,100
    endif
    IF (B0>20) AND (B0<25) THEN
    PWM PORTC.1,127,100
    endif
    IF (B0>25) AND (B0<28) THEN
    PWM PORTC.1,160,100
    endif
    IF (B0>28) AND (B0<30) THEN
    PWM PORTC.1,200,100
    endif
    if (B0>30) and (B0<32) then
    PWM PORTC.1,254,100
    endif

    GOTO main

    GETRESULT:
    PAUSEUS 50 'WAIT FOR ADC SETUP
    ADCON0.2 = 1 'START CONVERSION BY SETING GO/DONE BIT HIGH

    LOOP: ' WAIT FOR GO/DONE BIT TO CLEAR
    IF ADCON0.2 = 1 THEN
    GOTO loop
    ENdif
    goto main


    GETMBAT:
    ADCON0 =%00000101 'SET A/D Fosc/32, [4MHz], CHANNEL-0 = ON
    GOSUB GETRESULT 'START CONVERSION
    B0 = ADRES 'STORE THE A/D CONVERSION VALUE IN RESULT
    RETURN


    The PIC that I am using is PIC 16F874A, and i am trying use a 10k potentiometer to control the motor speed (increase or decrease the speed). Thus, I try the HPWM before, just cant get the result also.

    Hopefully, somebody will help me...thanks u

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