17
www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B)

Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

Embed Size (px)

Citation preview

Page 1: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

Inside LabVIEW

Steve Rogers

LabVIEW Software Engineer

Wed, 10:15a, 12:45p, and 3:30p

Mulberry (10B)

Page 2: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

Inside LabVIEW – TopicsInside LabVIEW – Topics

Virtual instrument organization How VIs are compiled LabVIEWs Execution system Single-threaded LabVIEW Multithreaded LabVIEW LabVIEW RTs remote execution system What happens when indicators display What happens when a subVI is called

Virtual instrument organization How VIs are compiled LabVIEWs Execution system Single-threaded LabVIEW Multithreaded LabVIEW LabVIEW RTs remote execution system What happens when indicators display What happens when a subVI is called

Page 3: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

VIVI

FrontFrontPanelPanel

BlockBlockDiagramDiagram

DataDataSpaceSpace

CompiledCompiledCodeCode

Always Always present in present in memorymemory

Loaded Loaded when usedwhen used

The Parts of a VIThe Parts of a VI

Page 4: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

VIs are compiledVIs are compiled

An Example DiagramAn Example Diagram

Page 5: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

Start of diagram•Read controlsRead controls•Read constantsRead constants•Schedule Clumps Schedule Clumps 1 & 2 (for loops) 1 & 2 (for loops)•Sleep...Sleep...

Completion of diagram•Execute divide nodes Execute divide nodes •Display indicatorsDisplay indicators•Exit VIExit VI

Top for loop•Update indicatorUpdate indicator•Schedule Clump 0Schedule Clump 0•Sleep...Sleep...

Bottom for loop•Updated indicatorUpdated indicator•Schedule Clump 0Schedule Clump 0•Sleep...Sleep...

Clump 0Clump 0

Clump 1Clump 1

Clump 2Clump 2

VIs are compiled – “Clumps”VIs are compiled – “Clumps”

Page 6: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

The Execution SystemThe Execution System

QElementQElementDS DS PCPC

QElementQElementDS DS PCPC

QElementQElementDS DS PCPC

QElementQElementDS DS PCPC

““RunQ”RunQ”headheadtailtail prioritizedprioritized

““curElem”curElem”

QElementQElementDSDSPCPC

VI Data SpaceVI Data SpaceVI Code VI Code

ebp (ds register)ebp (ds register)

instructioninstructioninstructioninstructioninstructioninstruction

Page 7: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

curElem = Dequeue(runQ)curElem = Dequeue(runQ)ebp = curElem DSebp = curElem DSres = call curElem PCres = call curElem PCif(res)if(res)

curElem PC = rescurElem PC = resEnqueue(runQ, curElem)Enqueue(runQ, curElem)

curElem = NULLcurElem = NULL

Exec() is a LoopExec() is a LoopSleeps on runQSleeps on runQwhen multithreadedwhen multithreaded

Cooperatively Cooperatively returns when returns when in UI threadin UI thread

““Rotates” the Rotates” the runQrunQcooperative cooperative multitaskingmultitasking

Page 8: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

ComputerComputer ThreadThread

User InterfaceUser InterfaceLoopLoop

Exec( )Exec( )Co-RoutinesCo-Routines

Single-Threaded LabVIEWSingle-Threaded LabVIEW

Page 9: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

Exec( )Exec( )

ThreadThreadComputerComputer

UI LoopUI Loop co-routinesco-routines

Exec()Exec()

ThreadThread

Exec( )Exec( )

ThreadThread

Exec( )Exec( )

ThreadThreadExec( )Exec( )

ThreadThreadMessagesMessages

Multithreaded LabVIEWMultithreaded LabVIEW

Page 10: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

Exec( )Exec( )

ThreadThreadRT ComputerRT Computer

CommunicationCommunicationLoopLoop

Co-routinesCo-routinesExec()Exec()

ThreadThread

Exec( )Exec( )

ThreadThread

Exec( )Exec( )

ThreadThreadExec( )Exec( )

ThreadThreadMessagesMessages

TCP/IPTCP/IP

LabVIEW RT – Target SystemLabVIEW RT – Target System

Page 11: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

Host LabVIEW RTHost LabVIEW RTComputerComputer

LabVIEW RT TargetLabVIEW RT TargetComputerComputer

ThreadThread

Exec()Exec()

ThreadThread

Exec()Exec()ThreadThread

Exec()Exec()

ThreadThread

Exec()Exec()

ThreadThread

CommunicCommunicationation

to host or to host or clientclient

Exec()Exec()

ThreadThread

User Interface LoopUser Interface LoopCommunication to Communication to

targettargetpossibly Exec()possibly Exec()

TCP/IPTCP/IP-shared -shared memorymemory-Ethernet-Ethernet-other-other

LabVIEW RT – Development SystemLabVIEW RT – Development System

Page 12: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

Client LabVIEWClient LabVIEWComputerComputer

LabVIEW RT TargetLabVIEW RT TargetComputerComputer

ThreadThread

Exec()Exec()

ThreadThread

Exec()Exec()ThreadThread

Exec()Exec()

ThreadThread

Exec()Exec()

ThreadThread

CommunicCommunicationation

to host or to host or clientclient

Exec()Exec()

TCP/IPTCP/IP-Shared -Shared memorymemory-Ethernet-Ethernet-Other-Other

ThreadThread

Exec()Exec()

ThreadThread

Exec()Exec()ThreadThread

Exec()Exec()

ThreadThread

Exec()Exec()

UI LoopUI Loopandand

Comm-Comm-unicationsunications

Exec()Exec()

ThreadThread

LabVIEW RT – Deployed SystemLabVIEW RT – Deployed System

Page 13: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

Display to an Indicator (Single Thread)Display to an Indicator (Single Thread)

Operate/ Display DataOperate/ Display DataExecution DataExecution Data

Running code copies execution data Running code copies execution data to the operate/display, and calls the to the operate/display, and calls the display function for the indicator.display function for the indicator.

Page 14: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

Display to an Indicator (Multithread)Display to an Indicator (Multithread)

Operate/ Display DataOperate/ Display DataExecution DataExecution Data

Running code Running code acquires mutex.acquires mutex.Copies execution Copies execution data to transfer data to transfer data, releases data, releases mutex, and posts mutex, and posts message to UI message to UI thread.thread.

Transfer Data:Transfer Data:MutexMutex““dirty flag”dirty flag”““update flag”update flag”

UI thread receives UI thread receives message, acquires message, acquires mutex, copies mutex, copies transfer data to transfer data to operate/ display data, operate/ display data, releases mutex, and releases mutex, and displays indicator.displays indicator.

Message queueMessage queue

Execution ThreadExecution Thread UI ThreadUI Thread

Page 15: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

SubVI Calls (SubVI Not Busy)SubVI Calls (SubVI Not Busy)

Caller Data SpaceCaller Data Space Callee Data SpaceCallee Data Space

QElementQElementDS DS PCPC

paramPtrparamPtr

ParamsParams param0param0 param1param1

““top level”top level”QElementQElement

DS DS PCPC

MutexMutexcurElem: NULLcurElem: NULLwaitQ: emptywaitQ: empty

Execution System Execution System – curElem curElem

Page 16: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

SubVI Calls (SubVI Running Caller)SubVI Calls (SubVI Running Caller)

Caller data spaceCaller data space Callee data spaceCallee data space

QElementQElementDS DS PCPC

paramPtrparamPtr

ParamsParams param0param0 param1param1

““top level”top level”QElementQElement

DS DS PCPC

MutexMutexcurElemcurElemwaitQ: emptywaitQ: empty

Execution System – curElemExecution System – curElem

Page 17: Www.natinst.com Inside LabVIEW Steve Rogers LabVIEW Software Engineer Wed, 10:15a, 12:45p, and 3:30p Mulberry (10B) Steve Rogers LabVIEW Software Engineer

www.natinst.comwww.natinst.com

SubVI Calls (SubVI is Busy)SubVI Calls (SubVI is Busy)

Caller data spaceCaller data space Callee data spaceCallee data space

QElementQElementDS DS PCPC

paramPtrparamPtr

ParamsParams param0param0 param1param1

““top level”top level”QElementQElement

DS DS PCPC

MutexMutexcurElemcurElemwaitQwaitQ

Execution System – curElemExecution System – curElem

other callerother caller