LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send single command to a device

I want to send a single command to a device about the com1-port. I
made a case-structure with a visa-write vi in the true case. In the
false case is another command. But if I start the vi with a binary
switch, the vi send continously data to the com port. How can I
inhibit this? I need only one execution of the vi in both cases.
0 Kudos
Message 1 of 8
(3,300 Views)
Are you definitely starting the VI with the "Run" button rather than
"Run Continuously"?

If that's not the problem, you'd be best off posting your VI here
before we all start making assumptions about any looping structures
you might be using.
0 Kudos
Message 2 of 8
(3,300 Views)
Yes I start the vi with Run continuosly because the vi has also some
other things to do.
My problem is basically to find a structure which execute a code only
one time, although the button value associated with the structure is
constant true.
0 Kudos
Message 3 of 8
(3,300 Views)
Rather than using "Run Continuously", have the code that you want
executed only once run first, leading onto a While loop containing the
code you want to run repeatedly, with a boolean button (labelled
Stop/Exit/whatever) added to the front panel to allow you to exit the
loop cleanly.
0 Kudos
Message 4 of 8
(3,300 Views)
I cannot understand this. Why its better not using continuously
running? Its very difficult for me to change the whole program.

I have a while loop which execute code every some milliseconds. The
loop runs until a binary-switch is true. After a certain time running
the loop I decide to start a generator. Now I must send one command
over the rs232. Then my process works. Sometimes later I want to stop
the generator and send one another command via RS232. The whole time
the while-loop execute its code every second or so. Last I can stop
the loop with the binary switch, store data and something else.
If I use a while loop as you have said, the whole process stopped if
the loop is finished. Than I can´t do anything other with my program.

I
think it must be possible to execute code for one time also in
continuous mode.
0 Kudos
Message 5 of 8
(3,300 Views)
You should post your VI so it can be properly looked at and give a
better idea of the sequence of events that you want to occur. I'm sure
there's a better way than using Run Continuously, I always use an
overall while loop and a stop button to make the functionality
self-contained in the VI.
0 Kudos
Message 6 of 8
(3,300 Views)
If you've got a while loop that stops after one execution, then you've
coded the termination incorrectly. The run continously mode is really
designed for debug purposes and isn't normally used. You will have
much better control of the program and the sequence if you avoid this
as well as using the Abort Exection button on the toolbar.
0 Kudos
Message 7 of 8
(3,300 Views)
cosw wrote in message news:<506500000005000000E15B0100-1075935269000@exchange.ni.com>...
> I cannot understand this. Why its better not using continuously
> running? Its very difficult for me to change the whole program.
>
> I have a while loop which execute code every some milliseconds. The
> loop runs until a binary-switch is true. After a certain time running
> the loop I decide to start a generator. Now I must send one command
> over the rs232. Then my process works. Sometimes later I want to stop
> the generator and send one another command via RS232. The whole time
> the while-loop execute its code every second or so. Last I can stop
> the loop with the binary switch, store data and something else.
> If
I use a while loop as you have said, the whole process stopped if
> the loop is finished. Than I can t do anything other with my program.
>
> I think it must be possible to execute code for one time also in
> continuous mode.

Although most anything is possible to do, perhaps a simple approach is
to place your existing code except the portion you only want to
execute once inside another While loop. Then you will not need the run
continuous button. There are perhaps better ways but this should
require less programming changes for you.

Good luck
0 Kudos
Message 8 of 8
(3,300 Views)