LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sync. method between two applications.

I am a novice in streaming of data. So I need to get your help.

I want to provide to other program a way of synchronization for other measurement at this time from my built application.

 

In my rough idea, just send a "fire" string "one time" during code execution through a protocol like radio antena.

 

Just send it but I have no time to check the delivery (precisely checking in other while loop "without interrupting the execution code")

 

1) shared variable: I found I need to complie two applications in the same time. It's not possible because my purpose is to provide some extension to other application.

 

2) network stream: I check the possibility as enclosed attachment.

 but I found the delivery should be done because the source has not been executed in the next until received the fire signal in sink code.

 

Can you suggest simple method for this regard?

 

labmaster

 

 

Download All
0 Kudos
Message 1 of 10
(4,365 Views)

I'm not sure I understand your issue with Shared Variables.  Of course you need to have both machines running at the same time, but that will be true whatever the method you are using (including Network Streams).

 

Synchronizing two machines is a pretty tricky process.  Probably the most reliable way would be for both machines to "subscribe" to a common time source, and to synchronize their internal clocks to that source.  I think NI has some Time Sync mechanisms available for its hardware products -- I've not looked into it closely.

 

If you want to synchronize the machines by using machine-to-machine communication, you need to consider the "unknown" variable of transmission time.  You can get an estimate of the "one-way" transmission time by measuring the "two-way" time.  I'd try the following:

   Machine 1 transmits M1 clock to Machine 2.

   On receipt, Machine 2 transmits M2 clock back to Machine 1.

   Machine 1 computes the round-trip time and divides by 2 to get an estimate of the one-way time.  It computes the Clock Offset (by knowing the M2 clock, the initial M1 clock, and the transmission time) and sends this back to Machine 2.

   Now both machines have an estimate of their clock offsets.

 

Bob Schor

0 Kudos
Message 2 of 10
(4,320 Views)

Thanks, Bob_Schor.

 

I forgot to mention important information: timing.

My application don't  have to have high precision of timing. Therefore, I didn't consider the timing amd just singaling like message queue between two applications.

Frankly my topic name should have "triggering" and sorry for my mistake.

 

However, I didn't know I can transfer the clock machine to machine or between two applications. is it right?

I am interested in such a topic. Can I find any example for that?

 

 

0 Kudos
Message 3 of 10
(4,312 Views)

Last things first -- what I mean by "transfer the clock" is Machine 1 gets the current time and sends it as Message Data to Machine 2.  When Machine 2 reads the Message, it knows Machine 1's Clock at the time the message was sent, and can compare that with its own Clock at the time the message was received.

 

Triggering -- here's how I handle the two Network Streams devoted to Messages between Host and Remote, where I want the Receiver to act on the Message "quickly" (in my case, within 10 msec).

 

For the purpose of this discussion, I'm going to consider the Host receiving Messages from the Remote.  When the Host starts running, it first establishes the (four, in my case) Network Streams.  It then starts a parallel loop to get any Messages being sent from the Remote.

 

This loop attempt to read a Message from the Remote, with a Timeout of 0 (no wait).  If it succeeds, it puts the Message on the Host's Message Queue (I'm running a Queued Message Handler on both Host and Remote), otherwise it sleeps for 10 msec.

 

Bob Schor

 

0 Kudos
Message 4 of 10
(4,282 Views)

For a one-shot trigger like this, network streams and shared variables seem like overkill. If you're communicating between two applications on the same computer, or over a reliable network, a UDP read would be an easy approach. One application opens a UDP port and sits there with a forever timeout waiting for the trigger; the other sends the UDP trigger packet.

 

Another fairly simple approach uses VI Server. The application that's waiting for the trigger contains a functional global variable, which it initializes with a user event (or a queue or notifier). The sending application opens a VI Server connection to that functional global VI and runs it with the "set trigger" action, which generates the user event (or enqueues an item, or sets a notification). The application that's waiting for the trigger, and which contains the functional global, can then act on or respond to the trigger appropriately.

Message 5 of 10
(4,256 Views)

Thanks, nathand.

 

I just achieved via network stream but it has a limitation the reader point should be made before execution of my application.

And I cannot check the writer point is still alive or not. I feel some headache in error shooting in various error situations.

 

However, I am very interesting in your idea.

Can I use the VI server and Functional global between two independent applications which complied in different time?

(As I mentioned, I want to provide a way of trigger to a user who want to use the signal.)

In this case, do I provide the GF.vi in raw code to the user?

Can you show me the concept a little bit more?

0 Kudos
Message 6 of 10
(4,243 Views)

Thanks, Bob_Schor.

 

I need some help for network stream.

 

Do I have to use the write point continuously without destroying in source for the next job? (attatched in source.vi) 

If so, Is there a way of checking if the current write point is valid or alive?

 

 

 

Download All
0 Kudos
Message 7 of 10
(4,229 Views)

When I complied in application builder, I cannot get the good communciation.

I found similar issue and read some article about this issue.

http://www.ni.com/white-paper/12267/en/

 

 

I put sink.exe (reader) //localhost:source.exe/data/writer (context name) as the write url, but it is useless.

What is the problem of url?

 

I enclosed the project file and .exe files for this.

 

 

0 Kudos
Message 8 of 10
(4,204 Views)

http://forums.ni.com/t5/LabVIEW/Network-streaming-stand-alone-application/td-p/2462564

 

Wow, poor manual.

When I put "//localhost:source.exe/data/writer" to the write name of writer, I got the signal.

 

According to the manual, there indicates the write "name" and reader "url"  abour writer function.

How name and url is the same level??

What do you think about the expression? I took much time to find the solution.

 

 

0 Kudos
Message 9 of 10
(4,189 Views)

labmaster wrote:

Can I use the VI server and Functional global between two independent applications which complied in different time?

(As I mentioned, I want to provide a way of trigger to a user who want to use the signal.)

In this case, do I provide the GF.vi in raw code to the user?

Can you show me the concept a little bit more?


I finally had time to put together a quick example. This is just enough to demonstrate the idea. I didn't build the VIs into applications but you could do so; make sure VI Server is enabled in the application, and don't try to open the same TCP port for VI Server in both an application and LabVIEW at the same time. The information that the two applications (or VIs) need to share is the TCP port on which VI server is running, the name of the functional global, and the connector pane of the functional global (you could do this with an empty VI that has the controls on the front panel connected to the connector pane; you don't need to supply any code). Note that I selected port 4363 by right-clicking on My Computer in the Project Explorer, choosing Properties, and then making changes in the VI Server category. The access list also needs to allow access to the computer and the VI; for simplicity I set the access lists to allow "*" meaning all VIs and all computers, but you could restrict this.

 

The Functional Global Variable:

Event FGV.png

 

The VI that waits for the trigger (using a User Event, but a queue or notifier works too):

Wait for Trigger.png

 

The VI that sends the trigger (opens a reference to the functional global and then runs it with the "Set Trigger" action, which generates a user event):

Send Trigger.png

 

0 Kudos
Message 10 of 10
(4,145 Views)