Jump to content

Using a new sub vi


Recommended Posts

Hi, I am very new to Labview and my first assignment is to maintain an existing Labview 7.1 application. This application is quite large, poorly built, and violates every single style rule presented in The Labview Style Guide. In any event I am trying to fix a bug regarding interval timing of calibrations and have concluded that there is no way to make the existing code work. I have found the Bloomy Controls and the interval vi has exactly the functionality I need. However I have a few questions.

When I open the vi I get this error: "Interval uses data range coercion, which now only applies to data entry; values will not be coerced when passed to subVIs. To coerce passed values, use the In Range and Coerce function." Is this something I need to fix before proceeding? If so, how do I fix this?

Next I am unsure how to integrate this vi into the existing application. Currently this functionality is attempted by a wildly desperate parts spread over a block diagram which is approximately 1 Meter x 2.5 meters in size. It uses global variables, strings, a myriad of local variables, seemingly random separate mathematic functions. Is my best avenue to wrap this into a non-reentrant sub-vi and create a small cadre of global & local variables, and then use these variables to replace the old ones all over the place? Or is there some more palatable solution I'm missing?

If it would be helpful I could post snippet jpegs of the old code in question.

Thanks!

Bhima

Link to comment

QUOTE(Bhima @ Dec 28 2007, 12:34 PM)

That's always tough.

QUOTE

The VI you mention uses 'data range coercion' on one of it's front panel controls. This means a user can't set the value to an invalid (unwanted) value.

However if you use the VI as a subVI the data is not coerced and an invalid value may be feed to the function. So you should use some data validation. A solution is to use the mentioned 'In Range and Coerce'.

QUOTE

Next I am unsure how to integrate this vi into the existing application. Currently this functionality is attempted by a wildly desperate parts spread over a block diagram which is approximately 1 Meter x 2.5 meters in size. It uses global variables, strings, a myriad of local variables, seemingly random separate mathematic functions. Is my best avenue to wrap this into a non-reentrant sub-vi and create a small cadre of global & local variables, and then use these variables to replace the old ones all over the place? Or is there some more palatable solution I'm missing?

I advise you to use a State Machine architecture. A good book on this topic is 'Software engineering approach for LabVIEW' (esp. the first half of the book)

QUOTE

If it would be helpful I could post snippet jpegs of the old code in question.

If you're going to I advice you to use the Code Capture Tool.

Just remember the two golden rules:

KISS (keep it simply stupid)

If it ain't broken, don't fix it.

Ton

Link to comment

QUOTE(tcplomp @ Dec 28 2007, 12:53 PM)

Just remember the two golden rules:

KISS (keep it simply stupid)

If it ain't broken, don't fix it.

Unfortunately this is neither ‘simple’ nor ‘not broken’! I have a *stack* of Labview books and I’m really having troubles actually using what’s presented in the books. The existing code is such a disaster and I am so new at this that I’m completely lost. I don’t have the book you recommend though, so I’ll order it.

Now as for your advice to use a state machine. Are you saying that I should wrap the bloomy interval timer vi a new sub vi using the standard state machine template? Then everywhere where there is interval time functionality that needs to be replaced, I put this new sub vi, set the state I want, and then add the input or get the output. Is that an accurate recounting?

Link to comment

QUOTE(Bhima @ Dec 28 2007, 01:35 PM)

Unfortunately this is neither 'simple' nor 'not broken'! I have a *stack* of Labview books and I'm really having troubles actually using what's presented in the books. The existing code is such a disaster and I am so new at this that I'm completely lost. I don't have the book you recommend though, so I'll order it.

If you already have a stack of books, this will only make you get more lost, just absorb wha't in the books, follow the example and try to find your own programming style.

QUOTE

Now as for your advice to use a state machine. Are you saying that I should wrap the bloomy interval timer vi a new sub vi using the standard state machine template? Then everywhere where there is interval time functionality that needs to be replaced, I put this new sub vi, set the state I want, and then add the input or get the output. Is that an accurate recounting?

No, I wasn't focusing on the bloomy interval timer (which I don't know) just a general hint.

Ton

Link to comment

hello Bhima,

if it is not too problematic, i would propose you to post your code, and we can try to help you implement an interval timer.

on the other hand, if you have read and fully understood the lv style book, and have a little programming experience, i think you have all the tools necessary to rewrite the code yourself. it depends of course how much time you have, but it seems to be the best option when dealing with messy codes. i think you will learn quite a bit doing so, and will have the opportunity to implement yourself an architecture that you will like.

begin by creating suvis, each performing a specific function. higher level functions should be built of several low level subvis. when you have the whole bunch of them, not only you will have a full overview of the functionality of the program, but the typical architecture necessary will probalby appear spontaneously. this bottom up approach might be the easiest for you to rewrite this code.

in any case, if you post your code we could try to help.

Link to comment

as far as easily posting code pictures and EVEN VIDEO!!

Check out www.JingProject.com

This will allow you to easily caputre screen shots, or portions of the screen and have them posted to the the web immediately for sharing or to your HD or many other services.

I really love the video feature, because you can walk someone through how messed up it is, w/ voice comments too!

Link to comment

QUOTE(Norm Kirchner @ Jan 2 2008, 11:37 AM)

Check out www.JingProject.com

Looks like a cool program. The site says it will eventualy become something else...any idea what? I'll have to play with it some more to decide if it's worth keeping.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.