Dial switch diemna... need more ANalog ports


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default Dial switch diemna... need more ANalog ports

    hello,

    I I am using the pic16f88 and I do not wish to change chip, but my dilemna is that I need more analog port. I want to add a selection button, where if you set the dial button on 1 it will put AN1 high, if dial button is set on 2 then AN2 will be high etc...
    I need 7 selection (so seven input pin) but I am only left with 3 ports to use.
    Is there anything like a analog to digital switch? or an alternative to either the switch or anything else that will give the same result?

    thanks
    K

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


    Did you find this post helpful? Yes | No

    Default

    Maybe use the POT or RCTIME command.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yes I need a pot switch, But I never seen one that has grooves in them so it do not change position by its own .. does that exist??

    K

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,131


    Did you find this post helpful? Yes | No

    Default

    They do exist and I think is called detent.

    Look in ALPS.

    Ioannis

  5. #5
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Use only 1 A/D

    You can configure your own "switching" pot with a 7 position switch and resistors then use only 1 A/D port.
    Name:  7 Pos SW.jpg
Views: 190
Size:  43.9 KB
    The values selected were not calculated for anything special just picked something that would probably give a decent spread for a 10bit A/D setting. Then using the SELECT CASE, set the values to the level "between" each setting.
    Suppose position 1 value is 170 and position 2 is 327 then make your 1st CASE setting to 248, middle of the two values, and continue from there for the whole range.

    Sample code:
    Code:
    check_switch:     
        ADCIN #, adval    
        SELECT CASE adval
            CASE IS < xxx: do this or that   ' Lowest value
            ......
            CASE IS < xxx: do this or that   ' Highest value   
        END SELECT    
    RETURN
    I just made this a couple of months ago and works as needed!
    Louie

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    thats agood idea, I used a similar switch arrangment but I will drop my if then statement and use Select case, I dod not know it was in picbasic, I used it in C++ a long time ago.
    thanks

    L

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