PICmicro + opamp = PGAContents
OverviewThis page describes a simple PGA (Programmable Gain Amplifier) built on PIC18F458 microcontroller and LM833 operational amplifier. The circuit works from single +5V supply. The described PGA was found to satisfactory amplify a narrow band 40kHz ultrasonic signal, with 9 dB to 23 dB (x8 to x194) gain without noticeable distortion. RequirementsMy application has no strict requirements for the accuracy of the gain. The goal is merely to boost the signal enough to be able to detect its presence, recover envelope, and sample with ADC built into PIC. The signal is coming from an ulrasonic receiver, preamplified. It is a train of 40 kHz pulses, relatively to 2.5V virtual ground, approximately 1ms long. Amplitude of the incoming signal varies between 15mV and 300mV peak-to-peak. The typical signal looks like this
Possible solutionsOne option was to use a transconductance amplifiers, but all sample designs I could find were using a split power supply, +/- 15V. My board has only has +12V unregulated supply (and +5 regulated derived from it), so I was looking for other options. A non-inverting amplifier with variable feedback resistor would solve the problem, at expense of additional analog switch or a digital potentiometer. As I did not require precise gain, I decided to try using PICmicro instead of an analog switch to control feedback of the opamp. Alghough I/O ports of PIC microcontrollers were not designed for this task, it happened to be feasible if one bears in mind some pecularities of PIC micro I/O ports, such as a protection diodes. Pecularities of PICmicro I/O portsThe following properties of I/O ports of PIC microcontrollers are relevant:
The images are taken from Microchip datasheet for PIC18F458 microcontroller. Click on image to enlarge. Schematics
It is a non-inverting AC amplifier, but with a variable gain. Thanks to the capacitor, amplifier's gain at DC is 1. The R2x resistors at the bottom are either tied to the ground or left floating, depending on TRISA bit settings. In the current implementation, only one resistor out of four is tied to the ground, others are effectively disconnected. However, it shoudl be possible to tie several resistors to the ground simultaneously, to have a finer gain steps.74 When choosing resistors, it is desirable to ensure that a voltage at point A does not drops below -0.3V. Otherwise, the protection diodes might start conducting which would probably result in a significant signal distortion. In +5V single supply configuration, output swing of the opamp is +/-2V relatively to the virtual ground (2.5V). So mininum R2/(R1+R2) ratio is 2V/0.3V = 6.6 . Values R1 = 68K, R2X = 330R, 1K, 3.3K, 10K worked for me. C1 capacitor should be have low impedance for the signal being amplified. Values between 10uF and 0.1uF seems to work equally well. DSchabel from Microchip forum has suggested aluminium electrolytic capacitors should not be used because "They have notoriously low self-resonant frequencies (the point at which their impedance rises due to the Equivalent Series Inductance - ESL - interacting with the capacitance).". Use ceramic capacitors instead. ExperimentHere are the screenshots of input (red) and amplified (green) signal taken at different gains. Weak (15mVpp to 300 mV peak-to-peak) input signal is amplified up to about 2Vppto range suitable for A/D conversion.
ConclusionThe PGA seems to work well and provides the expected gain. Alghough tested on PIC18F458 only, this approach is likely to work on other PICmicro devices. Miminum gain depends on the output voltage swing (because of protection diodes on PICmicro) as explained above. Maximum gain is determined by gain-bandwidth product of the opamp. LM833 opamp has minimum gain-bandwidth product of 10MHz, maximum gain for 40kHz signal is 10MHz/40kHz = 250. However, it is considered to be a good practice to not exceed the gain of 100 for one amplifying stage. I would love to hear critique, comments, suggestions, or questions. Please feel free to send me an email at Regards, |