02-28-2013 02:06 PM
This is driving me crazy. Basically I am building a liquid level control using a scale and a device that puts a liquid on the scale. I have a subVI that is reading the mass value from a scale and when it drops below a value (mass to boil down to) I want it to add liquid and when it goes above a value (fill level) I want it to stop adding liquid until the mass drops below value (mass to boil down to) again. I am using a while loop to check for both the fill level and the boil down to level, and in each while loop there is a comparison with a local variable. For some reason it is does not recognize when the mass is above the fill level, unless I hit the highlight execution button. I do not know if it has to do with the way my while loops are set up or with the local variable or sampling rate, i am at a loss. Thanks
02-28-2013 02:19 PM
You really should put some kind of wait in your polling loops. They are basically using up all of the CPU and not letting other things run. You could just be swamping out your update loop.
02-28-2013 03:55 PM
@lvuser333 wrote:
This is driving me crazy. Basically I am building a liquid level control using a scale and a device that puts a liquid on the scale. I have a subVI that is reading the mass value from a scale and when it drops below a value (mass to boil down to) I want it to add liquid and when it goes above a value (fill level) I want it to stop adding liquid until the mass drops below value (mass to boil down to) again. I am using a while loop to check for both the fill level and the boil down to level, and in each while loop there is a comparison with a local variable. For some reason it is does not recognize when the mass is above the fill level, unless I hit the highlight execution button. I do not know if it has to do with the way my while loops are set up or with the local variable or sampling rate, i am at a loss. Thanks
If it works in lightbulb mode, then it's a pretty good guess that you have some sort of race condition, since it forces things to execute squentially. From what I can see, that could definitely be the case. I'd probably rewrite this code with data flow in mind (plus some subVis to get the BD down to a reasonable size). Just doing that could solve your issue.
02-28-2013 08:18 PM - edited 02-28-2013 08:18 PM
I would also trdesign your code to use a state machine. It will be easier to maintain in the long run. I agree that you should learn more about how data flow works. I am sure you could eliminate the sequence frames (the one that is fully visible is not needed at all, at least not as a two frame structure). You also seem to rely quite a bit on local variables. As mentioned this can easily lead to race conditions.