Course contents 1. Labview basics – 2. Structures – – 3. SubVIs File I/O Analysis Signal processing Communication between loops Instrument control – 7. State machines, SubVIs, MainCluster Modular programming + recording – – – – – 6. arrays, clusters, charts, graphs Additional lecture – 5. for, while, case, ... editing techniques Controls&Indicators – 4. virtual instruments, data flow, palettes DAQ , Data collection, GPIB, Serial Additional lecture – Data Acquisition, Instrument control SubVIs • Modular programming – group related functions and icons into lower level VI – these subVIs can be called by higher level VIs • subVI components – connector – icon SubVI connectors • Terminals that correspond to the VI controls and indicators – data in from inputs, data passed to the outputs when VI finishes executing • Assigning terminals: – click on the connector terminal with the wiring tool – next click on the control/indicator you want to wire – or you can first select the control/indicator with wiring tool and then click the terminal Terminal patterns • You can modify the terminal pattern – or rotate and flip it • It is advisable to select a pattern which will cover your future needs – you can leave extra unwired terminals SubVI icon • SubVI is represented by an icon on the block diagram • VIs have a default icon – use the icon editor to edit the icon Create a subVI • From scratch – do the necessary wiring on block diagram or copy paste from an existing VI – connect the controls and indicators on the front panel to the connector pane • Use existing VI – open a VI – make the necessary connections in the connector pane Creating subVI automatically • Enclose area to be converted into a subVI • Select Edit»Create SubVI from the Edit Menu Add an existing VI on the block diagram as a subVI • Add any VI on the block diagram – From Functions palette: Select a VI... VI Hierarchy • View >> VI Hierarchy • Hierarchical structure of all VIs in memory – dependencies between top-level VIs and subVIs Strings • Sequence of characters • Numeric data often passed as strings: – file I/O – instrument control String functions Example: Format Into String Codes Display • Display characters like carriage return, tabs, white space File I/O • High-level File I/O – They have it All in one VI: create or open file, read/write data, close file Express File I/O • Write to Measurement File Express File I/O • Read From Measurement File Write To Spreadsheet File.vi • Write to text file Read from Spreadsheet File.vi • Read data from text file Decimal symbol • Write/Read To/From Spreadsheet File.vi uses operating system settings for decimal symbol – on windows7 you can change it from Region and Language settings Disk streaming • Keep the file open for multiple read/write operations – no overhead from opening and closing the file • If speed and disk space are crucial: use binary files Advanced file functions • File writing positions • Move, Copy, Delete files Datalog • If manipulating complex records or different data types and you will only use LabVIEW, try datalog • See Example Finder • Fundamentals >> File input/output >> Read/Write Datalog TDMS • Technical Data Mangement Solution – saving well-documented measurement data – quickly locating previously stored data • http://zone.ni.com/devzone/cda/tut/p/id/3539 Keynotes Communication between loops • Design Patterns – Producer/Consumer – Master/Slave • Local Variable • Shared Variable Producer/Consumer Local Variables • Local Variables allow data to be passed between parallel loops. • A single control or indicator can be read or written to from more than one location in the program – Local Variables break the dataflow paradigm and should be used sparingly Shared Variables • Shared Variables are used to send data between VIs. • Variable Types: – Single Process: share the data among VIs on the local computer. – Network-published: communicate between VIs, remote computers, and hardware through the Shared Variable Engine. • Shared Variable must exist within a project library. • Shared Variable must be deployed to be available to other projects and remote computers. Textual Math in LabVIEW • Integrate existing scripts with LabVIEW for faster development • Interactive, easy-to-use, hands-on learning environment • Develop algorithms, explore mathematical concepts, and analyze results using a single environment • Freedom to choose the most effective syntax, whether graphical or textual within one VI Supported Math Tools: MathScript script node Mathematica software Maple software MathSoft software MATLAB® software Xmath software MATLAB ® is a registered trademark of The MathWorks, Inc. Math with the MathScript Node • • • • Implement equations and algorithms textually Input and Output variables created at the border Generally compatible with popular m-file script language Terminate statements with a semicolon to disable immediate output (Functions»Programming» Structures»MathScript) Prototype your equations in the interactive MathScript Window. The Interactive MathScript Window • Rapidly develop and test algorithms •Share Scripts and Variables with the Node •View /Modify Variable Output content in 1D, 2D, and Window 3D Variable Workspace View/Modify Variable Contents User Commands m-file Script (LabVIEW»Tools»MathScript Window) Signal Generation • You can generate signals to test your programs Normalized Frequency • ranges from 0.0 to 1.0 in units cycles/samples [cycles/se c] • normalized frequency signal frequency sampling frequency • Example: – Sine Wave [samples/s ec] [cycles/sa mples] Waves and Patterns • Wave VIs generate continuous signals according to normalized frequency and number of samples • Pattern VIs create patterns according to number of cycles • Example: Sine Pattern Simulate Signal Express Signal Processing • Express VIs • Find Examples >> Analyzing and Processing Signal >> Basic Spectral Measurement Signal Processing • Fourier transform – frequency-domain representation of the signal • Find Examples >> Analyzing and Processing Signal >> FFT and Frequency Analysis >> FFT And Power Spectrum Units.vi Signal Processing Filters • Find Examples >> Analyzing and Processing Signals >> Filtering And Conditioning >> Extract The Sine Wave Fitting • Find Examples >> Analyzing and Processing Signal >> Curve Fitting and Interpolation >> Parametric Curve Fitting.vi