01-09-2008 12:57 PM - edited 01-09-2008 12:58 PM
Sorry to bump an old thread, but I think I accidentally figured out my problem. I had unknowingly generated a race condition in my sensor polling, which lead to an inefficient but oft-called sensor read algorithm during my event timeout. I had the timeout set at 10ms in order to update all my sensors several times a second, and upon developing a more efficient data gathering system, I have a 100ms timeout. Now it works without a hitch, so maybe the 10ms timeout made the system spend too much time polling and not enough time operating controls or something.
Interesting, at least.
01-09-2008 03:11 PM
And, another new problem. After automating it, I'm having trouble getting proper displays again. The valve display toggles back to its default state when it shouldn't, which makes me think the indicator is getting reinitialized. If it is, I can't figure out where. Also, my data poll has been moved outside the main while loop because it would freeze while in some of the subvis.
Finally, if anybody wants to look at my code and has comments about style or good practices, I would be more than thankful to hear them. It's looking like this contract job might turn into something more permanent.
01-09-2008 03:48 PM - edited 01-09-2008 03:54 PM
01-09-2008 03:57 PM - edited 01-09-2008 04:00 PM
JeffOverton wrote:
Finally, if anybody wants to look at my code and has comments about style or good practices, I would be more than thankful to hear them. It's looking like this contract job might turn into something more permanent.
01-09-2008 04:04 PM
01-10-2008 07:52 AM - edited 01-10-2008 07:54 AM
First, thanks for all the help. I really appreciate it. Second, I apologize for not providing the rest of the code, but what you see is all I'm allowed to post by my company's IS policy. Anyway, to the issues:
Ravens Fan
Regarding Write Valve, I've passed the actual fixture display indicator into the connector on the subvi, so I'm a little confused about how it is actually getting reset. It's passed in, a cluster value is updated, and the result is passed to the next stage, so I would think the values should stay. Also, the VI reference to update is a carryover from desperate attempts to fix the indicators by switching it to a control or using value set or using value signal or etc etc.
Also, I'm not sure what you mean by "Action Engine" and from what I've seen on the forums here, globals are usually recommended against. Would this be a proper situation for a global?
Boolean 2, which has an unwired event, is there to shut down the automation from another VI. For instance, if the automation VI hangs up and the 30,000 psi source valve is open, you want to regain control, which is also the reason I'm using a stop (yes, I'm kind of ashamed ) to prevent any further opens or closes from occuring after a fault.
And finally, a for loop is a really good idea.
Altenbach
Again, the for loop is a good idea. I'm actually a little disappointed in myself for creating an event to end a while loop after a predetermined number of iterations.
I'm not sure if a shift register would work in the data read loop, because I want the local to reinitialize every cycle. I was worried that if I called the local outside the loop and wired it in, it would constantly be writing the initial valve states at the same time as it updates the pressure displays, causing exactly the problem I'm having.
Also, I'm not sure what you mean when you say the replacement of cluster values could be done in one step.
Again, I've only been using LV for about three weeks, so if something seems completely backwards, it's probably not me misspeaking, it's probably me being wrong.
01-10-2008 08:29 AM
Action Engine is another term for a functional global variable. Ben wrote a community nugget about its uses here. They are also know as Labview 2 style globals. These aren't really the same thing as "globals", which are usually frowned upon. I have actually never used a global variable, but have written quite a few functional global variables (i.e. action engines.)
A FGV is a sub-VI that has a while loop with a True wired to the stop terminal so that it only runs once. It uses uninitialized shift registers on the while loop to store information from one iteration to the next. It has a case structure that has cases such as Get and Set. You can use the Set case to assign values input to the subVI to shift registers. You use the Get case to return the values from the shift register. You can really expand the functionality by added other operations in other cases, in which case it really takes on more of the meaning of Ben's term "Action Engine". The sub-VI is set to be non reentrant which means there is only one instance of it. And since it can only be executed from one location at a time, you helps eliminate problems with race conditions where one location is trying to write to the stored values while another is trying to read from them.
It is a very good architecture to learn and is very popular.
01-10-2008 09:08 AM
01-10-2008 10:05 AM
01-10-2008 10:59 AM - edited 01-10-2008 11:00 AM
JeffOverton wrote:
I'm not sure if a shift register would work in the data read loop, because I want the local to reinitialize every cycle. I was worried that if I called the local outside the loop and wired it in, it would constantly be writing the initial valve states at the same time as it updates the pressure displays, causing exactly the problem I'm having.
JeffOverton wrote:
Also, I'm not sure what you mean when you say the replacement of cluster values could be done in one step.
This is a good time to go into things a bit deeper and learn why some ways of doing things are better that others. If you don't, bad ideas become bad habits that are harder to get rid of later. It seems you are learning fast. Good luck! 😄
JeffOverton wrote:
Again, I've only been using LV for about three weeks, so if something seems completely backwards, it's probably not me misspeaking, it's probably me being wrong.