|
|
View previous topic :: View next topic |
Author |
Message |
William Guest
|
PIC16C774 12-bit ADC |
Posted: Tue Jul 08, 2003 10:28 am |
|
|
I am using the PIC16C774's built in ADC. I assign the read_adc() value to 16 bit unsigned value. The numbers I am getting are greater than 2^12, which is the resolution of the ADC. It seems the values are on the range of 2^16. Does the compiler shift the bits left after the read? Any suggestions?
Below is a snapshot of the ADC code.
#include <16C774.h>
#device ADC=12
.
.
.
typedef long uint16;
uint16 rateOut = 0;
.
.
.
setup_adc_ports(ALL_ANALOG|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
rateOut = read_adc();
printf("Gyro = \%lu \r\n", rateOut);
Thanks...
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515791 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: PIC16C774 12-bit ADC |
Posted: Tue Jul 08, 2003 11:37 am |
|
|
:=I am using the PIC16C774's built in ADC. I assign the read_adc() value to 16 bit unsigned value. The numbers I am getting are greater than 2^12, which is the resolution of the ADC. It seems the values are on the range of 2^16. Does the compiler shift the bits left after the read? Any suggestions?
:=
-------------------------------------------------------
It's controlled by the ADFM bit. This post tells how to fix it:
<a href="http://www.pic-c.com/forum/general/posts/12580.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/12580.html</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515793 |
|
|
R.J.Hamlett Guest
|
Re: PIC16C774 12-bit ADC |
Posted: Tue Jul 08, 2003 12:14 pm |
|
|
:=I am using the PIC16C774's built in ADC. I assign the read_adc() value to 16 bit unsigned value. The numbers I am getting are greater than 2^12, which is the resolution of the ADC. It seems the values are on the range of 2^16. Does the compiler shift the bits left after the read? Any suggestions?
:=
:=
:=Below is a snapshot of the ADC code.
:=#include <16C774.h>
:=#device ADC=12
:=.
:=.
:=.
:=
:=typedef long uint16;
:=uint16 rateOut = 0;
:=.
:=.
:=.
:=setup_adc_ports(ALL_ANALOG|VSS_VDD);
:=setup_adc(ADC_CLOCK_INTERNAL);
:=set_adc_channel(0);
:=rateOut = read_adc();
:=printf("Gyro = \%lu \r\n", rateOut);
:=
:=
:=
:=Thanks...
PCM programmer has answered this, but I have to make one other comment. You need a time delay, between selecting an adc channel, and reading it. The input signal has to charge the capacitance represented by the input, so the delay needed depends on the impedance of the source, and the accuracy you require. Typically something in the order of about 10uSec, is needed with a reasonably low source impedance. Otherwise your actual 'accuracy', will fall well below the adc's resolution...
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515794 |
|
|
|
|
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
|