vhha1972 Posted August 17, 2012 Report Share Posted August 17, 2012 Hi there, I am trying to implement a blood pressure (BP) monitor in Labview using NI 9239 and NI 9263. At this time, all I want is that the motor (pump) runs until a user-specified pressure is reached in the cuff. When that pressure is reached, the motor should stop but not the Labview program. As the cuff is deflating slowly through a pressure leakage valve, I want to record the pulses during cuff deflation. I used a switch statement. Gave it input from a comparator which compares the real-time pressure with user-set pressure. I put the DAQ Assistant inside this switch. I said to NI 9263, keep supplying my motor relay with rated voltage until the pressure is lower than the user-specified pressure. When this pressure exceed the user-specified pressure, I set the DAQ Assistant voltage to relay as zero, since I want the motor to stop. The above is OK. But when the cuff starts to deflate, again, the pressure becomes lower than the reference (user-defined) pressure. As a result the switch statement switches again and sends voltage to relay to run the motor again. I want something which can start off my supplying the relay with rated voltage to run the motor. As soon as real-time pressure exceeds user-defined pressure for the 1st time, I want the relay voltage to be set to zero, being unaffected by the fact that during cuff deflation, the real-time pressure will fall again below the reference pressure. I don't want the motor to run after it has pumped to a desired pressure, the first time. Thanks a lot! Saif Quote Link to comment
ShaunR Posted August 17, 2012 Report Share Posted August 17, 2012 There are several ways. For example, you can use this VI to detect the "direction" of your boolean change. 1 Quote Link to comment
Mark Smith Posted August 17, 2012 Report Share Posted August 17, 2012 Never Mind - Quote Link to comment
asbo Posted August 17, 2012 Report Share Posted August 17, 2012 You should consider refactoring your code into a state machine. Another simple way to handle it instead would be to add a boolean shift register to the loop and set it based on your motor's state (hmm...). Quote Link to comment
vhha1972 Posted August 17, 2012 Author Report Share Posted August 17, 2012 Hi Shaun and Asbo, Thank you for your replies! I tried what Shaun suggested. Please see pictures. The Boolean cross-over is detected and the motor stops momentarily. But then turns back on. Sorry but I am still a bit new to Labview. How do I utilize that cross-over trigger to keep it off for the rest of the recording? Thanks again! Saif Quote Link to comment
hooovahh Posted August 17, 2012 Report Share Posted August 17, 2012 There are several ways. For example, you can use this VI to detect the "direction" of your boolean change. Thank you I didn't know this VI existed I've always been using the OpenG Boolean Trigger VI, which seems to have a better name, and icon, for the function it performs, but I would rather use a NI VI than an OpenG VI if their functions are the same. Quote Link to comment
ShaunR Posted August 17, 2012 Report Share Posted August 17, 2012 Hi Shaun and Asbo, Thank you for your replies! I tried what Shaun suggested. Please see pictures. The Boolean cross-over is detected and the motor stops momentarily. But then turns back on. Sorry but I am still a bit new to Labview. How do I utilize that cross-over trigger to keep it off for the rest of the recording? Thanks again! Saif The output will be "TRUE" if the direction is detected. It looks like your case structure is set to "False" to turn off. Try swapping the cases around. It is usually better to post your VI or an example of what you are trying to achieve rather than an image. For simple VIs you sometimes get back the VI with the changes. Thank you I didn't know this VI existed I've always been using the OpenG Boolean Trigger VI, which seems to have a better name, and icon, for the function it performs, but I would rather use a NI VI than an OpenG VI if their functions are the same. There is a lot of replication in the openG VIs, presumably for completeness. Not using the openG stuff forces me to look in some of the more obscure palettes. Quote Link to comment
vhha1972 Posted August 17, 2012 Author Report Share Posted August 17, 2012 Hi Shaun, Thank you so much for your response! I think I tried what you suggested. But it seems to only work with what I have. Do you mean change the initialization pin to TRUE? When I do that, nothing happens. I am attaching the VI now. I would be very grateful If you could please advise what I might be doing wrong! Cheers, Saif Ex_7a.vi Quote Link to comment
vhha1972 Posted August 17, 2012 Author Report Share Posted August 17, 2012 I noticed that the output from the boolean direction VI is true only momentarily. So, when it does detect a change, it turns TRUE for a second then turns back to FALSE. Quote Link to comment
asbo Posted August 17, 2012 Report Share Posted August 17, 2012 Create a shift register on your loop, OR its value with the output from the boolean direction VI, and store the result back into the shift register. That value represents whether to turn the motor off. Quote Link to comment
ShaunR Posted August 18, 2012 Report Share Posted August 18, 2012 Give this a go. not sure I got the "sense/direction" you are trying to achieve right (and had to reorganise a bit to make be able to read it). but the "latching" is there. 1 Quote Link to comment
vhha1972 Posted August 18, 2012 Author Report Share Posted August 18, 2012 Hi Shaun and Asbo, Thanks so much for your responses. Shaun, the VI you uploaded works just fine! I used help commands to understand it. The feedback loop combined with AND and OR gate to achieve "latching" is a great idea! Also, the use of selector function for sending command to the motor is simple and straightforward. Can I please ask another question? Suppose a USER hits the stop button during cuff inflation (motor ON). At that point I would like the motor to stop. The program does EXIT, which is fine. But if the motor could also stop, that would be great! Hope this is possible Thanks again for all your help! Saif Quote Link to comment
ShaunR Posted August 18, 2012 Report Share Posted August 18, 2012 Suppose a USER hits the stop button during cuff inflation (motor ON). At that point I would like the motor to stop. The program does EXIT, which is fine. But if the motor could also stop, that would be great! Just put another motor stop (set the motor value to zero) outside the while loop so that it gets executed after the while loop stops. I'll leave you to figure out how to sequence it to make sure it happens after the loop stops rather than while the loop is running (hint, don't use sequence frames, ever!) Quote Link to comment
vhha1972 Posted August 19, 2012 Author Report Share Posted August 19, 2012 Hi Shaun, Thank you so much for all your guidance! What I did was that I wired the STOP button to the motor voltage module (inside a SWITCH statement) that I kept outside the WHILE loop. So, when STOP is true, I send zero voltage to the motor. This EXITS the program as well as STOPS the motor. Please see attached VI. I have two questions: 1. Is this a smart way of doing it? 2. This does not work if the user hits the ABORT button instead of STOP button! So, I went into File --> VI Properties and made the ABORT button invisible when the VI runs. In this situation, the user can only see my STOP button and is forced to use that to exit. Is is this OK? Thanks again! Saif Ex_7b.vi Quote Link to comment
ShaunR Posted August 19, 2012 Report Share Posted August 19, 2012 (edited) What I did was that I wired the STOP button to the motor voltage module (inside a SWITCH statement) that I kept outside the WHILE loop. So, when STOP is true, I send zero voltage to the motor. This EXITS the program as well as STOPS the motor. If it works. It's good. 1. Is this a smart way of doing it? There are many ways of doing things and whilst there are "accepted" solutions to common problems; "Smart" is subjective. Your only objective was to "sequence" the drive shutdown since LabVIEW is inherently parallel, and there are a lot of ways you could have achieved that. For example. In addition to your solution, you could also have wired the error terminals on the express VIs to outside the loop (a very common way of sequencing VIs). or for that matter, the 0. You could also have OR'd the STOP boolean to the selector. Worry about "smart" when you know where all the things are in the palettes, you've got a few utilities in your toolbox, written a few programs and been on some courses. This program is the "first pass" (your prototype, if you like). I can guarantee you will be revisiting it making it "smarter", prettier or more flexible. 2. This does not work if the user hits the ABORT button instead of STOP button! So, I went into File --> VI Properties and made the ABORT button invisible when the VI runs. In this situation, the user can only see my STOP button and is forced to use that to exit. Is is this OK? The stop button in the IDE is for the developer only. In deployed applications, users should not have access to it since it circumvents shutdown procedures by stopping the code dead. Never give the user any opportunity to do something you are not expecting otherwise he/she will! Edited August 19, 2012 by ShaunR 1 Quote Link to comment
vhha1972 Posted August 19, 2012 Author Report Share Posted August 19, 2012 Thanks a lot Shaun -- I really appreciate all your inputs! Will keep learning Quote Link to comment
Rolf Kalbermatter Posted August 21, 2012 Report Share Posted August 21, 2012 2. This does not work if the user hits the ABORT button instead of STOP button! So, I went into File --> VI Properties and made the ABORT button invisible when the VI runs. In this situation, the user can only see my STOP button and is forced to use that to exit. Is is this OK? Consider the abort button as a synonym to using a concrete wall to stop your car with. It works but can have undesirable effects! 1 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.