08-09-2012 04:44 AM
I have made a vi in which i am using property nodes of various controls to avoid long wiring, although i can wire through direct controls also but to make block diagram cleaner i am using there value propety nodes, i want to know that if we use more property nodes in our program than does it affect the program peformance or if there is any cons of using more propertu nodes in the vi. i am attaching the image of the block diagram, kindly suggest me the solution.
08-09-2012 04:54 AM
Passing values with property nodes like isn't particuarly good practice, and I believe it can lead to race conditions. (The same reason that you should avoid local variables)
I would always try to pass values with wires. Maybe bundle into a cluster if you want to keep things tidy.
Another point, your error handling looks a little hap-hazard. Error wires are useful for enforcing execution order, might be worth looking into that.
Also, the general program structure looks like it could do with some work. Try looking up state machines or (my personal preference) the producer consumer architecture.
(shift registers are your friend)
Hope that helps 🙂
08-09-2012 05:08 AM
Thankyou for quick response, i would try to implement state machine, and yes i know this that error handling in this vi is very bad, but i was not able to figure out the solution for making it better, it would be great help if you could suggest me some solution abt handling errors effectively and i also want to know that is it necessary to wire every error in and error out.I am attaching my vi.
08-09-2012 05:08 AM
Hi Ritu,
In order of "efficiency" in LabVIEW, it roughly goes: 1. Wire it 2. locals 3. Property nodes.In your case you are using lot of property nodes.Though you can use controls, control references, and Property Nodes to pass data between VIs, they were not designed for use as variables because they work through the user interface. Use local variables and the Value property only when performing user interface actions or when stopping parallel loops.
When using a property node, the code will stall when it gets to the property node read while it waits for the OS to do the thread swap to the UI thread to read the value and then it will drop out of the UI thread and finish that cycle of your loop.So Iam agreeying with phil that 'Passing values with property nodes like isn't particuarly good practice'.
08-09-2012 07:36 AM
My tips would be:
- Use the VI templates that come with Labview to get an idea about structures. Google is also your friend here. Or maybe buy a book. ('Labview for Everyone' and 'The Labview Style book' are good)
- Use your error wires to enforce the order that things execute (Dont leave them floating, connect the error wire to the next operation in the sequence). It is then easy to follow the flow of the program by following the error wire. Pass errors/variables/etc from one loop itteration to the next with a shift register.
You should only have one error control at the start and one error indicator at the end.
08-09-2012 07:53 AM
i will try to improve error handling as per your suggestion, and would also try to implement state machine although i am not getting how would i do this bcs i am not very expert in implementing any design pattern, but i will try and thankyou for your time, my doubts are clear and atleast now i know that there are lot of bugs in my program to solve.
08-09-2012 08:07 AM
Just to add to what has already been said. Property nodes are terribly slow. I once did a benchmark where I simply wrote to an indicator. I tested this using the terminal, local variable, and a property node. The local variable was about twice as slow as the terminal. The property node was thousands of times slower. I don't have the results with me right now, but it was quite obvious that property nodes are not the way to go.
Just as background, I did that because NI had this major "local variables are evil" campaign and so people started using the property nodes. The property nodes had the same issues as the locals (race conditions) plus are slower. I had to perform a crusade against property nodes in my company. I managed to fix most of the issues by implementing forms of state machines and/or using queues.
If you can, wires are by far the most efficient way to go. Also stated, shift registers are your friend. I haven't looked into your code, but I'm guessing a state machine is what you really want.
08-09-2012 09:20 AM - edited 08-09-2012 09:30 AM
here are the perfomance timings....that being said, I recommend "The LabVIEW Style Book" by Blume for your diverse architectures and performance matters(ie costant polling inherent in "State Machines" and others).