2Mechanical Actions of Boolean Objects Switch when pressedSwitch when releasedSwitch until releasedLatch when pressedLatch when releasedLatch until releasedPlay with the example VI : Mechanical Action of Booleans (search mechanical in the LV Example Finder, go to Help >>Find Examples)Switch when pressed—Changes the control value each time you click it with the Operating tool, similar to a light switch. This behavior is not affected by how often the VI reads the control.Switch when released—Changes the control value only after you release the mouse button during a mouse click within the graphical boundary of the control. This behavior is not affected by how often the VI reads the control.Switch until released—Changes the control value when you click it and retains the new value until you release the mouse button. At this time, the control reverts to its default value, similar to the operation of a door buzzer. This behavior is not affected by how often the VI reads the control. You cannot select this behavior for a radio buttons control.Latch when pressed—Changes the control value when you click it and retains the new value until the VI reads it once. At this point, the control reverts to its default value even if you keep pressing the mouse button. This behavior is similar to a circuit breaker and is useful for stopping a While Loop or for getting the VI to perform an action only once each time you set the control. You cannot select this behavior for a radio buttons control.Latch when released—Changes the control value only after you release the mouse button within the graphical boundary of the control. When the VI reads it once, the control reverts to its default value. This behavior works in the same manner as dialog box buttons and system buttons. You cannot select this behavior for a radio buttons control.Latch until released—Changes the control value when you click it and retains the value until the VI reads it once or you release the mouse button, depending on which one occurs last. You cannot select this behavior for a radio buttons control.
3Custom Controls & Type Definitions No connection between the one you saved and the instance in the VIUpdate the file, but the instances are not updatedType DefConnection between the saved file and all instancesForces the data type of each instance to be identical (clusters, enum)Changes made to file will populate throughout each instanceStrict Type DefConnection between saved file and all instancesForces everything about an instance to be identical to the strict type definition, except:labeldescriptiondefault valueA custom control, type def or strict type def all create a *.ctl file, which stores the customizations you make to a front panel control. The thing that is special about type defs and strict type defs is that every instance of that control you use on your block diagram is linked to the *.ctl and will update if you make changes to the file.The purpose of a *.ctl file saved as a Custom Control is to prevent you from going through the potentially lengthy process of creating it again- the file provides easy access to create another.The purpose of a type def is to make sure that the data type is consistent (including the item list for an enum- which is particularly helpful when building state machines) for each instance.Strict typ defs are just that, strict. Everything must be the same (most noticeable is cosmetic changes –size of LED, color, etc). To be able to tell them apart, the label should be different (labels should always be unique and descriptive). Descriptions can be different because they might serve slightly different purposes (LED indicating different warnings in a system – you would want to be able to describe which LED represents which process more than just using the label). Last, the default value can be different. Everything else is the same.*.ctl*.ctl*.ctl
4Data Flow Block diagram execution is dependent on the flow of data Block diagram does NOT execute left to rightNode executes when data is available to ALL input terminalsNodes supply data to all output terminals when doneIf the computer running this code had multiple processors, these two pieces of code could run independently without additional codingLabVIEW follows a dataflow model for running VIs. A block diagram node executes when all its inputs are available. When a node completes execution, it supplies data to its output terminals and passes the output data to the next node in the dataflow path. Visual Basic, C++, JAVA, and most other text-based programming languages follow a control flow model of program execution. In control flow, the sequential order of program elements determines the execution order of a program.Consider the block diagram above. It adds two numbers and then multiplies by 2 from the result of the addition. In this case, the block diagram executes from left to right, not because the objects are placed in that order but because one of the inputs of the Multiply function is not valid until the Add function has finished executing and passed the data to the Multiply function. Remember that a node executes only when data are available at all of its input terminals, and it supplies data to its output terminals only when it finishes execution. In the second piece of code, the Simulate Signal Express VI receives input from the controls and passes its result to the graph.You may consider the add-multiply and the simulate signal code to coexist on the same block diagram in parallel. This means that they begin executing at the same time and run independently of one another. If the computer running this code had multiple processors, these two pieces of code could run independently of one another (each on its own processor) without any additional coding.It is good LV programming practice to have your program go from left to right, but data flow is not dependent on location of terminals or nodes on the block diagram.Node executes when data is available to ALL input terminalsNodes supply data to ALL output terminals when done (not before) - this includes loops! – a loop must completely finish all iterations before data will be passed out of its output tunnels.Data flow being dependent on these two major rules allows independent sections of code to operate in parallelIntroduction to LabVIEW Hands-On 26 ni.com
5Arrays: the index The index (zero-based) tells you : index the dimension of the array (1D, 2D, 3D, etc.)the index of the element displayed in the upper left corner- the 1D array below is displaying index 1 to contain a value of 3.00; we do not know the value of index 0 from this image because the value at index 0 is hidden from view2D Array (uninitialized)1D Array (initialized)(row)To add dimensions to an array one at a time, right-click the index display and select Add Dimension from the shortcut menu. You also can use the Positioning tool to resize the index display until you have as many dimensions as you want.The index display tells you the index (location) of the element that is currently displayed in the box in the upper right-hand corner of the array. Imagine the border of the array like a window into a giant speadsheet of numbers, where the spreadsheet can slide around behind the window. The index will tell you how much the spread sheet has slid around from its home position, where the window shows the top left corner of the spreadsheet values. Therefore, the 1D array is hiding index 0 and possibly other values at index 3 or more.The index is zero-based, meaning it begins it counting with zero.Uninitialized arrays will have a gray background and grayed-out numbers. If you have a value at index 1,1 in an array (which would be a 2x2 array), then column 3 will be uninitialized and all columns less than 3 (0,1,2) must be initialized . Keep in mind an array is defined to be a 2x2 by the number of rows/columns that are initialized, not just the number of columns and rows being displayed through the “array window”.(column)indexTIP: drag the edge of the index to add another dimension to an arrayIntroduction to LabVIEW Hands-On 61 ni.com
6Arrays: the elementsArrays can be of many different data types, but only one data type at a timeAll the elements in an array must have the same data type, because arrays, by definition, are a way to group items of the same data type.6
7EnumerationAn enum represents a pair of values, a string and a numeric, where the enum’s value is one of a defined list of value pairsAppears as a string to you, and a number to computerAn enum (short for enumeration) is a data type that pairs a number with a string (ie, months of the year with the number 0-11).The list of pairings is maintained as part of the data type (this is important when it comes to type definitions and is different from a ring, which looks similar)
8Conditional Disable Structure Use to define conditions that indicate which code on the block diagram executesExamples:If running as an executable, then programmatically close LabVIEW when VI finishesIf running on Windows, look for file here; if running on Mac OSX then look here.Use the Conditional Disable structure to define conditions that indicate which code on the block diagram executes.Conditional Disable StructureThe Conditional Disable structure, shown as follows, has one or more subdiagrams, or cases, exactly one of which LabVIEW uses for the duration of execution, depending on the configuration of the conditions of the subdiagram. When compiling, LabVIEW does not include any code in the inactive subdiagrams of the Conditional Disable structure.Note LabVIEW does check the syntax of code in inactive subdiagrams. However, broken code within the inactive subdiagrams does not prevent the VI from compiling and executing.Use the Conditional Disable structure to define conditions in which specific code compiles and executes. For example, if one section of the VI is target-specific, you can put this code in a Conditional Disable structure and configure it to run on the specific target. Targets you might configure a Conditional Disable structure for include Windows, Mac, Unix systems and FPGA targets.
9Event StructureEvent Structure — LabVIEW’s programmatic tool for handling events.Therefore, execution of code can be dependent on whether or not an event has occurredWaits for an event to occur indefinitely, unless configured to timeout.When something happens (a button press, your mouse hovering over a particular region, pressing a key on the keyboard, clicking the mouse – examples of default events) an “event” is fired. This event can be “caught” and “handled” by an Event Structure. Therefore, when an event occurs (such as a mouse down on the Numeric as shown in the event selector label in this slide), the code inside the structure will execute (this slide’s example does not have any code to execute yet)
10Notify and Filter Events in Config. Window Notify Events (green arrow)User action has already occurredFilter Events (red arrow)User performed action but event is not processed. Allows you to customize event handling.Notify and Filter EventsFilter events have names that end with a question mark, such as Panel Close?, to help you distinguish them from notify events. Most filter events have an associated notify event of the same name, but without the question mark, which LabVIEW generates after the filter event if no event case discarded the event.
11Flat Sequence Structure Executes each frame beginning with the left-most frame and ending with the right-most frameThe previous frame must complete before the next frame executesData can be passed out of or between frames using tunnelsOnce the sequence begins, it cannot be stoppedA 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.Flat Sequence StructureUse 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.Each frame will send its outputs on the completion of that frame (this is different than the stacked sequence structure). The outputs may go to the next frame or external to the sequence structure.The sequence structure cannot be stopped in the middle, which is why it is not often used.1st2nd3rd
12Stacked Sequence Structure Executes frame 0, then frame 1, etc. until the last frame executesReturns data only after the last frame executesTo transfer data from frame to frame, a Sequence Local must be created (right-click » Add Sequence Local)Once the sequence begins, it cannot be stoppedFormula nodeSequence LocalTo convert a Flat Sequence structure to a Stacked Sequence structure, right-click the Flat Sequence structure and select Replace with Stacked Sequence from the shortcut menu. If you change a Flat Sequence to a Stacked Sequence and then back to a Flat Sequence, LabVIEW moves all input terminals to the first frame of the sequence. The final Flat Sequence should operate the same as the Stacked Sequence. After you change the Stacked Sequence to a Flat Sequence with all input terminals on the first frame, you can move wires to where they were located in the original Flat Sequence.Stacked Sequence StructureThe 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.To convert a Stacked Sequence structure to a Flat Sequence structure, right-click the Stacked Sequence structure and select Replace»Replace with Flat Sequence from the shortcut menu. The sequence selector identifier, shown as follows, at the top of the Stacked Sequence structure contains the current frame number and range of frames.
13Other Structures Formula Node Timed Loops Sequence Local To convert a Flat Sequence structure to a Stacked Sequence structure, right-click the Flat Sequence structure and select Replace with Stacked Sequence from the shortcut menu. If you change a Flat Sequence to a Stacked Sequence and then back to a Flat Sequence, LabVIEW moves all input terminals to the first frame of the sequence. The final Flat Sequence should operate the same as the Stacked Sequence. After you change the Stacked Sequence to a Flat Sequence with all input terminals on the first frame, you can move wires to where they were located in the original Flat Sequence.Stacked Sequence StructureThe 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.To convert a Stacked Sequence structure to a Flat Sequence structure, right-click the Stacked Sequence structure and select Replace»Replace with Flat Sequence from the shortcut menu. The sequence selector identifier, shown as follows, at the top of the Stacked Sequence structure contains the current frame number and range of frames.
14Multiple Loop Design Pattern Producer/ConsumerOne type of parallel loop design patterns is the Producer/Consumer. The producer will retrieve data – producing it for use in the VI. It will also be tasked with transferring the data/information to the consumer loop, which will process the data. Often, processing may take longer than desired especially if you are acquiring/collecting data at fast rates. By implementing the producer/consumer design patter, you can have the data acquisition and the processing occur at different rates because they are happening in different loops. We will discuss methods of transferring data from the producer to the consumer in the next few slides.
15Multiple Loop Design Pattern Master/Slave: a type of Producer/Consumeruses notifiers to allow loops to run at different ratesThe master/slave design pattern is a type of producer/consumer. It typically uses something called notifiers to communicate between loops.Notifiers send a flag/flair/notice when the Send Notification function executes. The Wait on Notification function (seen in the consumer loop before the case structure) waits for that notification. The Wait on Notification knows which notification to look for because of the reference input. Once the notification is received, the Wait on Notification VI sends its outputs and the rest of the code in the loop can execute according to data flow. On the next consumer loop iteration, the Wait on Notification will begin waiting once again (because it is inside the loop) until there is another notification.Notifiers are designed to have only one notification holding spot. In other words, the size of the memory buffer (temporary memory space) is 1. Therefore, if another notification is sent, it will OVERWRITE the previous notification. As a result, the notification will always have the most current data available.It is possible to send data with the notification. The data type of the data must be set at the Obtain Notifier VI (which creates the place in memory for the notifier) – a string is the data type in this example. You are not required to send data with the notifier, which is one of the reasons this structure is called a master/slave and not producer/consumer (nothing is being produced or consumed, but the timing/when the consumer loop iterates is dependent on the master)
16Producer/Consumer with Queues Data type here determines the data type that can be placed in the queueThe Obtain Queue creates a memory space for the queue. The data type that can be added to the queue is also defined (a string in this VI). The reference wire allows the queue functions to be operating on the same memory space (because you can have multiple queues in the same VI). In the Producer loop, the Enqueue Element VI adds an item into the queue. The next time the Enqueue Element executes, another item will be added to the queue as if it were getting in line. In the consumer loop, the Dequeue Element VI waits until something is placed in the queue. Once something is in the queue, the Dequeue Element VI removes the item and can pass it out to be used in the consumer loop (not shown in this slide). The process of the Enqueue Element adding to the end of the line and the Dequeue Element removing the item first in line continues, but the enqueuing and dequeuing can occur at different rates. If the enqueuing occurs faster, the line will build up by adding items to the end of the line. If the dequeuing occurs faster, the dequeue element will wait until there is something new to remove from the front of the line. There are also functions available to remove from the back of the line, but typically the Dequeue Element is used. The Release Queue VI releases the memory location for the queue. (Therefore, if the Dequeue Element tries to access that memory after it has been destroyed, an error will occur and that is what will stop the consumer loop in this slide)
17Graphs vs. Charts Chart: Graph: Remembers history – new point added to end of plotGood for inside a loopGraph:New plot of all new dataGood for outside the loopUse the Context Help window to determine how to wire multi- plot data to Waveform Graphs and XY GraphsChart can be used outside a loop and Graphs can be used inside a loop. However, because of the update methods for charts and graphs, the are often used inside and outside loops, respectively.If you place a graph inside a loop and send a new data point to it, only that data point will be plotted- not the entire history of data. You would have to build an array with each loop iteration and send the entire array to the graph in order to see the historical data with each loop iteration. This is commonly overlooked by new LabVIEW users.
18Chart Update ModesRight-click the chart and select Advanced»Update Mode from the shortcut menuStrip chart is the default update modeScope chart and Sweep chart modes display plots significantly faster than the strip chart modeStrip chart – once the right side of the plot area is reached, the next point added causes the entire plot to shift to the left, as if it were scrollingScope chart- once the right side of the plot area is reached, the next point added causes the plot to disappear and the new point is added to the far left sideSweep chart- once the right side of the plot area is reached, the next point added causes the plot to remain and the new point is added to the far left side- a red bar shows where new data is overwriting the old data a
19Notifier vs. Queue Tool Function When to use Notifier sends alert to helps control timing of parallel loopscan transfer data between loopsdata NOT buffered (lossy)have a parallel loops that are running at different rates and 1+ loop is dependent on anotherwant to transfer data from one loop to anotherQueuehelps control timing of parallel loopstransfers data between loopsbuffers data to be transferred (FIFO)want to transfer ALL data from one loop to another
20Run the bottom VI second SemaphoresRun the top VI firstRun the bottom VI secondMany semaphores can be acquired at one time. By default, only one. This means that of the code segments enclosed by an Acquire Semaphore and a Release Semaphore, only one segment can execute at a time.
21Timing FunctionsControl or measure the frequency at which a loop executesProvide the processor with time to complete other tasks, such as processing the user interfaceUses the operating system millisecond clockThere are many reasons to use the timing functions. The Wait and Wait Until Next Millisecond Multiple functions are used for two main reasons: to control loop frequency (how quickly you go to the next loop iteration) and to provide “down time” for the processor allowing it to go complete other (possibly non-LabVIEW) tasks, such as updating the front panel or run a virus scan. The Elapsed Time Express VI is used to check how much time is passed. The Tick Count and Get Date/Time In Seconds functions can be used to determine how much time has passed, as well, by taking the difference of two measurements. (Note that the Tick Count has a maximum value 4,294, 967, 295 (49 days) because it is limited by the data type, U32. Once the maximum is reached, it begins again at zero: also known as rolling over. Therefore, if you want to measure a longer time, use the Get Date/Time in Seconds.)The timing functions use the Operating System’s ms clockThe wait and wait until next ms multiple functions are discussed in the following slides in more detail.
22Comparison of Timing Functions Red represents times when Wait functions are NOT restrictingMoment next loop iteration can beginOther code (running in parallel with waits)This slide is to visualize the different behavior from the Wait and the Wait Until Next Millisecond Multiple functions.Assumptions: The “other code,” such as a subVI, is running in parallel with either Wait or Wait Until Next Millisecond Multiple, which are within a loop. (The concept holds for other structures, like a case structure, but is easiest to understand and most often used within a loop)Definitions:green star: the point at which the next loop iteration would beginBlue solid line: time when the “other code” is executing.Black solid line (horizontal): time when Wait is executingRed: times when Wait functions are NOT restrictingIf the other code (blue line) took 16 ms….…a loop with the Wait functions would go to the next iteration right at 16 ms because the value wired into the wait is less than the time the other code took to execute. [the blue line finishes within the red area for the Wait]… a loop with Wait Until Next Millisecond Multiple function would go to the next iteration at 20 ms because the loop can only go to the next iteration at multiples of 10ms and 20 is the next multiple of 10. [the blue line finishes between red dots for the Wait Until Next Millisecond Multiple and the loop can’t go until the next red dot, so the loop waits an additional 4ms until the 20 ms mark]10 ms20 ms30 ms
23VI Timing Types Execution Timing Software Control Timing Provides the design pattern with a function that specifically allows the processor time to complete other tasksIn some cases, a Wait function is not necessaryUse of Timeout inputs can provide execution timingSoftware Control TimingTiming (pauses, waits, time checks) you put in place to make the code execute after a certain amount of time.Example:If you must acquire data for 5 minutes, you could remain in the acquisition state until the 5 minutes elapses. However, during that time you cannot process any user interface actions such as stopping the VI. To process user interface actions, you must implement timing (checking if 5 min has passed since the start of acquisition) so that the VI continually executes for the specified timeExecution timing, in general, is something that releases the processor. This could be a timeout (we will see this later with event structure) or a wait function placed in a while loop. Allowing the processor to complete other tasks, may actually speed up your code, which is counterintuitive because it seems like adding a wait would slow down code.Software Control Timing is when you want the code to execute at/after certain amounts of time. For example, if you are controlling a car wash, you would want the soap cycle to be 1 min long and the rinse cycle to be 3 min long, then you will need to put in some timing code to ensure the time goals are met. Another example is you want to acquire data for 7.3 seconds, you will need to add code to make sure the acquisition doesn’t stop prematurely or last longer. In summary, you don’t want the code to simply execute as fast as it can, so you implement software control timing.
24Software Control Timing VI TimingExecution TimingThe software control timing is checking to see if X amount of time has elapsed and then using a case structure so when enough time has elapsed (True) something other than checking the time again (false) will happenThe wait in the upper corner of the while loop is allowing the processor to rest and complete other tasks before executing the next loop iteration.Software Control Timing
25File Formats ASCII TDMS Direct Binary Numeric Precision Good Best Share dataBest (Any program easily)Better (NI Programs easily)Good (only with detailed metadata)EfficiencyIdeal UseShare data with other programs when file space and numeric precision are not importantShare data with programs when storing simple array data and metadataStore numeric data compactly with ability to random access- Use text (ASCII) format files for your data:To make the data available to other users or applicationsIf disk space and file I/O speed are not crucialIf performing random access reads or writes is unnecessaryIf numeric precision is not important- Use binary format files for your data:When numeric precision is importantWhen you need to randomly access stored dataWhen efficiency is importantA specific type of binary file, known as a Datalog file, is the easiest method for logging cluster data to fileStores arrays of clusters in a binary representationThe storage format for Datalog files is complex, and therefore the data is difficult to access in any environment except LabVIEW- Use TDMS files for the following purposes:To store test or measurement dataTo create a structure for grouping your dataTo store information about your dataTo read and write data at high speedsTDMS file format:Binary file (.tdms) that contains data and stores properties about the dataBinary index file (.tdms_index) that provides consolidated information on all the attributes and pointers in the TDMS fileTDMS file format is publicly documentedCan use with TDM Excel Add-in Tool
26Modularity and SubVIsCan you identify a section of code in this VI that is repeated? Could that section be placed in a subVI, so the subVI could be reused instead of re-writing that section of code?
27Modularity and SubVIsNow that the repeated section of code has been placed into a subVI, the VI looks cleaner and is easier to understand. If we were to change the channel that the data was being read from, we could edit the subVI and wouldn’t have to change anything in the main VI because the subVI outputs the temperature, not raw data.The subVI icon is descriptive because we can tell that it involves something with temperature.
28Icon and Connector Pane: Setting up the Connector Pane Right-click the icon in the upper right corner of the front panel and select Show Connector (before LV 2011)Each rectangle on the connector pane represents a terminalSelect a different pattern by right-clicking the connector pane and selecting Patterns from the shortcut menuThe connector pane defines what can be passed in and out of the subVI. You can get to the connector pane by right-clicking on the icon FROM THE FRONT PANEL and selecting Show Connector. You can right click on the (now showing) connector pane and select Patterns to see the pattern options available.
29Errors vs. Warnings Error Status = TRUE Warning Status = FALSE Code is non-zeroErrorStatus = TRUEThere are both errors and warnings within LabVIEW. Most products and VI groups only have errors. Some products and VI groups have warnings. VISA is an example of a product group that has warnings.Most error codes are negative values and warning codes are positive values; however, this is not universally true. A status of TRUE is always an error. A non-zero code with a status of FALSE is considered a warning.
30Debugging Tools use highlight execution use probes to see the current value in the wireset breakpoints to pause execution at a specific point in the codesingle-step through the codeHighlight execution, probes, breakpoints and single-stepping are four tools available in LabVIEW to help you determine why the VI is behaving differently than anticipated. Each is discussed in greater detail in the following slides
31VI Server: Organization GenericObjectPetsDogsLabradorPoodleCatsControlBooleanStopLEDArrayGObjectControlControl ClassProperty: VisibleMethod: Reinitialize to DefaultBoolean Sub-ClassProperty: Boolean TextArray Sub-ClassProperty: Number of RowsStop ObjectVisible: YesReinitialize to Default: NoBoolean Text: StopBoolean
32Property Nodes Access the properties of an object Enable you to modify the appearance of front panel objects programmatically in response to certain inputs.For example,If a user enters an invalid password, you might want a red LED to start blinkingIf a data point is above a certain value, you might want to show a red trace instead of a green oneExecute from top to bottomBy default, if an error occurs on 3rd of 5 terminals, last two do not execute and error is outputProperty nodes are how you access and manipulate properties of LabVIEW objects.To override default, right-click and select Ignore Errors Inside Node
33Invoke NodesUse the Invoke Node to perform actions, or methods, on referenced items (VI, Control)Most methods have parametersExamples of VI Methods:Front Panel: CenterDefault Values: Reinitialize all to DefaultPrint: VI to HTMLInvoke nodes are very similar to property nodes, except the access and manipulate methods instead of properties. Also, methods will have parametersMethod NameParameters
34Implicitly and Explicitly Linking Invoke/Property Nodes Explicitly Linked(requires reference)Implicitly Linked(color/ label for data type/label)Property NodeInvoke Node
35Variables: Recap Variable Type Scope Notes Local variable A single VI Tied to a front panel control/indicatorGlobal variableMultiple VIs on same computerTied to a special global VI that has a front panel but no block diagramFunctional globalImplemented using a While Loop with an uninitialized shift register to store global dataSingle-process shared variableImplemented using a project library in a projectCan easily convert into a network- published shared variableNetwork-published shared variableAcross an Ethernet networkOften used to communicate with Real- Time targetsOther notes:Global variable: Each global VI can have multiple variables.Functional global: Often used for more complex data structures, such as a stack or queue. A Functional global VI can be used to protect access to global resources, such as files, instruments, and data acquisition devices, that you cannot represent with a global variable.Single-process shared variable: Similar to a global variable, but can easily be converted to network-published shared variable
36Race Conditions: Shared Resources Race conditions are most common when two tasks have both read and write access to a resourceA resource is any entity that is shared between the processes; most common resources are shared data storage, such as variablesMinimize shared resources and limit the number of writers to the remaining shared resourcesMost race conditions only occur when a resource has multiple writersIn top image, the reader reads whichever was the last value written to the resource. In bottom image, all readers read value A.
37Race Conditions: Sequencing What is the final value?Four possible outcomes:Value = (Value * 5) +2Value = (Value + 2) * 5Value = Value * 5Value = Value +2Because the multiple and add functions do not have a wire forcing one to operate before the other according to LabVIEW data flow, the value in Value may be very different depending on the order of execution.For example, let’s say the Add goes first and Value has a default value of = 2. Then the multiple executes. 2*5=10. Let’s compare with the multiply executing first: 0*5 = = 2. Clearly, 2 and 10 are not the same value and this code could produce both answers.This is a situation in which using wires instead of variable will guarantee consistent results.