DOC PREVIEW
PSU EE 200 - L10_EE200_s14

This preview shows page 1-2-3-4-5-6-44-45-46-47-48-49-50-89-90-91-92-93-94 out of 94 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 94 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ColorGrayscaleEE 200 Spring 2014Lecture 10.EE 200Design ToolsLecture 10Professor Jeffrey SchianoDepartment of Electrical Engineering1EE 200 Spring 2014Lecture 10.Lecture 10 Topics• Announcements• LabVIEW– Race Conditions and Synchronization Tools• Quadrature Encoders– Realization using a microcontroller and myDAQ • Laboratory Topics– Required circuits for Lab 202EE 200 Spring 2014Lecture 10.Announcements• Problem Set 10– Problem 37 (20 points) due in Lab 203EE 200 Spring 2014Lecture 10.Race Conditions: What Are they?• Race Condition - A situation where the timing of events or the scheduling of tasks may unintentionally affect an output or data value• Race conditions are a common problem for programs that execute multiple tasks in parallel and share data between the tasks4EE 200 Spring 2014Lecture 10.Lab 19 Exercise 1• Demonstrate race condition using two VIs5EE 200 Spring 2014Lecture 10.Lab 19 Exercise 1• Loop 1 Iterations + Loop 2 Iterations > Total Count. Why?• Consider the following race condition: – Suppose Count = 3– VI 1 reads Count = 3– Before VI 1 increments Count, VI 2 increments Count so that Count = 4– VI 1 increments and saves Count = 4, instead of Count = 5 – VI 1 misses the fact that VI 2 incremented the Count• Eliminate the race condition by insuring that VI 2 cannot increment Count after VI 1 reads, and before it updates, Count6EE 200 Spring 2014Lecture 10.Eliminating Race Conditions• A critical section of code is code that may behave inconsistently if some shared resource is altered while it is running, for example, in the Lab 19 demo• If one loop interrupts another loop while it is executing critical code, then a race condition can occur• Eliminate race conditions by identifying and protecting critical code with:– Functional Global Variables– Synchronization Tools 7EE 200 Spring 2014Lecture 10.Lab 19 Exercise 1• Shared resource: global variable count8• Critical codeEE 200 Spring 2014Lecture 10.Protecting Critical Code with a FGV• Place the critical code section within a FGV• Because the FGV is a non-reentrant VI, only one instance of the FGV can run at a time• What are non-reentrant VIs?9EE 200 Spring 2014Lecture 10.Non-Reentrant and Reentrant VIs• Non-Reentrant VIs (default)– When LabVIEW calls the same subVI from multiple locations within either the same VI or different VIs, only one instance of that subVI can run at a time– This limitation occurs because the subVI reserves only a single space in memory to store its data, so all instances of the subVI must take turns using that data space• Reentrant VIs– Separate data space allocated for each instance of the VI– Multiple instances of reentrant VIs can execute in parallel without interfering with each other VIs• All FGV VIs must be non-reentrant10EE 200 Spring 2014Lecture 10.Lab 19 Exercise 211EE 200 Spring 2014Lecture 10.Protecting Critical Code with Synchronization Tools• LabVIEW uses data flow to manage code execution sequencing • Dataflow programming allows multitasking, for example, running multiple loop structures in parallel• Lab 19 exercise 1 reveals that a race condition results when two loops simultaneously access a shared resource such as a local or global variable• Synchronization tools allow the user to coordinate the parallel execution of code12EE 200 Spring 2014Lecture 10.Synchronization Tools• LabVIEW synchronization tools available in the Programming >> Synchronization palette– Semaphores– Notifiers– Queues– Rendezvous– Occurrences– First Call?13EE 200 Spring 2014Lecture 10.Synchronization using Semaphores• A semaphore is a tool for limiting the number of tasks that can simultaneously operate on a shared (protected) resource• A protected resource or critical section of code might include writing to global variables or communicating with external instruments14EE 200 Spring 2014Lecture 10.Semaphore Operation• Use a semaphore to protect two or more critical sections of code that should not be called concurrently• Before entering a critical section, the executing code must acquire a semaphore• If the critical section is not already executing– The critical section is executed– Other portions of the code are blocked from using the critical section until the current execution is complete15EE 200 Spring 2014Lecture 10.Semaphore Palette16EE 200 Spring 2014Lecture 10.Lab 19 Exercise 317EE 200 Spring 2014Lecture 10.Synchronization using Semaphores:Summary• Protects two or more critical sections of code that should not run concurrently• No provision for passing data between processes18EE 200 Spring 2014Lecture 10.Synchronization using Notifiers• Notifier functions transfer messages/data between parallel loops• Notifier functions suspend the execution of a block diagram until it receives data or a message from another section of the block diagram or from another VI • Notifier functions are useful for communicating between two loop or more loops that need to run simultaneously, but at different speeds, for example• A fast loop that acquires data every 1 ms• A slow loop that graphs data every 100 ms• Known as a Master/Slave design pattern19EE 200 Spring 2014Lecture 10.Master/Slave Design Pattern• Used when two or more loops must run simultaneously and continuously but at different rates• A master loop controls all of the slave loops, and communicates with them using messaging via notifiersor queues• The slow loop, typically used for updating the user interface, runs in the Master loop• The fast loop, typically used for data acquisition or control, runs as a slave loop20EE 200 Spring 2014Lecture 10.Advantages afforded by Notifiers21• Slave loops are synchronized to the master loop—the slave loop only executes when the master loop sends a notification• You can use notifiers to create globally available data, making it possible to send data with a notification• Using notifiers creates efficient code—there is no need to poll to determine when data is available from the master loopEE 200 Spring 2014Lecture 10.Notifier Palette22EE 200 Spring 2014Lecture 10.Master/Slave Design Pattern using Notifiers23EE 200 Spring 2014Lecture 10.Disadvantages of Notifiers24• Notifiers do not buffer data• If the master loop sends another piece of data before the first piece of data has been read by the slave loops, that data is overwritten and lostEE 200 Spring 2014Lecture


View Full Document

PSU EE 200 - L10_EE200_s14

Download L10_EE200_s14
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view L10_EE200_s14 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view L10_EE200_s14 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?