Title: Pic16F877A A/D Converter Post by: smoogy on August 23, 2007, 06:22:46 06:22 Hi. I just tried to make a program to read an input voltage from an infrared sensor to convert it then to a digital output but it won't get compiled. Here's my code:
define osc 20 DEFINE ADC_BITS 8 ' Set number of bits in result DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3) DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds B0 var byte trisa = 255 ' Set PORTA to all input trisb = 0 ADCON1 = 2 ' PORTA is analog main: ADCIN 0, B0 if B0<125 then portb.0=0 else portb.0=1 endif goto main Can anyone help me? Title: Re: Pic16F877A A/D Converter Post by: GreenGiant on August 23, 2007, 08:07:58 08:07 Does it not compile or does it not work ?
If not compile, also post what error it puts out. Title: Re: Pic16F877A A/D Converter Post by: mcr on August 23, 2007, 08:56:45 08:56 Does it not compile or does it not work ? If not compile, also post what error it puts out. Do that please. Title: Re: Pic16F877A A/D Converter Post by: RCO on August 23, 2007, 09:06:42 09:06 smoogy
The code compiles fine here, using Picbasic Pro 247 and MPASM ;) Title: Re: Pic16F877A A/D Converter Post by: smoogy on August 30, 2007, 05:08:36 05:08 Thanks everyone. Code was fine. My pbp installation needed to be repaired due to missing files. :-[
Title: Re: Pic16F877A A/D Converter Post by: revoltage on September 05, 2008, 05:46:06 17:46 What infrared sensor did you used? Sharp IR?
Title: Re: Pic16F877A A/D Converter Post by: ero on September 07, 2008, 07:24:37 07:24 Pic 16F877A having also a default comparator (Pic16F877 not). You have to cancel it first by putting following command;
CMCON=7 otherwise some pins of PORTA will not work properly. Try it. Ero |