aswathymohan
Member level 4
- Joined
- Nov 11, 2012
- Messages
- 68
- Helped
- 5
- Reputation
- 10
- Reaction score
- 5
- Trophy points
- 1,288
- 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
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);
}
}