ecaits
Member level 4
- Joined
- Jan 16, 2014
- Messages
- 76
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 579
I have used 741 op-amp as amplifier with 50 Gain so I am getting 0-5 V w.r.t. 0-100mV analog input. I have also used the averaging in ADC program. I have also tried 10uF capacitor connected to adc pin and ground. Still I am getting fluctuation in reading of ADC. What may be the reason for that???
void ADC_Init()
{
ADCON0 = 0x81; // ADON = 1, Channel A.0 select, Fosc/32 select
ADCON1 = 0x8E; // 0x8E,0xC0 port a as analog, right justified output
} //original 0x8E
unsigned int ADC_Read(unsigned char channel)
{
int i;
unsigned int avg_output=0,temp=0, ;
if(channel > 7) return 0;
ADCON0 &= 0xC7; // AND= RAZ channel selection
ADCON0 |= channel<<3; // OR = Set chanel selection
Delay_ms(3);
for(i=0;i<32;i++)
{
GO_bit = 1;
_asm NOP // allways one instruction after setting bit GO
while(GO_bit); // Wait until conversion gets over
Delay_ms(2);
temp=temp+(unsigned int) (ADRESH<<8) + ADRESL ; // Store 10-bit output into a 16-bit variable
Delay_ms(5);
}
Delay_ms(5);
//temp=32736; // to test =32*1023
avg_output=temp>>5; // use SHIFT to divide by 32 to avoid use of maths.h
return(avg_output);
}
char CRam[6]; // pour affichage integer maxi= 65536
// in main()
......
M1= ADC_Read(0);
Lcd_Cmd(_LCD_SECOND_ROW );
WordToStr(M1,CRam0); // attention le buffer CRam0 ne doit pas etre trop long !! sinon deborde du LCD...
Lcd_Out_CP(CRam0);
.......
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?