Navigation

Saturday 11 April 2015

Difference Amplifier


The difference amplifier amplifys the difference between two voltages.


Why low impedance is ensured during EEG experiments

Electroencephalography (EEG) is the recording of electrical activity along the scalp. It is often required to ensure a low impedance between the scalp and the electrodes. Here is why.


From the figure above,
Rin_amp is the input resistance of the amplifier the EEG electrode is connected to.
Vin is the true voltage of the EEG signal
Reeg is the impedance between the scalp and the electrode
The output voltage, Vout, is the voltage that appears at the input of the amplifier and is given by:


This output voltage is the one that is amplified by the op-amp.

As shown by the equation above, if Rin_amp is far greater than Reeg, Vout goes into the op-amp will be approximately equal to Vin and so there is much confidence that we are amplifying the the input voltage, Vin.

But if otherwise, Vout will be attenuated and will not reflect the input voltage, Vin.

Therefore the input impedance of the amplifier has to be far greater than the input impedance of the EEG signal. Also, it is necessary to keep the input impedance of the EEG signal as low as possible.

Op-Amps: Why a high input resistance and low output resistance is required

A very high input resistance is required so that the input becomes an open circuit. A very high input resistance will imply an open circuit. As shown in the diagram below, for an open circuit, the current through Vin will be zero.



From KVL,
-Vs+VRi +Vin=0
-Vs+iRs+Vin=0
Since i = 0,
-Vs+Vin = 0
Therefore, Vs=Vin

If it is an open circuit, the exact source voltage, Vs, gets transferred to the input as Vin. This means that the Ri resistor almost did nothing. Therefore we need a very hight input resistance, Ri, to achieve a zero current, i, so that it becomes an open circuit and all the source voltage will be the input voltage.

This is also true for a voltmeter. A voltmeter should have a very high resistance so that little or no current is able to flow meaning that all the source voltage of the instrument being measured will appear at the input.


A very low output resistance is required so that all the current will be consumed by the load. A very low output resistance is required for an op-amp so that if a load RL is placed in series with it, all the current will be consumed by the load. See the figure below.


From the figure above, this is a short circuit so Vin=0. This implies that all the source current will be eaten up by the load

Interrupts in Microcontrollers

Interrupts can be defined as a hardware triggered software event. They are used in microcontroller programming to ensure that events occur in real time.

To implement interrupts, the condition or event is placed inside the Interrupt Service Routine (ISR). Say, when we press a switch we want a response within a specified period, this if statement followed by the corresponding action is placed in the ISR. The ISR is always called at a frequency/period given by the value written into the RELOAD register.

Another use of interrupt is producing a sound at a particular frequency. This is achieved because interrupts are implemented at a given frequency, so the frequency of the interrupt will be the frequency of the sound produced. Other uses are in obtaining sensor readings at every specified time.

In short, interrupts are used whenever we want to produce an output at a particular time irrespective of the line of code or step currently being executed by the microcontroller in the infinite loop. When the hardware event is triggered, the software will round up its current line of execution, then jump to the ISR to execute the codes, after execution, program flow would return to where it left off in the infinite loop.

Design of a 4-bit Digital to Analog Circuit

A DAC is a digital to analogue circuit. The microcontroller produces a digital value while the DAC converts it to an analog value. A DAC can be implemented using either a binary-weighted circuit or an R-2R ladder circuit.

For the binary weighted circuit, assuming a 4-bit DAC, there are 16 levels which are from 0-15. Assuming the voltage is between 0 – 5v

Digital Value (N)
b3
b2
b1
b0
Analog Value
0
0
0
0
0
0
1
0
0
0
5.0V
5.0*(1/15)
2
0
0
5.0V
0
5.0*(2/15)
3
0
0
5.0V
5.0V
5.0*(3/15)
4
0
5.0V
0
0
5.0*(4/15)
5
0
5.0V
0
5.0V
5.0*(5/15)
6
0
5.0V
5.0V
0
5.0*(6/15)
7
0
5.0V
5.0V
5.0V
5.0*(7/15)
8
5.0V
0
0
0
5.0*(8/15)
9
5.0V
0
0
5.0V
5.0*(9/15)
10
5.0V
0
5.0V
0
5.0*(10/15)
11
5.0V
0
5.0V
5.0V
5.0*(11/15)
12
5.0V
5.0V
0
0
5.0*(12/15)
13
5.0V
5.0V
0
5.0V
5.0*(13/15)
14
5.0V
5.0V
5.0V
0
5.0*(14/15)
15
5.0V
5.0V
5.0V
5.0V
5.0

The resolution of this DAC which represents the smallest change it can capture is given by the difference between each consecutive elements is 5v/15=0.33V. 

The b0 is the LSB while b3 is the MSB. The resistor values are chosen in the ratio of 1/2/4/8 such that the MSB, b3, is attached to the least value of resistor while the LSB, bo, is attached to the highest value of resistance. Bit 0 is the LSB so it is subjected to a higher resistance, Bit 3 is the MSB so it is subjected to the least resistance. The higher the significance of the bit, the lower is the resistor it is connected to


Doing the analysing of the circuit when N=8 from the table, b3-b0 is given by 1000 where b3 is at 5.0V. This means at the circuit becomes:


The equivalent circuit becomes:



So Vout needs to be obtained. The equivalent resistance of 3KOhms. 6KOhm and 12KOhms in parallel is 12/7 KΩ. Therefore, the circuit can be further reduced to:


From voltage divider rule,

This results in the same analog value for the N= 8 as shown in the table

Taking another condition, say N= 12, the equivalent circuit becomes


The equivalent circuit becomes:


Which can be further reduced to:




This value is also the same as the analogue value in the N=12 row of the table.

Inorder to implement the DAC binary-weighted circuit, the value of resistors required has to be 1/2/4/8/16/32/64 ... which will continue to increase depending on the resolution of the DAC. Therefore a 10-bit DAC will require resistors which are in multiples of 2 up to 1024. Generally, it might be difficult to obtain these resistance values. However, when 2 resistors of the same value are connected in parallel, the resulting resistance is half of the value of each of the resistors. Likewise, connecting 2 same valued resistors in series will produce a resistance that is twice each of the resistor. This can be taken into consideration when the exact value of resistance is not available.

Another way of implementing the DAC is an R-2R ladder network. In this case, just two resistance values are required but the number of resistors needed is increased when compared with the binary weighted circuit