Vous êtes sur la page 1sur 11

G ETTING STARTED WITH SCCT 2.

0 FOR L AB VIEW
TUTORIAL

December 2011

I NTRODUCTION
This tutorial explains basics of SCCT for LabVIEW. This tutorial is composed by three parts. LabVIEW source code is available at
http://www.toolsforsmartminds.com/tutorials.php

Evaluation copy of SCCT for LabVIEW is available at


http://www.toolsforsmartminds.com/products/SCCT.php

You can find SCCT VIs in Data Communication palette as shown below:

Part 1
With this step by step tutorial we are going to see how to add SCCT features to an existing app. We use a simple PID app created to control a pressure into a pipe. Basic application is composed by only one VI, shown below:

VI panel is shown here:

We don't care for the moment about control theory, so we don't spend words on PID tuning, but we focus on SCCT library. Now we want to monitor our application from remote locations, with a notebook, a tablet or a smart phone. Every platform requires a simple monitor application created with a specific programming language. For instance, if you want to monitor your app from a mobile with Android, you have to create a simple program in Java using SCCT for Java. Now we want to monitor our app from a PC so we are going to use SCCT for LabVIEW both for server side and client side.

PROGRAMMING SERV ER SIDE .


We want to publish PID output as well as PID target and process variable. Take a look to the following diagram:

We added 4 VIs: StartPublisher which starts publishing service as a background task into your application. it's a separated VI that takes care of sending and receiving data on the specified port. updateConfig.vi which updates system configuration. PublishData which makes your data available to subscribers. notice that data must be organized into a 2D array where every row contains samples from a specific channel. StopPublisher which closes background task and clears memory. If you deploy this application, it handles multiple connections at the time with different devices, platforms and applications created in Java, VB, LabVIEW, ANSI C, and More. Notice that we have described our system to incoming subscribers with a cluster which contains some details regarding our analog channels. This info is used by clients to properly present your data. Notice that when publisher starts, no connections are active, so updateConfig.vi is used to add system configuration to Welcome Kit. Welcome Kite feature sends a set of packages to every client when connection is established. doing so we do not need to handle initial setup when a new subscriber connects.

PROGRAMMING CLIENT SIDE


Now we take a look to the subscriber we want to create: below you see its panel and diagram:

Notice that we use the same port for both server and client and the same API-Key "tutorial". Client diagram contains 4 SCCT VIs only: openConnection which start a background task to handle incoming data. transferStatus which says to the server "please you can start push data for me" getAnalogData which returns analogData whenever ther are fresh data closeCommunication which close background task and clears memory.

P ART 2
In this part, we improve our client interface: we remove 2D array and present our analog data with three different indicators. We would like to change our indicator's captions according to their related channel's name and use some system configuration details to customize slide scales. Here are diagram and panel:

Notice that configuration is retrieved with getConfiguration.vi. It returns the same configuration cluster we created into our server.vi.

By default slide's caption are "Slide 1", "Slide 2" and "Slide 3", when we run client.vi, SCCT retrieves by itself system configuration and returns it to our application. Slide scales are changed according to our configuration.

With a small effort we learned how to take advantage of SCCT features to create a monitor application which uses our remote system configuration. Server application can change its configuration at any time and publish a newer configuration to all active subscribers. Use read availableConfigurationCount.vi to retrieve the count of unprocessed configuration packages in your client application and Read configuration.vi to process received configuration packages.

P ART 3
In this part we discover other interesting SCCT features. We would like to change PID parameters from our client applications. First of all take a look to client Panel and diagram:

We added a cluster to edit PID parameters and an UPDATE button.

We added a while loop to handle user events. We created only one event called "apply". When user presses "UPDATE" button, a request in sent to server with sendRequest.vi. Every request is composed by a numeric code and a text. PID parameters are formatted into a string and then we assign code=1 to this request. Notice that with can pass SCCT observer's wire to different loops. you can easily manage SCCT objects passing them to your subVIs. Now we modify server to handle client's requests. Here is its diagram:

10

We added a while loop dedicated to manage user requests, connected to SCCT publisher object, which simply waits user requests and, according to their codes, executes different functions. In our example there is only a code (=1) used to update PID parameters. Server must know the meaning of every request's code and in this example, has to know also how to read text messages. You can create your own format to exchange data throw messages and requests.

11

Vous aimerez peut-être aussi