View previous topic :: View next topic |
Author |
Message |
cool121
Joined: 16 Mar 2011 Posts: 10 Location: US
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed May 18, 2011 6:06 am |
|
|
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
|
|
Posted: Wed May 18, 2011 6:16 pm |
|
|
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
|
|
Posted: Fri May 20, 2011 10:36 am |
|
|
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
|
|
Posted: Fri May 20, 2011 11:13 am |
|
|
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
|
|
Posted: Fri May 20, 2011 2:27 pm |
|
|
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
|
|
Posted: Fri May 20, 2011 7:40 pm |
|
|
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 |
|
|
|