multiple switches~one ADC


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Never cared much for the POT command. Seems not as stable. But that is me.

    I am going to look at your other option. Sounds interesting.
    Thanks!
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by mackrackit View Post
    Never cared much for the POT command. Seems not as stable. But that is me.

    !
    Hi, Dave

    I generally do not use POT ... but for 10-12 keys or less result is reliable with a reasonnable range of values for each key.

    soooo, I do it simple ( for once !!! )

    I'll try dig out the EPE Keybd ... it's somewhere in my HDD !!!

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  3. #3
    Join Date
    Sep 2006
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    Hi All, tried this code, its working but is there any other reliable way....

    adval var byte ' Create adval to store result

    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00000010 ' Set PORTA analog
    Pause 500 ' Wait .5 second
    loop: ADCIN 0, adval ' Read channel 0 to adval
    Lcdout $fe, 1 ' Clear LCD
    Lcdout "Value: ", DEC adval ' Display the decimal value
    Select case adval
    CASE is <51
    high porte.0
    cASE 102
    high porte.1
    CASE 153
    high portd.2
    CASE 204
    high portd.3
    CASE is >225
    low porte.0 : low porte.1 : low portd.2 : low portd.3
    Pause 150
    END SELECT
    pause 100
    Goto loop
    End
    * this below line is not accepting :ERROR
    case >1 to <53
    'do some thing
    case >53 to < 102
    'do some thing..
    So On.....

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    That way looks good to me.

    This part ...
    Code:
    * this below line is not accepting :ERROR
    case >1 to <53
    'do some thing
    case >53 to < 102
    'do some thing..
    So On.....
    Work something like this into your code, maybe before the CASE part. If the conditions are not met then the code will run to the CASE select part.
    Code:
    IF (ADVAL > 1) AND (ADVAL < 53) THEN ....
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2006
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    Thanks mackrackit, IF (ADVAL > 1) AND (ADVAL < 53) THEN ... this code is working..
    Since we using ADCIN for switches, should be able to TOGGLE the ports.. I have tried with WHILE..WEND also.. no luck.. Could you pls ..Thanks again.

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Can we see your WHILE/WEND code? Or better yet your new and updated code.
    But something like this should work
    Code:
    ADCIN 0, adval
    WHILE (ADVAL > 1) AND (ADVAL < 53)
    do something
    ADCIN 0, adval
    WEND
    SELECT CASE ....
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Sep 2006
    Posts
    42


    Did you find this post helpful? Yes | No

    Default

    Hi, The debounce was the problem..Following both codes are working after adding some delay.. I didnt use CASE.. Pls suggest if it needs to be fine tuned..Thanx..
    if (ADVAL > 200) AND (ADVAL < 256) THEN
    toggle porte.0
    pause 150
    endif
    -----------------------------------------------
    ADCIN 0, adval
    WHILE (ADVAL = 255) 'AND (ADVAL < 256)
    toggle porte.0
    pause 150
    ADCIN 0, adval
    WEND

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. multiple ADC using DSpic 30f3010
    By angeline in forum mel PIC BASIC
    Replies: 6
    Last Post: - 22nd February 2008, 10:03
  3. 18F1320 ADC multiple channel select
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th November 2005, 21:40
  4. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46
  5. Reading multiple ADC channels FAST
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st April 2004, 22:37

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