doucheful80
Junior Member level 1
;*** ADC
movlw b'00000001' ;ADC enable
movwf ADCON0
movlw b'00001110' ;vrefs=vdd,vss .AN0 used only
movwf ADCON1
movlw b'10010100' ;ADRESH read as zero, follow
movwf ADCON2
Im using a LM35 to obtain temperature then calculate the speed of sound. But the problem is that it seem to be unstable. (lm35 out volt is stable when measured with multimeter)
for example im measuring temperature 25-31 C. When at 28C, the adreshL can be either decimal 37, 42 sometime 16 for awhile at the beginning.
I looked into the datasheet of pic18f4520 and check the acquisition time and A/D conversion clock. ADCON2 is currently set at 10010100, or AD conversion clock, =Fosc/4 and 4TAD for acquisition time. What does conversion clock and acquisition time means exactly? so far i get that conversion clock is depending on your oscillator (im using 4MHz crystal). and the acquisition time is the time it take to sample the voltage before conversion begins.
I calculated the acquisition time by refering the 4520 datasheet, basically everything is the same except the temperature, i put in a temp of 30C. (the example gave 85C)
So follow it, (30-25C)x0.02us/C = 0.1u
Tamp given 0.2u
Tc ,in my circuit i assume its the same with the datasheet, so= 1.05
Tacq (aquisition time) = 1.35us
Does this means that the Tacq should be 2Tad since my clock cycle is 2us (4MHz crystal), and is ADCON2 configuration correct? Thanks for helping ..!
movlw b'00000001' ;ADC enable
movwf ADCON0
movlw b'00001110' ;vrefs=vdd,vss .AN0 used only
movwf ADCON1
movlw b'10010100' ;ADRESH read as zero, follow
movwf ADCON2
Im using a LM35 to obtain temperature then calculate the speed of sound. But the problem is that it seem to be unstable. (lm35 out volt is stable when measured with multimeter)
for example im measuring temperature 25-31 C. When at 28C, the adreshL can be either decimal 37, 42 sometime 16 for awhile at the beginning.
I looked into the datasheet of pic18f4520 and check the acquisition time and A/D conversion clock. ADCON2 is currently set at 10010100, or AD conversion clock, =Fosc/4 and 4TAD for acquisition time. What does conversion clock and acquisition time means exactly? so far i get that conversion clock is depending on your oscillator (im using 4MHz crystal). and the acquisition time is the time it take to sample the voltage before conversion begins.
I calculated the acquisition time by refering the 4520 datasheet, basically everything is the same except the temperature, i put in a temp of 30C. (the example gave 85C)
So follow it, (30-25C)x0.02us/C = 0.1u
Tamp given 0.2u
Tc ,in my circuit i assume its the same with the datasheet, so= 1.05
Tacq (aquisition time) = 1.35us
Does this means that the Tacq should be 2Tad since my clock cycle is 2us (4MHz crystal), and is ADCON2 configuration correct? Thanks for helping ..!