Related Content

Contact Information

Viewpoint Systems, Inc.
800 West Metro Park
Rochester, NY 14623
Phone: 585.475.9555
Fax: 585.475.9645

Viewpoint Data Management, LLC.
800 West Metro Park
Rochester, NY 14623
Phone: 585.475.9555
Fax: 585.475.9645

round top

bulletViewpoint News, January 2012


Part 4: Architecture Design for the Data Logger App

by James Campbell - jac@viewpointusa.com

Last month’s issue of this newsletter described more of the LabVIEW Action Engines for the Data Logger application we are building in this ongoing series to show good practices for LabVIEW app development and preparation for the Certified LabVIEW Developer (CLD) exam.

The architecture being developed here can be used by many types of applications, not just data logging. The ultimate goal is to have a LabVIEW Project that you can download and run.

This month’s issue starts to outline the framework and show how the Action Engines (aka Functional Globals) will be included in the app.

Architecture Framework

The requirements for this app (see November newsletter) say that user actions must be handled quickly and without blocking or being blocked by data collection, graphing, and other actions that need to happen in a timely manner.

Many applications, including those on many CLD exams, can be developed using a State Machine or Producer/Consumer (P/C) design pattern, or some combination of these two. For example, combining a state machine structure and the consumer part of a P/C loop can make many problems much simpler to code. See https://decibel.ni.com/content/docs/DOC-14169 for an example of such a design pattern, which is called a Queued State Machine.

The next subsections describe the architecture for the data logger app. A Producer/Consumer pattern will be used in conjunction with a couple of State Machines for the data acquisition. The next section describes the reasoning.

Design Decisions

The requirements for the responsive user interface can easily be handled by a P/C pattern. Usually, when user interface responsiveness is required, it’s better to use the event structure in a P/C loop rather than a State Machine that requires polling for user interface changes. But how should the data acquisition be handled?

Last month’s article outlined some approaches for the data acquisition. Given that the data acquisition is inherently asynchronous to any user inputs, it makes sense to use LabVIEW’s native parallelism and put the data acquisition into one or more parallel loops outside the P/C loops. But then, some mechanism is needed to move the data in the DAQ loop(s) into the P/C framework since the app needs to interact with that data. An Action Engine (or two) could handle this need by having the DAQ loop push the acquired data into the AE to be later retrieved by a call to this AE inside the producer loop.Since the requirements mentions bundling the acquired data into a vector for writing to file, this AE can be the manager of that data vector.

Alternatively, the DAQ could happen inside the consumer part of the P/C loops, perhaps via a Queued State Machine kicked off by a timeout event in the producer part of the P/C loops.

But the requirement that pushes towards the parallel loop(s) approach is the need to allow for acquisition from more than one device, each with possibly different acquisition rates. By having separate parallel loop(s) for the DAQ, each operating at their own loop rates independently of the consumer loop, the consumer loop can run when required without getting held off or holding off either the user actions or the DAQ.

More Code

AE for Moving Data between DAQ

The ‘Data Value Manager AE.vi’, previously discussed in the November newsletter,will be able to manage the transfer of data from the DAQ loops to the consumer loop. Each DAQ loop will push its channel data into the elements of the vector held in this AE. The consumer loop will retrieve the entire data vector from this AE for graphing and writing to the result file.

Queue Data Type for the Producer/Consumer Framework

A really good way to move data between the producer and consumer loops is to use a queue configured for a cluster containing an enum and a variant. The enum indicates the type of data to be consumed by the case frame in the consumer loop and the variant contains the data.

Main VI

An initial layout of the P/C loop, this queue, and some code comments are starting to be captured in the ‘DataLoggerExampleforCLD Main.vi’ in the project file, the link to which is contained in the next section.

Source Code for the Project

Continuing with the release of the source code to date as we implement to code for this app, a ZIP file for the entire LabVIEW project can be found here. These VIs need LabVIEW 2009 or above.

Summary

The Data Logger app development continues by making the decision to implement the app with a producer/consumer loop and parallel loops for the data acquisition. Next month, the app development will continue by continuing with the architecture and providing details about the data acquisition code.