system analysis using labview, mathematica and...

12
© Conference for Industry and Education Collaboration American Society for Engineering Education February 2-4, 2011 San Antonio, Texas System Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja Swain, James Anderson, Brittany Wright, Keisha Jamison, and Muhamed Daudi South Carolina State University Orangeburg, SC 29117 Abstract Both Mathematica and LabVIEW are powerful programs for technical computing. However, each offers a completely different workflow and user experience. While Mathematica provides an interactive problem-solving environment and excels in symbolic manipulation and sophisticated data analysis, LabVIEW combines robust input-output capabilities with a highly polished collection of GUI components and RAD (rapid application development) tools for data acquisition and control. Most technical computing challenges can benefit from the combined power of the two approaches. The objective of this paper is to discuss and demonstrate design and use of LabVIEW, Mathematica, and Mathematica Link for LABVIEW in various in real life situations. I. Introduction The engineering, science, and technology field at present is very dynamic. This is due to the recent advances in computer and other technologies. These advances are resulted in number of computer programs to solve traditional and novel problems. These programs use the computer's increased computational capabilities and assist in the design, development and control of complex systems in matter of minutes. Automation is becoming a part and parcel of every industry and industries need trained workforce to manage this new development. As a result, the engineering, technology, and science programs are under pressure to incorporate use of computers into their curriculum so that their graduates can be well trained in the use and application of these changing technologies and serve the needs of the industrial community. To address this issue, many software programs are currently used in academia to design and analyze different systems. Some of these programs are text driven where the students have to write number of lines of code to analyze and design systems. Sometimes these are not user friendly and take longer time. With the advent of Object-Oriented Programming, we have now programs that are interactive and user friendly. Students need not have to write codes and the system design and analysis is achieved from the schematics of the system. Some of the examples

Upload: truongtuong

Post on 23-Mar-2018

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

System Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW

Nikunja Swain, James Anderson, Brittany Wright, Keisha Jamison, and Muhamed Daudi

South Carolina State University

Orangeburg, SC 29117 Abstract

Both Mathematica and LabVIEW are powerful programs for technical computing. However, each offers a completely different workflow and user experience. While Mathematica provides an interactive problem-solving environment and excels in symbolic manipulation and sophisticated data analysis, LabVIEW combines robust input-output capabilities with a highly polished collection of GUI components and RAD (rapid application development) tools for data acquisition and control. Most technical computing challenges can benefit from the combined power of the two approaches. The objective of this paper is to discuss and demonstrate design and use of LabVIEW, Mathematica, and Mathematica Link for LABVIEW in various in real life situations.

I. Introduction

The engineering, science, and technology field at present is very dynamic. This is due to the recent advances in computer and other technologies. These advances are resulted in number of computer programs to solve traditional and novel problems. These programs use the computer's increased computational capabilities and assist in the design, development and control of complex systems in matter of minutes. Automation is becoming a part and parcel of every industry and industries need trained workforce to manage this new development. As a result, the engineering, technology, and science programs are under pressure to incorporate use of computers into their curriculum so that their graduates can be well trained in the use and application of these changing technologies and serve the needs of the industrial community.

To address this issue, many software programs are currently used in academia to design and analyze different systems. Some of these programs are text driven where the students have to write number of lines of code to analyze and design systems. Sometimes these are not user friendly and take longer time. With the advent of Object-Oriented Programming, we have now programs that are interactive and user friendly. Students need not have to write codes and the system design and analysis is achieved from the schematics of the system. Some of the examples

Page 2: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

of such type programs are Mathematica from Wolfrom, MatLab from MathWorks, LabVIEW from National Instruments, and Mathe matica Link for LabVIEW form Bettervi Corportation. These allow the student to spend less time in writing the code to solve the problem and to spend more time to understand the concepts.

LabVIEW is a graphical programming environment and is based on the concept of data flow programming. Data flow programming concept is different from the sequential nature of traditional programming languages, and it cuts down the design and development time of an application. It is widely accepted by industry, academia, and research laboratories around the world as a standard for data acquisition and instrument control software. Since LabVIEW is based on graphical programming, users can build instrumentation called “virtual instruments (VIs)” using software objects. With proper hardware these virtual instruments can be used for remote data acquisition, analysis, design and distributed control. The built-in library of LabVIEW has number of VIs that can be used to design and develop any system. LabVIEW can be used to address the needs of various courses in a technology and science curriculum 1, 2, 3, 4, 5.

Mathematica is a computational software program used in the scientific, engineering, economic and mathematical fields as well as other areas of technical computing. It is an invaluable tool for modeling and simulation on a large number of issues and mathematical problems in a unified environment. Mathematica is used at virtually every university and institution of higher education around the world 6, 7.

Mathematica Link for LabVIEW (MLINK) provides a bridge between the two programs. Specifically, it allows users either to control a LabVIEW application (Virtual Instrument, or VI) from within a Mathematica notebook or to call the Mathematica kernel from within a LabVIEW VI. MLINK includes generic tools that enable Mathematica to control any VI directly without any additional programming or customization. Most technical computing challenges can benefit from the combined power of the two approaches 88.

This paper is arranged as follows: Section II discusses about LabVIEW and a VI module using LabVIEW. Section III discusses Mathematica and instructional modules using Mathematica. Section IV discusses MLINK and an example related to MLINK. Section V presents Conclusion and References and Section VI presents the References.

II. LabVIEW

LabVIEW Application Areas

LabVIEW 1, 2, 3, 4, 5 is extremely flexible and some of the application areas of LabVIEW are Simulation, Data Acquisition & Data Processing. The Data Processing library includes signal generation, digital signal processing (DSP), measurement, filters, windows, curve fitting,

Page 3: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

probability and statistics, linear algebra, numerical methods, instrument control, program development, control systems, and fuzzy logic. These features of LabVIEW, will help us in providing an interdisciplinary integrated teaching and learning experiences that integrates team-oriented, hands-on learning experiences throughout the engineering technology and sciences curriculum and engages students in the design and analysis process beginning with their first year.

LabVIEW can command DAQ boards to read analog input signals (A/D conversion), generate analog output signals (D/A conversion), read and write digital signals, and manipulate the on-board counters for frequency measurement, pulse generation, etc. The voltage data goes into the plug-in DAQ board in the computer, which sends data into computer memory for storage, processing, or other manipulation.

LabVIEW Example – Simulating Inverted Pendulum

Figure 1: Inverted Pendulum

This pendulum is modeled by a mass that is attached to a weightless rigid rod. According to Newton’s second law, as the pendulum swings back and forth, the sum of the forces that are acting on the mass equals the mass times acceleration. Figure 2 represents the LabVIEW VI control panel and Figure 3 represents the corresponding block diagram. With this VI, the user enters the initial and final times of the simulation parameters. Users can also adjust the mass and length of the pendulum. When executed the graph shows the movement of the pendulum until it gradually reaches zero. This example is used in Data Acquisition, Simulation and Modeling using LabVIEW course.

Page 4: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

Figure 2 – LabVIEW Control Panel

Figure 3 – LabVIEW Diagram Panel

Page 5: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

III. Mathematica

Use of Mathematica:

According to Mathematica Journal and article from Wolfram6, 7, Mathematica is used at virtually every university and institution of higher education around the world. In fact, thousands of universities in 54 countries have signed campus agreements with Wolfram Research. With recent versions of Mathematica, however, users of Mathematica have expanded greatly and vary in age from 9 to 90. From young students learning in the classroom to serious research using some of the world’s largest clusters, the scope and breadth of Mathematica has now revolutionized the cross-discipline approach to integrating software into educational curricula. The following are some of the quick facts about Mathematica:

• 100% of the world’s 200 top-ranked universities are using Mathematica and over 90% have organization site licenses.

• 43 of the top 50 liberal arts colleges in the United States have site-licensed Mathematica for integration in courses.

• Thousands of schools worldwide use Mathematica in their classrooms, including the #1 ranked U.S. high school.

• Mathematica is present in Fortune 500 companies, government research labs, universities, high schools, and homes, on all seven continents and beyond.

Mathematica Examples – Modeling and Simulation

Task 1

Use Mathematica to define the following two equations, plot their graphs and estimate the solutions to the system

1yxxy2yx

22

33

=+=+

Solution

Mathematica Code:

eqn1 = x^3 + y^3 - 2 x*y

eqn2 = x^2 + y^2 - 1

ContourPlot[{eqn1 0,eqn2 0},{x, -2, 2},{y,-2, 2},

Page 6: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

Axes -> True, Frame -> False]

Mathematica Results:

2 1 1 2

2

1

1

2

Figure 4: Graph of xy

Task 2:

The table below shows the enrollment in a liberal arts college for the years 1988 to 1995.

Year 1988 1989 1990 1991 1992 1993 1994 1995

Enrollment 1675 1704 1710 1768 1833 1918 1967 1972

A. Find a linear model for the data above. Let the independent variable t represent Year. Use the assign and the Fit commands to find the linear model of the form

btate +=)(

B. Evaluate e(t) at t = 2007.

Solution:

A. Matematica Code:

Results: 48.6071t94982.8- +

e[t_ ] = Fit [ { {1988, 1675}, {1989, 1704}, {1990, 1710}, {1991, 1768}, {1992, 1833}, {1993, 1918}, {1994,1967},{1995,1972}}, {1,t}, t]

Page 7: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

B. Use Mathematica to compute e(2007) by typing in the command

Results: 2571.79.

This example is used in Numerical Analysis and Calculus course to introduce students to Mathematica.

IV. MLINK for LABVIEW

MLINK Capabilities

Mathematica Link for LabVIEW 8,9 includes generic tools that enable Mathematica to control any VI directly without any additional programming or customization. The communication between LabVIEW and Mathematica relies on MathLink, a general interface used to manage the communication between Mathematica and external programs. The most frequently used MathLink functions have been implemented in LabVIEW and are included in Mathematica Link for LabVIEW.

Upon this basic layer, a whole series of utilities and higher-level functions has been built. All VIs are completely documented, and the higher-level functions can be modified as necessary or used unmodified as building blocks for larger applications. Mathematica Link for LabVIEW is a communications toolkit that gives one the ability to pass parameters back and forth between LabVIEW and Mathematica. Here is a partial list of the functions one can perform using the Mathematica Link:

• Open a communication path between Mathematica and LabVIEW to pass parameters and calculation results between the programs

• Send a numerical computation to the Mathematica kernel and return the results to LabVIEW

• Open and run LabVIEW VIs from inside Mathematica and optionally return LabVIEW data to a Mathematica notebook

• Visualize LabVIEW data using ListPlot, ListPlot3D, DensityPlot, and other native Mathematica data visualization functions

• Create and export publication-quality Mathematica graphics files in a wide variety of standard formats

• Introduce complex simulation and control, image processing, waveform processing and other advanced calculations into your LabVIEW VIs -- calculations that are not accessible with the built-in mathematical capabilities of LabVIEW

e [ 2007 ]

Page 8: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

Figure 5: Bidirectional Communication between Miathematica and LabVIEW

MLINK EXAMPLE – A Temperature Sensor System

This example demonstrates calling of a LabVIEW Virtual Instrument (VI) module for within Mathematica. This VI is designed to demonstrate record and plot temperature over time and also to display under and over temperature conditions. Figure 6 represents the block diagram for LabVIEW use only, Figure 7 represents the corresponding modification to use the VI from Mathematica, and Figure 8 represents the VI control panel. This VI is present in MLINK directory in LabVIEW and is produced here for demonstration purpose only. Figure 9 represent the Mathematica Output of this VI when called from Mathematica. Interested reader may refer to user guide for Mathematica Link for LabVIEW for detailed description and steps to run this and other examples. This example can be used in higher level Mathematics and Engineering courses (Numercal Analysis II and Advanced Data Acquisition).

Page 9: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

Figure 6 – Temperature Sensor VI Block Diagram without MLINK

Figure 7 – Temperature Sensor VI Block Diagram with MLINK Components

Page 10: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

Figure 8 – Temperature Sensor VI Control Panel with MLINK Components

Figure 9 – Mathematica Output when the VI is called from Mathematica

Page 11: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

V: Conclusion/Discussion

LabVIEW is a very high-quality method for solving real life problems systematically. From the results given, LabVIEW is a graphical programming environment used by millions of engineers and scientist. It allows them to create sophisticated measurement, test, and control systems using intuitive graphical icons and wires that resemble a flowchart. However, due to a time constraint, we weren’t able to link Mathematica to LabVIEW and explore the range of results opted through the Mathematica link. Thus, calling the Mathematica kernel from within a VI offers many practical advantages. For example, one may need Mathematica's sophisticated data-processing functions and may then want to display the resulting graphics on a VI front panel. Mathematica Link for LabVIEW provides a bridge between the two programs. Specifically, it allows users either to control a LabVIEW application (Virtual Instrument, or VI) from within a Mathematica notebook or to call the Mathematica kernel from within a LabVIEW VI. The LabVIEW examples presented in this paper are used in

Acknowledgement

This work was funded in part by a grant from the NSF-HBCU-UP/RISC grant. We are thankful to the NSF and SCSU for providing us with this help.

VI: Bibliography:

1. Chugani, M., Samant, A., and Cerna, N. LabVIEW Signal Processing, Prentice Hall, NJ 07458, 1998.

2. Anderson, J. A., Korrapati. R. B., & Swain. N. K., "Digital signal processing using virtual instrumentation". Proceedings of SPIE Vol. 4052.

3. Swain, Nikunja, and Raghu Korrapati. "Design and Development of Virtual Instrument (VI) Modules for an Introductory Digital Logic Course." 2006 IJME-INTERTECH Conference. (2006).

4. Swain, N. K., Anderson, J. A., & Korrapati. R. B. "Computer based virtual engineering Laboratory (CBVEL) and Engineering Technology Education". 2000 Annual ASEE Conference Proceedings.

5. Lisa Wells and Jeferey Travis, LabVIEW for Everyone, Graphical Programming Even Made Easier, Prentice Hall, NJ 07458, 1997.

6. The Mathematica Journal - http://www.ijournals.net/ 7. Experience Mathematica in Edication: From Concept to Classroom Clusters,

http://media.wolfram.com/brochures/AcademicBrochure-preview.pdf 8. LabVIEW -- Combining LabVIEW and Mathematica -

http://www.ni.com/analysis/mathematica.htm 9. Mathematica Link for LabVIEW - http://www.bettervi.com/mlink/

Page 12: System Analysis using LabVIEW, Mathematica and …ciec/Proceedings_2011/ETD/ETD-455/ETD-455_Swain.pdfSystem Analysis using LabVIEW, Mathematica and Mathematica Link for LabVIEW Nikunja

© Conference for Industry and Education Collaboration American Society for Engineering Education

February 2-4, 2011 San Antonio, Texas

Biographical information: Nikunja K. Swain is a Professor at the South Carolina State University. Dr. Swain has more than 25 years of experience as an engineer and educator. He has more than 50 publications in journals and conference proceedings; has procured research and development grants from the NSF, NASA, DOT, DOD, and DOE; and reviewed multiple books on computer-related subjects. He is also a reviewer for ACM Computing Reviews, IJAMT, CIT, ASEE, FIE, JET, IAJC, and other conferences and journals. He is a registered Professional Engineer in South Carolina and a member of IEEE and ACM.

James A. Anderson’s areas of specialization are in electro-optics, solid-state devices/microelectronics, and microwave and optical communications. He has performed research and design at various industries, worked as a consultant and professional engineer, and has been a university professor and Dean of the School of Engineering Technology and Sciences (SETS) at South Carolina State University. Currently, he serves as Professor and Manager of HBCU/UP grant at South Carolina State University.

Brittany Wright, Keisha Jamison, and Muhamed Daudi are undergraduate students in the Mathematics and Computer Science Department at the South Carolina State University.