12
User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

Embed Size (px)

Citation preview

Page 1: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

User Events in LabVIEW RT

Colorado ALARM User Group17 November 2011

STEVE SOLGA | ELECTROMECHA LLC

Page 2: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

Event Structure under LabVIEW RTRT TARGETS ONLY SUPPORT USER EVENTS Event structures on RT targets do not support events associated with user interface objects, such as VI panels or controls (i.e. no Value Change or Mouse Down type events)

The options for associating the Value Change event with a control still exist in LabVIEW RT but they have no effect

Page 3: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

Inter-Process Communication MechanismAN ALTERNATIVE RT COMMUNICATION MECHANISM User Events in LabVIEW RT are another way to communication between parallel processes More common communication mechanisms include Queues, RT-FIFO’s, and Shared Variables

RT SOFTWARESTANDARD METHODS

ALTERNATIVE METHOD

Page 4: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

Moving from Windows UE’s to RT UE’sMULTIPLE TASK (MULTIPLE CONTROL LOOP) COMMUNICATION METHOD In many applications, the RT controller runs multiple control processes that need to communicate with each other This presentation demonstrates a general state machine architecture which uses a Cluster of State Command Enum and Variant for the State Queue, User Event [UE], and Notifier data types

WINDOWS CODE QUICKLY PORTS TO RT Code transfers nicely from Windows to LabVIEW RT when control Value Change Events are converted to User Events. Each User Event can then have a dedicated State to handle required logic

GOOD FOR QUICK PROTOTYPING Using Networked Shared Variables (NSV) to communicate between the Host PC and the RT simplifies basic communication and utilizes existing communication methods (User Events) already existing in software architecture Host modules (Touch Panels, Tables, Windows PC Hosts) can fire User Events on the RT in a round-about way using Network Shared Variables

Page 5: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

SYSTEM ARCHITECTUREHost Communicates with RT Hardware via Networked Shared Variables

RT Asynchronous Processes Communicate via RT User Events

Module A UE API

Module B UE API

HOST INTERFACERT HARDWARE

SHARED VARIABLES

Page 6: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

RT CONTROLLER MODULELow priority loop in RT Controller Module polls Network Shared Variable for

State and Data Commands from Host. New State Commands fire User Events on the RT Controller Module

RT CONTROLLER MODULE

Poll ‘RT Cmd’ NSV for States other than ‘Idle’. Fire

associated State | Data Command as RT User Event

Page 7: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

Fundamentals Components of a ModuleThe general state machine architecture uses a State Command Enum and a Variant data for both the State Queue and User Event [UE] data types.

Type Defined Cluster of

Command | Data

User Event Mechanism for sharing the Created User Event to

other Modules

NotifierType Defined Main

Cluster for data internal to the

Module

Command Queue for Module State

Machine

Shared Variable

LV2 Functional Global

UE Publishing MechanismsGlobal

Single Element Queue

Page 8: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

UE handling in a Module

Convert Variant to LabVIEW data type and

process accordingly

Use Type Defined Controls for Complex

Data Types

A Module’s State Machine handles the specific State Command sent to the Module via the User Event. Variant Data is converted back to the LabVIEW data type for further processing Need to know the original data type in order to convert the variant data back to LV data type properly Specific States type defined in the Command Enum can be used to handle any number of unique User Events

Page 9: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

Sending a UE to a ModuleModules are ideally standalone processes that are often required to be command remotely or may need to patched into a higher level controller using sub panels.

Only sending one type of Registered User Event, a cluster of Command Enum and Variant Data

Each Module has an API that provides access to it’s registered user events Other modules can use the API to send User Events to the specific Module

Page 10: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

User Event API for a Module Provides access to the Dynamic Event registered for a Module Incorporates a Notifier that can be used for confirmation of commanded

User Event

Page 11: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

Run Demo Run Demo code on cRIO-9075 embedded controller Run Host Module and send commands to RT Controller Module which in

turns commands Modules A and B via RT User Events

Page 12: User Events in LabVIEW RT Colorado ALARM User Group 17 November 2011 STEVE SOLGA | ELECTROMECHA LLC

More Potentially Useful Information

Alternative Host – RT Communication Mechanisms TCP/IP UDP Data Socket Network Streams (LV ≥ 2010)http://zone.ni.com/devzone/cda/tut/p/id/12267 Serial 232, 484, CANbus, GPIB

Real-time VI to Host VI Communication Knowledgebase http://digital.ni.com/public.nsf/allkb/48D244EC86971D3986256BD4005CCC28#other

NI’s cRIO DEVELOPER GUIDE https://decibel.ni.com/content/groups/large-labview-application-development

Questions

Thanks!