Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 27th May 2004, 03:03 PM   #1
Default Potentiometer problem on PIC chip.

I'm trying to use a potentiometer to input one of four values to a 16F84 PIC chip, but I'm having problems. The value seems to go up exponentially as I slide the potentiometer, which doesn't make sense to me. As I slide it constantly, it will read:

0.........................1............2.....3.4.6 .16......................................

Smaller capacitors increase the size of the range that gives me 0, but decrease the range in which it goes from 1 to 16. I get that same effect when I change the scale value on the pot command.

Thanks for any help. If I posted in the wrong forum or somesuch, I apologize.

edit: I have a diagram of the circuit, in case it helps.



My program is:

Code:
Symbol TrisB = 134
Symbol PORTB = 6
Poke TrisB, 1
Poke PORTB, 0
loop1: Pot 0, 255, B0
	   Poke PortB, B0
	   GoTo loop1
RumpinRufus is offline  
Old 27th May 2004, 06:52 PM   #2
Default

It's an exponential "audio taper" pot. You seem to want "linear taper".
Oznog is offline  
Old 27th May 2004, 07:46 PM   #3
Default

You've also drawn the diagram wrong, you have the pot connected from HT to the capacitor, and not to any pin!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 28th May 2004, 02:31 PM   #4
Default

Quote:
Originally Posted by Oznog
It's an exponential "audio taper" pot. You seem to want "linear taper".
Thank you very much, I guess I should have checked that before I bought them.

And I fixed the diagram, thanks for the help.
RumpinRufus is offline  
Old 28th May 2004, 11:10 PM   #5
Default

Listen to Nigel too, I didn't study the schematic. If you hooked it up like you drew the schematic, it's hooked up wrong.
Oznog is offline  
Old 29th May 2004, 09:53 AM   #6
Default Re: Potentiometer problem on PIC chip.

The pot should be connected between the pin and the capacitor, not the 5v rail.
M.K.


Quote:
Originally Posted by RumpinRufus
I'm trying to use a potentiometer to input one of four values to a 16F84 PIC chip, but I'm having problems. The value seems to go up exponentially as I slide the potentiometer, which doesn't make sense to me. As I slide it constantly, it will read:

0.........................1............2.....3.4.6 .16......................................

Smaller capacitors increase the size of the range that gives me 0, but decrease the range in which it goes from 1 to 16. I get that same effect when I change the scale value on the pot command.

Thanks for any help. If I posted in the wrong forum or somesuch, I apologize.

edit: I have a diagram of the circuit, in case it helps.



My program is:

Code:
Symbol TrisB = 134
Symbol PORTB = 6
Poke TrisB, 1
Poke PORTB, 0
loop1: Pot 0, 255, B0
	   Poke PortB, B0
	   GoTo loop1
MarkK is offline  
Old 2nd June 2004, 10:47 AM   #7
Default

Mhhh..

Isn't this a better way..

connect the + to a 220Ohm resistor then the middle pin of a potentio meter (50K) then connect the last one or the first one to the 0volt line

then put a cable from the analog pin to the middle pin of the potentiometer

you can test it whit your multimeter..!!!

when you move the resistor there will be another voltage over the smaller Res. and that's what we want.

if you use other values you will get otherreactions..when turning the pot meter.


TKS
TKS is offline  
Old 2nd June 2004, 02:56 PM   #8
Default

Quote:
Originally Posted by TKS
Mhhh..

Isn't this a better way..

connect the + to a 220Ohm resistor then the middle pin of a potentio meter (50K) then connect the last one or the first one to the 0volt line

then put a cable from the analog pin to the middle pin of the potentiometer

you can test it whit your multimeter..!!!

when you move the resistor there will be another voltage over the smaller Res. and that's what we want.

if you use other values you will get otherreactions..when turning the pot meter.


TKS
He's using a 'F84 wich doesn't have an AD converter, the Pot command in basic uses a capacitor charge technique to test the voltage on the input, it measures the time taken to load the capacitor and can approximate the voltage with it. So what you discribe won't work, your system would just put a steady voltage on the input depening on the potentiometer position, measuring this requires an AD
Exo is offline  
Old 2nd June 2004, 04:18 PM   #9
Default ahhh

Now i untherstand..

i pulss down the pin...

and wait when it raises by it self..

and the amout of time needed for that gives him a rough indication..

of it... mhh..smart...

but not accurate..

TKS

the way i have described i sue self but self i'm finding problems because i cant find the 1023 value...
TKS is offline  
Old 2nd June 2004, 06:15 PM   #10
Default Re: ahhh

Quote:
Originally Posted by TKS
Now i untherstand..

i pulss down the pin...

and wait when it raises by it self..

and the amout of time needed for that gives him a rough indication..

of it... mhh..smart...

but not accurate..
It can be surprisingly so, and you can easily exceed 8 bit resolution - and this is actually how your PC joystick ports work!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 2nd June 2004, 10:10 PM   #11
Default

I believe it would be a good idea to put a current limiting resistor in series with the pot to prevent the latch on the I/O pin from being destroyed when the pot is set to zero.
kurtjo is offline  
Old 2nd June 2004, 11:39 PM   #12
Default

Quote:
Originally Posted by kurtjo
I believe it would be a good idea to put a current limiting resistor in series with the pot to prevent the latch on the I/O pin from being destroyed when the pot is set to zero.
Yes, the circuit as posted has never managed to be a workable design.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 4th June 2004, 01:25 PM   #13
Default

Quote:
Originally Posted by kurtjo
I believe it would be a good idea to put a current limiting resistor in series with the pot to prevent the latch on the I/O pin from being destroyed when the pot is set to zero.
Or the pot could, more correctly, be connected between pin and capacitor instead of the plusV rail.
MarkK is offline  
Old 9th June 2004, 03:01 PM   #14
Default

Son of a crap! I even had a test circuit set up the right way at one point. Thanks a million for helping me out.
RumpinRufus is offline  
Reply

Thread Tools
Display Modes




All times are GMT. The time now is 03:29 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker