using a pot to control a time range


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Question timing issues

    no this is not the entire programs i have my defines set as follows

    'Definitions'
    DEFINE OSC 4
    DEFINE ADC_BITS 10 ' set number of bits in result
    DEFINE ADC_CLOCK 3 ' set clock source
    DEFINE ADC_SAMPLEUS 50 ' set sampling time for microseconds
    'Definitions'

    'Register Initializations'
    ADCON0 = %10000011
    ANSEL = %00000011 ; A to D on AN0 and AN1
    'ANSELH = %00001100
    CMCON = %00000111
    TRISIO = %00011111 ; define Inputs and Outputs
    GPIO = %00000000 'set all pin states to off
    'OPTION_REG = %11100000
    WPU = %00000000
    'Register Initializations'


    'Variables'
    LOAD_OUT VAR GPIO.5
    DELAY VAR WORD
    COUNTER VAR WORD
    AD_AN0_VALUE VAR WORD
    MAIN_TRIGGER VAR GPIO.2
    A1 var Byte
    i var word


    im trying to achieve multiple time ranges. for example 0.5 sec to 5 sec, and i want to use the pot to adjust in that range.

    But when i do the AD conversion it is giving me a number between 0 and 1024. But inorder to get my specific range i need a value of 50 to 500.

    I am basically trying to figure out a way to spread the 50 to 500 range out over the full 0 to 1024 range so i get the same resolution and get my two endpoints of 50 and 500.

    I have also changed thge code as follows.

    MAIN:
    A1 = %00000000
    GOSUB READ_A_D_AN0
    LOAD_OUT = 1 ' ON FIRST TRIGGERABLE
    PAUSE 100
    BUTTON MAIN_TRIGGER, 1, 255, 0, a1, 0, RUN
    PAUSE 100
    GOTO MAIN


    TIME:

    for i = 1 to counter step 1
    FOR DELAY = 1 TO 10 STEP 1
    PAUSE 1
    GOSUB READ_A_D_AN0
    NEXT DELAY
    next i
    RETURN

    RUN:
    PAUSE 10
    LOAD_OUT = 0
    GOSUB TIME
    PAUSE 10
    GOTO MAIN

    I appreciate the help, thank you very much.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Talking K.i.s.s. ...

    Hi,

    The simplest way :

    Time = ( ADC result >> 1 + 50 ) MIN 500 ...

    or better

    Time = ( ADC Result >> 1 + 50 ) * 8 / 9

    Applause ... Thanks !

    Alain
    Last edited by Acetronics2; - 17th June 2008 at 20:17.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. 16F877 elapsed time control
    By BerkayT in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 12th February 2009, 17:23
  2. servo control via pot ?
    By n0oxv in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 1st March 2007, 07:11
  3. Control unlimited servos at the same time
    By mrx23 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th September 2006, 14:14
  4. Button pressed time control
    By tanero in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 15th August 2005, 15:17
  5. trying the pot command to control delay
    By reddogtj in forum mel PIC BASIC
    Replies: 2
    Last Post: - 20th May 2005, 12:50

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