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
Posted: Thu Apr 16, 2009 1:29 pm
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
int bit resolution
Posted: Thu Apr 16, 2009 3:17 pm
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.
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