Wednesday, 5 February 2014

First Step in LabVIEW Websocket project

FIRST SAMPLE PROJECT

Plan for first sample project. 

  • Generate a random number, store in a array and publish the array over network.

Tools I need

  • Labview
  • SCCT 3.0
Before start this project, I checked the examples supplied by TSM4. So that I can make use of it as a template for mine.

Fortunately I found a example project similar to one I want to develop. publisher-subscriber-demo.lvproj. this example is exact match to my plan of sample example project with little extra vi's. So I am going to make my simple from this supplied example.

The publisher-subscriber-demo.lvproj project contained two files named publisher and subscriber. from the name it is clear that publisher vi will have the code for generating the data and publish it. Subscriber vi will have code for connect to the publisher and present the data received.

In a Publisher.Vi, Five stages of code was documented,

1. Create configuration for subscribers
2. start publisher
3. publish data
4. check active subscribers count
5. terminate publisher

now we got a template from this vi to prepare our publisher vi. 2nd,3rd & 5th vis are must have vis in any project it seems. we will use those vis remaining thing let us go in details right now.


  • First I saved this project in my project folder in the name of RandomData_Sample.lvproj
  • Opened the publisher.vi, deleted the 1st & 4th stage vis and saved vis after correcting all the wires.

Block Diagram of Publisher.vi


Front Panel of Publisher.vi


two column & hundred rows Random number array is generated and connected to PublishData.vi for publishing the data

In the front panel, port and API-key controls are the input to the StartPublish.vi. The details of the port & API-Key will be explained later in the project. So whatever used in the supplied example is used as it is without any change.

It was ran and stopped. There is no any error in the vi.

Now, let us look in to subscriber vi. There is no need of change in this vi. we can use it as it is. Before proceeding let us understand what is there in this vi.

Subscriber vi contains OpenConnection.vi, TransferStatus.vi, ReadAnalogData.vi & CloseConnection.vi all these vi's are important for any subscriber vi that we develop except there will be changes ReadAnalogData.vi based on the type of data that we get.


Block Diagram of Subscriber.vi


Front Panel of Subscriber.vi

Let us run the publisher & subscriber .vi and check the program. Program ran successfully. our first simple program is completed.

basic familiarity is obtained. now we can proceed for the next step.

Publishing data over internet real time using LabVIEW SCCT 3.0

if our program is going to run local area network, we don't have any problem we can use the ipadrress or pc name in the host field of the subscriber side program.

but if we want to publish the data over internet, we cannot use pc name and using ipaddress may be difficult like remembering the address etc.

alternatively we can create dns for the PC in which publisher program is running. There are two ways to create dns for our ip address

1. Creating Free DNS
2. Webhost

1. Creating Free DNS
we can create a free dns in https://www.dnsdynamic.org

  • Signup
  • Activate account
  • Enter easy understandable name to your IP
  • Check availability for your preferred name











    • If available, enter the Ip address for which it has to point to
    • Click add
    • Now you easy to remember host address is ready for your subscriber program
    2. Webhost
    If you already own website the you can create much better host address for your subscriber program
    • Login to web host account
    • go to domain management section

    • created subdomain (for example. if your site name www.yoursite.com, create a subdomain of yourprefferedname.yoursite.com)
    • Check for zone editor in your domain manager page

    • choose the subdomain that you have created and enter your publisher IP address in the point to field.
    • Now your yourprefferedname.yoursite.com is your host address for your subscriber program.
    If you have any question please contact me.