06-27-2011 03:53 PM
Hi,
Im writing a VI to measure Current and Voltage accross a device.
To do that, I increment the voltage, and for each increment, I measure Voltage then Current.
I'm sending the SCPI commands to the Power Supply and Multimeter over GPIB.
My question is: looking at my code, it seems that there is no data dependency between "write to Power supply" (top left corner)
and "write to multimeter", so which one executes first?
The program works correctly, but I want to make sure it is not out of sheer luck.
I'm a beginner and I would most appreciate your help and comments.
Thank you,
Nicolas
Solved! Go to Solution.
06-28-2011 12:34 AM
Hi htnicolas,
Two possible options to control the execution order are:
1) Use the Sequence structure. (I imagine this one is preferred)
2) Pass a parameter from one subVI to another. Not sure if this one is good practice or not, but I have passed errors from one subVI to the next to control the execution order before.
Hope that helps a little.
06-28-2011 11:33 AM
@Miguel_F wrote:
Hi htnicolas,
Two possible options to control the execution order are:
1) Use the Sequence structure. (I imagine this one is preferred)
2) Pass a parameter from one subVI to another. Not sure if this one is good practice or not, but I have passed errors from one subVI to the next to control the execution order before.
Hope that helps a little.
Actually the sequence structure is the least prefered method for enforcing operation. Data dependancy is the prefered method (using the error chain)
LabVIEW is a dataflow language- for you new guys this means a block of code can execute as soon as all its inputs are available It does not matter what block that is a sub.vi, a case structure, a loop anything with a boundrary that you can wire an input to. Without data dependancy there is no easy means to determine what happens in what order and LabVIEW will even go so far as to execute as many of them AT THE SAME TIME as you have cores available. (Multithreading is easy in LabVIEW)
It used to be that the code would execute from the back to the front but a lot of things changed with the new compiler and optomizer so this is no longer true if code is changed during compile.
06-28-2011 11:48 AM
Hi Nicolas,
To control data flow in a program, we recommend error wires. Error wires are the wires that go into and out of functions (error in, error out). This connects otherwise disconnected functions and the functions execute from left to right along the wire. Error wires also serve the purpose of displaying an error if something does not function as expected, which is very useful in troubleshooting. To display the error, use a general or simple error handler.vi, found on your functions palette.
Though sequence structures are an easy fix to control data flow, they serve no other purpose and can lead to bulky code and in some cases, overhead in your program. When you use error wires, it supports sleeker and smarter programming.
Regards,
Jackie
06-28-2011
12:23 PM
- last edited on
11-11-2024
10:29 AM
by
Content Cleaner
I think you got lucky in the order of execution. I agree that you should use the error wires to enforce the data flow.
Even for this simple application I would suggest a State Machine. In my experiance someone will come along and say "Can you add this.." or "The UUT needs more time to settle.." and "We need to add this instrument/Measurement". A state machine is more flexible in these situations.
Also I see you are using SCIPI commands. Have you checked to see if there are instrument drivers already available for your instruments?
06-28-2011 12:55 PM
Thank you all for your replies.
I will reconsider my block diagram and try to incorporate all your suggestions.
I used the sequence structures because I need to give the instruments some time to execute the commands I send.
GovBob, I am now reading about State Machines. Could you elaborate on the drivers you mentioned?
I did download the drivers for my instruments and installed them. How does that exempt me from sending SCPI commands?
How would I communicate with the instruments otherwise?
As you can tell I'm very new to all of this.
Thank you very much for your help,
Nicolas
06-28-2011
01:36 PM
- last edited on
11-11-2024
10:30 AM
by
Content Cleaner
Nicolas,
If you downloaded GPIB drivers for your instruments they usually come with examples. Here is a explanation, here is a tutorial and here is a video about instrument drivers.
If you need more help as you go along please let us know what instruments you are using and what version of LabVIEW you are using. And including the code you have worked on also helps.
06-28-2011 05:44 PM
I used data dependency and got rid of all my flat sequences.
Thank you very much!
Sincerely,
Nicolas