04-09-2011 11:46 AM
I have previously posted a doubt regarding how to store previous values of the variables in labview but have not recieved any replies.
Hopefully this time I will get some hints or rather solution.
I have three control parameters A, B and C (they denote some percentage values) and their corresponding inidicators. For the first time, the user will give two inputs. So the third one will be automatically calculated from the sum of the two inputs and subtracting it from hundred. From the next time onwards, when the user changes one input, the other two will get modified. I am facing problem in this auto-tuning part. In the attached code I have designed the initialization step in 0th stage of the stack sequence and the auto tuning part in the 1st stage.
Now as the three controls are inter-dependable, I want to take three ratios i.e A/B. B/C and C/A. As the total unit is 100, So, for varying B we will get a modifed A = 100-B-C i.e 100-B(1+C/B). Simililarly for varying A, we will get a modified C= 100-A(1+B/A) and for varying C, we get a modifed B= 100 - C(1+A/C). In the auto-tuning part, I am first adding all the parameters and is equating with 100. The boolean output activates the true or false loop. If the case is true then whatever comes in the control gets displayed in the corresponding indicator. If the case is false, whatever comes in the control is displayed in the indicator along with modifying the value of the other one variable. Here only I am facing the problem. I am not able to connect the input control with the indicator.
It will of great help if you give me some solutions or hints regarding this problem. I am attaching the code, which is not yet complete, to present a rough overview.
Thanks in advance.
Solved! Go to Solution.
04-09-2011 11:59 AM
Do you have a "doubt" meaning you don't believe it can be done, or a question about how to do it?
What you could do is use an event structure to determine which control the user as changed. Then do your calculations and modify the other two variables by way of the local variables.
04-09-2011 12:04 PM
Thanks a lot. Actually I am a beginner and I dont know the function of each of those loops. Can you please show me just one loop in the code that I had attached earlier? And I doubted because in C I could have taken the variables and check for any change in them and would have correspondingly varied the other variables. But I was really clueless whether this thing could be done in labview or not!
But again thanks a lot and pleaseeeeee just show me one loop with the event structure in it.
04-09-2011 12:06 PM
Where are the values coming from? Is there a possibility that more than one changes at the same time, and what should be done in that case?
In any case, your code is way too complicated. All you need is a shift register containg an array of three elements. Also form an array with your three inputs using build array (or use an array control directly).
With every iteration of the loop, compare the two arrays and find which element has changed. Use a single case structure and create cases for all possibilities (non changed, A changed, B, changed, ... all changed).
Put the new values back in the shift register, wait a few milliseconds, then start the loop over.
And please get rid if that stacked sequence! It just clutters the diagram and makes the code hard to debug!
04-09-2011 12:11 PM
@Ravens Fan wrote:
Do you have a "doubt" meaning you don't believe it can be done, or a question about how to do it?.
Ravens, that phrase is quite common here and seems to happen with non-english speakers from a certain background. Maybe in their native language "doubt" and "question" are the same word. Whenever you see "I have a doubt" in the forum, substituting "I have a question" typically works well. 😉
04-09-2011 12:22 PM - edited 04-09-2011 12:24 PM
@altenbach wrote:
@Ravens Fan wrote:
Do you have a "doubt" meaning you don't believe it can be done, or a question about how to do it?.
Ravens, that phrase is quite common here and seems to happen with non-english speakers from a certain background. Maybe in their native language "doubt" and "question" are the same word. Whenever you see "I have a doubt" in the forum, substituting "I have a question" typically works well. 😉
I've always had a sense that people who seem to be from a particular part of the world use the word "doubt" when they mean question. Maybe I'm just hoping they'l learn that they are two completely different words in English that have very different implications in the way they are used.
Here is what I was thinking about the event structure. The code could be tightened up a bit. But this should give you the idea. It assumes that the changes are occurring by the user modifying a front panel control.
04-09-2011 01:17 PM
ya the user is giving a new value in the front panel. actually the problem is with the auto-tuning part. only one value will change at a time and correspondingly the other two values will change. neways, i will try that and will get back to you soon.... but thanks a lot, once again!
04-09-2011 02:22 PM - edited 04-09-2011 02:23 PM
I no longer have LabVIEW 6.1, but here's a simple implementation in LabVIEW 8.2 and a corresponding image.
Note that there is only one event case and that the code is scalable. It can easily be adapted to more than 3 controls by just expanding the array and some minor code changes (e.g. instead of division by 2, divide by "array size - 1").
Maybe you can adapt it to LabVIEW 6.1...
04-09-2011 05:39 PM
@Ravens Fan wrote:
Here is what I was thinking about the event structure. The code could be tightened up a bit. But this should give you the idea. It assumes that the changes are occurring by the user modifying a front panel control.
There is an error in my implementation. Because a control is read before the event structure executes, only old data is going in. I should have used the New Value terminal inside the event case.
04-09-2011 05:56 PM
@Ravens Fan wrote:
There is an error in my implementation.
The main problem is that the control cannot be operated at all, because whenever you try, it snaps back to the balance based on the other controls.
The way I understood the problem, we should be able to operate any of the controls freely and the other controls would adapt to keep the sum at 100.