SimonG Posted February 2, 2021 Report Share Posted February 2, 2021 Hi guys, I am very new to labview and it's graphical way of programming. I am used to programming with code and I love the concepts of object oriented programming. But here in Labview I don't quite get it yet. I just have a function (where the "Read data" note is) that updates the data in the object (It reads from a serial connection). But each time the loop iterates, the previous data is lost. I don't know how to express it, but I would like to do something like the blue line I draw. So the function keeps updating itself. Is there any way to do this? I've searched for a long time now, but I don't even know how to explain this problem. Thanks in advance! Quote Link to comment
Antoine Chalons Posted February 2, 2021 Report Share Posted February 2, 2021 Welcome! What you're looking for is called a shift register : https://www.ni.com/getting-started/labview-basics/shift-registers Quote Link to comment
SimonG Posted February 2, 2021 Author Report Share Posted February 2, 2021 Oh thanks a lot. Maybe I should start learning the basics first haha Quote Link to comment
hooovahh Posted February 2, 2021 Report Share Posted February 2, 2021 So one thing that might help make it click, is that objects aren't reference based by default. So you are initializing an object, adding an axis, and then passing that data into a loop. The data that the loop uses each iteration, does not change it is the same data over and over again. However if inside that data is a reference to something, then that something can change, and the reference doesn't. But that feature is only used if the developer of the class used references in the private data of the object. The class data can be thought of as a cluster (because it is). So imagine if you weren't using an object, and were just using a cluster. Would passing in that same cluster to the loop do anything different? Well if a reference was in that cluster then sure you could write to the reference in the loop, and then the next iteration would have a different value in the reference if you read it. But if in the cluster is just normal data types like string, numeric, boolean, etc. then it doesn't matter if you are updating that cluster in the loop because the same value is passed in each time. What Antoine was suggesting was to use a shift register which passes data from one iteration of a loop, to the next. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.