Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop Target vi and Host vi from either program using Command-Based Architecture?

I am running LVRT7.1 on a PXI8176 connected by Ethernet to Windows XP PC.

I am running a motion control program using Command-Based Architecture to communicate (http://zone.ni.com/devzone/conceptd.nsf/webmain/CD63FD0F746B17A686256F090065F572). My programs consist of:

RT Target vi:
1) Time-critical TIMED loop (handles motion control, reads and writes values to RT-FIFOs)
2) Receive WHILE loop to get commands from Host via TCP Read and write to RT-FIFO
3) Medium-Priority Tasks (MPT) TIMED loop to read from RT-FIFO and send values to host via TCP Write

Host vi:
a) Event-driven WHILE loop to write values to TCP when changed
b) Receive WHILE loop to read values written by MPT

I want to be able to stop all loops by either of two methods
A) User presses STOP button on front panel (command generated in loop a), or
B) actuator reaches some given position (command generated in loop 1)

How can I do this?
It is not so hard for condition A (STOP ends loop b, NewValue in event writes to TCP then ends loop a, received value on RT Target ends loop 2 and remotely stops loops 1 and 3). For condition B, I can stop all RT loops, but not the host loops. My Event structure has a short timeout, but I can't use local variables to stop both loops due to the latching action of the stop button.

Has anyone dealt with this issue (bidirectional stopping) specific to the Command-Based Architecture structure? I think the solution would also apply to RT Communication Wizard programs.


I do not have LabVIEW available now, but can include a small sample prgram in a few days if that would make the issue clearer. Thank you.
__________________________________
Laine
0 Kudos
Message 1 of 6
(4,086 Views)

Hi Laine,

You can use datasocket, TCP or UPD to transfer the boolean values between the host and the traget vi. In the target vi, you can read this boolean value and pass data across the while loops using RT FIFOs. You can create an RT FIFO for each while loop you want to stop. On the host vi you can use local variables to pass data between loops. The links below give more information:

Command-based Architecture for LabVIEW Real-Time http://zone.ni.com/devzone/conceptd.nsf/webmain/CD63FD0F746B17A686256F090065F572

TCP/IP between the Host PC and Real-Time Series Hardware http://zone.ni.com/devzone/conceptd.nsf/webmain/d02ce14a6781d1b7862568d200554988

Regards,
Prashanth
0 Kudos
Message 2 of 6
(4,068 Views)
Yes, this is the direction I was going, but the problem lies in the Target being able to stop the host program.
If I try to use local variables, I am prevented because of the latching action of the Stop button.
 
I need to stop both programs (host and target) by either:
- User presses stop button in host program
- A certain criteron is met in the target program
 
See the attached sample programs for Host and Target, noting the Case structure in the program loop.
 
 
Thank you.
__________________________________
Laine
Download All
0 Kudos
Message 3 of 6
(4,066 Views)

Hi Laine,

Do you see any issues with using a stop button with a switching action and changing the termination condition from 'Stop if True' to 'Continue if True'? This will let you use local variables.

Regards,
Prashanth

0 Kudos
Message 4 of 6
(4,054 Views)

I have tried this.  A little more complicated (must write F before or after loop runs) & seems more like a workaround.

I though more about it and am now trying to just pass the criteria values back to the host, then let the host make the judgement.  The host would stop its loop on StopButton OR criteria_met condition, then just pass a stop command to the target (which can't tell the difference, it just knows it needs to stop).  This eliminates the stop command bidirectionality.  Looks ok on a small test program.

 

But I am interested in comments from anyone who has used the Command-Based Architecture.  Such a simple task seems unusually difficult.

 

Thank you for your input.

 

__________________________________
Laine
0 Kudos
Message 5 of 6
(4,051 Views)

Hi Laine,

The issue primarily reduces to choosing different mechanisms to transfer a boolean data between loops on your host VI.

You can use a boolean button with a switching action on your target vi's front panel which is set to true when your motor condition is met and then initialized every time the target vi starts. This boolean data can be transferred to the host vi using TCP. You can then create a boolean control with a switching action on the front panel of your host vi to indicate that the condition to stop has been received from the target vi. This vi will also have to initialized every time your host vi starts. Now the issue reduces down to choosing a mechanism to transfer this boolean value between loops on your host vi. Besides using local variables and propery nodes to pass the data between loops, you can just add another condition [value change event of the second boolean button with switching action] to be monitored by the 'Stop' case of your event structure.

Hope this helps!

Regards,
Prashanth

0 Kudos
Message 6 of 6
(4,038 Views)