52
11/1/2012 1 ENGG*4420 ENGG*4420 ENGG*4420 Real Time System Design Real Time System Design Real Time System Design ([email protected]) ([email protected]) Due : Fri. Nov. 23 rd / Mon. Nov. 26 th Due : Fri. Nov. 23 rd / Mon. Nov. 26 th Due : Fri. Nov. 23 / Mon. Nov. 26 1 1

Real Time System Design - uoguelph.ca LABs PPP/Lab 4... · Lab 4 Report Requirements 1. ... highly dynamic data where any phase mismatch is unacceptable . ... The second task will

  • Upload
    voliem

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

1 1 / 1 / 2 0 1 2

1

ENGG*4420ENGG*4420ENGG*4420ENGG*4420

Real Time System DesignReal Time System DesignReal Time System DesignReal Time System Design

([email protected])([email protected])([email protected])

Due : Fri. Nov. 23rd / Mon. Nov. 26thDue : Fri. Nov. 23rd / Mon. Nov. 26thDue : Fri. Nov. 23rd / Mon. Nov. 26th

11

1 1 / 1 / 2 0 1 2

2

Today’s ActivitiesToday’s ActivitiesToday’s ActivitiesToday’s Activities

� Lab 4 Introduction.� Lab 4 Introduction.� Lab 4 Introduction.� Lab 4 Introduction.

� Lab 3 Demos.� Lab 3 Demos.� Lab 3 Demos.� Lab 3 Demos.

� Start work on Lab 4.� Start work on Lab 4.� Start work on Lab 4.� Start work on Lab 4.

22

1 1 / 1 / 2 0 1 2

3

Lab 4 Development EnvironmentLab 4 Development EnvironmentLab 4 Development EnvironmentLab 4 Development Environment

� Host PC � Host PC � Host PC � Host PC

� Target Quad-Core PC � Target Quad-Core PC � Target Quad-Core PC � Target Quad-Core PC

� NI PCI-6229 DAQ� NI PCI-6229 DAQ� NI PCI-6229 DAQ� NI PCI-6229 DAQ

� LabVIEW 2009 Software� LabVIEW 2009 Software� LabVIEW 2009 Software� LabVIEW 2009 Software

� Standard Module.� Standard Module.� Standard Module.

� Real-Time Development Module.� Real-Time Development Module.� Real-Time Development Module.

� Trace Execution Toolkit.� Trace Execution Toolkit.� Trace Execution Toolkit.

33

1 1 / 1 / 2 0 1 2

4

Lab 4 RequirementsLab 4 RequirementsLab 4 RequirementsLab 4 Requirements

� The goal of lab 4 is to implement a� The goal of lab 4 is to implement a� The goal of lab 4 is to implement ahalf-car vehicle suspension systemhalf-car vehicle suspension systemhalf-car vehicle suspension systemmodel using the quarter-carhalf-car vehicle suspension systemmodel using the quarter-carmodel using the quarter-carmodel using the quarter-carsuspension implemented in lab 2.suspension implemented in lab 2.suspension implemented in lab 2.

The implementation is divided into� The implementation is divided into� The implementation is divided into� The implementation is divided intotwo main components:two main components:two main components:� RT Target PC: LQR control system.� RT Target PC: LQR control system.� RT Target PC: LQR control system.

� Host PC: Half-Car suspension system� Host PC: Half-Car suspension system� Host PC: Half-Car suspension systemplant model.plant model.plant model.

44

1 1 / 1 / 2 0 1 2

5

Lab 4 ArchitectureLab 4 ArchitectureLab 4 ArchitectureLab 4 Architecture

55

1 1 / 1 / 2 0 1 2

6

Half-Car Suspension ModelHalf-Car Suspension ModelHalf-Car Suspension ModelHalf-Car Suspension Model

66

1 1 / 1 / 2 0 1 2

7

Host PC ImplementationHost PC ImplementationHost PC ImplementationHost PC Implementation

Road DisturbanceRoad DisturbanceRoad Disturbance

Half-Car Suspension systemHalf-Car Suspension system

System StatesFront Quarter-Car Communication and

System StatesFront Quarter-Car Communication and

Synchronization Task

System StatesFront Quarter-Car

Suspension Synchronization TaskSuspension Synchronization Task

Damping Damping

CoefficientsRear Quarter-Car CoefficientsRear Quarter-Car

Suspension

Coefficients

Suspension

DAQmxDAQmx

77

1 1 / 1 / 2 0 1 2

8

Host PC ImplementationHost PC ImplementationHost PC ImplementationHost PC Implementation

� Two quarter-car models representing the front and� Two quarter-car models representing the front and� Two quarter-car models representing the front andrear suspension systems.rear suspension systems.rear suspension systems.

� The models should use the parameters in Table� The models should use the parameters in Table� The models should use the parameters in Table2.3.2.3.2.3.

� The front and rear sprung mass values are� The front and rear sprung mass values are� The front and rear sprung mass values arecalculated using equations 2.18 and 2.19.calculated using equations 2.18 and 2.19.calculated using equations 2.18 and 2.19.

� Road profile� Road profile� Road profile

� Generated using a time-delayed input. Assume� Generated using a time-delayed input. Assume� Generated using a time-delayed input. Assumethat the rear suspension is 2 samples behind thethat the rear suspension is 2 samples behind thethat the rear suspension is 2 samples behind thefront suspension.front suspension.front suspension.

� The ride quality of the half-car body must be� The ride quality of the half-car body must be� The ride quality of the half-car body must becalculated using equation 2.28 in the lab manual.calculated using equation 2.28 in the lab manual.calculated using equation 2.28 in the lab manual.

88

1 1 / 1 / 2 0 1 2

9

Real-Time Target PC Real-Time Target PC Real-Time Target PC Real-Time Target PC ImplementationImplementationImplementation

99

1 1 / 1 / 2 0 1 2

1 0

Real-Time Target PC Real-Time Target PC Real-Time Target PC Real-Time Target PC ImplementationImplementationImplementation

� Implement two separate LQR controllers� Implement two separate LQR controllers� Implement two separate LQR controllersusing equation 2.14 from the manual.using equation 2.14 from the manual.using equation 2.14 from the manual.using equation 2.14 from the manual.

� Each of the LQR controllers must execute� Each of the LQR controllers must execute� Each of the LQR controllers must executeon a dedicated CPU.on a dedicated CPU.on a dedicated CPU.

� The communication and synchronization� The communication and synchronization� The communication and synchronizationtask must have it’s own dedicated CPU.task must have it’s own dedicated CPU.task must have it’s own dedicated CPU.

Communication between the various tasks� Communication between the various tasks� Communication between the various tasksmust be implemented using Real-Timemust be implemented using Real-Timemust be implemented using Real-Timemust be implemented using Real-TimeFIFOs.FIFOs.FIFOs.

1010

1 1 / 1 / 2 0 1 2

1 1

Host/Target CommunicationHost/Target CommunicationHost/Target CommunicationHost/Target Communication

� You have the following channels available for� You have the following channels available foruse in your implementation:

� You have the following channels available foruse in your implementation:use in your implementation:

Host PC:� Host PC:� Host PC:� 2 Analog Outputs� 2 Analog Outputs� 2 Analog Outputs� 2 Analog Inputs� 2 Analog Inputs� 2 Analog Inputs� 1 Digital Output� 1 Digital Output

Target PC:� Target PC:� Target PC:� 2 Analog Outputs� 2 Analog Outputs� 2 Analog Outputs� 2 Analog Inputs� 2 Analog Inputs� 2 Analog Inputs� 1 Digital Input� 1 Digital Input

Note: You’ll need to handle timing such that� Note: You’ll need to handle timing such that� Note: You’ll need to handle timing such thatyour transmissions are not delayed and datayour transmissions are not delayed and datayour transmissions are not delayed and datasets are not separated.sets are not separated.sets are not separated.

1111

1 1 / 1 / 2 0 1 2

1 2

Lab 4 – Requirements/StepsLab 4 – Requirements/StepsLab 4 – Requirements/StepsLab 4 – Requirements/Steps

� Step 1: Check that your target computer� Step 1: Check that your target computer� Step 1: Check that your target computerand DAQ are available in NIMax (slideand DAQ are available in NIMax (slideand DAQ are available in NIMax (slide22).22).22).

� Step 2: Set up your project file (slide 24).� Step 2: Set up your project file (slide 24).� Step 2: Set up your project file (slide 24).

� Step 3: On the Host PC implement the� Step 3: On the Host PC implement the� Step 3: On the Host PC implement thehalf-car suspension system by duplicatinghalf-car suspension system by duplicatinghalf-car suspension system by duplicatingyour quarter-car suspension model fromyour quarter-car suspension model fromyour quarter-car suspension model fromyour quarter-car suspension model fromLab 2.Lab 2.Lab 2.

1212

1 1 / 1 / 2 0 1 2

1 3

Lab 4 – Requirements/Steps Lab 4 – Requirements/Steps Lab 4 – Requirements/Steps Lab 4 – Requirements/Steps

� Step 4: Review the DAQmx examples in LabVIEW.� Step 4: Review the DAQmx examples in LabVIEW.� Step 4: Review the DAQmx examples in LabVIEW.

� Step 5: Build the synchronization and communication� Step 5: Build the synchronization and communication� Step 5: Build the synchronization and communicationprocess between the plant system and controllerprocess between the plant system and controllerusing the DAQmx interface.using the DAQmx interface.using the DAQmx interface.� Communication must be implemented using the two� Communication must be implemented using the two

connection blocks (DAQs).connection blocks (DAQs).connection blocks (DAQs).� Task communication must be performed using� Task communication must be performed using

queues on the host PC and Real-Time FIFOs on thequeues on the host PC and Real-Time FIFOs on theRT target PC.queues on the host PC and Real-Time FIFOs on theRT target PC.RT target PC.

� Step 6: On the target PC implement two LQR� Step 6: On the target PC implement two LQRcontrollers each occupying a dedicated CPU (one forcontrollers each occupying a dedicated CPU (one foreach suspension system). Note that Math Scriptcontrollers each occupying a dedicated CPU (one foreach suspension system). Note that Math Scripteach suspension system). Note that Math Scriptnodes CANNOT be used on the Target PC.nodes CANNOT be used on the Target PC.nodes CANNOT be used on the Target PC.

1313

1 1 / 1 / 2 0 1 2

1 4

Lab 4 – Requirements/StepsLab 4 – Requirements/StepsLab 4 – Requirements/StepsLab 4 – Requirements/Steps

� Step 7: Test the correctness and performance of� Step 7: Test the correctness and performance of� Step 7: Test the correctness and performance ofyour design using:your design using:your design using:

� Expected system response.� Expected system response.� Expected system response.

The Performance Profiler (slide 44).� The Performance Profiler (slide 44).� The Performance Profiler (slide 44).

� Real-Time System Manager (RTSM) (slide 46).� Real-Time System Manager (RTSM) (slide 46).

� The Real-Time Execution Trace Toolkit (RTETT)� The Real-Time Execution Trace Toolkit (RTETT)� The Real-Time Execution Trace Toolkit (RTETT)(slide 50).(slide 50).

� Step 8: Experiment with changing parameters such� Step 8: Experiment with changing parameters such� Step 8: Experiment with changing parameters suchas: Loop priority, timing, processor allocation, andas: Loop priority, timing, processor allocation, andSubVI priority. Observe the behavior of your designSubVI priority. Observe the behavior of your designSubVI priority. Observe the behavior of your designusing the RTSM and the RTETT.using the RTSM and the RTETT.using the RTSM and the RTETT.

1414

1 1 / 1 / 2 0 1 2

1 5

Lab 4 Demo RequirementsLab 4 Demo RequirementsLab 4 Demo RequirementsLab 4 Demo Requirements

� The demo will include the examination of the� The demo will include the examination of the� The demo will include the examination of thefollowing:following:following:

� Front Panel (graphs and controls).� Front Panel (graphs and controls).

� Model Response (both with and without semi-� Model Response (both with and without semi-� Model Response (both with and without semi-active control).active control).

� Organization of host and target implementations.� Organization of host and target implementations.� Organization of host and target implementations.

� Communication and synchronization between the� Communication and synchronization between the� Communication and synchronization between thehost and target.host and target.

� Understanding of LabVIEW implementation.� Understanding of LabVIEW implementation.� Understanding of LabVIEW implementation.

� Understanding of the Execution Trace Toolkit� Understanding of the Execution Trace Toolkit� Understanding of the Execution Trace Toolkitfigures.figures.figures.

1515

1 1 / 1 / 2 0 1 2

1 6

Lab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report Requirements

1. Introduction:1. Introduction:1. Introduction:

� Briefly describe the problem (i.e. what system are you� Briefly describe the problem (i.e. what system are youimplementing, why is control required, difference fromimplementing, why is control required, difference fromimplementing, why is control required, difference fromimplementation in lab 2, etc…).implementation in lab 2, etc…).implementation in lab 2, etc…).

� System Requirements.� System Requirements.� System Requirements.

2. Implementation:2. Implementation:2. Implementation:

� Equipment used.� Equipment used.� Equipment used.

� Short overview of the benefits of using the LV RTOS.� Short overview of the benefits of using the LV RTOS.� Short overview of the benefits of using the LV RTOS.

� Present your designed control strategy, discuss the� Present your designed control strategy, discuss the� Present your designed control strategy, discuss thenumber of cores used, and which tasks will benumber of cores used, and which tasks will beallocated on which core. Also, present your proposedallocated on which core. Also, present your proposedallocated on which core. Also, present your proposedcommunication method.communication method.communication method.

1616

1 1 / 1 / 2 0 1 2

1 7

Lab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report Requirements

2. Implementation Cont.:2. Implementation Cont.:2. Implementation Cont.:� Present a top-down implementation of your� Present a top-down implementation of your

system, showing which major operations are� Present a top-down implementation of your

system, showing which major operations aresystem, showing which major operations arebeing performed on the Host and Target PCsbeing performed on the Host and Target PCsbeing performed on the Host and Target PCs

� Theory presented in Lab 2 does not need to be� Theory presented in Lab 2 does not need to bedocumented in the Lab 4 report.documented in the Lab 4 report.documented in the Lab 4 report.

� Semi-Active Suspension� Semi-Active SuspensionLQR Theory� LQR Theory� LQR Theory

� Fully document your LabVIEW implementation� Fully document your LabVIEW implementationwith figures and code snippets where

� Fully document your LabVIEW implementationwith figures and code snippets wherewith figures and code snippets whereappropriate.appropriate.appropriate.

� Front Panel� Front Panel� Block Diagram� Block Diagram� Block Diagram� Script Nodes� Script Nodes

1717

1 1 / 1 / 2 0 1 2

1 8

Lab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report Requirements

3. Simulation/Results:3. Simulation/Results:3. Simulation/Results:

Document your system’s performance for� Document your system’s performance for� Document your system’s performance forvarious configurations. Timing and CPUvarious configurations. Timing and CPUvarious configurations. Timing and CPUusage can be obtained using the performanceusage can be obtained using the performanceusage can be obtained using the performanceanalyzer, the RTSM and the RTETT.analyzer, the RTSM and the RTETT.analyzer, the RTSM and the RTETT.

Experiment with changing the periods of the� Experiment with changing the periods of the� Experiment with changing the periods of theloops, processor allocation, and assigned VIloops, processor allocation, and assigned VIloops, processor allocation, and assigned VIand loop priorities.and loop priorities.and loop priorities.

Use figures where appropriate to document� Use figures where appropriate to document� Use figures where appropriate to documentthe results (e.g. RTSM usage graph andthe results (e.g. RTSM usage graph andthe results (e.g. RTSM usage graph andVI/Thread execution graphs from the RTETT).VI/Thread execution graphs from the RTETT).VI/Thread execution graphs from the RTETT).

1818

1 1 / 1 / 2 0 1 2

1 9

Lab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report Requirements

3. Simulation/Results Cont.:3. Simulation/Results Cont.:3. Simulation/Results Cont.:

� Discuss any changes that need to be made to� Discuss any changes that need to be made to� Discuss any changes that need to be made toyour design to obtain better systemyour design to obtain better systemyour design to obtain better systemperformance in terms of memory consumption,performance in terms of memory consumption,performance in terms of memory consumption,CPU performance, core allocation, etc.CPU performance, core allocation, etc.CPU performance, core allocation, etc.

� Discuss any difference in performance between� Discuss any difference in performance between� Discuss any difference in performance betweenyour lab 2 and lab 4 implementations.your lab 2 and lab 4 implementations.your lab 2 and lab 4 implementations.

� Replace the Timed Loops in your lab 4� Replace the Timed Loops in your lab 4� Replace the Timed Loops in your lab 4implementation with standard while loops andimplementation with standard while loops andimplementation with standard while loops andcomment of any change in performance (usecomment of any change in performance (usecomment of any change in performance (usefigures from the RTETT).figures from the RTETT).figures from the RTETT).

1919

1 1 / 1 / 2 0 1 2

2 0

Lab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report RequirementsLab 4 Report Requirements

3. Simulation/Results Cont.:3. Simulation/Results Cont.:3. Simulation/Results Cont.:

� Experiment with controlling your Timed� Experiment with controlling your Timed� Experiment with controlling your TimedLoops through both hardware and softwareLoops through both hardware and softwareLoops through both hardware and softwaretiming.timing.timing.

4. Conclusion:4. Conclusion:4. Conclusion:

� Provide some brief concluding statements� Provide some brief concluding statements� Provide some brief concluding statementson the lab based upon your implementationon the lab based upon your implementationon the lab based upon your implementationand the observed effects of varyingand the observed effects of varyingparameters. This section should be clearand the observed effects of varyingparameters. This section should be clearparameters. This section should be clearand concise.and concise.and concise.

2020

1 1 / 1 / 2 0 1 2

2 1

Deadlines and MarkingDeadlines and MarkingDeadlines and MarkingDeadlines and Marking

� Lab 4 is worth 12%.� Lab 4 is worth 12%.� Lab 4 is worth 12%.

6% for the report and 6% for the demo� 6% for the report and 6% for the demo� 6% for the report and 6% for the demo� 6% for the report and 6% for the demo

� The Demo is due Nov. 23rd/Nov. 26th, 2012 � The Demo is due Nov. 23rd/Nov. 26th, 2012 � The Demo is due Nov. 23 /Nov. 26 , 2012 in the Lab.in the Lab.in the Lab.

� The Report is due Nov. 23rd/Nov. 26th, 2012 � The Report is due Nov. 23rd/Nov. 26th, 2012 � The Report is due Nov. 23 /Nov. 26 , 2012 in the Lab.in the Lab.in the Lab.� Physical and Electronic copy.� Physical and Electronic copy.� Physical and Electronic copy.

� A signed group evaluation sheet must be � A signed group evaluation sheet must be � A signed group evaluation sheet must be submitted with the lab report.submitted with the lab report.submitted with the lab report.

� Do NOT include student numbers on the lab � Do NOT include student numbers on the lab report.

� Do NOT include student numbers on the lab report.report.

21

report.212121

1 1 / 1 / 2 0 1 2

2 2

Target ConfigurationTarget ConfigurationTarget ConfigurationTarget Configuration

� Open NI - Measurement and Automation (NIMax)� Open NI - Measurement and Automation (NIMax)� Open NI - Measurement and Automation (NIMax)on the host computer and expand the remoteon the host computer and expand the remotesystems tab.systems tab.systems tab.

� Find your target PC. The target displays both its� Find your target PC. The target displays both its� Find your target PC. The target displays both itsname and IP address when RT LabVIEW is running.name and IP address when RT LabVIEW is running.name and IP address when RT LabVIEW is running.

� Expand the “Devices and Interfaces” tab of your� Expand the “Devices and Interfaces” tab of your� Expand the “Devices and Interfaces” tab of yourtarget PC.target PC.

� Check that the DAQ is detected and available.� Check that the DAQ is detected and available.

� DO NOT TURN OFF YOUR TARGET PC!!! DUE TO� DO NOT TURN OFF YOUR TARGET PC!!! DUE TONETWORK PERMISSIONS ADMINISTRATIVENETWORK PERMISSIONS ADMINISTRATIVENETWORK PERMISSIONS ADMINISTRATIVEACCESS IS REQUIRED TO RECONFIGURE THEACCESS IS REQUIRED TO RECONFIGURE THETARGETS!!ACCESS IS REQUIRED TO RECONFIGURE THETARGETS!!TARGETS!!

2222

1 1 / 1 / 2 0 1 2

2 3

Target ConfigurationTarget ConfigurationTarget ConfigurationTarget Configuration

2323

1 1 / 1 / 2 0 1 2

2 4

Creating a LabVIEW RT ProjectCreating a LabVIEW RT ProjectCreating a LabVIEW RT ProjectCreating a LabVIEW RT Project

� Step 1: Create a� Step 1: Create a� Step 1: Create aReal-Time Project.Real-Time Project.Real-Time Project.Real-Time Project.

� Step 2: Select the� Step 2: Select the� Step 2: Select the‘Continuous‘Continuous‘Continuouscommunicationcommunicationcommunicationarchitecture’ .architecture’ .architecture’ .

2424

1 1 / 1 / 2 0 1 2

2 5

Creating a LabVIEW RT ProjectCreating a LabVIEW RT ProjectCreating a LabVIEW RT ProjectCreating a LabVIEW RT Project

� Step 3: Add your� Step 3: Add your� Step 3: Add yourconfigured target PC toconfigured target PC toconfigured target PC toyour project.your project.your project.

� Step 4: New Vis and� Step 4: New Vis and� Step 4: New Vis andDAQ tasks may now beDAQ tasks may now beDAQ tasks may now beadded to the Host andadded to the Host andTarget by right-clickingTarget by right-clickingTarget by right-clickingin the project window.in the project window.in the project window.

Remember to save your� Remember to save your� Remember to save yourproject file and not justproject file and not justproject file and not justyour VIs.your VIs.your VIs.

2525

1 1 / 1 / 2 0 1 2

2 6

Project OrganizationProject OrganizationProject OrganizationProject Organization

� You can experiment with the organization� You can experiment with the organization� You can experiment with the organizationof your project to find what you feel worksof your project to find what you feel worksof your project to find what you feel worksbest.of your project to find what you feel worksbest.best.best.

� Note that priorities can be set at the VI� Note that priorities can be set at the VI� Note that priorities can be set at the VIlevel (I.E. “Time-Critical”, “Normal”, etc..)level (I.E. “Time-Critical”, “Normal”, etc..)level (I.E. “Time-Critical”, “Normal”, etc..)and in timed loops running within a VI.and in timed loops running within a VI.and in timed loops running within a VI.

� Group similar tasks together.� Group similar tasks together.� Group similar tasks together.

Start off making use of three cores and� Start off making use of three cores and� Start off making use of three cores and� Start off making use of three cores andchange the allocations later as you see fit.change the allocations later as you see fit.change the allocations later as you see fit.

2626

1 1 / 1 / 2 0 1 2

2 7

Useful ToolsUseful ToolsUseful ToolsUseful Tools

� SubVIs: Used to build frequently used� SubVIs: Used to build frequently used� SubVIs: Used to build frequently usedfunctions that can later be added tofunctions that can later be added tofunctions that can later be added tothe main VI.functions that can later be added tothe main VI.the main VI.the main VI.

� Global and Shared Variables: Used to� Global and Shared Variables: Used to� Global and Shared Variables: Used tomove data between loops and VIs.

� Global and Shared Variables: Used tomove data between loops and VIs.move data between loops and VIs.move data between loops and VIs.

� DAQmx channels and tasks for� DAQmx channels and tasks for� DAQmx channels and tasks forconnected devices: Used to move

� DAQmx channels and tasks forconnected devices: Used to moveconnected devices: Used to movedata between the host and targetconnected devices: Used to movedata between the host and targetdata between the host and targetdata between the host and targetPCs.PCs.PCs.

2727

1 1 / 1 / 2 0 1 2

2 8

Useful ToolsUseful ToolsUseful ToolsUseful Tools

2828

1 1 / 1 / 2 0 1 2

2 9

Creating SubVICreating SubVICreating SubVICreating SubVI

� SubVIs can be created as functions to be used in the� SubVIs can be created as functions to be used in themain VI.

� SubVIs can be created as functions to be used in themain VI.main VI.

� These subVIs can have their own priorities predefined� These subVIs can have their own priorities predefined(default priority is ‘Normal’).

� These subVIs can have their own priorities predefined(default priority is ‘Normal’).(default priority is ‘Normal’).

� To create your own VI:� To create your own VI:� To create your own VI:� Build your function on the block diagram.� Build your function on the block diagram.

Right click the VI icon on the top right corner of the� Right click the VI icon on the top right corner of the� Right click the VI icon on the top right corner of theblock diagram.block diagram.From here you can define the terminals the VI needs,� From here you can define the terminals the VI needs,� From here you can define the terminals the VI needs,and the shape of the icon.and the shape of the icon.Drag your newly created subVI onto your main block� Drag your newly created subVI onto your main block� Drag your newly created subVI onto your main blockdiagram.diagram.

� Remember that by default the VIs are not set for� Remember that by default the VIs are not set for� Remember that by default the VIs are not set forreentrant execution.reentrant execution.

2929

1 1 / 1 / 2 0 1 2

3 0

Creating SubVICreating SubVICreating SubVIRight click icon

Creating SubVIRight click icon Right click icon

to get VI related to get VI related

optionsoptionsoptions

3030

1 1 / 1 / 2 0 1 2

3 1

VI PropertiesVI PropertiesVI PropertiesVI Properties

� VI properties can be set by going to “File”�”VI� VI properties can be set by going to “File”�”VI� VI properties can be set by going to “File”�”VIProperties”. You can set and enable debugging (activeProperties”. You can set and enable debugging (activeby default) and set priority to be normal or time-critical.by default) and set priority to be normal or time-critical.by default) and set priority to be normal or time-critical.Most needed options can be found under “execution”Most needed options can be found under “execution”

3131

1 1 / 1 / 2 0 1 2

3 2

Useful Structures - CommunicationUseful Structures - CommunicationUseful Structures - CommunicationUseful Structures - Communication

� In order to send and receive data, you’ll� In order to send and receive data, you’ll� In order to send and receive data, you’llneed to setup NI-DAQmx tasks.

� In order to send and receive data, you’llneed to setup NI-DAQmx tasks.need to setup NI-DAQmx tasks.need to setup NI-DAQmx tasks.

� To do this, right click on the desired PC� To do this, right click on the desired PC� To do this, right click on the desired PC� To do this, right click on the desired PC(host or target) and go to “New DAQmx(host or target) and go to “New DAQmx(host or target) and go to “New DAQmxtask”. Configuration is then performedtask”. Configuration is then performedtask”. Configuration is then performedin the same fashion as using a DAQin the same fashion as using a DAQin the same fashion as using a DAQassistant.in the same fashion as using a DAQassistant.assistant.assistant.

� You can then drag the configured� You can then drag the configured� You can then drag the configured� You can then drag the configuredchannel or task on to the block diagram.channel or task on to the block diagram.channel or task on to the block diagram.

3232

1 1 / 1 / 2 0 1 2

3 3

Useful Structures - CommunicationUseful Structures - CommunicationUseful Structures - CommunicationUseful Structures - Communication

� Right-clicking on the channel or task� Right-clicking on the channel or task� Right-clicking on the channel or task� Right-clicking on the channel or taskwill give you the option to access thewill give you the option to access thewill give you the option to access theDAQmx pallet where you can find theDAQmx pallet where you can find theDAQmx pallet where you can find theDAQmx pallet where you can find theblocks for both reading and writing.blocks for both reading and writing.blocks for both reading and writing.The configured channel/task can thenThe configured channel/task can thenThe configured channel/task can thenThe configured channel/task can thenbe connected as shown below.be connected as shown below.be connected as shown below.

3333

1 1 / 1 / 2 0 1 2

3 4

Useful Structures – Timed LoopsUseful Structures – Timed LoopsUseful Structures – Timed LoopsUseful Structures – Timed Loops

� Within a VI, timed loops can be� Within a VI, timed loops can be� Within a VI, timed loops can be� Within a VI, timed loops can beplaced. The loops can be configuredplaced. The loops can be configuredplaced. The loops can be configuredto have different priorities, executionto have different priorities, executionto have different priorities, executionto have different priorities, executionperiods, and processor allocations.periods, and processor allocations.periods, and processor allocations.

Double click the left terminal to Double click the left terminal to

get the configuration windowget the configuration windowget the configuration window

3434

1 1 / 1 / 2 0 1 2

3 5

Useful Structures – Timed LoopsUseful Structures – Timed LoopsUseful Structures – Timed LoopsUseful Structures – Timed Loops

Useful Link:Useful Link:

http://www.ni.com/swf/presentation/us/labview/timeloop/http://www.ni.com/swf/presentation/us/labview/timeloop/http://www.ni.com/swf/presentation/us/labview/timeloop/

3535

1 1 / 1 / 2 0 1 2

3 6

Task/Loop SynchronizationTask/Loop SynchronizationTask/Loop SynchronizationTask/Loop Synchronization

� Synchronized measurements refer to� Synchronized measurements refer to� Synchronized measurements refer tomeasurements that start at the samemeasurements that start at the samemeasurements that start at the sametime and share a single clock.time and share a single clock.time and share a single clock.

� Needed when measuring/sampling� Needed when measuring/sampling� Needed when measuring/samplinghighly dynamic data where any phasehighly dynamic data where any phasehighly dynamic data where any phasemismatch is unacceptable.mismatch is unacceptable.mismatch is unacceptable.

Two methods:� Two methods:� Two methods:� Two methods:� Software Synchronization� Software Synchronization� Software Synchronization

� Hardware Synchronization� Hardware Synchronization� Hardware Synchronization

3636

1 1 / 1 / 2 0 1 2

3 7

Task/Loop SynchronizationTask/Loop SynchronizationTask/Loop SynchronizationTask/Loop Synchronization

� Software Synchronization� Software Synchronization� Software Synchronization� Software Synchronization

� Allows for simple but not accurate� Allows for simple but not accurate� Allows for simple but not accuratesynchronization between the varioussynchronization between the varioussynchronization between the varioussynchronization between the variousTimed Loops in the implementation.Timed Loops in the implementation.Timed Loops in the implementation.

Global Timing source that is� Global Timing source that is� Global Timing source that is� Global Timing source that isindependent of the loop timingindependent of the loop timingindependent of the loop timingsource.source.source.

3737

1 1 / 1 / 2 0 1 2

3 8

Task/Loop SynchronizationTask/Loop SynchronizationTask/Loop SynchronizationTask/Loop Synchronization

� Hardware Synchronization� Hardware Synchronization� Hardware Synchronization

� Highly accurate timing� Highly accurate timing� Highly accurate timingsource.source.

� For best synchronization with� For best synchronization withthe Timed Loop use thethe Timed Loop use thethe Timed Loop use the‘Control Loop From Task’‘Control Loop From Task’‘Control Loop From Task’instance.instance.

3838

1 1 / 1 / 2 0 1 2

3 9

Passing Data Between ThreadsPassing Data Between ThreadsPassing Data Between ThreadsPassing Data Between Threads

� Data should be passed between tasks� Data should be passed between tasks� Data should be passed between tasksand timed loops using one of theand timed loops using one of theand timed loops using one of thefollowing methods:following methods:following methods:following methods:

� Global Variables � Good� Global Variables � Good� Global Variables � Good

� Functional Global Variables � Better� Functional Global Variables � Better� Functional Global Variables � Better

� RT FIFO VIs� Best method.� RT FIFO VIs� Best method.� RT FIFO VIs� Best method.

3939

1 1 / 1 / 2 0 1 2

4 0

Global Variables (GVs)Global Variables (GVs)Global Variables (GVs)Global Variables (GVs)

Shared resource can cause jitter� Shared resource � can cause jitter� Shared resource � can cause jitter� Shared resource � can cause jitter

� Global variables may be written to many� Global variables may be written to many� Global variables may be written to manytimes before being read.times before being read.times before being read.

� Using GVs in time-critical tasks can� Using GVs in time-critical tasks can� Using GVs in time-critical tasks cancompromise determinism.compromise determinism.compromise determinism.

If one task accesses the variable, no other task� If one task accesses the variable, no other task� If one task accesses the variable, no other taskcan access it until the first task releases thecan access it until the first task releases thecan access it until the first task releases thevariable. The second task will be forced to wait,variable. The second task will be forced to wait,variable. The second task will be forced to wait,therefore introducing jitter.therefore introducing jitter.therefore introducing jitter.

4040

1 1 / 1 / 2 0 1 2

4 1

Functional Global Variables (FGVs)Functional Global Variables (FGVs)Functional Global Variables (FGVs)Functional Global Variables (FGVs)

� Avoid shared resource problems by using� Avoid shared resource problems by using� Avoid shared resource problems by usingFGVs.FGVs.FGVs.FGVs.

� Can have several inputs and outputs.� Can have several inputs and outputs.� Can have several inputs and outputs.

Allows for a ‘skip if busy’ function.� Allows for a ‘skip if busy’ function.� Allows for a ‘skip if busy’ function.� Allows for a ‘skip if busy’ function.

� Functional global variables can be a lossy� Functional global variables can be a lossy� Functional global variables can be a lossyform of communication, if a VI overwritesform of communication, if a VI overwritesform of communication, if a VI overwritesthe shift register data before another VIthe shift register data before another VIthe shift register data before another VIreads the data.reads the data.reads the data.reads the data.

4141

1 1 / 1 / 2 0 1 2

4 2

Real-Time FIFO (RT-FIFO)Real-Time FIFO (RT-FIFO)Real-Time FIFO (RT-FIFO)Real-Time FIFO (RT-FIFO)

� Best method of communication.� Best method of communication.� Best method of communication.� Best method of communication.

� Ensures determinism of time-critical� Ensures determinism of time-critical� Ensures determinism of time-criticaltasks.tasks.tasks.tasks.

Uses fixed buffer size.� Uses fixed buffer size.� Uses fixed buffer size.� Uses fixed buffer size.

An RT-FIFO can be a lossy� An RT-FIFO can be a lossy� An RT-FIFO can be a lossycommunication method. When the FIFOcommunication method. When the FIFOcommunication method. When the FIFOcommunication method. When the FIFOgets full, the system starts to overwritegets full, the system starts to overwritegets full, the system starts to overwritethe old data.the old data.the old data.

4242

1 1 / 1 / 2 0 1 2

4 3

Performance AnalysisPerformance AnalysisPerformance AnalysisPerformance Analysis

� LabVIEW Real-Time has several tools that� LabVIEW Real-Time has several tools that� LabVIEW Real-Time has several tools thatcan be used to evaluate the performance

� LabVIEW Real-Time has several tools thatcan be used to evaluate the performancecan be used to evaluate the performanceand response of your system.can be used to evaluate the performanceand response of your system.and response of your system.and response of your system.

� Performance Profiler� Performance Profiler� Performance Profiler

Real-Time System Manager� Real-Time System Manager� Real-Time System Manager� Real-Time System Manager

� Real-Time Execution Trace Toolkit� Real-Time Execution Trace Toolkit� Real-Time Execution Trace Toolkit

Note that your application needs to be� Note that your application needs to be� Note that your application needs to be� Note that your application needs to berunning on the target for anyrunning on the target for anyrunning on the target for anyperformance metrics to be recorded.performance metrics to be recorded.performance metrics to be recorded.

4343

1 1 / 1 / 2 0 1 2

4 4

Performance ProfilerPerformance ProfilerPerformance ProfilerPerformance Profiler

� Can be used to track the timing� Can be used to track the timing� Can be used to track the timing� Can be used to track the timingstatistics of both main and sub VIs.statistics of both main and sub VIs.statistics of both main and sub VIs.

� The performance profiler can also be� The performance profiler can also be� The performance profiler can also beused to track the memory usage of aused to track the memory usage of aused to track the memory usage of aused to track the memory usage of agiven part of the application.given part of the application.given part of the application.

� It can be opened by going to “Tools� It can be opened by going to “Tools� It can be opened by going to “Tools� Profile � Performance and� Profile � Performance and� Profile � Performance and

Memory”.Memory”.Memory”.Memory”.

4444

1 1 / 1 / 2 0 1 2

4 5

Performance ProfilerPerformance ProfilerPerformance ProfilerPerformance Profiler

4545

1 1 / 1 / 2 0 1 2

4 6

Real-Time System ManagerReal-Time System ManagerReal-Time System Manager(RTSM)(RTSM)(RTSM)(RTSM)

� The RTSM can be used to track the� The RTSM can be used to track the� The RTSM can be used to track theproportional CPU usage of eachproportional CPU usage of eachproportional CPU usage of eachprocessor.processor.processor.processor.

� It can also be used to start and stop� It can also be used to start and stop� It can also be used to start and stoptop-level VIs during execution on thetop-level VIs during execution on thetop-level VIs during execution on thetop-level VIs during execution on thetarget to evaluate the effects on CPUtarget to evaluate the effects on CPUtarget to evaluate the effects on CPUload.load.load.

� The RTSM runs on the host computer� The RTSM runs on the host computer� The RTSM runs on the host computerand receives information from the targetand receives information from the targetand receives information from the targetduring operation.during operation.during operation.during operation.

4646

1 1 / 1 / 2 0 1 2

4 7

Real-Time System ManagerReal-Time System ManagerReal-Time System Manager(RTSM)(RTSM)(RTSM)(RTSM)

� The RTSM can be found under “Tools �� The RTSM can be found under “Tools �

Real-Time Module System Manager”.� The RTSM can be found under “Tools �

Real-Time Module � System Manager”.Real-Time Module � System Manager”.Real-Time Module � System Manager”.

4747

1 1 / 1 / 2 0 1 2

4 8

RTSM ConfigurationRTSM ConfigurationRTSM ConfigurationRTSM Configuration

� In order to use the RTSM, you need to� In order to use the RTSM, you need to� In order to use the RTSM, you need toconfigure TCP/IP communication betweenconfigure TCP/IP communication betweenconfigure TCP/IP communication betweenthe target and host computers.the target and host computers.the target and host computers.

Under the properties of the target� Under the properties of the target� Under the properties of the targetcomputer, make sure that TCP/IP is enabled

� Under the properties of the targetcomputer, make sure that TCP/IP is enabledcomputer, make sure that TCP/IP is enabledin the “VI Server” menu.computer, make sure that TCP/IP is enabledin the “VI Server” menu.in the “VI Server” menu.

� Add the host’s IP address (this can be� Add the host’s IP address (this can be� Add the host’s IP address (this can bechecked using “ipconfig/all”) to the list ofchecked using “ipconfig/all”) to the list ofpermitted machines in the Machine Accesschecked using “ipconfig/all”) to the list ofpermitted machines in the Machine Accesspermitted machines in the Machine AccessList of the “VI Server” menu.permitted machines in the Machine AccessList of the “VI Server” menu.List of the “VI Server” menu.List of the “VI Server” menu.

4848

1 1 / 1 / 2 0 1 2

4 9

RTSM ConfigurationRTSM ConfigurationRTSM ConfigurationRTSM Configuration

4949

1 1 / 1 / 2 0 1 2

5 0

Real-Time Execution ToolkitReal-Time Execution ToolkitReal-Time Execution ToolkitReal-Time Execution Toolkit

Use the Execution Trace Toolkit to capture� Use the Execution Trace Toolkit to capture� Use the Execution Trace Toolkit to capturethe timing and execution data of VIs and

� Use the Execution Trace Toolkit to capturethe timing and execution data of VIs andthe timing and execution data of VIs andthread events for your implementation.thread events for your implementation.thread events for your implementation.

� In LabVIEW select “Tools � Real-Time� In LabVIEW select “Tools � Real-Time� In LabVIEW select “Tools � Real-TimeExecution Trace Toolkit”.Execution Trace Toolkit”.Execution Trace Toolkit”.

� Before you use the toolkit to observe your� Before you use the toolkit to observe yourapplication performance, go through the

� Before you use the toolkit to observe yourapplication performance, go through theapplication performance, go through thetoolkit examples in “Help � Open Exampleapplication performance, go through thetoolkit examples in “Help � Open Exampletoolkit examples in “Help � Open ExampleSession” in the RTETT window.Session” in the RTETT window.Session” in the RTETT window.� For examples on how to use the toolkit� For examples on how to use the toolkit� For examples on how to use the toolkit

see the context help of the toolkit Vissee the context help of the toolkit Vis(search Execution Trace in the LabVIEWsee the context help of the toolkit Vis(search Execution Trace in the LabVIEW(search Execution Trace in the LabVIEWfunction pallet).(search Execution Trace in the LabVIEWfunction pallet).function pallet).

5050

1 1 / 1 / 2 0 1 2

5 1

Real-Time Execution ToolkitReal-Time Execution ToolkitReal-Time Execution ToolkitReal-Time Execution Toolkit

5151

1 1 / 1 / 2 0 1 2

5 2

Real-Time Execution ToolkitReal-Time Execution ToolkitReal-Time Execution ToolkitReal-Time Execution Toolkit

5252