impedance meter using audio i/o
TRANSCRIPT
Electronic Design Lab
EE-344
IMPEDANCE METER USINGAUDIO I/O
Group 21 (DD Batch) :Ashwin Bhat - 13D070006Rohit Rothe - 13D070013Anand Pathak - 13D070019
Supervisors :Prof. Dipankar (Guide)Suryakant Toraskar (TA)Deepak Malani (TA)
April 15, 2016
Impedance Meter EE-344 : EDL
INDEX
Abstract 2
Aim 2Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Introduction 3
Block Diagram 4PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Analog Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Circuit Diagrams & Design Procedure 7PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Analog Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Complete Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Photographs 13
Results 13
Problems Faced 14
Conclusion 15
Future Work Suggestions 15
References 15
1
Impedance Meter EE-344 : EDL
ABSTRACT
The multimeters that we use can measure Resistance only. There is no provision formeasuring capacitor or inductor values. To measure those, we need to use a LCR meterwhich is not commonly available. Also, there is no way to measure the impedance (R+jX)in case we have a combination of RLC components. In order to overcome this barrier,we want to make a device which can measure the impedance(in a certain range) at one go.
In our labs or while working with circuits in any projects, we often need to measurethe values of our RLC components. Without a breadboard and some wires, it is quite te-dious to do so with the thick probes of the multimeter. Also, laptops are more commonlyused and carried around than multimeters. Hence we thought of making a small devicewhich could be powered by the laptop itself and when the DUT (device under test) isconnected to our device, a small set of steps should display the impedance value of theDUT on the laptop screen.
In order to do that, we would use the sound card of the laptop as the source as wellas listener to the signals . The sound card can produce sinusoids of a particular frequencywhich will be modified uniquely by particular impedance. With some processing on thereceived voltage signals, the impedance would be displayed on the screen.
AIM
Objectives
Our project goal is to provide a handy tool to circuit designers and students. RLCcomponents are the most commonly used in electronic circuits. Hence, our goal is to havean Impedance Meter to measure the RLC values with high accuracy. The multimeterwhich we use in our labs have facility to measure Resistances only. Although it saysit can measure up to 2 MΩ , the accuracy goes down because of the Internal SourceImpedance of the device. On searching further, we stumbled upon independent devices tomeasure Capacitance and Inductance. Having different instruments to measure differentcomponents is a cumbersome task. Hence our goal is to combine the functioning intoa single device which can measure RLC values over a wide range. As mentioned beforeLaptops are very common among students. A small , portable , robust device can easilybe carried along with it. Thus we are replacing the multimeter with something thatcan measure impedance in general and not just resistance. Hence, our goal is to makesomething handy and portable which can eliminate the need for extra separate devicesfor measuring C and L.
2
Impedance Meter EE-344 : EDL
Specifications
The range of values which we aim to measure :-
• Resistance – 10 Ω to 10 MΩ
• Capacitance – 10 pF to 10 µF
• Inductance – 10 µH to 1 H
Also, we aim to keep the error % within 5 %. The error will be measured by comparingour measured values with that given by a standard LCR meter.
INTRODUCTION
Concept Behind the Project
The main idea is that any impedance can be measured by comparing it with a referenceimpedance. The reference impedance we have used is a resistance. The following is thebasic circuit diagram of the same
Figure 1
Knowing the voltages at each node, we can calculate the Unknown Impedance connectedin the circuit by the simple application of triangle law of addition.Defining the voltages which we are measuring
Va = V1 − V3
Vb = V1 − V2
Vc = V2 − V3
(1)
3
Impedance Meter EE-344 : EDL
Same current will flow through both the components. Assuming Zunknown = R+ jX andsolving we get
R2 +X2 = R2known
(VbVc
)2
R = RknownV 2a − V 2
b − V 2c
2V 2c
This can be visualized from the following diagram To increase the accuracy of the mea-
Figure 2: Voltage Phasors forming a triangle
surement, we would prefer not to keep the angle between A and B very large or verysmall. A reasonable limit is to maintain this inequality
1
20≤ VbVc
≤ 20
Following this inequality doesn’t let voltages that are to be measured, to go smaller thana value below which noise is dominant as compared to the signal voltage.We have selected three resistors of values 27 Ω , 4.7 kΩ and 560 kΩ as the known resistances
Figure 3: Impedance Ranges that can be measured
For measuring inductors and capacitors, we conduct the same measurements for twodifferent frequencies 4.1 kHz and 8.2 kHz. If the impedance measured increases withfrequency we declare the impedance as inductive and vice versa for the capacitor. Forresistance, the impedance won’t change with frequency.The frequencies enable us to measure inductance in the range 50 µH - 200 H andcapacitance in the range 15 µF - 3.5 pF. The inequality can be relaxed a bit in case ofcapacitance with values higher than 15 µF to obtain result with a lower accuracy.
4
Impedance Meter EE-344 : EDL
BLOCK DIAGRAM
The device can be broken down into three major blocks namely - the PC, the analogcircuits and the microcontroller
Figure 4: Block Diagram
PC
The sound card of the PC provides the audio i/o. The PC is used for the followingpurposes :-
• Stereo out of the PC is split into two independently controlled mono audio outputs.One of them acts as the sinusoid signal source for the Analog Circuit while theother one sends commands to the µC in the form of sinusoids of different frequen-cies, thus establishing communication between the different subsystems. The job ofsynchronizing is carried out through the PC.
• Line-in of the PC receives the waveform from a certain node of the circuit andmeasures the amplitude of the sinusoid it receives.
• Based on the measured amplitudes, the ratio of the unknown impedance can becalculated. In this way, we deduce the value of the unknown impedance and displayit on the PC itself.
• The power to the circuit is given through the USB port of the PC.
5
Impedance Meter EE-344 : EDL
• Two 3-pin audio cables were used and two break-out boards were made for the sameusing 3-pin audio jack.
ANALOG CIRCUITS
Power
The board is powered from the USB port of the PC. The USB connector used is a B typeUSB connector. The USB connector supplies uni-polar 5 volts supply with a currentcapacity of ˜100mA. We have used LM 7660 IC to convert the positive voltage to negativethereby obtaining a bipolar supply on the board.
Rectifier Component
• It receives a sinusoid of a particular frequency from one of the channels of the stereoout of the PC
• A comparator converts the bipolar sinusoid into a bipolar square wave
• Further, a half wave rectifier converts this bipolar square wave into a unipolar squarewave
• This unipolar square wave is then fed into the microcontroller
Analog Switches
We are using CD 4066 Analog Switches. These are required in two sections of the circuit
• Changing the known resistor
• Switching the output channel to be read in the Line-in port
Buffers and Instrumentation Amplifier
We have used Buffers made using OP-AMPS at each measuring point. These Buffersalso serve as measuring point for the voltages. The Instrumentation Amplifier is used tomeasure the floating voltages which need to be measured.
MICROCONTROLLER
The basic purpose of the microcontroller is to serve as a communication and control unitbetween the PC and the analog circuitry. The known resistor values need to be selecteddepending on the range of the impedance to be measured. Which among the known or
6
Impedance Meter EE-344 : EDL
unknown voltages to be measured is also to be selected. This control task is performed bygiving proper control inputs to CD4066 switches through the microcontroller dependingon the frequency signal sent to it by the PC.
CIRCUIT DIAGRAMS & DESIGN PROCEDURE
PC
Most of the codes for generating sinusoids or measuring the amplitude of the receivedsignal have been written based on the ALSA Library(Advanced Linux Sound Archi-tecture). Below is the description of the steps taken to enable the PC to carry out itsrequirements in this project :-
Splitting the stereo-out of the PC
The default configuration of the ALSA library needs to be overwritten in order to achievethis. The configuration was written in the .asoundrc file. The configuration basicallycreated two aliases/slaves of the audio device residing in the sound card. Each alias wasassigned a separate channel. The aplay command was used to select which alias to use inorder to output samples to the audio-out channel. The sampling rate and the endiannessof the samples can also be set using the aplay command. Simultaneously playing twodifferent .raw files (which contain the samples of sinusoid of certain frequency) using pipe,the stereo out was effectively split into two independently controlled mono audio outputchannels.
Generating Sinusoids
Initially sinusoid generation was done using one of the example codes provided in the doc-umentation of the ALSA Library. Using this we were able to determine the frequencieswhich the sound card could provide. We found out that the amplitude of the sinusoid didnot remain stable beyond 18 kHz. Also, we were able to measure the p-p voltage value ofthe sinusoid which we obtained from the PC and the effect of adjusting the volume levelon the amplitude. The amplitude should be limited so as to limit the current drawn andnot cause change in known resistance values due to heating. However, there was no easyway in which the stereo-out could be split using this method since it directly outputs thesamples to the speaker while aplay command requires a file containing the samples.The aplay command requires a file containing the samples of the waveform that it needsto play. We chose to store the samples in the .raw format since it does not have anyheaders. The default sampling frequency used in the sound card is 44.1 kHz. Hence wecreated .raw files containing samples of sinusoids of different frequencies sampled at 44.1kHz using MATLAB. Sufficient samples were stored in order to allow the file to play for
7
Impedance Meter EE-344 : EDL
a few seconds before it runs out of samples. Using the aplay command and the proceduredescribed in the previous subsection, we could play different sinusoids on the two channelsof the stereo-out of the PC.Different frequencies were required because we need to establish FSK-based communi-cation with the µC and to measure Capaciatance or Inductance, we need to measuretheir impedance at two different frequencies since we are not doing any phase differencecalculation.
Measuring Received Voltages
For recording the signals, one of the example codes in the documentation of the ALSALibrary was used. The samples being read were redirected to a .raw file. After reading thesamples for a specific time duration, another C++ code was used to read the generated.raw file and convert the samples to float data type. During the conversions, the maximumand minimum values were tracked. In this was we could measure the amplitude of thereceived signal.The different frequencies sent as signal source for the analog circuits were 2.05 , 4.1 and8.2 kHz. We calibrated the measured amplitude at these frequencies. Using the functiongenerator, we manually sent sinusoids of different amplitudes at the line-in port. In thisway the measured values could be mapped to the actual voltage.
Synchronization & Processing
Running the code for generating sinusoids at each mono audio output channel and mea-suring amplitude at the line-in port, the code for automating the measurement processcan be written. Based on the measured voltage levels at different frequencies, we candeclare whether its a resistance, capacitance or inductance along with its value. A GUIcan be made for triggering the measurement process and to display the measured value.
ANALOG CIRCUITS
Power Supply
We obtain the unipolar +5 Volts voltage supply from the PC USB port.But we need bipo-lar supply to power the OP-AMPS, Instrumentation Amplifier and the Analog Switchesinstalled on the board.The LM 7660 IC is a positive to negative voltage converter thereby providing is with the-5 volts supply required. The Voltage converter is used in the following configuration - twoLM 7660 ICs have been used in the parallel configuration to increase the output currentso that it can drive all the ICs on the board & also ensures lower output impedance.
8
Impedance Meter EE-344 : EDL
Figure 5: LM 7660 in Parallel Configuration
Rectifier Component
It receives the sinusoid input of a particular frequency from the PC. Based on the require-ments of the microcontroller the following was done.
• This sinusoid is compared with 0 volts using a comparator made using an OP-AMP(TL-082)
• The comparator output is a bipolar square wave of the same frequency (since it iscompared with 0) as that of the incoming sinusoid
• Half wave rectifier comprises of a diode and a resistor. All it does is raise the negativevalue(-5) to 0 and retains the positive value(+5).
Figure 6: Rectifier Component
9
Impedance Meter EE-344 : EDL
Analog Switches
The PC provides only one Line-in channel. However we need to measure three differentvoltages. We also need to change the value of the Rknown for allowing a wider range ofmeasurement of impedance. Hence the need of a switch or a multiplexer.The CD 4066 switch has a very low ON resistance and provides four switches with in-dependent control signals in a single IC. Hence we decided to use it. In order to furtherreduce the resistance of the switch creeping into the circuit, we used an OP-AMP in thefollowing configuration.In this configuration, when the switch is turned on, the feedback loop of the OP-AMP
Figure 7: Analog Switch
is complete. This adds the switch resistance in the feedback path. But due to the virtualshorting of the positive and negative pins, the required ground potential is obtained onthe required terminal of the Rknown resistor.
Buffers and Instrumentation Amplifier
Buffers have been made using the unity gain voltage follower configuration of the OP-AMP. The TL-082 dual OP-AMPs IC has been used to create this configuration. Theyisolate the Rknown and the Zunknown components from the measuring part of the circuit.The instrumentation amplifier used is INA 121 which is a measurement grade amplifier.This has been used to measure the difference between two floating voltage nodes. Thegain used for the instrumentation amplifier is 1.
10
Impedance Meter EE-344 : EDL
Figure 8: Instrumentation Amplifier
MICROCONTROLLER
Aurum v1.2 board developed at ”e-Prayog, WEL lab” has been used in this project.This board is centred around PIC18F4550, an 8 bit microcontroller by Microchip Tech-nology. The input to the microcontroller is obtained by processing sinusoids of particularfrequencies sent by the PC. The output constitutes switching of some of the control pins.The microcontroller cannot take negative inputs at its pins. Hence the sinusoid sent bythe PC is first passed through a comparator to get a bipolar square wave which is thenrectified to a unipolar square wave using a half wave rectifier.The code involves the use of timer interrupt and the external interrupt for edge detec-tion. Every time the input has a rising edge, the interrupt occurs. At every instanceof an interrupt, the time elapsed since the previous interrupt occurred is recorded. Thistime corresponds to the period of the unipolar square wave input to the microcontroller,i.e. that of the sinusoid sent by the PC. Thence, the frequency of the sinusoid sent by thePC gets detected.Using FSK modulation, based on the frequency detected, the desired output pins whichserve as control pins of the CD4066 switches are enabled/disabled.The outputs have been taken on selected pins from JP5 and JP6 connectors on the Au-rum board which have not been multiplexed for some other function being utilised byus in our code. We have identified 9 distinct ranges of frequencies which can be used toenable/disable any of the above selected pins.
11
Impedance Meter EE-344 : EDL
The pins used, the frequency ranges identified and the final frequencies used for controlare as follows:
Figure 9: Frequencies used
COMPLETE CIRCUIT DIAGRAM
Figure 10
12
Impedance Meter EE-344 : EDL
PHOTOGRAPHS
(a) Schematic
(b) Layout
Figure 11: Eagle Schematic and Layout
(a) Top (b) Bottom
Figure 12: Printed Circuit Board
13
Impedance Meter EE-344 : EDL
RESULTS
What we have achieved so far
• Breadboard level implementation to verify the concept of the project
• Testing and verification of each subsystem independently
• FSK based communication scheme using µC
• Calibration of the measured voltage of the PC - through curve fitting we founda linear expression relating the measured value shown by the PC (between -0.5and +0.5) and the actual voltage sent in for different frequencies.We subsequentlyverified the concept of the project with voltage measurements on the PC
• PCB design and testing
• Integration of the subsystems and measurements of resistance values in differentranges
In all the measurements, the error % for R and L was found to be lower than 5 % whichmeets the specifications. However in the case of C, the error was higher.
What is left to do
• Code for processing the measured amplitudes to identify RLC and output the value
• Complete automation of the measurement process
• Calibration of the device
PROBLEMS FACED
These were some of the stumbling blocks obstructing the progress of the project :-
• The example code of the ALSA Library were very complicated and difficult tounderstand. The code did not work directly as it is. A lot of time was spent figuringout and fixing the errors and to determine which audio device of the sound card wasto be used.
• Splitting the stereo-out into mono-audio out - no examples on how to do this onthe internet except using softwares like VLC Media player. Even these do not allowperfect independent control. In order to overcome this, we tried to use the rearand front mic of the PC as two signal sources. In this trial we somehow managedto achieve our original aim itself. We were stuck with the working of the CD 4066
14
Impedance Meter EE-344 : EDL
Analog Switch. Later we realized that we hadn’t provided a load resistance at theoutput terminal.
• Calibration of the sound card measured values - initially the gain of the line-in portwas high which caused problems due to noise. However, using alsamixer the gaincould be reduced to allow for greater voltage measurement range and less noiseamplification
• We had to make the layout quite a few times to try to fit the layout on one layer inorder to minimize the number of vias.
CONCLUSION
After proper calibration, we would be able to determine the range of RLC values whichcan be measured by our Impedance Meter within the allowed tolerance level.
FUTURE WORK SUGGESTIONS
• A smaller on board µC can be used instead of the Aurum board to make the devicerobust and a one piece device
• The PCB can be laid out in a smaller area as compared to the current design whichwill make the device a lot smaller
• The idea can be extended to include more facilities of a multimeter
• More known resistances can be used to extend the range of measurement of impedances
REFERENCES
• ALSA Library Exampleshttp://www.alsa-project.org/alsa-doc/alsa-lib/examples.html
• .asoundrc configuration file explanationhttp://www.alsa-project.org/main/index.php/Asoundrc
• Sites like StackOverflow and other Google results for various shell commands onLinux
• Data sheets of various IC’s used in the Analog Circuit part
• PIC 18F4550 datasheetwww.rakeshmondal.info
15