240 likes | 292 Views
Learning LabVIEW. Learning LabVIEW Data Acquisition Control. Learning. How do you learn the best? What conditions make it easiest for you to learn? What factors make it difficult to learn?. Play, Fun, Curiosity. Children learn by exercising their curiosity and by playing
E N D
Learning LabVIEW Learning LabVIEW Data Acquisition Control
Learning • How do you learn the best? • What conditions make it easiest for you to learn? • What factors make it difficult to learn?
Play, Fun, Curiosity • Children learn by exercising their curiosity and by playing • Successful students will also think of learning as fun
What is the role of “The Educator” • The sage on the stage (banking theory) • Deposit the knowledge (lectures) • Withdraw it later (exams) • Learners are passive recipients of sage’s wisdom • The guide by your side • Learners are active participants
Take Responsibility! • Who takes the initiative to learn? • Educator or student? • It’s an attitude! • Are the tasks set by the educator chores that you get through with as little work as possible? • Are the tasks learning opportunities that you engage in fully because you are interested in learning? • Allow yourself to go beyond the minimum • Learn because YOU want to learn! • Role of confidence • Believe in your strengths • Be comfortable with your weaknesses • Use all of your resources • Ask for help
Life Long Learning • How will you respond when your employer asks you to do something that you didn’t learn how to do at Cornell? • Sorry, I wasn’t trained to do that. (banking theory) • I know where some resources are that I could use to learn how to do that.
Why should you learn LabVIEW? • LabVIEW is the best environment for developing computer interface with the real world • Software development in LabVIEW is 4 to 10 times faster than in text based languages • Graphical • No syntax errors • No need to memorize function calls • Automation is everywhere: as engineers you should understand how computers make decisions
Learning Software • Curiosity • Explore the menus, toolbars, palettes • Right click everywhere! • Try to figure out what the different options do • Explore the help and example files • Play • Give yourself permission to be “unproductive”! • Give yourself a challenge • If you can’t figure something out ask a friend (or a sage) • Don’t allow yourself to get frustrated
Learning LabVIEW • Learning resources • Help • Example files • Right click • Control and Function palettes • Don’t reinvent the wheel! • Before writing any code ask: • Is this code that someone else might have already written? • Where might I find an example of this code?
Programming Overview • Virtual Instruments (VIs) • Front panel (Graphical User Interface) • Block diagram (code) • SubVIs • A Virtual Instrument that can be called by another Virtual Instrument • Represented by an icon • Modular code! • Programming Structures • Data Structures
Virtual Instruments • Modular pieces of code that can easily be used wherever they are needed • Input (______)→logic→output (_______) • Ex. Peristaltic pump calculator • Given tubing size and pump rpmcalculateflow rate • Or inverse problem: Given tubing size and flow rate calculatepump rpm control indicator
Programming Structures • Loops • For (n times) • Execute a fixed number of times determined before the loop executes • While (something is true) • Executes until the exit condition is met • Event • Executes when a user changes something on the front panel (usually inside a _______ loop) • Cases (more general than if-then statements) • Select one option from a set of options • Sequences • Forces code to execute in a set order while
Data types: Standard Types • Numbers • Positive integers (U8, U16, U32) • Integers (I8, I16, I32) • Real numbers (SGL: 6 digit, DBL: 15 digit, EXT) • Complex numbers • Booleans (true or false) • Strings (text) • Enumerated • Graphs
User Defined Data Types: Arrays and Clusters • Array • An ordered sequence of identical data types • The number of elements can be changed while a program is running • Cluster • Contains a set of data types • The number of elements is fixed while a program is running
Cluster with an array with a cluster Array index Cluster Cluster Array Note: The number of elements in the array is still variable!
How do you choose a data structure? • A well defined data structure will make your programming easier • Example: Sensor data and Control settings • Data that is related should be kept together • The data should be organized in a logical manner • The data structures will likely evolve as you build your program • User defined data structures can be saved as type definitions (makes revising the code easier)
Data Flow • Data flows in wires from one SubVI to the next • SubVIs wait until all input wires contain the necessary data to execute • The exact order in which SubVIs execute isn’t known • Except when there is data dependency
Student Exercises • Water Treatment Plant Designer • Peristaltic pump calculator • Enumerated type, arrays, SubVIs • Alum dose • Case structure • Plant control logic • Complex data structures (clusters) • Boolean logic • HMI (Human – Machine Interface)
Data acquisition using Web-based Data Server Technology • A computer (the Data Server) in the environmental teaching lab continuously monitors 128 analog channels at 100 Hz. • The computer “listens” for any computers (Clients) that connect to it and request data • Four commands can be sent to the data server • Idle • Send data continuously • Send single sample of requested channels (used repeatedly by WTP) • Logoff • In addition the Client sends the Data Server a data structure with information on which channels to send and how frequently to send the data
Data Server SubVIs • Logon • Read data (inside while loop) • Logoff • Calibrate • Select ports • Apply conversions from volts to physical units • Conversion information is stored in a global variable that is also accessed by the read data subVI
Digitization • Analog: continuously variable • Digital: finite number of values • Analog to Digital converter maps voltage to numbers
Techniques to reduce noise • Increase the number of bins (buy a more expensive Analog to Digital converter) • 12 bit (used in the lab) - _____ bins • 16 bit - ______bins • More precisely match the voltage range of the A/D converter to the signal voltage range (apply appropriate gain) • Over sample and average • Sample faster than your application requires 4096 65536
Control with Stamp Microprocessor • Three SubVIs use the Sensor data and Control settings to calculate the desired valve and pump settings • The control settings are sent to the Stamp SubVI • The Stamp SubVI codes the settings as a string of 2 ASCII characters (letters) and sends the string to the serial port • The Stamp microprocessor • Reads the codes from the serial port • Turns the correct valves on • Sets the pump rpm