• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problem in ADC - PIC18F1220

Status
Not open for further replies.

SSIDAO

New Member
Hello,

I'm using a PIC18F1220 to control a lead-acid battery charger circuit.
I'm having troubles in the A/D conversion in the simulations with Proteus.

The follow message appears:
''ADC conversion clock period (8e-06) is below recommended 1.6us."

I'm using 2 ADC channels (10-bits) (to read temperature and battery voltage)

Temperature function:

int read_temp (void)
{
restart_WDT();
set_adc_channel (sAN0);
delay_ms(30);
Trd = read_adc();
delay_ms(30);
restart_WDT();

return (Trd);
}

Voltage reading function:


float read_voltage (void)
{
restart_WDT();
set_adc_channel (sAN1);
delay_ms(30);
restart_WDT();
Vrd = read_adc();
delay_ms(30);
V = ((Vrd*150)/1023);
restart_WDT ();

return (V);
}

What I need to do to solve this problem? :confused:

Thx.
 

eng1

New Member
Can you show where you configure the A/D module of the PIC in your code?
In particular, you should have configured the A/D clock in the ADCON2 register. Please refer to Table 17-1 in the datasheet to choose it correctly.
 

SSIDAO

New Member
How I can configure this ADCON2 register programming in C?

The A/D configurations are:

restart_WDT();
setup_oscillator (OSC_2MHZ|OSC_NORMAL);
SETUP_ADC(ADC_CLOCK_DIV_32 | ADC_TAD_MUL_20);
SETUP_ADC_PORTS(ALL_ANALOG| VSS_VDD); //Actually i use only the pins
restart_WDT(); //A0 and A1 as analog inputs

I'm using standard_io.
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top