ntward Posted July 8, 2007 Report Share Posted July 8, 2007 Hi all, I'm new here, and new to LabVIEW. I've done a lot of reading recently, but I'm a bit stuck. Apologies if this has been asked before, I've tried searching but I'm not certain what I'm looking for! I need to make a control which is also an indicator (in the sense that it reflects it's output state as well as an input). I know I can customise standard controls, but I can't figure out how to do this. Any tips, pointers, suggested help topics etc. greatly appreciated. To explain more clearly: My control needs two states; on and off. When on, the control will open a valve (I've got all that sorted). A micro-switch measures the position of the valve. If the valve has failed to open (i.e. control output and input differ) then I want to indicate this by altering the background colour of the control. Thanks for any help... Quote Link to comment
gb119 Posted July 8, 2007 Report Share Posted July 8, 2007 QUOTE(ntward @ Jul 7 2007, 10:17 AM) I need to make a control which is also an indicator (in the sense that it reflects it's output state as well as an input). I know I can customise standard controls, but I can't figure out how to do this. Any tips, pointers, suggested help topics etc. greatly appreciated.To explain more clearly: My control needs two states; on and off. When on, the control will open a valve (I've got all that sorted). A micro-switch measures the position of the valve. If the valve has failed to open (i.e. control output and input differ) then I want to indicate this by altering the background colour of the control. You probably want to look at property nodes for this - they're a way of programmatically changing the appearance of a control. Right click (or platform specific equivalent) on the cotrol (I'm assuming you're using a boolean here !) and select Create->Property Node and pick the property of the control you want to change. I'd suggest you look at colors (to change the colouring of the control) and probably disabled (to stop the user from trying to change the control if there is a malfunction). Other (more complicated) solutions would involve having a transparent control overlaying an indicator - the user operates the transparent control and you report report what is happening with the indicator - e.g. make the indicator a color box and use different colours to report valve open/closed/stuck open/stuck closed. Quote Link to comment
ntward Posted July 8, 2007 Author Report Share Posted July 8, 2007 QUOTE(Gavin Burnell @ Jul 7 2007, 11:05 AM) Other (more complicated) solutions would involve having a transparent control overlaying an indicator - the user operates the transparent control and you report report what is happening with the indicator - e.g. make the indicator a color box and use different colours to report valve open/closed/stuck open/stuck closed. Hello, Thanks for the advice, property nodes look good - it would have taken me ages to find that! However, having spent more time thinking about it I have thought of a more intuitive representation which would use four different images to represent the four possible states. So, I guess I need to overlay a control and indicator. Setting each part of a button to transparent is easy enough, but this doesn't seem very elegant - I assume the control still needs all the memory for the images even though they are not drawn? Is there a way to remove all of these images? Thanks again for the advice... Quote Link to comment
Yair Posted July 8, 2007 Report Share Posted July 8, 2007 If you want to have completely different images, I suggest you use a picture ring, make it an indicator and detect clicks on it using an event structure and the mouse down event. If you don't, I would suggest following the proposed solutions of using a color box under a boolean or changing the color of the boolean. The images of a boolean control take up memory, but it is usually so little there is no point in removing them. In any case, you can't actually remove them, but you can replace them with simpler (and therefore smaller) images by customizing the control. I suggest you search for some LV tutorials or books, as some of them are sure to cover these areas. Quote Link to comment
Aristos Queue Posted July 10, 2007 Report Share Posted July 10, 2007 QUOTE(ntward @ Jul 7 2007, 04:17 AM) Hi all,I'm new here, and new to LabVIEW. I've done a lot of reading recently, but I'm a bit stuck. Apologies if this has been asked before, I've tried searching but I'm not certain what I'm looking for! I need to make a control which is also an indicator (in the sense that it reflects it's output state as well as an input). I know I can customise standard controls, but I can't figure out how to do this. Any tips, pointers, suggested help topics etc. greatly appreciated. To explain more clearly: My control needs two states; on and off. When on, the control will open a valve (I've got all that sorted). A micro-switch measures the position of the valve. If the valve has failed to open (i.e. control output and input differ) then I want to indicate this by altering the background colour of the control. Thanks for any help... There isn't any "control and indicator" concept in LV. Data enters a VI at controls, and leaves a VI at an indicator. In your case, input says either "open" or "close", the VI executes to do the operation, returns the current state of the valve and then the current state is compared against the original input, and the results of that comparison are displayed in an indicator. This would be fine for calculating the value, but what you're describing is that you need the composite behavior not because of any calculation of value work but instead to provide a nice user interface. <joke>There goes UI, messing with the purity of dataflow again.</joke> There are two possible solutions. The first is to physically stack the input control on top of the output indicator on the front panel. You might put the boolean indicator as a background behind the control. For some user interfaces, this works fine. To some degree, it is my preference, since if the control itself changes color/state to indicate an error, the user may think he/she can no longer use that control. But there are user interfaces where this is desirable, so the second option would be using a property node to set display properties of the control programmatically. You can right click on any control on the front panel and select Create>>Property. Drop the resulting property node on the block diagram and choose the property that you'd like to set. Quote Link to comment
ntward Posted July 21, 2007 Author Report Share Posted July 21, 2007 Hi all. Thanks for the advice. I made (what I think is) a nice looking control that does the trick. Now, can I use it as a sub vi? Obviously I need to be able to display its front panel on the main front panel, is this possible? I can't figure it out... It would be quite elegant and simplify my block diagram if I can do this, since I have dozens of valves... Thanks again for any pointers Quote Link to comment
Neville D Posted July 21, 2007 Report Share Posted July 21, 2007 QUOTE(ntward @ Jul 20 2007, 08:41 AM) Hi all.Thanks for the advice. I made (what I think is) a nice looking control that does the trick. Now, can I use it as a sub vi? Obviously I need to be able to display its front panel on the main front panel, is this possible? I can't figure it out... It would be quite elegant and simplify my block diagram if I can do this, since I have dozens of valves... Thanks again for any pointers You can load the front panel of a subVI into the main VI using a subpanel. Check LV help on "loading a front panel in a subpanel". Note the subVI then has to be called by reference, and you can't plonk the subVI onto the block diagram of the top-level VI. I am sure your next question is going to be "whats call by reference"? I suggest you take the time to read through some basic LabVIEW tutorials or a good starter book like Jim Kring's excellent text or Gary Johnson's wonderful reference. Also, there is an example showing loading of subpanels in LV. This will go a long way in getting you up and running quickly. Neville. Quote Link to comment
ntward Posted July 21, 2007 Author Report Share Posted July 21, 2007 Neville, That is most helpful. One other question would be: is this actually the most elegant way of doing things then? Or is it simpler to just lump everything in one vi? Thank you Quote Link to comment
Neville D Posted July 21, 2007 Report Share Posted July 21, 2007 QUOTE(ntward @ Jul 20 2007, 09:13 AM) Neville,That is most helpful. One other question would be: is this actually the most elegant way of doing things then? Or is it simpler to just lump everything in one vi? Thank you Certainly, it is quite elegant. You could put different valves (or subVI's) on different tab sheets of your top-level VI. The only issue is that the code might be hard to understand or debug, for a new LV-er with VI's called by reference, etc. I would go with a toggle switch for every valve, and a status indicator (enum). Toggle valve--->show status Open Success, Close Success, Open Failed! Close Failed! This would be in a subVI in a main loop or event Structure. User hits a valve toggle, that generates an event to do the action, and the enum shows the status of that action. You can color the enum differently for a fail (use a property node and color background to red or yellow for a fail etc). I would also look at the different types of code architecture producer-consumer, event driven state machine etc in the examples to get some ideas. N. Neville. Quote Link to comment
Yair Posted July 22, 2007 Report Share Posted July 22, 2007 The code would probably be more understandable if you encapsulate the control of the subpanel into subVIs and use arrays to define the properties of your valves. Another option is to use a picture control to do this. You can use the code to decide exactly where each valve should appear and calculate when the user clicks on it, but this method is more complex and has its drawbacks. 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.