If your oupput signal swings below 0V you may have a problem with the signal path through the port pins. A more serious problem may be that you are connecting the signal path through the port pins directly to your digital ground. It is possible that this will add some noise to your signal. Joe ----- Original Message ----- From: Nikolai Golovchenko To: Sent: Tuesday, October 26, 1999 6:26 AM Subject: Variable gain amp using PIC - possible? > 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. >