Mikroc adc uart problem

Status
Not open for further replies.

aswathymohan

Member level 4
Joined
Nov 11, 2012
Messages
68
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,288
Visit site
Activity points
1,727
I wish to display the adc values coming from serial port to hyper terminal.I have created a level shifter circuit with sine wave (5 vp-p) and 2.5 v dc as inputs and input the data to the pic 16f877a

wat i m getting from the terminal are in the range of 2.5-8.6v,since i gave input below 5.0v ,i got more than tat i expected.

i have attached mikroc code,can ayone tell me how to fix this issue

Code:
char uart_rd[50],uart1_rd,uart_rd1[50];  //Declare the character strings
float val,val1;//Declare the adcvalue stored variables



void main()
{
    TRISA=0XFF;//porta as input
    ADCON1=0X80;
    UART1_Init(9600);               // Initialize UART module at 9600 bps

    while(1)
    {


  val= ADC_Read(1);
  val1=(val*5.0)/1023.0;

  FloatToStr(val1,uart_rd1);
  //i++;
  strncpy(uart_rd,uart_rd1,4);
  UART1_Write_Text(uart_rd);
  UART1_Write(10);
  UART1_Write(13);
  

  delay_ms(1000);

}


}
 

What values do you get when you dont do the calculation " val1=(val*5.0)/1023.0;" and just send "val" to uart (with string conversion)
 

hello,



show you level shifter schematic..

do you add +2,5V to your signal 5V AC peak to peak ?



have alook on **broken link removed**
it's to measure main AC 230V => reduce to 1,6V efficace + 2,50V
so adc input keept in the range 0 to 5V
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…