PDA

View Full Version : Dial switch diemna... need more ANalog ports



lerameur
- 8th November 2010, 19:09
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

mackrackit
- 8th November 2010, 19:57
Maybe use the POT or RCTIME command.

lerameur
- 8th November 2010, 20:31
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

Ioannis
- 8th November 2010, 21:26
They do exist and I think is called detent.

Look in ALPS.

Ioannis

LinkMTech
- 10th November 2010, 02:14
You can configure your own "switching" pot with a 7 position switch (http://www.mouser.com/ProductDetail/Alpha-Taiwan/SR2611F-0107-21F5B-D8-N/?qs=sGAEpiMZZMvNbjZ2WlReYnqYHrQfuERsPBC1pG6novE%3d ) and resistors then use only 1 A/D port.
4926
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:


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!

lerameur
- 11th November 2010, 13:12
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