# Door access/Howard Community College/Fall2012/p2-502-cash/amplifier
### Sensor Amplifier

The sensor amplifier increases the output voltage of the sensor in order to allow more freedom of threshold adjustments within the arduino program and improve the signal to noise ratio, which means to make a larger difference between a knock and no knock, so it is easier for the arduino to differentiate between random noises such as caused by opening/closing the door and an actual knock. Two variations were attempted; one based on bipolar junction transistors (BJT), and one based on operational amplifier integrated circuits. Generally, the operational amplifier was much easier to adjust, more reliable, and, most importantly, much higher gain. However, it is a more complicated circuit, requires more components, and also requires a dual voltage power supply, all of which are potential drawbacks. The BJT based amplifier was a very simple circuit requiring few parts, but was found to be much less reliable, sometimes ceasing to function simply when changing sensors, and had far less gain than the op amp version. However, unlike the op amp, the transistor amp required only a single polarity power source, 12 volts DC. With the motors we were using, this meant that the amplifier could be powered from the same power source as the motor, saving weight and bulk of the entire system. An additional, and in fact recommended, option for the future team would be to pursue an amplifier based on one or more FETs, which has the potential to have gain and high input impedance comparable to the op amp, but would be capable of running on a single polarity power source like the BJT amplifier. However, the schematics and circuit descriptions of both amplifiers are included below should you choose to use them.

#### Bipolar Junction Transistor Version

The BJT based amplifier uses a pair of the very common 2N2222 transistors connected as a darlington pair and requires a single power supply capable of 12 volts, 500 mA (actually, it could probably work with a far less powerful source, perhaps 100 mA or lower). This circuit is far from optimized, so perhaps future teams could improve it by rearranging transistor connections or changing biasing/load resistor values.

##### Circuit Description

Refer to the schematic of the refined transistor amplifier for parts and connections; the part identifications in the circuit description match those in the schematic.
transistors Q1 and Q2 are the active elements that amplify the signal voltage. They are type 2N2222, a very common and low cost component; There should be some already available in the engineering lab. In this circuit two are connected as a Darlington Pair, to increase gain and sensitivity. R1 is a biasing resistor, pulling some current through the base of driver transistor Q1 to set the idle, or no signal, collector current at a value such that, with the anticipated output signal, the transistor operates in the range of collector current over which it has the highest possible forward current gain. From looking at a datasheet, this would put each transistor at 55 or 60 mA idle current, but in practice this circuit seems to work best with a combined collector current of 26 to 30 mA total for both transistors; R1 is a potentiometer to allow for adjustment of bias current for best operation. R2 is the signal input resistor, to provide a dc return path for the signal to ground. It may not be necessary, or its value may not be optimized, but keep in mind that changing it will change the voltage at the base of Q1 because R2 forms a voltage divider with R1; changing R2 is likely to result in a need to readjust R1. C1 is a DC blocking capacitor; it serves many functions:
   * to keep dc current from biasing network R1/R2 from flowing through the sensor
   * to prevent low resistance sensors from upsetting transistor bias by acting in parallel with R2 to lower the resistance of the part of the biasing voltage divider that runs from Q1 base to ground
   * to prevent dc from a sensor circuit, such as that needed for a photo resistor or carbon microphone, from changing the transistor bias current
   * to increase the impedance seen by sensors; in the case of high impedance sensors such as the piezo buzzer, this has a substantial effect on usable output voltage.
The combination of R3 and R4 in series are the collector load resistor. This could just as easily have been a single resistor of the appropriate value; two resistors were used because of the parts available. Several total resistance values were tried, and the circuit seemed to work best with a collector load resistance around 200 ohms. C2 was intended to be a power supply bypass capacitor so that the amplified signal could get around the power supply and any connecting leads;it was accidentally connected to the collector leads instead of to the power supply lead, but the circuit worked, so it was left as it was and documented. Later efforts showed that this capacitor may not be necessary, and that C4, which was intended to perform the same function, may not be either. C3 is the output coupling capacitor, intended to keep high dc voltages and currents off of the arduino pin. Basically, it has many of the same effects as C1, but does so for the arduino instead of the Q1. At the suggestion of this tutorial, power supply decoupling resistor R5 was added to improve performance, but may not be necessary. Search the tutorial website for "decoupling" to find a detailed description of R5's function if desired. During tests with the sensor, the noise coupled into the system was comparable to, or sometimes even greater than, the signal voltage, posing substantial challenges for reliability and measurement. To reduce this effect, a factory made line noise filter was connected between the power supply leads and the circuit, with its case being tied to a grounded metal object. This would not be necessary with either a high output sensor or an electrically clean power supply, but should be kept in mind as an option if similar problems are encountered. Finally, for power supply V1, 12 volts was readily available and should be so in the lab also. However, if more voltage is available, more voltage gain could be obtained from the amplifier. If the voltage is changed, values of collector load resistor would have to be changed to take advantage of the extra capability (otherwise, the only effect would be to shift the DC level of the signal) and biasing resistors will probably need to be changed as well (a higher voltage would pull more base current through R1, changing collector idle current). The transistors are capable of taking a maximum of 30 volts, and the arduino motor shield can take up to 16, so at least 16 volts could be used and still power amplifier and motor form the same source. However, given the changes that would likely be necessary, simply using the existing circuit and a 12 volt computer power supply would probably be a more efficient path to success.

##### Parts List

all resistors 5% tolerance 1/4 watt
R1: 50k ohm potentiometer, ideally 5 or 10 turn R2: 56k ohm R3: 100 ohm R4: 120 ohm (R3 and R4 can be combined into a single resistor, 220 ohm) R5: 33 ohm C1: 0.22 uF 16VDC(this value is by no means critical, anything bigger would work, probably better) C2: 0.22 uF 16 VDC(this value is by no means critical, anything bigger would work, probably better) C3: 2200 uF 16 VDC(again, value not critical, could probably vary as much as 50 % either way with similar results) C4: 1000 uF, 16 VDC (later efforts suggest this may not be needed) Q1,Q2: 2N2222 or 2N2222A line noise filter (optional) 12 volt DC voltage source, ideally electrically very clean
advantages of BJT version:
   * fewer parts, simpler circuit that op amp version
   * needs only a single polarity voltage source, instead of pos/neg like the op amp
diasdvantages:
   * low gain
   * unstable/unreliable
   * harder to modify gain/biasing conditions

##### Photo
#### Op Amp Version

In an effort to overcome reliability problems, a more sensitive amplifier was built based on the LM741, a common integrated circuit op amp. It uses two Lm741's cascaded so that the overall gain of the amplifier is roughly the product of the gains of the individual stages. The operating parameters such as gain and DC offset of the op amp are readily adjustable by selecting different values for various resistors, as explained in detail in the schematic, and online calculators are available to do gain/resistor value calculations automatically. LM741's and all other parts needed to build this amplifier should be available in the engineering lab. A functioning computer power supply should be capable of providing the positive and negative voltages required.

##### Circuit Description

Refer to the schematic while reading; part identifiers in the schematic correspond to references in the description.
R1 and R2 set the gain of the first stage of amplification, accomplished by IC1 (LM741). The gain of the stage is R2/R1, within certain limits. R3 and R5 determine the DC voltage offset of the output of the first stage, which, after amplification by the second stage, has an effect on the dc offset of the output. R3 and R5 should be changed by future teams to obtain a positive voltage of about 6 volts at the output with no input signal. With the values shown, there is almost no positive offset at the output. The method of adjusting this and the reason it needs to be adjusted is explained in greater detail in notes on the schematic. R4 is the DC return path for the non inverting input to ground. Based on information in this tutorial, "An operational amplifier circuit will not work at all unless Both inputs have direct-current return path to ground of a similar reference." (sic) R6 and R7 set the gain of the second stage, and act exactly as R1 and R2, respectively. R8 and R10 set the DC offset introduced into the output by the second stage, and work exactly as R3 and R5, respectively. R9 is the second stage's non inverting input DC return path to ground, acting as R4 does in the first stage. V1 and V2 represent a dual voltage power supply, though some computer power supplies should be capable of delivering both voltages from a single unit. C1 is a DC blocking capacitor to keep DC off the arduino analog input pin, performing the exact same role as C3 in the BJT amplifier. Additional, very important, information is included in the note on C1 built in to the schematic.

##### Parts List:

all resistors 1/4 watt 5%
R1,R6:1100 ohm R2,R7:27k ohm
R3:6200 ohm R4,R9: 100k ohm R5:4700 ohm R8,R10:5100 ohm C1:2200 uF, 16 VDC IC1,IC2: LM 741 op amp or equivalent hook up wire dual voltage power supply, pos. and neg. 12 volts DC
advantages of op amp version:
   * much more gain
   * easier to design/adjust
   * more stable, not so great a tendency to just stop working
disadvantages of op amp version
   * requires more parts
   * wiring is more complex, a potential challenge for those new to electronics
   * requires dual voltage power supply

##### Photo

Return to Team Page