flamesier
Newbie level 6
- Joined
- Oct 2, 2010
- Messages
- 13
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,453
hi,
im new to programming..
but managed to do this...below..
i want to measure the actual voltage that is being measured..but everytime i tried its not displaying anything...
after some editing i managed to display the adc value that is being read by the pic16f887...
can anyone help me on how to display the 0-5vdc that is measured?? in the virtual terminal in proteus?i dont know how else to do it..
thanks in advance..
here is my code..
void main() {
int adc_rd;
char text[12];
ANSEL = 0b00000100; // Configure AN2 pin as analog
ANSELH=0; //other are digital
INTCON=0; //disable interrupts
ADCON0=1; //ADC enable(bit1)
CM1CON0=0; //disable comparators
CM2CON0=0;
//ADCON1 = 0x80; //Setting result format, conversion clock and activating ADC function.
//TRISA = 0x2F; //Setting Port A as input.
//TRISE = 0x07; //Setting Port E as input.
//TRISC = 0x80; //Setting Port C as input and output
TRISA=0xFF; // PORTA is input
PORTA=0;
ADC_init();
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text("Start");
UART1_Write(10);
UART1_Write(13);
while(1) {
delay_ms(250);
adc_rd = ADC_read(2); // get ADC value from 2nd channel
//adc_rd = adc_rd*5;
//adc_rd = adc_rd/10;
inttostr(adc_rd,text);
UART1_write_text(text);
UART1_write_text("\n");
UART1_write_text("\r");
}
im new to programming..
but managed to do this...below..
i want to measure the actual voltage that is being measured..but everytime i tried its not displaying anything...
after some editing i managed to display the adc value that is being read by the pic16f887...
can anyone help me on how to display the 0-5vdc that is measured?? in the virtual terminal in proteus?i dont know how else to do it..
thanks in advance..
here is my code..
void main() {
int adc_rd;
char text[12];
ANSEL = 0b00000100; // Configure AN2 pin as analog
ANSELH=0; //other are digital
INTCON=0; //disable interrupts
ADCON0=1; //ADC enable(bit1)
CM1CON0=0; //disable comparators
CM2CON0=0;
//ADCON1 = 0x80; //Setting result format, conversion clock and activating ADC function.
//TRISA = 0x2F; //Setting Port A as input.
//TRISE = 0x07; //Setting Port E as input.
//TRISC = 0x80; //Setting Port C as input and output
TRISA=0xFF; // PORTA is input
PORTA=0;
ADC_init();
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text("Start");
UART1_Write(10);
UART1_Write(13);
while(1) {
delay_ms(250);
adc_rd = ADC_read(2); // get ADC value from 2nd channel
//adc_rd = adc_rd*5;
//adc_rd = adc_rd/10;
inttostr(adc_rd,text);
UART1_write_text(text);
UART1_write_text("\n");
UART1_write_text("\r");
}