LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

tcp/ip write help - need to send a motor command with parameters

hello - i have one small, main labview 7.0 vi that i use to control a drill's two motors.
 
right now i press a button on the front panel to move the motor, and when i do, a sub vi window pops up so the operator can set a couple of parameters and press an ok button.....the vi then sends the command with the parameters to the drill's motors.
 
i am trying to change it so i can send the move command from another computer, in another room, while the main vi sits on the computer with the drill. i know i will use TCP listen, write, read, and close in both the main vi (the TCP server?) and the client which is on the remote computer.
 
my problem is with setting the parameters for the subvi's that usually pops up. how do i set the parameters from the remote-client and have them be sent into the subvi on the main vi. if i can do this, i would have to also have a way to close the sub vi after it pops up in the main program too.
 
OR should i use something else like and application reference or an invoke node function?????
 
please help
 
thanks!!!!
sam
0 Kudos
Message 1 of 4
(2,887 Views)
Hi Sam, The good news is that you have lots of options in this category. If you happen to be a TCP guru, then we can go down that route, but I think in general it would be unnecessarily difficult for what you want to accomplish. I would strongly recommend using VI Server (i.e. invoke nodes, application and VI references, etc) to programatically lauch the VI in your lab that controls your motor. You would have a popup dialog VI in your office that would allow the user to input parameters for the motor, but then all it would do is dynamically launch the VI in your lab and pass it those parameters. I would recommend using a Call by Reference Node to call the VI in the lab and pass the parameters to it. I will attach some tutorials on using it. I'll also attach a little mock example below. Just make sure both VIs are in the same directory and run the VI set to be in the office.

Your other option depends on how you send your data to the motor. Are you using a GPIB instrument perhaps? If so, you can actually set up a Remote VISA connection and control the instrument directly from your office as if it were connected to the computer in the office. No extra VIs to call in the lab, nothing. Just a modified VISA Resource Name. Let me know if that's the case. In any case, the VI Server example above is really pretty simple and a very powerful programming technique!

Calling a VI by Reference Tutorial
Jarrod S.
National Instruments
Download All
0 Kudos
Message 2 of 4
(2,875 Views)

Thanks for your response. I have a couple of questions...

The vi in the lab is continuously running at the drill's side. So, if a user sends a motor command from their office using the method you mentioned, where is the main vi receiving it in the code? Is it  pressing the button remotely? Or is it sending the commands with drilling parameters directly to the motor? One issue is that , the motor commands on the front panel of the main-lab vi opens up a sub vi for the operator to choose the drilling/motor parameters, and then they have to press an ok button. So, what happenes if the sub vis pop up on the main vi? How will they close or is there a way to avoid that? OR I would like to have the parameters from the office be input into the subvis inputs. Is this possible to add?

 

Thanks!


@jarrod S. wrote:
Hi Sam, The good news is that you have lots of options in this category. If you happen to be a TCP guru, then we can go down that route, but I think in general it would be unnecessarily difficult for what you want to accomplish. I would strongly recommend using VI Server (i.e. invoke nodes, application and VI references, etc) to programatically lauch the VI in your lab that controls your motor. You would have a popup dialog VI in your office that would allow the user to input parameters for the motor, but then all it would do is dynamically launch the VI in your lab and pass it those parameters. I would recommend using a Call by Reference Node to call the VI in the lab and pass the parameters to it. I will attach some tutorials on using it. I'll also attach a little mock example below. Just make sure both VIs are in the same directory and run the VI set to be in the office.

Your other option depends on how you send your data to the motor. Are you using a GPIB instrument perhaps? If so, you can actually set up a Remote VISA connection and control the instrument directly from your office as if it were connected to the computer in the office. No extra VIs to call in the lab, nothing. Just a modified VISA Resource Name. Let me know if that's the case. In any case, the VI Server example above is really pretty simple and a very powerful programming technique!

Calling a VI by Reference Tutorial


0 Kudos
Message 3 of 4
(2,871 Views)
Hi again, If the VI in the lab will be running continuously, then you will need to alter some things from the example I sent you or look at an alternate implementation. The example I sent you assumed that the VI in the lab was not running. This technique actually starts the VI and runs it somewhat like a subVI. It inputs values into the connector pane, runs it, and then returns values from the outputs on the connector pane after it finishes executing. It will not work to call a VI by reference if it is already continuously running.

Instead I imagine you would want to have your VI in the lab have some sort of State Machine that polls a certain control value, such as an enum control, to determine which state to execute next. You could modify the technique I first sent to still open a reference to the VI in the lab, but it wouldn't try to run it. Instead you could use the VI method Set Control Value to set the value of a certain control or controls in the lab VI to certain values. The VI in the lab would then hopefully be in some Idle state where it polled one of those control values continuously to decide what to do next. That would allow the VI in the office to programmatically send commands to the other VI, as well as parameters for those commands. Simply set control values for the VI in the lab and let the VI in the lab go about its business. I've attached an example below.

That's just one idea. Other options you have would be to use a DataSocket connection to send parameters and commands back and forth between computers. This is a pretty simple API to use. If you have LabVIEW 8, Shared Variables are an option. Or you might look into simply using Remote Front panels, which allows you to connect to a VIs Front Panel across the network. You could then have the whole VI in the Lab, but you could connect to it, view it, modify the controls and so on from your office. If you want to view and control a VI without having LabVIEW installed on the viewing computer, you can use the Web Publishing Tool to create a web interface for your front panel. Lots of options. Let me know what sounds interesting.
Jarrod S.
National Instruments
Download All
0 Kudos
Message 4 of 4
(2,853 Views)