Hi Nikolay. Your idea will work. If all pins are tri-stated total amplifying is equal to 1. If you ground some resistors it will increase amplification. You only thing you should take into account that true ground for op-amp (nor negative supply pin but really ground) and ground of PIC are connected together otherwise in case of connection negative supply pin of op-amp with PIC ground you will cause re-charging of cap every time you change code on pins. So in this case put some delay before beginning ADC read. The second point is PCB tracing. Do ground between PIC and op-amp and ADC as short and wide as possible. Else you get additional error because of ground level shifting. (Very easy to see it with 10 bit conversion ;-) WBR Dmitry. > On Tue, 26 Oct 1999, Nikolai Golovchenko wrote: > > > Hello all. > > I need to read 50Hz signal with PIC16F877. Actually, 10-bit accuracy is > > enough, but the signal level is unknown, therefore PIC has to adjust to the > > signal. The level changes relatively slowly and there is some time allowed > > for adjusting. In this case four gain bands (1:2, 1:4, 1:8, 1:16) will do > > the job. > > > > Now, the problem is that I don't want to use variable gain amps, because > > they are too expensive and hard to get here, in Ukraine. Another way is to > > use analog switches which will change the gain of a usual op amp. Can the > > PIC's pins be used as analog switches, connected to ground? The datasheet > > says that ports use FETS and that the leakage current is as small sa 1uA. > > > > I would connect four resistors to PIC and made the pins go low or tri-state. > > Will the circuit work? > > > > __ > > -------|+ \ > > | \ > > | >------------- To RA0/AN0 > > +-|- / | > > | |--/ | > > | _____ | > > |-----[_____]---+ > > --------- > > --------- > > |---------------- > > | | | | > > [ ] [ ] [ ] [ ] > > [ ] [ ] [ ] [ ] > > | | | | > > | | | ---------- RA1 > > | | --------------- RA2 > > | --------------------- RA3 > > -------------------------- RA5 > > > > Thanks in advance. > > > >