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 CCS Technical Support

capacitance meter

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



Joined: 16 Mar 2011
Posts: 10
Location: US

View user's profile Send private message

capacitance meter
PostPosted: Wed May 18, 2011 5:50 am     Reply with quote

http://www.pic_examples.byethost3.com/capacitance_meter.html

I'm going to build above meter using pic18f4550. can somebody give me the picc code for this.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed May 18, 2011 6:06 am     Reply with quote

Well...you've got 3 choices

1) convert the C code from the webpage to CCS C. Easy to do, maybe 1-2 hours

2) create or locate a 'sourcecode' translation program.Not so easy, but doable in 1 -2 days

3)use 'google' to locate CCS C code.Simple these day, maybe 10-20 minutes....
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed May 18, 2011 6:16 pm     Reply with quote

If you go for option 1 you have a fair chance of learning HOW the code works. That means you can modify it to do exactly what YOU want instead of what to original coder wanted.
_________________
The search for better is endless. Instead simply find very good and get the job done.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri May 20, 2011 10:36 am     Reply with quote

I really hate how somebody says, "I want to do this project, now give me the code so I don't have to think". TRY to learn HOW to do something, that way you don't have to keep asking for somebody else to do it for you.

Ronald
Pie are square, right?
cool121



Joined: 16 Mar 2011
Posts: 10
Location: US

View user's profile Send private message

PostPosted: Fri May 20, 2011 11:13 am     Reply with quote

I did it. but it does not give correct value.

Code:

#include <16F877A.H>
#device adc=8
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=16000000)

#include <lcd.c>
#Byte PR2= 0x92
unsigned int32 cnt=0;

#INT_TIMER2
 void timer2_isr(){
 CLEAR_INTERRUPT(INT_TIMER2);
 cnt++;
 set_timer2(0);
 PR2=66;
 }

void main()
{
lcd_init();
 setup_adc_ports(ALL_ANALOG);
setup_comparator(A0_A3_A1_A2);
setup_timer_2(T2_DISABLED,255,1);
C1OUT=1;
while(1){
 
if(!input(PIN_B0)){
   cnt=0;
   set_timer2(0);
   setup_timer_2( T2_DIV_BY_4,40, 1);
   OUTPUT_HIGH(PIN_B4);
 
   ENABLE_INTERRUPTS(INT_TIMER2);
   ENABLE_INTERRUPTS(GLOBAL);
   
   while(!C1OUT){}
      OUTPUT_LOW(PIN_B4);
      disable_interrupts(GLOBAL);
      setup_timer_2(T2_DISABLED,255,1);

      float VAL=cnt*10;
      lcd_putc("\f");
      printf(lcd_putc,"%f",VAL);
     delay_ms(200);
}
 
}
 
     
}
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri May 20, 2011 2:27 pm     Reply with quote

Since few of us have your PIC and none of us have your hardware...can you give us a hint? What sort of value does it give you? Does it print anything? Does it print a number? Does it print a stable number? Is the error small or huge?

For troubleshooting this sort of circuit it really helps to have a scope. Put the scope on the capacitor you are measuring and see if the waveform is what you expect. Of course you need to understand how the system should work to know what waveform to expect.
_________________
The search for better is endless. Instead simply find very good and get the job done.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri May 20, 2011 7:40 pm     Reply with quote

rnielsen wrote:
I really hate how somebody says, "I want to do this project, now give me the code so I don't have to think". TRY to learn HOW to do something, that way you don't have to keep asking for somebody else to do it for you.



Most of the time I ignore such "demands" for help. Sometimes I tell the person they'd probably attract a lot more help if they asked for it rather than insisted on the straight path to insistence/demanding.

-Ben

p.s. and yes, I realize sometimes there's a language barrier too.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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