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

ADC WITH 16F877

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







ADC WITH 16F877
PostPosted: Thu Apr 16, 2009 7:05 am     Reply with quote

hello my friends
I want to send a positive SIGNAL alternative (0-5v) to the PIC 16F877 by PORT A (RA0) and send it to pc via rs232 to see what signal (interface to the signal with delphi or vb ....)
I wrote a program :
Code:
 #include "C:\Documents and Settings\youcef\Mes documents\fin.h"
int  adcValue;
float result;
void main()
{
   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_DIV_8);
   set_adc_channel(0);
   delay_ms(20);
   while(true){
     adcValue=read_adc();
         result = (float)(adcValue)*5/255;
         printf("%f",result);
         delay_us(40);
        }
   
 

   // TODO: USER CODE!!

}

is what this program is sufficient to make this work and thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 16, 2009 1:29 pm     Reply with quote

Post the contents of this file:
Quote:
"C:\Documents and Settings\youcef\Mes documents\fin.h"

Then we can check the parameters used in your program.

Also post your compiler version.
sapy44



Joined: 01 Feb 2004
Posts: 19
Location: Cedar Rapids, IA

View user's profile Send private message MSN Messenger

int bit resolution
PostPosted: Thu Apr 16, 2009 3:17 pm     Reply with quote

With the 16F877 the ADC value is 10 bits. A simple int declaration will create an 8-bit variable. Try using int16 instead. You will all need to multiply by 1023 instead of 255.
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