06-14-2010 02:50 PM
Hi!
I have attached the current VI I am working on and I am having a little trouble working out the logic for my particular interest.
The basic application of this VI is to time an interval registered by a start switch and then ended by a separate stop switch. The difference is then found between those two times.
On the stop switches (which is the lower half of the block diagram) I am trying to register the stop time. Right now, the time registers when the switch closes and remains closed until the program stops. Currently, inorder to register the time, the switch must remain closed throughout the entire program.
I would like the stop time to register if the switch remains closed OR if the switch is closed and then opens again (due to the weight bouncing off/rolling off) I would like it to work in either situation of the weight keeping the switch closed OR the weight initially closing the switch and then rolling off.
In either case, I would like the first moment the switch closes to be the time used in the time interval calculation. I think it should be a pretty easy fix...I apologize if it's really basic...
Thanks so much!
06-14-2010 03:00 PM
Blizabeth,
I would consider adding a shift register to the inner For Loops that carries an array of booleans initialized to false. Then, set the element of the array to true the first time the switch closes. You can use this with an AND to make sure that the event only registers one time.
Cheers, Matt
06-14-2010 03:02 PM
Could I see this on the block diagram? I'm a visual learner and sometimes get mumbled up in the logic of the sentences.
thanks so much!
06-14-2010 03:05 PM
06-14-2010 03:12 PM
06-14-2010 03:13 PM
So I was able to try your suggestion and have attached my attempt...I'm still confused how to connect the shift register of the inner for loop?
I really appreciate your help!
06-14-2010 04:17 PM
Blizabeth,
I realize you are a visual learner, but you should probably think about this a little bit (the problem is fairly straightforward and a good learning exercise). Looking at the VI I realized I led you a little off-track.
06-14-2010 04:33 PM
Matt will probably get pissed off at me, but I think this is a bit above the beginners level, so I added some code to record the time the stop switch reopens after it has been closed.
I changed your lower shift register because the old way made no sense to me. Now that shift register is used to hold a flag which states if the switch has been closed once or never closed. The case structure determines if the switch has been closed and is now open, and if so then it records the reopen time. After the loop, the new For Loop calculates the time from the switch closure to the reopen. But if th switch never reopens, then this loop is meaningless. You can modify it to produce something meaningful, or disregard it completely.
The attached vi is in LV2009.
06-14-2010 05:38 PM
Haha...never, Tbob! I was just trying to motivate a little thought given the fact that we have attempted to guide the user through a similar problem over here.
Matt
06-14-2010 06:04 PM
mtat76 wrote:Haha...never, Tbob! I was just trying to motivate a little thought given the fact that we have attempted to guide the user through a similar problem over here.
Matt
I didn't notice that this was a second post for the same vi. Glad you caught that Matt.
Blizabeth37, you should stick to one post for the same vi, even though your problem may be different.