john120
Banned
- Joined
- Aug 13, 2011
- Messages
- 257
- Helped
- 11
- Reputation
- 22
- Reaction score
- 10
- Trophy points
- 1,298
- Activity points
- 0
Hello there,can some body help me to know where the error is I am design a 0-30V digital voltmeter but I am always getting 0V on the seven segment display.
Here are the code and the proteus circuit.
Thanks.
Here are the code and the proteus circuit.
PHP:
#include "16f876a.h"
#DEVICE ADC=10
#fuses XT,NOWDT,NOLVP,NODEBUG,NOCPD
#use delay(clock=4M)
#include<STDLIB.H>
#use standard_io(A)
#use standard_io(B)
#define PORTB
#DEFINE PORTC
#define PORTA
byte const digit[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
char display[3];
unsigned int volt1,volt2;
int value;
void main()
{
set_tris_a(0xff);
set_tris_b(0x00);
set_tris_c(0x00);
while(TRUE){
//setup_comparator(NC_NC_NC_NC);
Setup_adc(ADC_CLOCK_DIV_8);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(FALSE);
delay_us(10);
read_adc(ADC_START_ONLY);
delay_us(100);
value=read_adc();
volt2=(value*500)/1023;
delay_ms(1);
volt2=volt1;
output_low(PIN_b2);
display[0]=volt1/10;
output_c(digit[display[0]]);
output_high(PIN_b4);
output_high(PIN_b5);
delay_ms(10);
output_low(PIN_b4);
display[1]=volt1%10;
output_c(digit[display[1]]);
output_high(PIN_b2);
output_high(PIN_b5);
delay_ms(10);
output_low(PIN_b5);
display[1]=volt1%10;
output_c(digit[display[1]]);
output_high(PIN_b2);
output_high(PIN_b4);
delay_ms(10);
}
}