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

PIC16C774 12-bit ADC

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







PIC16C774 12-bit ADC
PostPosted: Tue Jul 08, 2003 10:28 am     Reply with quote

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

View user's profile Send private message

Re: PIC16C774 12-bit ADC
PostPosted: Tue Jul 08, 2003 11:37 am     Reply with quote

:=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
PostPosted: Tue Jul 08, 2003 12:14 pm     Reply with quote

:=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
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