CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Potentiomter and pic18f452 question...<hardware question&

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
KamPutty
Guest







Potentiomter and pic18f452 question...<hardware question&
PostPosted: Tue Nov 15, 2005 6:27 pm     Reply with quote

Hi all,

Okay, I'm having major brainfarts, and I need to get moving with my project!
I want to read a value from a potentiometer, and display that value.

I can display etc., but need some telling on how to physically hook up the potentiometer to the pic (connect pinx to rez to pot etc.). I'm not a electronics person, and can handle the programming end, but may need some guidance. I currently have a pic18f454 physically hooked up and running on a 9vold, with lcd, so this should be a peace of cake...yes?!

INFO

I have currently 3 different pots I want to use, in order of importance.

#1. 100k OHM
#2. 20k OHM
#3. 200 OHM

All pots are 10 turn.
I would prefer the 100k as that yields a better resolution.

Any guidance in the hookup would be greatly appriciated!

~Kam (^8*
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Nov 15, 2005 7:05 pm     Reply with quote

Quote:
I have currently 3 different pots I want to use, in order of importance.

#1. 100k OHM
#2. 20k OHM
#3. 200 OHM

All pots are 10 turn.
I would prefer the 100k as that yields a better resolution.


If they are all the same tolerance and manufactured to the same standards, then they are all the same resolution.

Of the choices 2 is the best. A pot between 1K and 10K would have been better. You have to consider the loading into the A/D input unless you are using a voltage follower between the wiper and the PIC.

Connect one end of the pot to the VDD of the PIC (5V or 3.3V whatever you are powing the PIC from). Connect the other end of the pot to ground. Connect the wiper (usually the middle connection) to the A/D input on the PIC.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Tue Nov 15, 2005 7:15 pm     Reply with quote

asmallri wrote:
A pot between 1K and 10K would have been better.


The datasheet calls for input impedance under 2.5k. If you can get a pot with resistance less then 2.5k, you will have negligible distortion in your reading. If only a large value pots are available and you need high accuracy as well, consider bufering the output of your pot with an op-amp. Here's a reference schematic for the buffer: http://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/OpAmps/OpAmp3.html the very first drawing. Use a rail-to-rail op-amp such as LMC6462, this way you will not need the negative power supply.
kamputty
Guest







pot values
PostPosted: Tue Nov 15, 2005 7:18 pm     Reply with quote

Andrew, et al.,

The 3 pots I have are rated differently.

The pots I got are these: http://www.bourns.com/pdfs/3540.pdf

I got these 3: resistence=200, 20000 and 100000.

I would like to use the 100k as I understand, I can get better resolution for the 10 turns, yes?

Again, thanks for the reply!

~Kam (^8*
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Nov 15, 2005 7:30 pm     Reply with quote

Quote:

I would like to use the 100k as I understand, I can get better resolution for the 10 turns, yes?


No. If you are measuring voltage and put them in mid position they will all give you 2.5xx volts.

Kender is right about the 2.5K input impedance which is why a 1K would have been better however 10K will work provided you allow enough settling time. The higher value resistor will introduce a small error because of internal leakage current in the PIC however it is trivial.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
kamputty
Guest







Pot rez.
PostPosted: Tue Nov 15, 2005 7:45 pm     Reply with quote

Huh? Confused

Quote:
No. If you are measuring voltage and put them in mid position they will all give you 2.5xx volts.


Okay, now my head just exploded Shocked

I just cannot get this straight Crying or Very sad

All I want to do is this:

#1. Have a 10 turn pot that is checkable with a pic18f452 that has at least 768 unique "points" to it. In other words, I want to print the values 0 ~ 768 based on the pots 10 turns!

I purchased 3 different pots (200 OHM, 20k, and 100k). If they are all the same, then I can use the 200 OHM as its below the rating and pretty much just hardwire it to the pic....

Can someone please set me straight? I've gone mad, mad I tell you...

~Kam (^8*
cmdrdan



Joined: 08 Apr 2005
Posts: 25
Location: Washington

View user's profile Send private message

PostPosted: Tue Nov 15, 2005 8:35 pm     Reply with quote

Try this experiment, using your three potentiometers and a voltmeter, forgetting about your PIC....

Connect each pot to five volts and ground, and measure the voltage from the wiper to ground at each full turn, starting at zero turns and ending at 10 turns. Your readings should be the same (depending on how close to a complete turn you are) regardless of which pot you're testing. Potentiometers are ratiometric devices.

Now, back to the PIC. I'll assume that you're running at five volts and using a 10-bit ADC setup (since you stated 768 points). Zero volts will be represented by an ADC code of zero, and five volts will be represented by a code of 1023. If you were to turn the pot to the exact center of its rotation, you would see a code of 512, and a corresponding voltage of 2.5 volts if you were to measure it with your voltmeter.

The PIC works best with input resistances less than 2.5k ohms, and as the others have stated, you'd need a buffer amplifier to have success with your 20k and 100k pots. The 200-ohm pot is going to draw 25 mA (again assuming five volts) which is a little high for most practical purposes, and you may want to consider a 2k pot if this is a long-term project.

Hope this helps put your head back together!

Dan
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: Pot rez.
PostPosted: Tue Nov 15, 2005 8:48 pm     Reply with quote

kamputty wrote:
Huh? Confused

Quote:
No. If you are measuring voltage and put them in mid position they will all give you 2.5xx volts.


Okay, now my head just exploded Shocked

I just cannot get this straight Crying or Very sad

All I want to do is this:

#1. Have a 10 turn pot that is checkable with a pic18f452 that has at least 768 unique "points" to it. In other words, I want to print the values 0 ~ 768 based on the pots 10 turns!

I purchased 3 different pots (200 OHM, 20k, and 100k). If they are all the same, then I can use the 200 OHM as its below the rating and pretty much just hardwire it to the pic....

Can someone please set me straight? I've gone mad, mad I tell you...

~Kam (^8*


The pot, connected as I decribed, is just a voltage divider. Ignoring any loading caused by the PIC, it does not matter what the resistance of the pot is, the voltage at the wiper will be proportional to the position of the wiper. A 1R pot and a 1M pot will read the same voltage as each other at each corresponding angle of rotation of the pot.

The reason I did not suggest the 200R pot was because of the current consumption. I assumed (probably incorrectly) that you were running this from a 9 volt battery in which case you want to limit the current consumption to conserve the battery.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!


Last edited by asmallri on Tue Nov 15, 2005 8:59 pm; edited 1 time in total
kamputty
Guest







nearly there...
PostPosted: Tue Nov 15, 2005 8:51 pm     Reply with quote

Dan, et al.,

I think I get it! I was thinking that the OHM's and resolution where related as they listed a smaller/better resolution for the higher ohm's.

So, getting a 10 turn 2k ohm pot should work for me as this is a long term project...

Now to locate a 10 turn 2k pot!

Thanks!

~Kam (^8*
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Nov 16, 2005 9:24 am     Reply with quote

The 200 Ohm pot would work if you can handle the power. At 5V the pot will dissapate P=E^2/R = 125mW and draw 25mA from your supply. Depending on the application that may be OK.
Otherwise if the pot is only going to turn slowly, like by a human hand, you can lower the impedance seen by the A/D by putting a capacitor on the wiper of a high impedance pot. Something like 1.0uf or 0.1uf should satisfy the A/D input. Put the cap from the A/D input to ground. If the chip has a seperate analog ground pin that is the ground you should use for both the cap and the pot.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group