La presentazione è in caricamento. Aspetta per favore

La presentazione è in caricamento. Aspetta per favore

LabVIEW Laboratory Virtual Instrument Engineering Workbench

Presentazioni simili


Presentazione sul tema: "LabVIEW Laboratory Virtual Instrument Engineering Workbench"— Transcript della presentazione:

1 LabVIEW Laboratory Virtual Instrument Engineering Workbench
Introduzione LabVIEW Laboratory Virtual Instrument Engineering Workbench 31 ottobre 2007 Giada Giorgi

2 Introduzione Ambiente di sviluppo per particolari applicazioni:
Acquisizione dati e gestione strumentazione. Creazione di interfacce utente dedicate. Creazione di test dedicati per il controllo di apparati. Ambiente grafico di programmazione grafica ad oggetti: Il programma equivale a un diagrammi a blocchi. Permette l’integrazione con sistemi per acquisizione dati e controllo di strumentazione: Interfacce IEEE-488, RS-232/422, schede A/D-D/A, GPIB, VXI, LXI. Dispone di una ricca collezione di librerie: Interazione con il sistema operativo Post-processing dei dati Immissione e visualizzazione dei dati. 31 ottobre 2007 Giada Giorgi

3 Esempio Introduzione Controllo della strumentazione, banco di misura, mediante calcolatore. Il calcolatore diventa parte integrante del sistema di misura. 31 ottobre 2007 Giada Giorgi

4 Differenze tra strumento stand-alone e VI
Introduzione Strumento stand-alone Interazione solo attraverso il pannello frontale. Pannello frontale fisso. Funzioni svolte da strumento prefissate. Strumento virtuale Interazione indiretta con uno o più strumenti. Pannello frontale gestibile dal programmatore. Elaborazione e post-processing dei dati. Sviluppo di appositi test di misura. 31 ottobre 2007 Giada Giorgi

5 GENERATORE DI FUNZIONI
Esempio Introduzione OSCILLOSCOPIO GENERATORE DI FUNZIONI AMPLIF. LINEARE STRUMENTO VIRTUALE 31 ottobre 2007 Giada Giorgi

6 Definizione di Virtual Instrument (VI)
Un programma è detto Virtual instrument (VI). L’aspetto e le operazioni dei VI “imitano” quelle degli strumenti reali, come oscilloscopi, multimetri, ecc. Un VI è composto da 3 parti: Pannello frontale: interfaccia utente Diagramma a blocchi: contiene il codice sorgente del VI che ne definisce le funzionalità. Icona e connettore: identificano il VI in modo da poterlo riutilizzare in un altro VI. L’icona è un simbolo associato al VI. Il connettore definisce gli ingressi e le uscite del VI. Definizione di VI 31 ottobre 2007 Giada Giorgi

7 Pannello frontale – Front Panel
Controllo Indicatore Il pannello frontale è l’interfaccia utente di un VI. E’ formato da controlli ed indicatori: i controlli rappresentano gli ingressi del programma (manopole, bottoni, finestre di dialogo,ecc.), gli indicatori rappresentano le uscite del VI (LED, display, messaggi testuali, ecc.). 31 ottobre 2007 Giada Giorgi

8 Diagramma a blocchi – Block Diagram
Il diagramma a blocchi contiene il codice sorgente. Il codice sorgente è formato da funzioni e strutture rappresentati graficamente per mezzo di blocchi. Gli oggetti del pannello frontale (input e output del programma) sono rappresentati da terminali. Terminali e blocchi sono collegati per mezzo di fili (wires). L’ordine di esecuzione del programma è determinato dal flusso di dati (dataflow). Block Diagram 31 ottobre 2007 Giada Giorgi

9 Diagramma a blocchi – Block Diagram
Indicatore Filo Controlli Terminali Blocco 31 ottobre 2007 Giada Giorgi

10 Flusso di esecuzione - 1 3 8 5 Block Diagram 31 ottobre 2007
Giada Giorgi

11 Flusso di esecuzione - 2 3 8 5 1 7 Block Diagram 31 ottobre 2007
Giada Giorgi

12 Icona e connettore Nell’angolo in alto a destra del pannello frontale e del block diagram è visualizzata l’icona associata al VI. Right-click con il mouse sull’icona si aprirà un menù a tendina: VI properties: informazioni sul VI. Edit icon: creazione dell’icona. Show connector: visualizza il connettore. Right-click con il mouse sul connettore si aprirà un menù a tendina per impostarne le proprietà. Usare il tool wiring per connettere indicatori e controlli ai terminali del connettore. Icona e connettore Icona Connettore 31 ottobre 2007 Giada Giorgi

13 Ambiente di sviluppo Ambiente di sviluppo 31 ottobre 2007 Giada Giorgi

14 Tools palette Automatic Tool Selection.
Operating: modifica il valore di un controllo. Positioning: posiziona, ridimensiona e seleziona gli oggetti. Labeling: modifa etichette e testo all’interno di un controllo. Wiring: collega gli oggetti di un block diagram e definisce in/out connettore. Breakpoint: interrompe l’esecuzione del programma in un dato punto. Probe: controlla i valori intermedi in fase di debug. Coloring: imposta i colori degli oggetti e dello sfondo. Tools Palette 31 ottobre 2007 Giada Giorgi

15 Controls Palette Disponibile solo per il Pannello frontale.
Labview 8.0 Controls Palette Disponibile solo per il Pannello frontale. Contiene le librerie di oggetti indicatori e controlli. Per posizionare un oggetto è sufficiente selezionare l’oggetto dalla Controls Palette e trascinarlo nel Pannello Frontale. 31 ottobre 2007 Giada Giorgi

16 Functions Palette Disponibile solo per il Diagramma a blocchi.
Contiene le librerie di blocchi e funzioni per la realizzazione del codice sorgente. Per posizionare un oggetto è sufficiente selezionare l’oggetto dalla Functions Palette e trascinarlo nel Diagramma a Blocchi. FUNCTIONS 31 ottobre 2007 Giada Giorgi

17 Running e Debugging Esegue il VI una sola volta.
Esegue ciclicamente il VI. Interrompe l’esecuzione del VI Sospende temporaneamente il debug. Esecuzione animata del programma. Entra nel subVI per debug. Esegue il subVI e riprende il debug nel VI principale. Running e Debugging 31 ottobre 2007 Giada Giorgi

18 Pannello frontale: Controlli ed Indicatori
Definizione dell’interfaccia utente. L’interfaccia utente è data dall’insieme di controlli ed indicatori sul pannello frontale. Right-click con il mouse sul controllo/indicatore viene visualizzato un menù a tendina: Cambiare da controllo ad indicatore e viceversa. Creare variabili locali, ecc. Sostituire con un altro controllo/indic. Inizializzare la variabile. Modificare il tipo di dati, il range di valori accettabili, il loro formato, precisione e notazione. Controlli ed Indicatori 31 ottobre 2007 Giada Giorgi

19 Pannello frontale: Controlli ed Indicatori
31 ottobre 2007 Giada Giorgi

20 Pannello frontale: Controlli ed Indicatori
31 ottobre 2007 Giada Giorgi

21 Pannello frontale: Diagrammi e grafici
Collezione di oggetti adatti alla rappresentazione di diagrammi e grafici. Diverse modalità di connessione ai terminali interni al VI e di visualizzazione. I più utilizzati sono: Waveform chart: riceve in ingresso un valore scalare. Waveform graph: riceve in ingresso un vettore di dati. XY Graph: riceve in ingresso un cluster di numeri. Diagrammi e grafici 31 ottobre 2007 Giada Giorgi

22 Pannello frontale: Waveform Chart
Waveform Charts The waveform chart is a special type of numeric indicator that displays one or more plots of data typically acquired at a constant rate. The waveform chart maintains a history of data, or buffer, from previous updates. Right-click the chart and select Chart History Length from the shortcut menu to configure the buffer. The default chart history length for a waveform chart is 1,024 data points. The frequency at which you send data to the chart determines how often the chart redraws. Displaying a Single Plot on Waveform Charts If you pass the chart a single value or multiple values at a time, LabVIEW interprets the data as points on the chart and increments the x index by one starting at x = 0. The chart treats these inputs as new data for a single plot. Displaying Multiple Plots on Waveform Charts To pass data for multiple plots to a waveform chart, you can bundle the data together into a cluster of scalar numeric values, where each numeric represents a single point for each of the plots. If you want to pass multiple points per plot in a single update, wire an array of clusters of numeric values to the chart. Each numeric represents a single y value point for each of the plots. Tipo di indicatore numerico che visualizza uno o più plot di dati, tipicamente acquisiti ad un rate costante. Mantiene la storia delle precedenti acquisizioni (la dimensione del buffer viene impostata da Chart History Length). La frequenza con la quale vengono inviati i dati al chart determina la velocità di aggiornamento. Diagrammi e grafici 31 ottobre 2007 Giada Giorgi

23 Pannello frontale: Waveform Graph
Waveform Graphs The waveform graph displays one or more plots of evenly sampled measurements. The waveform graph plots only single-valued functions, as in y = f(x), with points evenly distributed along the x-axis, such as acquired time-varying waveforms. The following figure shows an example of a waveform graph. Displaying a Single Plot on Waveform Graphs The waveform graph accepts several data types for single-plot waveform graphs. The graph accepts a single array of values, interprets the data as points on the graph, and increments the x index by one starting at x = 0. The graph accepts a cluster of an initial x value, a delta x, and an array of y data. The graph also accepts the waveform data type, which carries the data, start time, and delta t of a waveform. Displaying Multiple Plots on Waveform Graphs The waveform graph accepts several data types for displaying multiple plots. The waveform graph accepts a 2D array of values, where each row of the array is a single plot. The graph interprets the data as points on the graph and increments the x index by one, starting at x = 0. Wire a 2D array data type to the graph, right-click the graph, and select Transpose Array from the shortcut menu to handle each column of the array as a plot. Aspetto sul pannello frontale identico ai Waveform Chart. Vengono costruiti in un unico momento. Visualizzano i dati contenuti in un vettore. Diagrammi e grafici 31 ottobre 2007 Giada Giorgi

24 Pannello frontale: XY Graphs
The XY graph is a general-purpose, Cartesian graphing object that plots multivalued functions, such as circular shapes or waveforms with a varying time base. The XY graph displays any set of points, evenly sampled or not. You also can display Nyquist planes, Nichols planes, S planes, and Z planes on the XY graph. Lines and labels on these planes are the same color as the Cartesian lines, and you cannot modify the plane label font. The figure shows an example of an XY graph. Displaying a Single Plot on XY Graphs The XY graph accepts three data types for single-plot XY graphs. The XY graph accepts a cluster that contains an x array and a y array. The XY graph also accepts an array of points, where a point is a cluster that contains an x value and a y value. The XY graph also accepts an array of complex data, in which the real part is plotted on the x-axis and the imaginary part is plotted on the y-axis. Grafico di tipo general-purpose, in grado di visualizzare un insieme qualsiasi di punti. Può inoltre visualizzare (funzioni avanzate) il piano di Nyquist, il piano S, Z, ecc. Diagrammi e grafici 31 ottobre 2007 Giada Giorgi

25 Block diagram: Tipi di dati
Controlli Indicatori Boolean Intero con segno a 32 bit Intero senza segno a 32 bit Intero con segno a 16 bit Intero senza segno a 16 bit Intero con segno a 8 bit Intero senza segno a 8 bit Double Double complesso Tipi di dati String Cluster 31 ottobre 2007 Giada Giorgi

26 Block diagram: Ciclo for e while
I cicli vengono rappresentati mediante strutture grafiche. Ogni struttura ha un bordo ridimensionabile che comprende la sezione del diagramma a blocchi appartenente al corpo del ciclo. Le strutture hanno terminali che le connettono ad altri blocchi o strutture detti tunnel. Quando sono disponibili dei valori validi in ingresso, queste strutture vengono eseguite automaticamente. Al termine dell’esecuzione della struttura vengono automaticamente forniti i dati in uscita. Ciclo for e while 31 ottobre 2007 Giada Giorgi

27 Block diagram: Ciclo For
Si vuole calcolare la potenza y=x^a, dove i valori x ed a vengono forniti come variabili di ingresso: INPUT -> x //Base INPUT -> a //Esponente temp = 1 //Variabile temporanea N = a //Numero di cicli for i=0 to N-1{ temp=temp*x //Corpo del ciclo } y = temp -> OUTPUT //Potenza Ciclo for e while 31 ottobre 2007 Giada Giorgi

28 Block diagram: Ciclo For
Count terminal Shift register For Loop Executes its subdiagram n times, where n is the value wired to the count (N) terminal. The iteration (i) terminal provides the current loop iteration count, which ranges from 0 to n-1. Iteration terminal Il valore del count terminal (N) indica il numero di iterazioni. E’ una variabile di ingresso. Il valore dell’iteration terminal (i) contiene il numero di iterazioni completate. E’ una variabile di uscita. Il valore iniziale è pari a 0. N ed i sono interi con segno a 32 bit. Per passare dei valori da un’iterazione del ciclo alla successiva si usano degli shift register. Ciclo for e while 31 ottobre 2007 Giada Giorgi

29 Block diagram: Ciclo for
Invece dello shift register è possibile utilizzare una feedback note. La feedback note viene creata automaticamente quando si collega l’uscita di un blocco con l’ingresso dello stesso. Feedback Node The Feedback Node appears automatically in a For Loop or While Loop when you wire the output of a node or group of nodes to the input of that node or group of nodes. You also can select the Feedback Node on the Functions palette and place it inside a For Loop or While Loop. Use the Feedback Node to avoid long wires across loops. Like a shift register, the Feedback Node stores data when the loop completes an iteration, sends that value to the next iteration of the loop, and transfers any data type. The Feedback Node arrow indicates in which direction the data values flow along the wire. The arrow automatically changes direction if the direction of data flow changes. If you connect the wire to the tunnel after the Feedback Node, the Feedback Node passes each value back to the input of the node and then passes the last value to the tunnel. Initializing Feedback Nodes Right-click the Feedback Node and select Initializer Terminal from the shortcut menu to add the initializer terminal to the loop border to initialize the loop. When you select the Feedback Node on the Functions palette or if you convert an initialized shift register to a Feedback Node, the loop appears with an initializer terminal. Initializing a Feedback Node resets the initial value the Feedback Node passes to the first iteration of the loop when the VI runs. If you do not initialize the Feedback Node, the Feedback Node passes the last value written to the node or the default value for the data type if the loop has never executed. If you do not wire the input of the initializer terminal, each time the VI runs, the initial input of the Feedback Node is the last value from the previous execution. Replacing Shift Registers with a Feedback Node Replace a shift register with a Feedback Node by right-clicking the shift register and selecting Replace with Feedback Node from the shortcut menu. Replace a Feedback Node with shift registers by right-clicking the Feedback Node and selecting Replace with Shift Register from the shortcut menu. Ciclo for e while 31 ottobre 2007 Giada Giorgi

30 Block diagram: While loop
Iteration terminal Conditional terminal While Loop Repeats the subdiagram inside it until the conditional terminal, an input terminal, receives a particular Boolean value. The Boolean value depends on the continuation behavior of the While Loop. Right-click the conditional terminal and select Stop if True or Continue if True from the shortcut menu. The While Loop always executes at least once. The iteration (i) terminal provides the current loop iteration count, which is zero for the first iteration. Il ciclo while viene eseguito fino a quando il Conditional Terminal (variabile di ingresso booleana) assume uno specifico valore. Per modificare il valore della variabile di controllo, right-click con il mouse sulla variabile e spuntare l’opzione desiderata dal menù a tendina. Il valore dell’Iteration Terminal (i) contiene il numero di iterazioni completate. E’ una variabile di uscita. Il valore iniziale è pari a 0. Ciclo for e while 31 ottobre 2007 Giada Giorgi

31 Block diagram: Osservazioni
Il valore delle variabili fornite in ingresso al ciclo viene letto soltanto una volta all’inizio del ciclo e non ad ogni iterazione del ciclo. Il valore delle variabili in uscita al ciclo viene aggiornato soltanto alla fine del ciclo e non ad ogni iterazione del ciclo. Le variabili locali sono utili per la lettura, all’interno di un ciclo, del valore di un controllo esterno al ciclo. Ciclo for e while 31 ottobre 2007 Giada Giorgi

32 Block diagram: Variabili locali
Esempio: si vuole realizzare un VI che incrementa un contatore ogni 250 ms con possibilità di fermare sia l’iterazione, sia il VI. Arresta iterazione ma non il VI (conteggio riparte da 0). Local Variable Use local variables to read or write to one of the controls or indicators on the front panel of a VI. When you create a local variable, a local variable icon for the object appears on the block diagram. Writing to a local variable has the same result as passing data to a terminal, except that you can write to it even though it is a control, or read from it even though it is an indicator. Creating Local Variables You might need to use a local variable when writing to one front panel object from two block diagram locations or when reading from one front panel object to two block diagram locations. Right-click an existing front panel object or block diagram terminal and select Create»Local Variable from the shortcut menu to create a local variable. A local variable icon for the object appears on the block diagram. Complete the following steps to create a local variable and associate it with a front panel object. Place a local variable on the block diagram. The local variable node is not yet associated with a control or indicator. Right-click the local variable node and select a front panel object from the Select Item shortcut menu. The shortcut menu lists all the front panel objects that have owned labels. You also can use the Operating tool or Labeling tool to click the local variable node and select the front panel object from the shortcut menu. Note  LabVIEW uses owned labels to associate local variables with front panel objects, so label front panel controls and indicators with descriptive owned labels. Arresta VI (quindi anche iterazione) senza dover premere il pulsante “STOP”. Ciclo for e while 31 ottobre 2007 Giada Giorgi

33 Block diagram: Prima soluzione…
Ciclo for e while 31 ottobre 2007 Giada Giorgi

34 Block diagram: Seconda soluzione…
Ciclo for e while 31 ottobre 2007 Giada Giorgi

35 Block Diagram: Struttura if
Queste strutture eseguono una parte di codice piuttosto che un’altra a seconda del valore assunto dalla variabile di controllo, detta Selector Terminal. Per ottenere una struttura if è sufficiente collegare il Selector terminal ad una variabile di controllo di tipo Boolean. Case Selector identifier Case Structure Has one or more subdiagrams, or cases, exactly one of which executes when the structure executes. The value wired to the selector terminal determines which case to execute and can be Boolean, string, integer, or enumerated type. Right-click the structure border to add or delete cases. Use the Labeling tool to enter value(s) in the case selector label and configure the value(s) handled by each case. Only one subdiagram is visible at a time, and the structure executes only one case at a time. An input value determines which subdiagram executes. The Case structure is similar to switch statements or if...then...else statements in text-based programming languages. You must wire an integer, Boolean value, string, or enumerated type value to the selector terminal. You can position the selector terminal anywhere on the left border of the Case structure. If the data type of the selector terminal is Boolean, the structure has a TRUE case and a FALSE case. If the selector terminal is an integer, string, or enumerated type value, the structure can have any number of cases. Specify a default case for the Case structure to handle out-of-range values. Otherwise, you must explicitly list every possible input value. For example, if the selector is an integer and you specify cases for 1, 2, and 3, you must specify a default case to execute if the input value is 4 or any other unspecified integer value. Case Selector Values and Data Types You can enter a single value or lists and ranges of values in the case selector label. For lists, use commas to separate values. For numeric ranges, specify a range as , meaning all numbers from 10 to 20 inclusively. You also can use open-ended ranges. For example, represents all numbers less than or equal to 100, and represents all numbers greater than or equal to 100. You also can combine lists and ranges, for example ..5, 6, 7..10, 12, 13, 14. When you enter values that contain overlapping ranges in the same case selector label, the Case structure redisplays the label in a more compact form. The previous example redisplays as ..10, For string ranges, a range of a..c includes all of a and b, but not c. A range of a..c,c includes the ending value of c. When you enter string and enumerated values in a case selector label, the values display in quotation marks, for example "red", "green", and "blue". However, you do not need to type the quotation marks when you enter the values unless the string or enumerated value contains a comma or range symbol ("," or ".."). In a string value, use special backslash codes for non-alphanumeric characters, such as \r for a carriage return, \n for a line feed, and \t for a tab. If you change the data type of the wire connected to the selector terminal of a Case structure, the Case structure automatically converts the case selector values to the new data type when possible. If you convert a numeric value, for example 19, to a string, the string value is “19”. If you convert a string to a numeric value, LabVIEW converts only those string values that represent a number. The other values remain strings. If you convert a number to a Boolean value, LabVIEW converts 0 to FALSE and 1 to TRUE, and all other numeric values become strings. If you enter a selector value that is not the same type as the object wired to the selector terminal, the value appears red to indicate that you must delete or edit the value before the structure can execute, and the VI will not run. Also, because of the possible round-off error inherent in floating-point arithmetic, you cannot use floating-point numbers as case selector values. If you wire a floating-point value to the case, LabVIEW rounds the value to the nearest even integer. If you type a floating-point value in the case selector label, the value appears red to indicate that you must delete or edit the value before the structure can execute. Input and Output Tunnels You can create multiple input and output tunnels for a Case structure. Inputs are available to all cases, but cases do not have to use each input. However, you must define each output tunnel for each case. When you create an output tunnel in one case, tunnels appear at the same position on the border in all the other cases. If even one output tunnel is not wired, all output tunnels on the structure appear as white squares. You can define a different data source for the same output tunnel in each case, but the data types must be compatible for each case. You also can right-click the output tunnel and select Use Default If Unwired from the shortcut menu to use the default value for the tunnel data type for all unwired tunnels. Selector terminal Struttura if a case 31 ottobre 2007 Giada Giorgi

36 Block diagram: Struttura case
Per ottenere una struttura case è sufficiente collegare il Selector terminal ad una variabile di controllo di tipo Integer, String oppure di un altro tipo comunque enumerabile. E’ possibile specificare anche un Default case. Struttura if a case 31 ottobre 2007 Giada Giorgi

37 Block diagram: Sequence Structures
Le strutture Sequence servono per controllare il flusso di esecuzione di un programma. Una “struttura sequenza” contiene uno o più subdiagrams (detti frame) che vengono eseguiti sequenzialmente. All’interno di ogni frame l’ordine di esecuzione viene determinato dalle relazioni di dipendenza dei nodi, come avviene comunemente in Labview. Esistono due tipi di Sequence Structures: Flat Sequence structure; Stacked Sequence structure. Sequence Structures A sequence structure contains one or more subdiagrams, or frames, that execute in sequential order. Within each frame of a sequence structure, as in the rest of the block diagram, data dependency determines the execution order of nodes. Sequence structures are not used commonly in LabVIEW. Use the sequence structures to control the execution order when natural data dependency does not exist and flow-through parameters are not available. There are two types of sequence structures—the Flat Sequence structure and the Stacked Sequence structure. Struttura sequence 31 ottobre 2007 Giada Giorgi

38 Block diagram: Flat sequence
Questa struttura visualizza tutti i frames contemporaneamente ed esegue i frames in modo sequenziale, iniziando da quello più a sinistra fino a quello più a destra. Flat Sequence Structure The Flat Sequence structure displays all the frames at once and executes the frames from left to right and when all data values wired to a frame are available, until the last frame executes. The data values leave each frame as the frame finishes executing. Use the Flat Sequence structure to avoid using sequence locals and to better document the block diagram. When you add or delete frames in a Flat Sequence structure, the structure resizes automatically. Struttura sequence 31 ottobre 2007 Giada Giorgi

39 Block diagram: Stacked sequence
Questa struttura visualizza un frame per volta. Il primo frame che viene eseguito è il frame 0, quindi viene eseguito il frame 1 e così via fino all’ultimo frame. Stacked Sequence Structure The Stacked Sequence structure, shown as follows, stacks each frame so you see only one frame at a time and executes frame 0, then frame 1, and so on until the last frame executes. The Stacked Sequence structure returns data only after the last frame executes. Use the Stacked Sequence structure if you want to conserve space on the block diagram. The sequence selector identifier at the top of the Stacked Sequence structure contains the current frame number and range of frames. Use the sequence selector identifier to navigate through the available frames and rearrange frames. The frame label in a Stacked Sequence structure is similar to the case selector label of the Case structure. The frame label contains the frame number in the center and decrement and increment arrows on each side. Click the decrement and increment arrows to scroll through the available frames. You also can click the down arrow next to the frame number and select a frame from the pull-down menu. Right-click the border of a frame, select Make This Frame, and select a frame number from the shortcut menu to rearrange the order of a Stacked Sequence structure. Unlike the case selector label, you cannot enter values in the frame label. When you add, delete, or rearrange frames in a Stacked Sequence structure, LabVIEW automatically adjusts the numbers in the frame labels. To pass data from one frame to any subsequent frame of a Stacked Sequence structure, use a sequence local terminal. An outward-pointing arrow appears in the sequence local terminal of the frame that contains the data source. The terminal in subsequent frames contains an inward-pointing arrow, indicating that the terminal is a data source for that frame. You cannot use the sequence local terminal in frames that precede the first frame where you wired the sequence local. Using Sequence Structures The tunnels of a sequence structure can have only one data source, unlike Case structures. The output can emit from any frame. If you use a Flat Sequence structure, the data from outside the sequence structure enter the frame as each frame executes. The data leave the frame after the frame executes. If you use a Stacked Sequence structure, the structure does not start to execute until all data wired to the structure arrive. The data wired from each frame leave only when all the frames complete execution. As with Case structures, data at input tunnels are available to all frames in either the Flat Sequence or the Stacked Sequence structure. To pass data from one frame to any subsequent frame in a Flat Sequence structure, wire from the tunnel of one frame to any other frame in the structure. You can wire through a frame or out of a one frame to another frame. Avoiding Overusing Sequence Structures To take advantage of the inherent parallelism in LabVIEW, avoid overusing sequence structures. Sequence structures guarantee the order of execution and prohibit parallel operations. For example, asynchronous tasks that use I/O devices, such as PXI, GPIB, serial ports, and DAQ devices, can run concurrently with other operations if sequence structures do not prevent them from doing so. Struttura sequence 31 ottobre 2007 Giada Giorgi

40 Block diagram: Formula node
Consente di valutare formule ed espressioni simili a quelle usate nel linguaggio C all’interno del diagramma a blocchi. Formula Node Evaluates mathematical formulas and expressions similar to C on the block diagram. The following built-in functions are allowed in formulas: abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, cot, csc, exp, expm1, floor, getexp, getman, int, intrz, ln, lnp1, log, log2, max, min, mod, pow, rand, rem, sec, sign, sin, sinc, sinh, sizeOfDim, sqrt, tan, tanh. There are some differences between the parser in the Mathematics VIs and the Formula Node. Complete the following steps to create a Formula Node. Place a Formula Node on the block diagram. Review the available functions and operators you can use. Use the Labeling tool or the Operating tool to enter the equations you want to calculate inside the Formula Node. Each assignment must have only a single variable on the left side of the assignment (=). Each assignment must end with a semicolon (;). Confirm that you are using the correct Formula Node syntax. If a syntax error occurs, click the broken Run button to display the Error list window. LabVIEW marks the syntax error with a # symbol. Tip  Add comments to the text in a Formula Node by enclosing them inside a slash-asterisk pair (/*comment*/), or after a double-slash (//comment). Create an input terminal for each input variable by right-clicking the Formula Node border and selecting Add Input from the shortcut menu. Type the variable name in the terminal that appears. You can edit the variable name at any time using the Labeling tool or the Operating tool, except when the VI is running. Variable terminals are case sensitive. There is no limit to the number of terminals or equations in a Formula Node. You can change a terminal type or remove a terminal. Create an output terminal for each output variable by right-clicking the Formula Node border and selecting Add Output from the shortcut menu. Type the variable name in the terminal that appears. You can edit the variable name at any time using the Labeling tool or the Operating tool, except when the VI is running. Output variables have thicker borders than input variables. Note  No two inputs and no two outputs can have the same name. However, an output can have the same name as an input. (Optional) The default data type for output terminals is double-precision, floating-point. To change the data type, create an input terminal with exactly the same name as the output terminal and wire a data type to that input terminal. Doing so also provides a default value for the terminal. You also can use the Formula Node syntax to define the variable inside the Formula Node. For example, int32 y; changes the data type of the output terminal y to 32-bit integer. Wire the input and output terminals of the Formula Node to their corresponding terminals on the block diagram. All input terminals must be wired. Output terminals do not have to be wired. Struttura node 31 ottobre 2007 Giada Giorgi

41 Block diagram: Riassunto strutture
Ciclo for Struttura case Ciclo while Formula Node Evaluates mathematical formulas and expressions similar to C on the block diagram. The following built-in functions are allowed in formulas: abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, cot, csc, exp, expm1, floor, getexp, getman, int, intrz, ln, lnp1, log, log2, max, min, mod, pow, rand, rem, sec, sign, sin, sinc, sinh, sizeOfDim, sqrt, tan, tanh. There are some differences between the parser in the Mathematics VIs and the Formula Node. Complete the following steps to create a Formula Node. Place a Formula Node on the block diagram. Review the available functions and operators you can use. Use the Labeling tool or the Operating tool to enter the equations you want to calculate inside the Formula Node. Each assignment must have only a single variable on the left side of the assignment (=). Each assignment must end with a semicolon (;). Confirm that you are using the correct Formula Node syntax. If a syntax error occurs, click the broken Run button to display the Error list window. LabVIEW marks the syntax error with a # symbol. Tip  Add comments to the text in a Formula Node by enclosing them inside a slash-asterisk pair (/*comment*/), or after a double-slash (//comment). Create an input terminal for each input variable by right-clicking the Formula Node border and selecting Add Input from the shortcut menu. Type the variable name in the terminal that appears. You can edit the variable name at any time using the Labeling tool or the Operating tool, except when the VI is running. Variable terminals are case sensitive. There is no limit to the number of terminals or equations in a Formula Node. You can change a terminal type or remove a terminal. Create an output terminal for each output variable by right-clicking the Formula Node border and selecting Add Output from the shortcut menu. Type the variable name in the terminal that appears. You can edit the variable name at any time using the Labeling tool or the Operating tool, except when the VI is running. Output variables have thicker borders than input variables. Note  No two inputs and no two outputs can have the same name. However, an output can have the same name as an input. (Optional) The default data type for output terminals is double-precision, floating-point. To change the data type, create an input terminal with exactly the same name as the output terminal and wire a data type to that input terminal. Doing so also provides a default value for the terminal. You also can use the Formula Node syntax to define the variable inside the Formula Node. For example, int32 y; changes the data type of the output terminal y to 32-bit integer. Wire the input and output terminals of the Formula Node to their corresponding terminals on the block diagram. All input terminals must be wired. Output terminals do not have to be wired. Struttura sequence Struttura node Struttura node 31 ottobre 2007 Giada Giorgi

42 Array e matrici Gestione di array Creazione di un array Indexing Tipi di filo Esempi E’ possibile creare un array, o una matrice, di dati dello stesso tipo. L’array può essere creato sia come valore di ingresso (controllo), sia come valore di uscita (indicatore). Array e matrici sono indicizzati sempre a partire da 0. Creazione di array Creazione di un array nel pannello frontale. 31 ottobre 2007 Giada Giorgi

43 Tunnel con indicizzazione disabilitata.
Indexing Gestione di array Creazione di un array Indexing Tipi di filo Esempi I cicli permettono l’accesso indicizzato a un array. Se l’indicizzazione è disabilitata, in uscita dal ciclo viene fornito solamente l’ultimo valore calcolato. Se l’indicizzazione è abilitata, in uscita vengono forniti tutti i valori calcolati. Per abilitare-disabilitare l’indicizzazione: Right-click con il tasto destro del mouse sul tunnel in uscita. Indexing Tunnel con indicizzazione disabilitata. 31 ottobre 2007 Giada Giorgi

44 Tunnel con indicizzazione abilitata.
Indexing Gestione di array Creazione di un array Indexing Tipi di filo Esempi Indexing Tunnel con indicizzazione abilitata. Se l’autoindicizzazione è abilitata, la connessione di un array a un ciclo for forza il numero di iterazioni alla dimensione dell’array. 31 ottobre 2007 Giada Giorgi

45 Tipi di filo Scalare: filo sottile Array: filo spesso
Gestione di array Creazione di un array Indexing Tipi di filo Esempi Tipi di filo Scalare: filo sottile Array: filo spesso Matrice: filo doppio 31 ottobre 2007 Giada Giorgi

46 Fine! 31 ottobre 2007 Giada Giorgi


Scaricare ppt "LabVIEW Laboratory Virtual Instrument Engineering Workbench"

Presentazioni simili


Annunci Google