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

newbies in C language

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



Joined: 13 Feb 2009
Posts: 3

View user's profile Send private message Send e-mail

newbies in C language
PostPosted: Fri Feb 27, 2009 9:15 pm     Reply with quote

hi everyone...

i am really new in this stuff..i need to compare two set of voltage using pic 16f877A..how do i achieve this...
IceMetal



Joined: 20 Nov 2008
Posts: 79
Location: white Plains, NY

View user's profile Send private message Yahoo Messenger

PostPosted: Fri Feb 27, 2009 9:45 pm     Reply with quote

you will need to start looking at ADC samples, whats the voltage range that you have?
sunny



Joined: 13 Feb 2009
Posts: 3

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 27, 2009 10:15 pm     Reply with quote

my voltage range is between 5V to 25V..thanks..i should try...
sunny



Joined: 13 Feb 2009
Posts: 3

View user's profile Send private message Send e-mail

PostPosted: Tue Mar 03, 2009 2:14 am     Reply with quote

This is my code. How can I refer to reference voltage and compare it with input voltage ? Does it have special code or something ?
Code:

#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif

#define LED pin_A5


void main() {

   int ref,voltage;

   setup_port_a( RA0_RA1_ANALOG_RA3_REF );
   setup_adc( ADC_CLOCK_INTERNAL );
   set_adc_channel( 0 );
   ref=5;
   
   while(true){
   voltage=read_adc();
    if(voltage>ref){
    output_high(LED);
    }
}
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