Introduction To Labview
Introduction To Labview
Introduction to LabVIEW
LabVIEW is a program development application, much like various commercial C or BASIC development systems, or National Instruments Lab Windows. However, LabVIEW is different from those applications in one important respect. Other programming systems use textbased languages to create lines of code, while LabVIEW uses a graphical programming language, G, to create programs in block diagram form. We can use LabVIEW with little programming experience. LabVIEW uses terminology, icons, and ideas familiar to scientists and engineers and relies on graphical symbols rather than textual language to describe programming actions. LabVIEW programs are called virtual instruments, or VIs, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeters. LabVIEW contains a comprehensive set of tools for acquiring, analysing, displaying, and storing data, as well as tools to help you troubleshoot code we write LabVIEW has extensive libraries of functions and subroutines for most programming tasks. For Windows, Macintosh, and Sun, LabVIEW contains application specific libraries for data acquisition and VXI instrument control. LabVIEW also contains application-specific libraries for GPIB and serial instrument control, data analysis, data presentation, and data storage. LabVIEW includes conventional program development tools, so you can set breakpoints, animate program execution to see how data passes through the program and single-step through the program to make debugging and program development easier. In LabVIEW, we build a user interface, or front panel, with controls and indicators. Controls are knobs, push buttons, dials, and other input mechanisms. Indicators are graphs, LEDs, and other output displays. After we build the user interface, you add code using VIs and structures to control the front panel objects. The block diagram contains this code. We can use LabVIEW to communicate with hardware such as data acquisition, vision, and motion control devices, as well as GPIB, PXI, VXI, RS232, and RS485 instruments. National Instruments provides a graphical system design platform for test, control, and embedded design applications that are transforming the way engineers and scientists design, prototype, and deploy systems.
VIs receive instructions from a BLOCK DIAGRAM, which you construct in G. The block diagram supplies a pictorial solution to a programming problem. The block diagram contains the source code for the VI
VIs use a hierarchical and modular structure. You can use them as top-level programs, or as subprograms within other programs or subprograms. A VI within another VI is called a subVI. The icon and connector pane of a VI work like a graphical parameter list so that other VIs can pass data to it as a subVI.
With these features, LabVIEW promotes and adheres to the concept of modular programming. We divide an application into a series of tasks, which we can divide again until a complicated application becomes a series of simple subtasks. We build a VI to accomplish each subtask and then combine those VIs on another block diagram to accomplish the larger task. Finally, our top-level VI contains a collection of subVIs that represent application functions. Because one can execute each subVI by itself, apart from the rest of the application, debugging is much easier. Furthermore, many low-level subVIs often perform tasks common to several applications, so that you can develop a specialized set of subVIs suited to applications you can construct.
3. Essentials to build a VI
3.1 Block Diagram: Select Windows Show Diagram. Pop up in a free area of the block
diagram and choose Functions Select a VI. For example the following Figure-1 shows a block diagram.
3.2 Front Panel: We will build a VI that generates a signal and displays that signal in a
graph. After you complete the exercises, the front panel of the VI will look similar to the front panel in Figure 2.
Figure-1 Figure-2
3.3 Functions Palette: It consists of a graphical, floating palette that automatically opens
when we switch to the block diagram. We use this palette to place nodes (constants, indicators, VIs, etc.).
3.4 Tools Palette: LabVIEW uses a floating Tools palette to edit and debug VIs.
Operating tool places Controls and Functions palette items on the front panel and block diagram.
Figure-3
Figure-4
3.5 Controls Palette: It consists of a graphical, floating palette that automatically opens
when we launch LabVIEW. We use this palette to place controls and indicators on the front panel.
Numeric Controls and Indicators to enter numeric quantities and display numeric quantities respectively.
Boolean Controls and Indicators for entering and displaying Boolean (True/False) values. Boolean objects simulate switches, buttons, and LEDs. Configuring Controls and Indicators by using options from their pop-up menus. Popping up on individual components of controls and indicators displays menus for customizing those components.
Figure-5 LabVIEW contains VIs for controlling the following: Plug-in data acquisition boards (Windows, Macintosh, and Sun) GPIB (IEEE 488) instruments Serial port instruments
4. PROGRAM- I
4.1 Object: To develop a memory element for fixed inputs using logic gates in LabVIEW 4.2 Theory:
The circuit implemented should have following truth table: Qn (previous output) X X X X S (first input) 0 0 1 1 R (second input) 0 1 0 1 Qn+1 (present output) 0 Qn Qn 1
Table-: Truth table for memory element The Boolean expression obtained for circuit implementation is given by:
Qn (previous output) 0 0 0 0 1 1 1 1
S (first input) 0 0 1 1 0 0 1 1
R (second input) 0 1 0 1 0 1 0 1
Table-: Simplified truth table of the memory element This Boolean expression generated can be further explained through the following simplified form.
Figure-6: Block
diagram
4.4 The programmable circuit employs following structures to customize the problem:
LOGIC GATES: It uses 2 kinds of logic gates.
6
AND: This gate AND the 2 given inputs. OR: This gate OR the 2 inputs. BOOLEN CONTROL: The boolean control let us control the input directly through front panel. ROUND LED: It glows when output reaches the specified condition. LOCAL VARIABLE: Here we have used local variable of output in read only mode. It reads the present output value and transfers it to the input of the circuit. It is put in the block diagram via front panel.
2. The output is connected to LED display. 3. Local variable of output is generated and converted to read mode.
4. This local variable is connected in the intermediate circuit. 5. We run the program on front panel.
4.6 OUTPUT:
The given Boolean function and truth table is implemented correctly.
5. PROGRAM- II
5.1 Object: Application of memory element as an amplitude limiter 5.2 Theory: The principle of the program is that of the memory element discussed via truth
table in the previous program. The lower and upper limit required is given as input to the circuit. The logic generated on the output of LED selects the value to reach the given limit. In this way the final output is amplitude limited between a lower and upper limit defined by the user.
Figure-8: diagram
Block
5.4 The programmable circuit employs following structures to customize the problem:
LOGIC GATES, LOCAL VARIABLE, WAVEFORM CHART and ROUND LED: Explained in the previous program. ADDER: Here we use one addition block of two inputs. COMPARISION: Here we use two G/E blocks. SELECTOR: This block is used for selecting two values given as inputs.
5. A waveform chart is connected to the output of adder which display the amplitude limited waveform. Here we generate a waveform which has its upper limit = 5 and lower limit = 3.
5.6 OUTPUT:
The controlling of upper and lower limit of the waveform is achieved.
10
6. PROGRAM- III
6.1 Object: To perform Amplitude Modulation & Demodulation on given baseband signal.
6.2
Theory:
6.2.1 AMPLITUDE MODULATION: Consider a signal that you wish to transmit, that has the form S (t) = m cosmt To transmit this signal requires you to have a carrier signal with a higher frequency than m and an amplitude greater than m. Adding the signal and carrier gives an output of the form: A (t) = Aocosct (1 + m cosmt) If the signal is at a single frequency, the Fourier spectrum of the amplitude-modulated signal comprises the unmodified carrier c and two side bands at c m.
Figure-10: Frequency spectrum of a modulated single-frequency signal. The form of this frequency spectrum can be derived from the trigonometric function-product relations (cos. cos ): A(t) =Aocosct(1+m cosmt) = A [cosct + m.cosct.cosmt] = Aocosct+m/2[cos (c-m)t + cos (c + m)t] 6.2.2 AMPLITUDE DEMODULATION (Synchronous Detection): The synchronous AM detector is a more complex circuit that can provide a larger, less distorted output, and will also allow you to demodulate a signal having an arbitrary modulation index.The theory behind the synchronous detector assumes that we have an AM signal of the form: = Aocosct+m/2[cos (c-m) t + cos (c + m)t] If we multiply this signal by the original carrier, we will generate the following:
11
A (t)cos ct = Ao/2 + m/2cos mt + 0.5 cos2 ct + m/4cos (2c m) t + m/4 cos (2c + m)t The resulting signal contains a DC term, a baseband term, a term at twice the carrier, and terms at twice the carrier, plus and minus the baseband frequency. A coupling capacitor can remove the DC term, and a low-pass filter eliminates the high frequency components, recover the modulated signal regardless of the incoming AM signal carrier amplitude (within limits). The principal restriction on the demodulaing signal is that it must be of exactly the same frequency as the carrier signal that originally generated the AM.
6.3
Circuit implemented:
6.4 The programmable circuit employs following structures to customize the problem:
MULTIPLIER: It multiplies 2 inputs. WAVEFORM CHART, NUMERIC CONTROL: Explained in the previous programs. SIMULATE SIGNAL (SIM): Simulates a sine wave, square wave, triangle wave, sawtooth wave, or noise signal which is configured as follows: Signal type, Frequency, Amplitude, Phase, Offset, Sampling rate, No. of samples, Timing, Time stamps. FILTER: An IIR filter is used, in Butterworth topology, to band pass the incoming signal. SLIDE CONTROL: We can change the scale limits, the text labels adjust scale markers, and select linear or logarithmic spacing for numeric objects with a scale. CONROL KNOB: In this program we change the frequency of message and carrier signal by moving respective knobs in the given range.
1. The SIM block generates low frequency message signal. [Amplitude: variable (through slide); frequency: variable (through knob)] This is displayed on the waveform graph. 2. Another SIM block generates a high frequency carrier signal. [Amplitude: variable (through slide); frequency: variable (through knob)] 3. The message signal is multiplied by the high frequency carrier to generate the amplitude modulated wave. 4. This modulated wave is smoothened by a bandpass filter with lower cut-off frequency= 100Hz and upper cut-off frequency=400Hz (say). 5. The finally filtered signal is displayed on the waveform chart as the amplitude modulated signal. 6. For synchronous demodulation of incoming wave, the modulated signal is again multiplied by original carrier signal. This demodulated signal is also displayed on the front panel. 7. The multiplied signal of the last part is sent to the low pass filter for the removal of high frequency components. The low frequency message signal is filtered out. 8. Here we use 3 lowpass filters for the smoothing of the received signal such that it is easily identified as original message on the waveform chart.
6.6 OUTPUT:
13
Figure-12: Front panel-Amplitude modulation & demodulation of the carrier wave w.r.t message signal.
7. PROGRAM-IV
7.1 Object: To design BCD to seven segment display. 7.2 Theory:
BCD TO SEVEN SEGMENT DISPLAY: Each segment of a seven-segment display is a small light-emitting diode (LED) or liquid-crystal display (LCD). A decimal number is indicated by lighting a particular combination of the LED's or LCD's elements.
Figure-13: Seven segment LED display for decimal digits The truth-table corresponds to a seven-segment LED device whose display elements are active high, i.e., each element will be active when its corresponding input is 1. Decimal digit N 0 1 2 3 4 5 6 7 8 9 x 0 0 0 0 0 0 0 0 1 1 BCD code input y 0 0 0 0 1 1 1 1 0 0 z 0 0 1 1 0 0 1 1 0 0 w 0 1 0 1 0 1 0 1 0 1 a 1 1 1 1 0 1 1 1 1 1 b 1 1 1 1 1 0 0 1 1 1 Seven segment LED output c 1 0 0 1 1 1 1 1 1 1 d 1 0 1 1 0 1 1 0 1 0 e 1 0 1 0 0 0 1 0 1 0 f 0 0 1 1 1 1 1 0 1 1 g 1 0 0 0 1 1 1 0 1 1 h 1 0 1 1 1 1 1 0 1 1
14
When entering a circuit schematic in sum-of-products or product-of-sums form, we may find it convenient to form a 'bus' of all inputs and their complements. For sum-of-products we would then have a layer of and-gates followed by a layer of or-gates. So in SOP form we deduce logics from the above truth table with the help of karnaugh map.
Figure-15: subVI diagram The three parts of the circuit are connected serially to display the given numeric input on the seven segment display.
15
7.4 The programmable circuit employs following structures to customize the problem:
FOR LOOP: A For Loop, shown as follows, executes a sub diagram a set number of times. The count terminal, N is an input terminal whose value indicates how many times to repeat the sub diagram. Set the count explicitly by wiring a value from outside the loop to the left or top side of the count terminal, or set the count implicitly with auto-indexing. The iteration terminal, i is an output terminal that contains the number of completed iterations. BUILD ARRAY, NUMERIC CONTROL, QUOTIENT AND REMAINDER, NUMERIC INDICATOR, AND GATE and OR GATE: Explained in the previous programs. INDEX ARRAY: When you wire an array to this function, the function resizes automatically to display index inputs for each dimension in the array we wire to ndimension array. We also can add additional element or sub array terminals by resizing the function. NUMERIC TO BOOLEAN CONVERTER: Assigns given numeric value to either true or false as a Boolean output, which can be used further. LOGIC GATES: NOT GATE: Inverts the input applied to it. EX-NOR GATE: Performs the EX-NOR operation on the two inputs. EX-OR GATE: Performs the EX-OR operation on the two inputs. SQUARE LED: We use square LEDs here, which glow when specified condition is reached.
Numeric to Boolean converter converts the index value generated by index array block to Boolean value- true (T) or false(F) This acts as an mediator between part-1 circuit and part-3 circuit which we will discuss as follows, to finally lit the corresponding LEDs.
PART-3: LED output a b c d e f G Logical expression = x + z + yw + y*w* = y*+z*w*+zw = z* + y + w = y*w* + zw* + yz*w + x*y*z = y*w* + zw* = x + yz* + y*z + zw* = x + z*w* + yz* + yw* combination for each LED
Table-: Input
1. The 4 boolean output generated in previous part are labelled as x, y, z & w. 2. The logical function defined by the truth table of the theoretical part of program is
implemented by these 4 as various input combinations. 3. The logical functions are developed through karnaugh maps which are based on input/output combinations defined by truth table. 4. These logical functions are implemented with the appropriate gates, with their apt combination. 5. Each output logic is connected to correspondingly labelled square LED, which will lit up when condition is met. Finally a sub VI of the above circuitry is created with all the input controls and output indicators outside it, as shown in circuit implementation part as shown in Figure-
7.6 OUTPUT:
The front panel has one numeric control to control the input as per our requirement. There are 4 numeric indicators which show the BCD equivalent of the given numeric input ( from 0 to 15).The seven square LEDs are arranged to form a 8 in digital display form. According to the numeric given, corresponding LEDs glow to display that particular input (from 0 to 9).
17
8. PROGRAM- V
8.1 Object: To develop an electrical measurement system in LabVIEW 8.2 Theory:
Here we develop an electrical measurement system which measures the following parameters for both Single phase and three phase load. Power Fundamental frequency Power factor Voltage and currents I. II. III. RMS value Peak to peak value Total Harmonic Distortion(THD)
Waveform plots
Let us revise all the necessary concepts and formulas to calculate above parameters: POWER MEASUREMENT: A Wattmeter is an instrument to measure the active power drawn by a load. There are two coils inside a single-phase Wattmeter a current coil connected in series with the load, and a potential coil connected in parallel with the load. The current coil measures the current flowing into the load, while the potential coil measures the voltage across the load. The deflection of the Wattmeter is proportional to VIcos, where V is the RMS voltage across the potential coil, I is the RMS current through the current coil, and is the angle
18
between V and I. Ideally, three single-phase. This is done by connecting their current coils in series with each phase, and their potential coils in parallel from each phase to the neutral, and finally adding all the three Wattmeter readings. The neutral point represents any common point in the circuit, where all the three Wattmeter potential coils are connected, i.e. the vector sum of the voltages measured by all the potential coils is zero. This wattmeter may be dispensed with, and the remaining two wattmeters can effectively measure the total active power consumed by the three-phase load. Note, the load does not have to be balanced for this method to work. Consider the circuit of Fig. 1 which shows a three-phase star connected balanced load supplied by a three phase balanced supply. There are two wattmeters, W1 and W2, connected in the circuit. The common point lies on the line corresponding to phase b. Hence, there is no wattmeter connected in this phase. The current coil of W1 measures Ia, while the potential coil measures Vab. The current coil ofW2 measures Ic, while the potential coil measures Vbc. Thus, the 2 wattmeter readings are: W1=VabIacos W2=VbcIccos
a
Where a and c are the angles between Ia and Vab, and Ic and Vbc respectively. For a balanced load, Vab=V bc=VL and Ia=I c=I L .From the phasor diagram of a three-phase load it can be verified that a = + 30 and c = 30 - ; where is the angle corresponding to the power factor of the load. Hence, the two Wattmeter readings are: W1=VabIacos a= VL IL cos( + 30) W2= VbcIccos The sum of the two readings is W1+W2 = VL IL[cos ( + 30) + cos (30 - )] = 3^0.5 VL ILcos = W1-W2 = VL IL[cos ( + 30) - cos (30 - )] = VL ILsin The power factor cos , of the load can be found out as: P
c
= VL IL cos(30 - )
FUNDAMENTAL FREQUENCY:
It is the frequency of the fundamental component of oscillations. The component of the waveform of an alternating current, e.m.f., oscillations or wave that is a pure sine wave of the principal frequency upon which harmonics at various higher frequencies may be superposed is called fundamental component. This is to be measured both in the case of one phase and three phase loads by measuring the fundamental frequencies of their alternating current and voltage signals.
PEAK TO PEAK:
It is the maximum instantaneous value of a varying current, voltage or power during the time interval under consideration. It is also known as crest value. For alternating sinusoidal voltage or current signal it is the maximum value at which the sinusoidal function becomes maximum.
POWER FACTOR:
The power factor of an AC electric power system is defined as the ratio of the real power flowing to the load to the apparent power in the circuit. Real power is the capacity of the circuit for performing work in a particular time. Apparent power is the product of the current and voltage of the circuit. Due to energy stored in the load and returned to the source, or due to a non-linear load that distorts the wave shape of the current drawn from the source, the apparent power will be greater than the real power. In an electric power system, a load with a low power factor draws more current than a load with a high power factor for the same amount of useful power transferred. Power factor in a single-phase circuit (or balanced three-phase circuit) can be measured with the wattmeter-ammeter-voltmeter method, where the power in watts is divided by the product of measured voltage and current. The power factor of a balanced polyphase circuit is the same as that of any phase. The power factor of an unbalanced polyphase circuit is not uniquely defined.
20
reducing harmonics added by electronics and audio media. A THD rating less than 1% is considered to be in high-fidelity and inaudible to the human ear. When the input is a pure sine wave, the measurement is most commonly the ratio of the sum of the powers of all higher harmonic frequencies to the power at the first harmonic, or fundamental, frequency. This can equivalently be written as:P
Measurements based on amplitudes (e.g. voltage or current) must be converted to powers to make addition of harmonics distortion meaningful. For a voltage signal, for example, the ratio of the squares of the RMS voltages is equivalent to the power ratio:
Where Vn- is the RMS voltage of nth harmonic and n=1 is the fundamental frequency. THD is also commonly defined as an amplitude ratio rather than a power ratio, resulting in a definition of THD which is the square root of that given above:
WAVEFORMS:
The waveforms generated in case of three phase load are 120 degree phase shifted with respect to each other both in the case of voltage and current. These shifted waveforms are simultaneously plotted to explain the phase difference. In case of one phase signal, both kinds of waves are pure sinusoidal waves.
21
22
CASE-1
23
24
25
sources labelled as V1, V2, V3, I1, I2, I3 respectively. Each of these blocks is provided with amplitude control and frequency control. Six additional SIM blocks are also used to provide distortion. Each of the additional SIM block is also provided with amplitude control. Frequency for each of these blocks is maintained at five times of the frequency given to the initial six SIM blocks. A user controlled phase difference is provided to select the appropriate phase difference between the voltage and current sources. Finally signals (signal + distortion) are applied as inputs for the measurement of various parameters of three phase and single phase supply. All the above components are a part of the Input subVI. 2. A ring control is used to select either of the two phase i.e. Three phase or single phase. Following measurements such as of power, power factor, fundamental frequency, calculation of various V/I values, display of voltage and current waveforms are done for each of the two phases i.e. three phase or single phase. 3. For single phase supply Power-factor is evaluated by simply changing the required phase-difference from
Power
is calculated by first multiplying the voltage and current signals (signal + distortion) and again multiplying the product with the power factor calculated above. Fundamental frequency is measured by applying the voltage signal (signal + distortion) as input to the HA block. For the calculation of various V/I values, we put a case structure. The ALM block is set to measure the RMS value of the current and voltage signals which is displayed on the numeric indicator connected. (case-0) The ALM block is set to measure the Peak to peak value of the current and voltage signals which is displayed on the numeric indicator connected. (case-1) For the measurement of total harmonic distortion in the two signals, HA block is used and the output is displayed on the numeric indicator(case-2)
Voltage and Current Waveforms are displayed by using a selector. When the selector value is true, current waveform is displayed on the graph indicator.
26
When the selector value is false, voltage waveform is displayed on the graph Indicator. 4. For three phase supply
We build three subVI. One for measurement of power, power-factor, fundamental frequency. Second for calculation of various V/I values. Third for displaying voltage and current waveforms. In power measurement of 3 phase load, we apply 2-wattmeter method employing following simple mathematics: W1 = (V1-V2) * I1 ; W2 = (V2-V3) * I3 Total power (W) = W1+W2 For the measurement of power factor of the three phase load, we apply the mathematical formula explained below Power factor = total power (W) / (Vn*In). Where Vn=V1, V2, V3 and In=I1, I2, I3
Calculation of V/I values: The ALM block is set to measure the RMS value of the current and voltage signals which is displayed on the numeric indicator connected. The ALM block is set to measure the Peak to peak value of the current and voltage signals which is displayed on the numeric indicator connected.
For the measurement of total harmonic distortion of the signals , HA block is used and the output is displayed on the numeric indicator
Voltage and current waveforms are displayed by using a boolean control and merge signal. When the Boolean control is true signals from the three SIM current blocks merge together and the resulting waveform is displayed on the Waveform graph. When the Boolean is false signals from the three SIM voltage blocks merge together and the resulting waveform is displayed on the waveform graph.
8.6OUTPUT:
27
28
9. Conclusion
The project work is successfully completed and given task is implemented efficiently. Through LabVIEW, we studied basic concepts of VIRTUAL INSTRUMENTATION which provides highly modular code, user friendly environment, capability to make instruments as per our requirements by its variety of control and functions. We can design any circuit for our self-made equations through the functions and controls provided by LabVIEW. The circuit is easy to comprehend. The knowledge and experience gained by us during this project work will definitely be very useful in future. This was a very encouraging experience for me.
29
10. References
1. www.ni.com/labview/default.html
2. www.wikipedia.org/wiki/LabVIEW 3. www.wikipedia.org/wiki/Pulse_wave 4. Digital Logic and Computer Design by M. Morris Mano fourth edition. 5. Basic Electrical Engineering by D.P. Kothari second edition.
6. Communication systems by Simon Haykins -third edition.
30
31