From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI sends out the command to the physical instrument twice instead of once

Solved!
Go to solution

Hello!

With the help of user Dennis Knudson and NI support engineer Denis Stavila (both of whom I thank very much )

I managed to communicate with this HighVoltage source (vi.jpg).

The problem is that the VI sends duplicate commands(please see attached image"dublu.jpg"): 

44 0D at 10:57:28 
answer  56 41  at 10:57:28
then resends the identical command,within a second of the first, without anything being pressed by me
44 0D at 10:57:29

The duplication of the command is true for any function: set voltage,set step voltage,quit, everyone is sent/answered to/sent/answered to.

I am a beginner so it may be a simple setting of the event case or the controls that I overlooked.

When I use the manufacturer's visual basic control software it sends the commands once;

when I use a simple VI made by me (simpl.jpg) ,again, it sends the commands once which is ok.

 

Why does the VI send the same command twice?

 

 

Download All
0 Kudos
Message 1 of 11
(2,767 Views)

It is a bit hard to debug without you posting your actual VI. Please post them.

 

Your architecture seems a bit off:

 

Instead of having "set vmax" inside of the event stucture (it looks like initialization code) either have it outside and to the left of the while loop or use the simple state machine that labview ships with and have an initialization case that only will run once to get connected to the instrument.

 

Also have the button changes set up in the event structure with corresponding code inside of the event structure. For example, do a value change on "vou"t inside of the event structure.

 

Do you have way to stop communication when you go to exit your program? If not, have this to the right of the program outside of the while loop and use an error wire to enforce dataflow or use a simple state machine with an exit case.

 

 

 

0 Kudos
Message 2 of 11
(2,755 Views)

SetMax and SetStep do two things: 

1-they command the max value of the Vout knob and its scale increment

2-when the buttons SetMaxV and setStep are pressed, they send the command to visa write buffer through the converters from number to string.

I don't know how I could insert them into a case and still have them controlling the Vout knob

 

But here is the VI

 

PS: taking the triggers outside the while loop did not work either.

0 Kudos
Message 3 of 11
(2,724 Views)
The design of the event structure is not what I said you should do. Post the VI as suggested and please take some of the basic tutorials.
0 Kudos
Message 4 of 11
(2,723 Views)

I think you get your values twice because you enter when the event is TRUE and once when the event is FALSE...

 

+ you should check your Visa Read for the amount of chars available before reading 2.

0 Kudos
Message 5 of 11
(2,713 Views)

You are opening and closing the visa everytime you write a command. Just open and close it once before and after the while loop.

 

Use shift registers to pass data between loop iterations.

 

Delete the timeout case if you aren't going to use it.

 

The top 100 ms timer seems unnecessary.

 

Clean your wires so they go left to write and no big bends.

 

I have attached a VI with some code that will hopefully put you on the right track.

 

Do some labview training as some of these are basic concepts and are need to make proficient code.

0 Kudos
Message 6 of 11
(2,698 Views)
Solution
Accepted by topic author TibiG

Make sure that boolean is not switch until released.  (Latch when released would be perfered)  If it is switch until released of course there are two events fired.

 

And "Bingo"

Capture.PNG


"Should be" isn't "Is" -Jay
Message 7 of 11
(2,687 Views)

Thank you !

tomorrow morning,at work,where I have Labview, I will do everything you advised me to.

But first I have to understand it: shift registers

I will reply as soon as I get the results.

 

Thank all of you again!

0 Kudos
Message 8 of 11
(2,657 Views)

Bingo indeed !

 

""Latch when pressed"" was the answer.

 

Thank you,  !

 

I would also like to thank everyone else for their advice: it will help me become a better labview user.

 

 

0 Kudos
Message 9 of 11
(2,614 Views)

Another question:

at start up, even if the previous time I had selected volume knob Scale to start from 0,

it starts from -1 .Why?

-how can I make labview remember my settings, I mean change the default values that it now has -1 for min scale to 0,

set Step to 100 instead of 0, Vmax to 1000 instead of zero?

 

But the most important question: when I press RUN, is there a way (there has to be a way)...

what is the way to do this:

press RUN => labview sends a READ command to the physical object to receive info. Vout setting, Vstep setting, Vmax setting

receives this information and updates the labview values fot Vout,Vstep and Vmax?

 

Let's say the values set on the voltage source are Vout=0V, Vmax=1000V, Vstep=100v .

When I hit RUN in labview, it sends a read Vout,readVmax,readVstep

and updates the labview controls : sets the Vout knob to 0, Vmax to 1000, Vstep to 100.

How would I do that?

1-link a read command to the RUN button? 

 

2-make a loop that updates the values of Vmax,Vstep (so use another property node for Vmax,Vstep that is controlled by visa read)

 

How do I do 1?

0 Kudos
Message 10 of 11
(2,601 Views)