74
Authors: Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Faculty Lab Coordinator: Dr. Vadim Geurkov April 10, 2014 A Multi-Measurement Unit with the Internet Access EDP Project Report Department of Electrical and Computer Engineering Faculty of Engineering and Architectural Science

Multi measurement Unit

Embed Size (px)

DESCRIPTION

A microprocessor base measurement unit.

Citation preview

  • Authors: Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman

    Faculty Lab Coordinator: Dr. Vadim Geurkov

    April 10, 2014

    A Multi-Measurement Unit with the Internet Access

    EDP Project Report

    Department of Electrical and Computer Engineering Faculty of Engineering and Architectural Science

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 2

    Introduction

    Measurement devices are very commonly used unit in different aspects of daily life. Es-

    pecially in engineering field and research, a measurement unit is a very vital component to be

    used. For this project, a multi-measurement unit was designed with different instrumentation

    techniques.

    Firstly, the measurement unit requires a central processor from which to take in meas-

    ured values, display them on an LCD and upload them to a server. For this basic function, the

    simplest and most cost-effective device is a microcontroller. In this purpose, ChipKIT WF32

    board was selected with a PIC32 micro-processor on board. One of the main reason to pick this

    board was it has a built in Wi-Fi module and a SD card facility which can be implemented to

    establish the web server and web site for the project. The multi-measurement unit that is going

    to be designed in this project is a universal device, which can perform in multiple modes of op-

    eration, such as voltmeter, LCR Meter, and oscilloscope. The voltmeter was implemented using

    the ADC of the micro-processor.

    Fig. 1. Flow diagram representing the Measurement Process

    For the LCR meter, different measurement techniques were researched and analyzed. At

    the end, it was decided to use three individual circuitry systems to measure inductance, capaci-

    tance and resistance. The reason behind this was to make the design comparatively simple,

    easily implementable, less time consuming and cost effective. For the webserver, the SD card

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 3

    facility of the PIC32 was used and a webpage was created with login credential for the client to

    access and see the measurement results. The overall, accuracy for all four measurement was

    remained significantly acceptable (less than 5%).

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 4

    Acknowledgements

    We would like to acknowledge the inimitable support of our Faculty Lab Coordinator

    Dr. Vadim Geurkov. His generous guidance towards the conceptual building of project was al-

    ways motivational for us. We would also like to thank Dr. Mahmood Kassam for his guidance

    and support. Thanks to Jim Koch for his technical support for the development of the project.

    Lastly, we would like offer our gratitude to Electrical and Computer Engineering Department

    of Ryerson University for their laboratory and instrumental support for the completion of the

    project.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 5

    Certification of Authorship

    We Jabran Sajid, Mohammad Rokibul Islam and Sajidur Rahman, hereby declare that

    we are the authors of this Engineering Design Project report. We also certify that this project

    was analyzed, designed and developed with our own research and any additional assistance we

    have received in its preparation is fully acknowledged and cited in the paper. We further au-

    thorize Ryerson University to use or reproduce this report entirely or partially for the purpose

    of scholarly research.

    Jabran Sajid _____________________

    Mohammad Rokibul Islam _____________________

    Sajidur Rahman _____________________

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 6

    Table of Contents

    Introduction ...................................................................................................................... 2

    Acknowledgements .......................................................................................................... 4

    Certification of Authorship ............................................................................................... 5

    Table of Contents ............................................................................................................. 6

    Figures and Tables .................................................................................................... 7

    Abstract ............................................................................................................................. 8

    Objectives ......................................................................................................................... 9

    Theory ............................................................................................................................. 10

    Voltage Measurement ................................................................................................. 10

    LCR Measurement ...................................................................................................... 11

    Impedance ................................................................................................................... 12

    Measurement Issues .................................................................................................... 13

    LCR Measurement Techniques .................................................................................. 15

    ChipKIT WF32 Board and PIC32 Microcontroller .................................................... 26

    Design ............................................................................................................................. 31

    Documentation Including Schematics and Parts Lists ................................................... 37

    Measurement and Testing Procedure ............................................................................. 38

    Performance Measurement ............................................................................................. 40

    Analysis of Performance ................................................................................................ 41

    Conclusion ...................................................................................................................... 42

    Appendices ..................................................................................................................... 43

    References ...................................................................................................................... 74

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 7

    Figures and Tables

    Fig. 1. Flow diagram representing the Measurement Process 2

    Fig. 2. A/D Converter Module Block Diagram 9

    Fig. 3. Simple Block Diagram of Auto-Balancing Bridge 16

    Fig. 4. Signal Source Section Block Diagram 17

    Fig. 5. Block Diagram of Simplified Auto Balancing Bridge Section 18

    Fig. 6. Block Diagram of Vector Ratio Detector Section 19

    Fig. 7. Vector Ratio Calculation Process 19

    Fig. 8. Simplified Block Diagram of Dual-Slope ADC 20

    Fig. 9. Three Phases of Dual Slope ADC Conversion. 21

    Fig. 10. LC Tank Circuit 22

    Fig. 11. Wheatstone Bridge 23

    Fig. 12. Four Wire Method of Resistance Measurement 24

    Fig. 13. Voltage Drop Method 25

    Fig. 14. The ChipKIT WF32 Board 26

    Fig. 15. Colpitts Oscillator Circuit to Measure Inductance 32

    Fig. 16. Astable 555 Timer Circuit to Measure Capacitance 34

    Fig. 17. Webpage Display for the Measurement Unit 38

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 8

    Abstract

    This report presents the development of a microprocessor based multi-measurement unit

    with data transfer capability from the microprocessor to the internet wirelessly. A chipKIT

    WF32 board was used in this project with a PIC32MX695F512L on board. The measurement

    unit was designed to compute: capacitance, inductance, resistance, voltage. The design was

    completed in two phases: hardware designing and software designing. In the first phase, the

    hardware setup was developed for inductance measurement using resonant frequency method,

    capacitance measurement using 555 timer oscillation circuit, and resistance measurement using

    voltage drop process. The completion of the project was apprehended successfully. The final-

    ized design was capable of measuring voltages from (+ve) 4V to (-ve) 4V, resistance from 1

    k to 15 k, capacitance from 1 F to 1 mF, and inductance from 1mH to 1H with a maxi-

    mum error of less than 5%. The webserver and the webpage were also established to view the

    result remotely via internet access.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 9

    Objectives

    The major objective of this Engineering Design Project is to understand, design and im-

    plement a multi-measurement unit with internet access. The entire project is needed to develop

    in two distinctive unit: the measurement unit and the PC based computational unit. At the most

    basic level, the measurement unit must be able to take in measurements as- a logic analyzer, an

    analog voltmeter and a LCR meter. Then the PC based unit will receive the information and

    will relay on a local display via a LCD display and will upload to an online server. Lastly, the

    data on the server must be accessible remotely through an online interface and can be con-

    trolled as well.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 10

    Theory

    Voltage Measurement

    Voltmeter is a measurement device used for obtaining the potential difference or volt-

    age between two points in an electrical circuit. It takes in the voltage of a point with respect to

    the ground and takes in the voltage reading from another point, and then displays the compared

    potential difference between these two points.

    Measuring voltage with an analog multimeter is a very commonly used task in the field

    of electrical research. However, it is possible to measure analog voltage with a microprocessor

    by converting it into digital signal. Present days, microprocessor are provided with a special

    feature called ADC (Analog-to-Digital Converter) which allows to perform this operation. The

    operation is completed in two stages: acquisition and conversion.

    Fig.2. A/D Converter Module Block Diagram

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 11

    In the first stage, the microprocessor reads the analog voltage provided by a power sup-

    ply. It should be mention that, micro-controllers have limitations while receiving the voltage as

    most of cannot read more than 5V generally (with exceptions). Often, sample and hold (S&H)

    capacitor is used to the match the voltage with the input pin voltage of the microprocessor. This

    S&H capacitor converts the voltage to readable binary input for the microprocessor. In the case

    of PIC32 series microprocessor, the conversion process is carried on with a successive approx-

    imation register (SAR) register. A successive approximation ADC compares the pins voltage to

    an internal analog voltage generated by an internal digital-to-analog converter. The DAC volt-

    age will be incremented until a match is found. When this happens, the 10-bit value used to

    drive the DAC becomes the 10-bit analog value. The PIC32 ADC has its own clock with a pe-

    riod which can be configured by the user.

    LCR Measurement

    An inductor acts as a passive electronic component made of a conductor wounded into a

    coil. When electricity starts to flow through the coil, it stores electrical energy by generating a

    magnetic field. Inductance of any material depends on the radius of the coil and on the wound-

    ing material used. Higher valued inductors are used in the power supply of different electronic

    devices to resist any change in the amount of current flowing through it.

    Capacitor is a very important component used in different electronic circuits- such as, in

    timer circuit or to smooth a current to prevent false triggering of other components such as re-

    lays. It is basically a passive electronic component consisted of two conducting plates separated

    by an insulating material (dielectric) that stores energy in the form of an electrostatic field. The

    accuracy of a capacitor measurement may vary due to different physical characteristics of the

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 12

    capacitance elements. In generally, capacitors are tend to have higher temperature coefficients

    Also, the room temperature of the laboratory or the test DUT temperature drift can cause error.

    Moreover, the system parasitic as well as the noise from surrounding could also affect the re-

    sult, especially in higher frequency.

    Resistors are basically an electrical component to resist the flow of electric current. It is

    considered as one of the most important element for any circuitry presents in the modern elec-

    trical devices and it has a very wide range of uses.

    Impedance

    Electrical impedance (Z) is an expansion of the concept of resistance in electric circuits.

    It can be defined as the total opposition or prevention which can be offered by an electrical cir-

    cuit or component against the alternating current (AC) flows through the circuit, at a given fre-

    quency. It changes according to the components used in the circuit. Impedance is a very com-

    monly used parameter in the electric circuitry; consisted of resistance (R), inductive reactance

    (XL), and capacitive reactance (XC). However, impedance is not the algebraic combination of

    the resistance, inductive resistance, and capacitive reactance present in a circuit. Taking re-

    sistance as the reference (which is always in phase with the applied voltage), both capacitive

    and inductive reactance are 90 degrees apart from phase angle of the resistance.

    For a DC supply, resistance (R) is generally defined by the ratio of the voltage (V) to

    the generated current (I) due to the supply voltage. Therefore, according to Ohms law, Re-

    sistance, R= V/I. For an AC supply, the current produced by the AC voltage keeps changing its

    polarity in a regular fashion. Therefore, if there is either capacitive resistance or inductive re-

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 13

    sistance, or both are present in the circuit, then the Ohms law is needed to be modified accord-

    ingly. The impedance for a series model in an AC circuit is referred by:

    Z = V/I = R + jX.

    Here, Z is a complex number consisted of two significant terms, R (real component of

    impedance) and X (imaginary component of impedance). In another word, R denotes resistance

    and X denotes reactance. In a similar way, for a parallel model, admittance is used instead of

    impedance; Y=G+jB, where G is conductance and B is referred as susceptance. Unlike re-

    sistance, reactance actually changes with the variation of frequency of the AC signal. There are

    two types of reactance: capacitive reactance (Xc) and inductive reactance (XL).

    The total reactance, X = XL - Xc.

    To mention, capacitive and inductive reactance have somewhat opposing characteristic:

    at lower frequency, capacitive reactance is usually large at lower frequencies and small at high-

    er frequencies; whereas, the inductive reactance tends to behave in opposite manner.

    Measurement Issues

    Different methods and measuring instruments can cause variation in results of imped-

    ance measurement. Therefore, when measuring different parameters (such as, voltage, re-

    sistance, capacitance, inductance etc.) of an electric circuit, there are several factors which

    needed to be acknowledged.

    Component Parasitics

    The standard values of resistive, inductive and capacitive components are normally rep-

    resented by the nominal values of respective components at a given condition. However, purely

    resistive or reactive components do not exist in reality. They have different parasitics depend-

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 14

    ing on the materials and manufacturing process were used in production of those component. In

    fact, many parasitics reside in components and affect both the usefulness and precision of com-

    ponents. The quality factor Q represents the non-ideal characteristics of any component. The

    higher the Q is, the better or more ideal would be the component.

    Test Frequency

    Due to the existence of parasitics, generally all the test components are affected by the

    test frequency. In case of capacitor measurement, capacitor tends to act as a capacitive compo-

    nent at lower frequencies. Actually, self-resonant frequency of any component determines the

    maximum usable frequency of that particular component. When the capacitor frequency re-

    sponse reaches to its self-resonant frequency, the capacitive and inductive reactance of the

    component became equal and it acts as a resistor. When it passes the self-resonant frequency,

    the phase angle gets closer to positive 90 degrees and the component acts as a inductive re-

    sistance due to the dominance of inductive parasitics. Similarly, the inductor has a maximum

    impedance point at the self-resonant frequency due to the presence of parasitics capacitance. In

    the low frequency region below the resonant frequency, the reactance is inductive. After the

    resonant frequency, the capacitive reactance due to the parasitic capacitance is dominant.

    Test signal level

    The AC signal applied through the DUT may affect the measurement result. Specially,

    for surface mounted devices, test signal level is a very significant dependency factor. Consider-

    ing the case of fixed valued ceramic capacitors, the measurement results get affected with the

    increment of the test signal voltage. This dependency differs with the variation of the dielectric

    constant (K) of the material that is used in the ceramic capacitor. As for inductors, measure-

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 15

    ment result depends on the current produced by test signal due to the electromagnetic hysteresis

    of the core material. For, a high test signal level, an excessive distorted signal may pass through

    the terminal and may cause unbalance.

    DC Bias

    Both capacitor and inductor shows DC bias dependency in different cases. The capaci-

    tance of a high-K type dielectric ceramic capacitor changes depending on the applied DC bias

    voltage. In the case of cored-inductors, the inductance changes depending on the DC bias cur-

    rent flowing through the coil, due to the magnetic flux saturation characteristics of the core ma-

    terial.

    Test Fixture

    The accuracy of measurement also depends on the test fixtures used. A test fixture is ac-

    tually a set up or device used to hold or connect the DUT for the testing process. As example,

    metal probes would be used in the case of this project to connect with the two end of different

    resistive components (resistor, capacitor or inductor). When the probes or any other conducting

    materials are come to contact with an inductor, eddy current starts to flow due to relative mo-

    tion of the field source and conductor. These circulating eddies of current have inductance and

    thus induce magnetic field which in turn results in deviated inductance values during measure-

    ment process.

    LCR Measurement Techniques

    Measuring impedance of any component can be performed using numerous methods

    and technologies. However, each of them comes with distinctive advantages and disadvantages.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 16

    Therefore, different significant criteria are necessary to keep in mind while apprehending a

    measuring technique for this project. The major factors would be the frequency range within

    the test will be performed, the physical characteristics of the DUT and its impedance measure-

    ment range, the precision of the measurement, and test conditions. Moreover, the facilities and

    easiness of implementation, and cost effectiveness of designing materials are one of the most

    compelling factors for the selection process. In cases, one individual method may be suitable

    for measuring inductance, but not highly viable for measuring capacitance or the other way

    around. Therefore, it may be necessary to implement different methods or combining tech-

    niques to design the complete measurement unit. Different measurement techniques are being

    described in the following sections:

    Auto Balancing Bridge Method

    The auto balancing bridge technique is one of the most prominent methods to measure

    impedance at any frequency lower than 40 MHz. It renders possibly the most precise measure-

    ments with broad measurement range. To measure the complex impedance of the DUT, two

    parameters are needed to be measured- the voltage of the test signal applied to the DUT and the

    current that flows through the DUT. Keeping the concept in mind, the circuit for auto balancing

    method is built with a signal source, a high gain operational amplifier, a voltmeter, and an am-

    meter as shown in Fig. 3.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 17

    Fig. 3. Simple Block Diagram of Auto-Balancing Bridge

    For lower frequencies, auto-balancing bridge will use a current to voltage (I/V) convert-

    er circuit which includes an operational amplifier with a negative feedback loop instead of the

    ammeter. The bridge section determines the impedance by sending the test signal current Ix

    which flows through the DUT and in turn flows into the converter. The same amount of current

    (Ir) then flows back through the resistor (Rr) as negative feedback. The I/V converter output

    voltage (Vr) can be represented by the following equation:

    Vr = Ir Rr = Ix Rr

    Ix is determined by the following equations:

    Ix = Vx / Zx

    The equation for impedance (Zx) can be derived from the above two equations as fol-

    lowing:

    Zx = (Vx / VR) Rr

    Therefore, the whole circuit is actually divided into three sections depending on their

    functionality: signal source section, auto balancing bridge section, and vector ratio detector sec-

    tion.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 18

    Fig. 4. Signal Source Section Block Diagram

    The signal source section generates the test signal that passes through the DUT. The

    frequency of the generated signal varies from 40 Hz to 110 MHz. This signal passes through a

    source resistor and gives output at Hc terminal which is connected to the input of the DUT. In

    the case of a microprocessor, both the initial signal (source) and internal reference signal can be

    generated with an integrated oscillator or the microprocessor. Frequency synthesizer and fre-

    quency conversion techniques are used to generate high-resolution test signals with a minimum

    resolution of 1 mHz.

    The auto-balancing bridge section balances the range resistor current with the DUT cur-

    rent while maintaining a zero potential at the Low terminal. When the range resistor current (Ir)

    is not balanced with the DUT current (Ix), an unbalance current which is the difference between

    Ix and Ir, flows into the null detector at the Lp terminal. The unbalance current vector represents

    how much the magnitude and phase angle of the range resistor current differ from the DUT cur-

    rent. The null detector detects the unbalance current and controls both the magnitude and phase

    angle of the second oscillator output to assure that the detected current is zero (null).

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 19

    Fig. 5. Block Diagram of Simplified Auto Balancing Bridge Section

    Low frequency instruments, below 100 kHz, employ a simple operational amplifier to

    configure the null detector. To mention, this particular circuit configuration can be used for fre-

    quencies less than 100 kHz, as the operational amplifier has performance limitation above that

    frequency range. The instruments that cover frequencies above 100 kHz have an auto balancing

    bridge circuit consisting of a null detector, a phase detectors, and a vector modulator. When an

    unbalance current is detected with the null detector, the phase detectors in the next stage sepa-

    rate the current into 0 and 90 vector components. The phase detector output signals go

    through integrators (loop filters) and are applied to the vector modulator to drive the 0 or 90

    component signals. Next, the component signals are compounded and the resultant signal is fed

    back through range resistor (Rr) to cancel the current flowing through the DUT. In the case of

    the balancing control loop having phase errors, the unbalance current component can also be

    detected and fed back to cancel the error in the range resistor current. Thus, the unbalance cur-

    rent becomes nullified to assure that the current passing through the DUT and the current pass-

    ing through the range resistor remain up to 110 MHz.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 20

    Fig. 6. Block Diagram of Vector Ratio Detector Section

    The vector ratio detector section processes the ratio of vector voltages across the DUT

    (Vx), and voltage across the range resistor (Vr). This sections has an input selector switch (S), a

    phase detector that detects phases between 0 to 90, and an Analog to Digital converter. The

    measured vector voltages are used to calculate the complex impedance (Zx). The following dia-

    gram shows the vector ratio calculation process of the voltages:

    Fig. 7. Vector Ratio Calculation Process

    The problem with this method is when the frequency is too high or when the cable

    length is too long, the bridge circuit cannot perform the automatic balancing; as a result, the

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 21

    unbalance current cannot be nullified. Also, the impedance measurement range is quite limited

    due to the existence noise level.

    Dual Slope ADC Method

    A very popular method to measure capacitance and inductance is by using a dual slope

    ADC method. The dual slope conversion takes place in three distinct phases: auto zero phase,

    signal integration phase and reference integration phase.

    In the auto-zero phase, the errors in the analog components (e.g. buffer offset voltages)

    will be automatically nulled out by grounding the input and closing a feedback loop such that

    error information is stored on an auto-zero capacitor.

    Fig. 8. Simplified Block Diagram of Dual-Slope ADC

    The signal integration phase will start the real conversion process. The input signal

    would be integrated for a fixed number of clock pulses. For a 31

    2-digit converter, 1,000 pulses is

    the general count. On completion of the integration period, the voltage VREF is directly propor-

    tional to the input signal.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 22

    Phase 3, Reference Integrate. At the beginning of this phase, the integrator input is

    switched from VIN to VREF. The polarity of the reference which was determined during Phase 2

    such that the integrator discharges back towards zero. The number of clock pulses counted be-

    tween the beginning of this cycle and the time when the integrator output passes through zero is

    a digital measure of the magnitude of VIN.

    Fig. 9. Three Phases of Dual Slope ADC Conversion.

    The effective part of the dual slope technique is that the theoretical accuracy depends

    only on the absolute value of the reference and the equality of the individual clock pulses with-

    in a given conversion cycle. The latter can easily be held to 1 part in 106, so in practical terms

    the only critical component is the reference. Changes in the value of other components such as

    the integration capacitor or the comparator input offset voltage have no effect, provided they

    dont change during an individual conversion cycle. This is in contrast to Successive Approxi-

    mation converters which rely on matching a whole string of resistor values for quantization

    Although, this method has the advantage of simplicity and precision, it also comes with

    following design limitations which can cause deviation in the measurement process:

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 23

    Dielectric absorption of the integrator capacitor must be compensated, even with high-

    quality integrator capacitors, which can require complicated calibration procedures.

    The signal must be gated on and off, as must the reference. This process can introduce

    charge injection into the input signal. Charge injection can cause input-dependent errors

    which are difficult to compensate for at very high resolutions.

    The ramp-down time seriously degrades the speed of measurement. The faster the ramp

    down, the greater the errors introduced by comparator delays, charge injection, and so on.

    Some topologies use a trans-conductance stage prior to the integrator to convert the voltage

    to a current, and then use current steering networks to minimize charge injection. Unfor-

    tunately, this added stage introduces complexity and possible errors.

    Resonant Frequency Method

    The concept of this method actually was derived from the idea of resonant frequency.

    The natural frequency of any physical system or object are the frequencies at which it will vi-

    brate if physically disturbed. However, resonance is the phenomenon that occurs when a physi-

    cal system is periodically disturbed at the same period of one of its natural frequencies. The

    very particular frequency at which resonance occur for a system is defined as the resonant fre-

    quency of that system.

    Fig. 10. LC Tank Circuit

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 24

    In general, a condition of resonance can be met with the help of a LC tank circuit with a

    set of capacitor and inductor of equal value. As, the inductive reactance of the inductor increas-

    es with increasing frequency and capacitive reactance of the capacitor decreases with increas-

    ing frequency; at a common resonant frequency both of the reactance would share an equal

    physical value which can be profound by the following formula:

    = 1

    2

    Using this concept, if an unknown inductor is connected in series with the existed in-

    ductor, or a capacitor is connected in parallel with both the inductor and capacitor of the tank

    circuit; in both cases a different resonant frequency will develop. By comparing the initial res-

    onant frequency with the new frequency (due to the attachment of unknown DUT), it is possi-

    ble to measure the value of the capacitor or inductor.

    Resistance Measurement

    There are numerous methods for measuring solely the resistance; such as- Wheatstone

    bridge method, auto balancing bridge method, four wire resistance method, voltage drop meth-

    od etc. Both the Wheatstone bridge and its modified version (auto balancing bridge) use the

    similar concept of maintaining the resistance ratio between the bridges to be equal.

    Fig. 11. Wheatstone Bridge

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 25

    For the above circuit, the ratio would be: 12

    =3

    Here, Rx is the unknown resistor to be measured. If R1 and R2 are of equal value, then Rx will

    be equal to R3. The major issue with this method is the nullification of the bridge as well as

    high inaccuracy compare to other methods.

    The four wire method of measurement is preferred for resistance values below 100.

    From the name it is clear that four different wires are used to measure resistance via this pro-

    cess. Two of the wires carry the source or lead current and test current through the R. The other

    two wires known as the sense or potential leads, are used to sense the voltage drop across R.

    The volt drop across the ohmmeters sense terminals is therefore virtually the same as the volt

    drop across the unknown resistor. The disadvantage of this method is it can measure up to

    100 resistance.

    Fig. 12. Four Wire Method of Resistance Measurement

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 26

    Voltage Drop Method

    It is probably the simplest yet quite accurate way of measuring resistance. From, Ohms

    law, it is known that, if two resistors are connected in series after a voltage source, then the

    generated voltage get dropped accordingly at output depending on the value of the resistors by

    using the following formula:

    = (2

    1 + 2) 2 = (

    ) 1

    Fig. 13. Voltage Drop Method

    If both the input and output voltages and R1 is known, then it is a very straight

    forward approach to obtain the value of R2 (DUT).

    ChipKIT WF32 Board and PIC32 Microcontroller

    PIC microcontrollers (Programmable Interface Controllers), are electronic circuits that

    can be programmed to carry out a vast range of tasks. They can be programmed to be timers or

    to control a production line and much more. They are found in most electronic devices such as

    alarm systems, computer control systems, phones, in fact almost any electronic device. THE

    ChipKIT WF32 is a prototyping platform based on Arduino with PIC32 microcontroller

    onboard. The PIC32MX695F512L microcontroller comes with a 32-bit MIPS (Microprocessor

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 27

    without Interlocked Pipeline Stages) based processor core running at 80 MHz, SRAM (Static

    random-access memory) data memory of 128K and a flash memory of 512K. It has an installed

    Wi-Fi MRF24 module and a micro-SD card module with distinctive signal. For its low price,

    wide range of application, high quality and easy availability, it is an ideal solution in applica-

    tions such as: the control of different processes in industry, machine control devices, measure-

    ment of different values etc. It has a wide range of operating frequency that could be highly ap-

    preciable for this project as the measurement range is quite dynamic.

    Fig. 14. The ChipKIT WF32 Board

    ChipKIT WF32 also features a USB serial port interface for connection to the MP IDE

    and can be powered via USB or by an external power supply. It also provides with 43 available

    I/O pins and 12 dedicated analog inputs. The serial communication port on the WF32 board is

    enacted using an FTDI FR232RQ USB serial converter. The MPIDE uses a serial communica-

    tions port to communicate with a boot loader running on the WF32 board. The serial port on the

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 28

    WF32 board is implemented using an FTDI FT232RQ USB serial converter. The WF32 board

    has a standard mini-USB connector. Every time before the connection between MPIDE and

    WF32 board is established, the board is reset and activates the boot loader. The MPIDE then

    establishes communications with the boot loader and uploads the program to the board. To

    open the serial communications connection on a PC, the DTR pin on the FT232RQ chip is set

    to low and thus the microcontroller is reset and it initializes the process with boot loader. How-

    ever, if necessary, then this auto reset operation can be disabled via a jumper JP1 by unshorten-

    ing it. There are two LEDs (LD1 and LD2) present in the board which blinks when data trans-

    fer between the WF32 and the PC over the serial connection is in process.

    The WF32 board can also use an external power supply via J14 of J17 pin. The power

    supply section provides with a 3.3V and a 5V voltage regulators. The 3.3V regulator is used to

    power up the board and to perform any internal operation; whereas, the 5V supply is dedicated

    to any external circuits or shields. In fact, The WF32 can be operated as a self-powered device

    or as a bus powered device from either the USB serial connector (J1) or the USB OTG/device

    connector (J12). The jumper block (J15) is used to select the power source to be used to power

    the board.

    It also comes with a micro-SD card connector to access data stored on micro-SD sized

    flash memory cards using the SD card library provided as part of the MPIDE software system.

    Dedicated SPI interface on PIC32 microcontroller pins are used to access the SD card. The

    most important function of the SD card is it can be used as the store for server. After writing

    any HTTP Web server hosting page in a HTML editor, it can be saved and keep functional by

    plugging in the SD card in the ChipKIT boards SD card slot and implementing necessary pro-

    gramming.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 29

    Wi-Fi Module

    The WF32 comes with a microchip MRF24WG0MA 802.11 b/g compatible Wi-Fi in-

    terface. The firmware of the interface provides the 802.11 network protocol support. The

    DNETcK and DWIFIck libraries present the TRP/IP network protocol support for the Wi-Fi

    module. The module can keep up to 25 MHz of SPI clock speeds. The interface to the Wi-Fi

    module also includes a reset signal, an interrupt signal and a hibernate signal. The active low

    RESET signal is used to reset the Wi-Fi module. The INT signal on the Wi-Fi module is con-

    nected to external interrupt INT4 on the PIC32 microcontroller. The active low hibernate signal

    is used to power the Wi-Fi module down and to keep it in a low power state.

    SPI

    The synchronous serial port can be accessed using the SPI standard library. Pin 10, 11,

    12 and 13 are dedicated for this purpose. Jumpers JP6 and JP7 are used to select the operation

    mode: a Master (transmit on MOSI, receive on MISO) or a Slave (transmit on MISO, receive

    on MOSI) device. The shorting blocks on JP6 and JP7 are normally placed in the Master posi-

    tion for the WF32 to function as an SPI master. Jumper JP3 is used to select PWM output or the

    SPI SS function on Pin 10. The shorting block on JP3 should be in the PWM position to select

    PWM output. It should be in the SS position to select the SPI SS function.

    A/D Converter

    The PIC32 has a 10-bit Analog-to-Digital Converter (ADC) with a capacity of up to 1

    Msps conversion speed and has 16 analog inputs. It uses a Successive Approximation Register

    (SAR) conversion method. It also has two analog input pins for external voltage reference con-

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 30

    nections which is allowed to share with other analog input pins. The analog inputs are connect-

    ed through two multiplexer. The analog input MUXs can be switched between two sets of ana-

    log inputs between conversions. Unipolar differential conversions are possible on all channels.

    The left-most outer pin on connector J5 is used to provide an external voltage reference to de-

    termine the input voltage range of the analog pins. The maximum voltage that can be applied to

    this pin is 3.3V. This pin can also be used as digital pin 42. The 10-bit ADC is connected to a

    16-word result buffer. Each 10-bit result is converted to one of eight 32-bit output formats

    when it is read from the result buffer.

    Server

    A server is a computer system designed to process requests and deliver data to other

    computing system (client) computers over a local network or the Internet. Web server applica-

    tions provide network access to Web pages and other intranet and Internet content. Server can

    refer to either software or software server system. The typical server is actually a scheme where

    a user or client approaches and requests for particular services and the server carries on the ser-

    vice accordingly.

    In a client-server environment, each computer has some resources which can be ac-

    cessed through the other computers. Also, a particular computer can act as a resource centre or

    storage from where the other computers can access them. PIC32 microprocessor has a pre-built

    application system that includes FreeRTOS, embDUAL (IPv4 and IPv6 TCP/IP stack) and

    embHTTP. Instructions are provided to download the pre-build binary, program the PIC32

    flash memory, and interact with the demo using a standard web browser. For this project, a

    server will be established to store the measurement data in the internet webpage, which can be

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 31

    accessible by the clients or users with authentic credential. The server is capable of sending and

    receiving data from the microprocessor to the webpage.

    Design

    As it is a multi-measurement unit; hence, 4 different measurements are processed in

    four different states. Each state can be selected using designated switches provided in the

    measurement unit board. Pin A2 is set for selecting voltage measurement, pin A3 for resistance,

    pin A4 for capacitance and pin A5 for measuring inductance. The four switches themselves are

    connected with pin A0 of the microcontroller. Pin A6 to A11 are initialized as output pins.

    Voltage measurement

    The PIC microcontroller used in this project is a PIC32MX695F512L that has 16 analog

    input pins for the in-built 16-bit ADC. The voltage to be measured is fed to one of the 16 ana-

    log channels. PIC32 has a range of voltage between 0V-3V. To match with the input range an

    instrumentation amplifier is used just before the input voltage. The initial supply voltage is fed

    through the negative input of the amplifier. A reference voltage, Vref was sent through the posi-

    tive input. R1 and R2 were selected as 9890 and 991 respectively. In this process, even

    negative voltage is possible to handle. The following formulation was used to adjust the input

    voltage:

    = (1 +2

    1) (

    2

    1) ; = (

    10) + 2.11

    This output voltage was then fed to the ADC input and then the microprocessor calcu-

    late the actual input voltage using the following formula:

    = ( 2.11)(10)

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 32

    The resultant voltage is then displayed in the LCD of the measurement unit.

    Inductance Measurement

    After much researching and cost analysis, it was decided that the resonant frequency

    method would be chosen to measure inductance. Colpitts Oscillator was used for this purpose

    as it consists of a similar parallel LC resonator tank circuit, which has configuration with less

    self and mutual inductance in the circuit, and provides more stable frequency at output. How-

    ever, in the LC circuit there instead of a single capacitor, Colpitts oscillator uses two capacitors

    in series which actually acts a capacitor based voltage divider. The oscillating frequency which

    is a pure sine-wave voltage is determined by the resonance frequency of the tank circuit. When

    the power supply is connected with to the junction of the capacitor C1 and C2, they get charged

    up and then discharged through the coil (inductor). The frequency of oscillations for is deter-

    mined by the resonant frequency of the LC tank circuit:

    = 1

    2

    Here, CT is the equivalent capacitance of the series connected C1 and C2:

    =

    121+2

    The amount of the feedback will depend on the values of the two capacitors; the feed-

    back will be higher with small valued capacitors. There were options to choose either bipolar

    junction transistor (BJT) as the amplifiers active stage of the Colpitts oscillator, or an opera-

    tional amplifier. However, the op-amp based Colpitts oscillator was chosen as it was simple to

    design and the gain for the op-amp circuit depend on the input and feedback resistors; no other

    circuit elements have any effect on it.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 33

    Fig. 15. Colpitts Oscillator Circuit to Measure Inductance

    At inverting mode, the op-amp used R1 = 1 k as input resistor and R2 = 100 k as the

    feedback resistor. Therefore, the gain was obtained as, A= 2

    1 = 100. The capacitor values

    were chosen as C1=C2= 1F and CT = 0.5 F.

    Pin A5 of the microcontroller was used as the input which was connected to the Vout of

    the oscillator circuit. XR2206 function generator was used as an external oscillator was to pro-

    vide high quality sine waveform (0-3 V at 9V DC input) of high-stability and accuracy. The

    frequency value for the initial parallel LC circuit is measured and stored. Then the unknown

    inductance Lx is connected and the new frequency is received by the microprocessor. Then both

    the frequencies are processed and the value of the inductance is achieved. The output values are

    then displayed in the LCD as well as the value would be wirelessly uploaded to the webpage

    created for this project.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 34

    Capacitance Measurement

    In general, capacitance is used as a very common and significant component in deter-

    mining the frequency of various oscillatory circuits. In this project, an astable multivibrator 555

    timer IC was used to apprehend the frequency of an oscillation which then use to find the un-

    known capacitance used in the designed circuitry. 555 timer has a broad frequency output rang-

    es which mostly depend on the two resistors and the timing capacitors used in the circuit.

    The frequency of oscillation for the 555 timer circuit can be derived from the

    following formula:

    =1.44

    (1 + 22)

    The values for R1 and R2 were taken as 66.7 k and 67 k respectively which were al-

    most equal. To improve the duty cycle of the 555 timer, a diode was added in parallel with R2

    which change the frequency equation to:

    =1.44

    (1 + 2)

    For an unknown capacitor C (which is actually the timer capacitor of the 555 timer cir-

    cuit) is connected for measurement purpose; a pulse will send be sent through the 555 timer. It

    will produce an output pulse with a certain frequency which will be taken as input via A5 pin of

    the PIC32. The microprocessor will count the value of the frequency and from the above for-

    mula calculate the value of the capacitor and will output in the LCD as well as to the webpage

    designed for the project.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 35

    Fig. 16. Astable 555 Timer Circuit to Measure Capacitance

    Resistance Measurement

    For the designing of the resistor measurement system, the voltage divider is implement-

    ed with a known small valued shunt resistor of 1.058 . The reference voltage will be meas-

    ured by the microprocessor using the process described in the previous voltage measurement

    section. In the next step, the voltage divider equation mentioned in the theory section will be

    used to calculate the unknown resistance of the DUT. However, while measuring the resistance,

    it was appeared that the voltage across the shunt resistor was very small (0.32 mV) which was

    not possible to read by the microprocessor accurately. To solve this issue, an instrumentation

    amplifier was connected in parallel to the shunt resistor. The amplifier will initially increase the

    gain of the output voltage across the shunt resistor. The gain of the amplifier could be measured

    by the following formula:

    =49400

    + 1; where RG = 55, is the resistor connected in between the positive and

    the negative power supply of the amplifier. Using this amplified voltage, the microprocessor

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 36

    will calculate the output voltage using the following formula and then will use it to find the

    value of the unknown resistance.

    = (+ )() = (0.32 0)(899)

    Web Server and Site Design

    The web server was set up using the chipKITs built in SD card facility. First the server

    was created using HTML and then it was copied to the SD card. It is needed to confirm that any

    links which was specified in the web pages should be relative to the current page, or relative to

    the root of the SD file system. The website was built using the basic HTML with the JavaScript

    support to send and receive data from the internet. The chipKIT WF32 board can be connected

    with a router using the Ethernet port present in the board. The server is running from the board.

    Whenever, the board does any measurement, it stored in a variable inside the html file which is

    inside the SD card. With the help of Wi-Fi module in the board, is connected to the router by

    matching the SSID which is already programed in the board and the pass phrase. Basically, Wi-

    Fi module scan all the Wi-Fi networks and connects to the appropriate networks. After the con-

    nection is made, the Wi-Fi module, starts listening to the pre-defined IP address, at which point

    the web server goes online. The variables which are stored in the html file (V, R, L, C) and the

    current state. And they are being displayed in a table format in the webpage. The main HTML

    file refreshes every 2 seconds to get the updated value.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 37

    Documentation Including Schematics and Parts

    Lists

    Component Model / Details

    Micro-processor Board ChipKIT WF32

    Micro-controller PIC32MX695F512L

    555 Timer IC LM511

    Function Generator XR2206

    Switch PBS-26

    Operational Amplifiers LM741, LM314, AD620

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 38

    Measurement and Testing Procedure

    As mentioned earlier, the measurement unit has four different states for four distinctive

    parameters. Each states are selected with a push button switch. At every push, it changes one

    state and it follows as: voltage resistance capacitance inductance. Therefore, a single

    push initiates the first state (voltage measurement), consecutive two pushes initiates the second

    state (resistance measurement), and third and fourth state activate with three and four pushes

    respectively. If a user wants to move to the capacitance measurement directly (without measur-

    ing the first two parameters), the switch is needed to be pushed thrice. At the hardware side,

    when any DUT is connected to the measurement probe, the switch is pushed for respective

    number of times. As soon as the state is selected, the particular measurement circuitry will be

    activated and the function generator will supply a pulse through that circuit. For the voltage

    measurement, the microprocessor will measure the voltage via ADC and display it in the LCD.

    In the similar fashion, whenever any DUT will be connected to the measurement probe, the

    particular type of measurement (inductance, resistance or capacitance) will be displayed in the

    LCD.

    These results can be seen from the website created for this project. Any user (client pc)

    with the login credential can access the website. The website contents a table consisted of the

    measurement results which will be updated automatically time to time. Whenever a state is se-

    lected, it will be highlighted in the table and the data will be displayed. At the very same time, a

    graphical representation of the output pulse will be displayed in the webpage which was devel-

    oped using JavaScript.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 39

    Fig. 17. Webpage Display for the Measurement Unit

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 40

    Performance Measurement

    Voltage

    Range % error

    (+ve) 4V (-ve) 4V Less than 3%

    Resistance

    Range % error

    1 k - 15 k Less than 3.5%

    Capacitance

    Range % error

    1 F 1 mF Less than 5%

    Inductance

    Range % error

    1 mH 1 H Less than 3%

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 41

    Analysis of Performance

    From the performance measurement section, the accuracy of the results were within a

    reasonable accuracy range. In all four cases of measurements, the measured values had less

    than 5% of accuracy. The frequency range for this measurement could have been improved us-

    ing different values of resistor with relay or CMOS switches which would reroute the supply

    voltage to a different set of resistor set (that can handle that higher or lower range of frequency).

    Voltage values were fairly close to the actual input values. In the case of webpage, the tables

    were updated in an acceptable manner. However, the output voltage graph was not fair enough

    to consider.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 42

    Conclusion

    The project was focused on the measurement unit with multi-functionality with internet

    access. To choose the right method for the measurement as well as the server and Wi-Fi mod-

    ule development, a great deal of research was apprehended. The measurement parameters were:

    voltage, inductance, capacitance and resistance. After the completion of the measurement unit,

    the results we had received were with in an acceptable percentage error. The measurement

    range for all four components were for voltage, (+ve) 4V to (-ve) 4V; for resistance, from 1 k

    to 15 k; for capacitance, from 1 F to 1 mF; and for inductance from 1mH to 1H. The internet

    access for the results was established successfully with the aid of the SD card system and Wi-Fi

    module of the ChipKIT WF32 board. The frequency range could have been higher with a dif-

    ferent configuration of the resistor set used in the measurement units circuitry; however, for

    that relays or switch should have been implemented. Overall, the design project appeared to be

    successful in terms of the final result and the learning aspects.

    This engineering designing project was a practical experience of a typical designing

    process for an engineer. There are some aspects of engineering field in real life which were ex-

    perienced through this project. Throughout this project, we have learnt to research and analyze

    different measurement processes, the combinational approach of hardware and software devel-

    opment, and the different sides of a professional report writing techniques. Moreover, it al-

    lowed us to learn team-work, time management, cost minimization, managerial experience as

    well. In the conclusion, it can be said that the designing of this multi-measurement unit was a

    valuable experience for the final year students; as it would vastly help us to implement our the-

    oretical knowledge in practical engineering field.

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 43

    Appendices

    Code for measurement unit

    #include

    #include

    #include // MRF24WG WiFi transceiver -- also use for the

    WF32

    #include

    #include

    #include

    LiquidCrystal lcd(9, 8, 7, 6, 5, 4);

    const int chipSelect_SD_default = 51; // Change 10 to 53 for a Mega

    const int chipSelect_SD = chipSelect_SD_default;

    static const char szHTMLRestart[] = "GET /Restart ";

    static const char szHTMLTerminate[] = "GET /Terminate ";

    static const char szHTMLReboot[] = "GET /Reboot ";

    static const char szHTMLFavicon[] = "GET /favicon.ico ";

    static const char szHTMLSample[] = "GET /Sample ";

    GCMD::ACTION ComposeHTMLSamplePage(CLIENTINFO * pClientInfo);

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 44

    /// State Variables

    int x=0,count=0,count2=0;

    /// Voltage Variables

    float v=0,vactual=0,vref=1.918,r1=9890,r2=991;

    /// Resistance Variables

    int samples=100;

    float vr=0,g=49400/55+1,rshunt=1,iactual=0,vrref=3.245,R=0;

    /// Capacitance Variables

    float fc=0;

    float rc1=465,rc2=463,C=0,CmF=0,CuF=0,CnF=0;

    //float r1=66700, r2=67000;

    /// Inductance Variables

    float fi=0, fave=0, w=0, w2=0, CT=0.5*pow(10,-6),L=0,LmH=0;

    /// File declarations

    File dataFile;

    void setup()

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 45

    {

    Serial.begin(9600);

    Serial.print("Initializing SD card...");

    lcd.begin(16,2);

    pinMode(A2, INPUT); // Voltage

    pinMode(A3, INPUT); // Resistance

    pinMode(A4, INPUT); // Capacitance

    pinMode(A5, INPUT); // Inductance

    pinMode(A0, INPUT); // Switch

    pinMode(A6, OUTPUT);

    pinMode(A7, OUTPUT);

    pinMode(A8, OUTPUT);

    pinMode(A9, OUTPUT);

    pinMode(A10, OUTPUT);

    pinMode(A11, OUTPUT);

    //// SPI Intializations

    pinMode(chipSelect_SD_default, OUTPUT);

    digitalWrite(chipSelect_SD_default, HIGH);

    pinMode(chipSelect_SD, OUTPUT);

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 46

    digitalWrite(chipSelect_SD, HIGH);

    // see if the card is present and can be initialized:

    if (!SD.begin(chipSelect_SD)) {

    Serial.println("Card failed, or not present");

    return;}

    Serial.println("card initialized.");

    //////////// WEB SERVER

    AddHTMLPage(szHTMLSample, ComposeHTMLSamplePage);

    AddHTMLPage(szHTMLRestart, ComposeHTMLRestartPage);

    AddHTMLPage(szHTMLTerminate, ComposeHTMLTerminatePage);

    AddHTMLPage(szHTMLReboot, ComposeHTMLRebootPage);

    SetDefaultHTMLPage(ComposeHTMLSDPage);

    SDSetup();

    ServerSetup();

    ProcessServer();

    }

    void loop()

    {

    buttoncount();

    lcd.setCursor(0,0);

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 47

    lcd.clear();

    // save to file

    dataFile = SD.open("target.htm", FILE_WRITE);

    dataFile.seek(83);

    dataFile.println("");

    dataFile.print("var V=");

    dataFile.print(vactual,4);

    dataFile.print(";");

    dataFile.println("");

    dataFile.print("var R=");

    dataFile.print(R,4);

    dataFile.print(";");

    dataFile.println("");

    dataFile.print("var C=");

    dataFile.print(C,8);

    dataFile.print(";");

    dataFile.println("");

    dataFile.print("var L=");

    dataFile.print(L,8);

    dataFile.print(";");

    dataFile.println("");

    dataFile.print("var S=");

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 48

    dataFile.print(count2);

    dataFile.print(";");

    dataFile.println("");

    dataFile.close();

    switch(count2){

    case 0:

    lcd.setCursor(0, 0);

    lcd.print("Voltage ");

    // voltage acquisition

    v=((3.25-0)/(pow(2,10)-1))*analogRead(A2);

    vactual=-(v-(1+r2/r1)*vref)/(r2/r1);

    // print to lcd

    lcd.setCursor(0, 1);

    lcd.print(vactual);

    lcd.print("V");

    break;

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 49

    case 1:

    lcd.setCursor(0,0);

    lcd.print("Resistance ");

    vr=0;

    for(int i=0;i

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 50

    fc=(1/(2*pulseIn(A4, HIGH)*pow(10,-6))) ;

    C=1/((rc1+rc2)*fc);

    CmF=C*pow(10,3);

    CuF=C*pow(10,6);

    CnF=C*pow(10,9);

    lcd.setCursor(0,1);

    lcd.print(CuF, 6);

    lcd.print(" uF");

    break;

    case 3:

    lcd.setCursor(0,0);

    lcd.print("Inductance ");

    fi=(1/(2*pulseIn(A5, HIGH)*pow(10,-6))) ;

    w=(2*3.14159265359*fi);

    w2=pow(w,2);

    L=1/(w2*CT);

    LmH=L*1000;

    lcd.setCursor(0,1);

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 51

    lcd.print(L,6);

    lcd.print(" H");

    break;

    }

    ProcessServer();

    delay(40);

    }

    void buttoncount(){

    x=digitalRead(A0);

    if(x==HIGH){

    count++;

    if(count>10){

    count2++;

    count=0;

    if(count2>3){

    count2=0;

    }}}}

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 52

    Code for Webserver

    /*********************************************************************/

    /* */

    /* HTTPServerConfig.h */

    /* */

    /* The network and WiFi configuration file required */

    /* to specify the network parameters to the network libraries */

    /* */

    /*********************************************************************/

    /* Author: Keith Vogel */

    /* Copyright 2013, Digilent Inc. */

    /**********************************************************************

    **/

    /*

    This library is free software; you can redistribute it and/or

    modify it under the terms of the GNU Lesser General Public

    License as published by the Free Software Foundation; either

    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

    GNU

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 53

    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public

    License along with this library; if not, write to the Free Software

    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

    */

    /**********************************************************************

    **/

    /* Revision History: */

    /* 7/19/2013(KeithV): Created */

    /**********************************************************************

    **/

    #if !defined(_WEBSERVERCONFIG_H)

    #define_WEBSERVERCONFIG_H

    //*********************************************************************

    ***

    //*********************************************************************

    ***

    //****************** SET THESE VALUES FOR YOUR NETWORK

    *****************

    //*********************************************************************

    ***

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 54

    //*********************************************************************

    ***

    // You have a choice of either calculating a static IP based on LocalStaticIP (next varia-

    ble)

    // Or setting the whole IP yourself. If you want DHCP to supply and automatically set

    // your network parameters, set this to {0,0,0,0}. However, you then MUST set lo-

    calStaticIP.

    // If you fully specify your static IP, then you do NOT need to set localStaticIP

    // but you MUST then set the remaining Gateway, subnet, and DNS values below.

    //static IPv4 ipMyStatic = {192,168,1,225}; // a place to calculate our static IP

    static IPv4 ipMyStatic = {0,0,0,0}; // a place to calculate our static IP

    // This will be ignored if ipMyStatic is NOT set to {0,0,0,0}

    // If ipMyStatic == {0,0,0,0} AND localStaticIP == 0, then the full IP returned by

    DHCP will be used

    // Otherwise this is the last octet in the IP address... so if DHCP comes up with a subnet

    of 192.168.1.x

    // this will set your IP address to 192.168.1.(localStaticIP) for example if

    // localStaticIP == 190; your final IP address would be 192.168.1.190 assuming the

    subnet address of 192.168.1.x

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 55

    static byte localStaticIP = 195; // this will be the gateway IP with the last octet of the

    IP being 195

    // Set the port to listen on; this is a required item

    static unsigned short listeningPort = 80; // 80 is the default for an HTTP server

    // how many sockets/connections will we be able to handle at once? Also required

    #define cMaxSocketsToListen 6

    // You ONLY MUST set these if you specifically assigned ipMyStatic to a static

    // IP address other than {0,0,0,0}; otherwise DHCP will overwrite these.

    static IPv4 ipGateway = {192,168,1,1};

    static IPv4 subnetMask = {255,255,255,0};

    static IPv4 ipDns1 = {8,8,8,8}; // public Google DNS server

    static IPv4 ipDns2 = {8,8,4,4}; // public Google DNS server

    //*********************************************************************

    ***

    //*********************************************************************

    ***

    //***************** SET THESE VALUES FOR YOUR WIFI AP

    ******************

    //************* only have to set these if you are using WiFi *************

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 56

    //*********************************************************************

    ***

    //*********************************************************************

    ***

    #ifdef USING_WIFI

    // Specify the SSID of your AP

    const char * szSsid = "jabran";

    // select ONLY 1 for the security you want, or none for no security

    // then updated the appropriate section below for your key or passphrase

    #define USE_WPA2_PASSPHRASE

    //#define USE_WPA2_KEY

    //#define USE_WEP40

    //#define USE_WEP104

    #define USE_WF_CONFIG_H // See documentaton for WF_Config.x override

    // modify the security key to what you have.

    #if defined(USE_WPA2_PASSPHRASE)

    const char * szPassPhrase ="hello123";

    #define WiFiConnectMacro() DWIFIcK::connect(szSsid, szPassPhrase, &status)

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 57

    #elif defined(USE_WPA2_KEY)

    DWIFIcK::WPA2KEY key = { 0x27, 0x2C, 0x89, 0xCC, 0xE9, 0x56, 0x31, 0x1E,

    0x3B, 0xAD, 0x79, 0xF7, 0x1D, 0xC4, 0xB9, 0x05,

    0x7A, 0x34, 0x4C, 0x3E, 0xB5, 0xFA, 0x38, 0xC2,

    0x0F, 0x0A, 0xB0, 0x90, 0xDC, 0x62, 0xAD, 0x58 };

    #define WiFiConnectMacro() DWIFIcK::connect(szSsid, key, &status)

    #elif defined(USE_WEP40)

    const int iWEPKey = 0;

    DWIFIcK::WEP40KEY keySet = { 0xBE, 0xC9, 0x58, 0x06, 0x97, // Key 0

    0x00, 0x00, 0x00, 0x00, 0x00, // Key 1

    0x00, 0x00, 0x00, 0x00, 0x00, // Key 2

    0x00, 0x00, 0x00, 0x00, 0x00 }; // Key 3

    #define WiFiConnectMacro() DWIFIcK::connect(szSsid, keySet, iWEPKey, &status)

    #elif defined(USE_WEP104)

    const int iWEPKey = 0;

    DWIFIcK::WEP104KEY keySet = { 0x3E, 0xCD, 0x30, 0xB2, 0x55, 0x2D, 0x3C,

    0x50, 0x52, 0x71, 0xE8, 0x83, 0x91, // Key 0

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 58

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, // Key 1

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00, // Key 2

    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

    0x00, 0x00, 0x00 }; // Key 3

    #define WiFiConnectMacro() DWIFIcK::connect(szSsid, keySet, iWEPKey, &status)

    #elif defined(USE_WF_CONFIG_H)

    #define WiFiConnectMacro() DWIFIcK::connect(0, &status)

    #else // no security - OPEN

    #define WiFiConnectMacro() DWIFIcK::connect(szSsid, &status)

    #endif

    // this should be uncommented if you want to restart

    // the WiFi connection when DNETcK is restarted.

    // This is generally uninteresting unless you have a reason

    // #define RECONNECTWIFI

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 59

    #endif // USING_WIFI

    //*****************************************************************

    //*****************************************************************

    //******************* END OF CONFIGURATION *********************

    //*****************************************************************

    //*****************************************************************

    #endif // _WEBSERVERCONFIG_H

    Code for SD card

    /**********************************************************************

    **/

    /* */

    /* HTMLSDPage.cpp */

    /* */

    /* Renders pages off of the SD card filesystem */

    /* Typically you would make this the default page handler */

    /* */

    /**********************************************************************

    **/

    /* Author: Keith Vogel */

    /* Copyright 2013, Digilent Inc. */

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 60

    /**********************************************************************

    **/

    /*

    This library is free software; you can redistribute it and/or

    modify it under the terms of the GNU Lesser General Public

    License as published by the Free Software Foundation; either

    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

    GNU

    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public

    License along with this library; if not, write to the Free Software

    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

    */

    /**********************************************************************

    **/

    /* Revision History: */

    /* 7/19/2013(KeithV): Created */

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 61

    /**********************************************************************

    **/

    #include

    /**********************************************************************

    **/

    /* SD Card Reader variables */

    /**********************************************************************

    **/

    #define pinSdCs PIN_SDCS

    // used externally to this file

    // this should not be used externally directly

    // use the "is/take/release" functions defined in HTPServer.h

    bool fSDfs = false;

    uint32_t sdLockCur = SDUNLOCKED;

    uint32_t sdLock = 1;

    // you can use this directly externally only if you "take" the card reader

    File fileSD = File();

    static const char * szFileName = NULL;

    static const char szDefaultPage[] = "HomePage.htm";

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 62

    static CLIENTINFO * pClientMutex = NULL;

    static uint32_t cbSent = 0;

    static uint32_t tStart = 0;

    static uint32_t sdLockId = SDUNLOCKED;

    /**********************************************************************

    **/

    /* HTML Strings */

    /**********************************************************************

    **/

    static const char szEndOfURL[] = " HTTP";

    static const char szGET[] = "GET /";

    /**********************************************************************

    **/

    /* State machine states */

    /**********************************************************************

    **/

    typedef enum {

    PARSEFILENAME,

    BUILDHTTP,

    EXIT,

    SENDFILE,

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 63

    JMPFILENOTFOUND,

    DONE

    } STATE;

    /*** void SDSetup(void)

    *

    * Parameters:

    * None

    *

    * Return Values:

    * None

    *

    * Description:

    *

    * Initializes SD Reader for HTML file operations

    *

    * ------------------------------------------------------------ */

    void SDSetup(void)

    {

    // set up the lock counters

    sdLockCur = SDUNLOCKED;

    sdLock = SDUNLOCKED + 1; // never want this to be zero

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 64

    // Set the pin used to control the SS line on the SD card to output.

    digitalWrite(pinSdCs, HIGH);

    pinMode(pinSdCs, OUTPUT);

    // See if there is an SD card connected

    // and that the motion subdirectory exists

    fSDfs = false;

    if (SD.begin(pinSdCs))

    {

    // Card successfully initialized, so we have a file system.

    Serial.println("SD card initialized. File system found.");

    if(SD.exists((char *) szDefaultPage))

    {

    Serial.print("Default HTML page:");

    Serial.print(szDefaultPage);

    Serial.println(" exists!");

    fSDfs = true;

    }

    else

    {

    Serial.print("Unable to find default HTML page:");

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 65

    Serial.println(szDefaultPage);

    }

    }

    else

    {

    Serial.println("Unable to find SD Card Reader or filesystem");

    }

    }

    /*** GCMD::ACTION ComposeHTMLSDPage(CLIENTINFO * pClientInfo)

    *

    * Parameters:

    * pClientInfo - the client info representing this connection and web page

    *

    * Return Values:

    * GCMD::ACTION - GCMD::CONTINUE, just return with no outside action

    * - GCMD::READ, non-blocking read of input data into the rgbIn buff-

    er appended to the end of cbRead

    * - GCMD::GETLINE, blocking read until a line of input is read or un-

    til the rgbIn buffer is full, always the line starts at the beginnig of the rgbIn

    * - GCMD::WRITE, loop writing until all cbWrite bytes are written

    from the pbOut buffer

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 66

    * - GCMD::DONE, we are done processing and the connection can be

    closed

    *

    * Description:

    *

    * This renders a page off of the SD filesystem. Pages of type

    * .htm, .html, .jpeg, .png, .txt and more may be rendered

    * The file extension on the filename determine the MIME type

    * returned to the client.

    *

    * ------------------------------------------------------------ */

    GCMD::ACTION ComposeHTMLSDPage(CLIENTINFO * pClientInfo)

    {

    char * pFileNameEnd = NULL;

    GCMD::ACTION retCMD = GCMD::CONTINUE;

    switch(pClientInfo->htmlState)

    {

    case HTTPSTART:

    if(pClientMutex != NULL || (sdLockId = lockSD()) == SDUNLOCKED)

    {

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 67

    break;

    }

    pClientMutex = pClientInfo;

    Serial.println("Read an HTML page off of the SD card");

    Serial.print("Entering Client ID: 0x");

    Serial.println((uint32_t) pClientMutex, HEX);

    pClientInfo->htmlState = PARSEFILENAME;

    retCMD = GCMD::GETLINE;

    break;

    case PARSEFILENAME:

    // the assumption is that the file name will be on the first line of the command

    // there is a bunch of other stuff on the line we don't care about, but it is at the

    // end of the line.

    Serial.println((char *) pClientInfo->rgbIn);

    // find the begining of the file name

    szFileName = strstr((const char *) pClientInfo->rgbIn, szGET);

    if(szFileName == NULL)

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 68

    {

    pClientInfo->htmlState = JMPFILENOTFOUND;

    break;

    }

    szFileName += sizeof(szGET) - 1;

    // find the end of the file name

    pFileNameEnd = strstr(szFileName, szEndOfURL);

    if(pFileNameEnd == NULL)

    {

    pClientInfo->htmlState = JMPFILENOTFOUND;

    break;

    }

    else if(pFileNameEnd == szFileName)

    {

    szFileName = szDefaultPage;

    }

    else

    {

    *pFileNameEnd = '\0';

    }

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 69

    Serial.print("SD FileName:");

    Serial.println(szFileName);

    if(SD.exists((char *) szFileName))

    {

    Serial.print("HTML page:");

    Serial.print(szFileName);

    Serial.println(" exists!");

    pClientInfo->htmlState = BUILDHTTP;

    }

    else

    {

    Serial.print("Unable to find HTML page:");

    Serial.println(szFileName);

    pClientInfo->htmlState = JMPFILENOTFOUND;

    }

    break;

    // We need to build the HTTP directive

    case BUILDHTTP:

    if((fileSD = SD.open(szFileName, FILE_READ)) && fileSD.seek(0) )

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 70

    {

    pClientInfo->cbWrite = BuildHTTPOKStr(false, fileSD.size(), szFileName,

    (char *) pClientInfo->rgbOut, sizeof(pClientInfo->rgbOut));

    if(pClientInfo->cbWrite > 0)

    {

    pClientInfo->pbOut = pClientInfo->rgbOut;

    retCMD = GCMD::WRITE;

    pClientInfo->htmlState = SENDFILE;

    cbSent = 0;

    tStart = millis();

    Serial.print("Writing file:");

    Serial.println(szFileName);

    }

    else

    {

    Serial.print("Unable to build HTTP directive for file:");

    Serial.println(szFileName);

    pClientInfo->htmlState = JMPFILENOTFOUND;

    }

    }

    else

    {

    Serial.print("Unable to open HTML page:");

  • A Multi-Measurement Unit with the Internet Access

    Jabran Sajid, Mohammad Rokibul Islam, Sajidur Rahman Page 71

    Serial.println(szFileName);

    pClientInfo->htmlState = JMPFILENOTFOUND;

    }

    break;

    // Send the file

    case SENDFILE:

    {

    uint32_t cbT = 0;

    if((cbT = SDRead(fileSD, pClientInfo->rgbOut, sizeof(pClientInfo-

    >rgbOut))) > 0)

    {

    cbSent += cbT;

    pClientInfo->pbOut = pClientInfo->rgbOut;

    pClientInfo->cbWrite = cbT;

    tStart = millis();

    retCMD = GCMD::WRITE;

    }

    else if(cbSent == fileSD.size())

    {

    pClientInfo->htmlState = EXIT;

    }

    else if((millis() - tStart) > SDREADTIMEOUT)

    {

  • A Multi-Measurement Uni