View previous topic :: View next topic |
Author |
Message |
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
measurement linearity ??? |
Posted: Wed Feb 06, 2008 9:00 am |
|
|
Hi guys can't figure out why my results are not linear , i'm using a potentiometer to measure a 0 to 90 degre movement , the pot is linear (i did measure it) but my A2D count are not any idea why ???
here part of the code that show settings
the pot is simply connected as a divider between vcc and ground with wiper directely coneected to AN0
Code: |
#include <16F877A.h>
#device adc=10
int16 ANGLE_POS , OLD_ANGLE_POS ;
setup_adc_ports(AN0); // Setup a2d ch 0
setup_adc(ADC_CLOCK_DIV_16);
while(1)
{
set_adc_channel(Pot_ANGLE);
delay_ms(50);
ANGLE_POS=read_adc();
if(ANGLE_POS != OLD_ANGLE_POS)
{
printf(lcd_putc,"\f%Ld ",ANGLE_POS);
OLD_ANGLE_POS = ANGLE_POS;
}
} |
|
|
|
Ttelmah Guest
|
|
Posted: Wed Feb 06, 2008 9:34 am |
|
|
What is the resistance of the pot?.
Though it should be OK, given the relatively 'long' settling time you give, there may be a problem with the loading, if the pot has a high resistance. Look at the 'analog input model' in figure 11-2 of the data sheet. If (for instance), the pot was 1MR, the leakage current would cause the values especially in the centre of the range, to read well low, and the time needed for the internal capacitor to charge would also become significant. Look at the last line in the note above...
Best Wishes |
|
|
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
|
Posted: Thu Feb 07, 2008 5:07 am |
|
|
i was using a 10k pot , now i replaced it with a 2.5k and no change !!! as i'm moving only 90 degre i tried using upper or bottom part of the pot . no change , the voltage readings are not linear lets say that between 80 and 90 degre i have 140 mV change and between 0 and 10 degre 175mV !!!
any idea of what can be done ??? |
|
|
Ttelmah Guest
|
|
Posted: Thu Feb 07, 2008 5:56 am |
|
|
One possibility, relates to how well you have the processor supply decoupled at the chip. Since you are using the supply for the reference, and because of the way the PIC ADC works, if there is noise present on the supply rail, you can get exactly this type of behaviour. Obviously the same comment applies regarding noise on the incoming signal (35mV, is only going to be 7 counts on the ADC), but normally this tends to work the other way round (giving increased radings away from the supply rails). Are you really _sure_ of the linearity of the pot - unless you are using high accuracy types, most are not that good...
Best Wishes |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Feb 07, 2008 8:07 am |
|
|
Are those mV readings as calculated from the A/D or from an independent voltmeter? I would like to know if the voltage at the PIC pin is linear. That would help determine if it is a digital problem or analog problem. _________________ The search for better is endless. Instead simply find very good and get the job done.
Last edited by SherpaDoug on Thu Feb 07, 2008 10:28 am; edited 1 time in total |
|
|
mindstorm88
Joined: 06 Dec 2006 Posts: 102 Location: Montreal , Canada
|
|
Posted: Thu Feb 07, 2008 8:47 am |
|
|
Ok guys here it is !!!
the f!@#$@ pots were too cheap and not really linear !!!
So i took a high quality multiturn , as a 90 degre turn doesn't give a big voltage span i put it into a diferentiator with a reference voltage for the 0 .the differntiator has a gain that allow me to get a span of 2.5 VDC for my 1\4 turn giving about 5 count per degre, as i need only 1 degre precision this is now working good with few part addon !!! best way in future would be to use an encoder !!!
Thanks guys for your time !!! |
|
|
|