LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help creating a few quick programs

I was asked to create a few VI's and am having trouble due to my limited working knowlege with LabVIEW.
 
I need to write a VI that:
 
1) Calculates the batting average of a baseball player (Hits/At-Bats).  Both are ratio numbers but the ratio is a floating point number.  Use two separate controls to input values for Hits and At-Bats.
2) If the batting average is greater than or equal to .300, display the message "potential hall of famer".  If the ratio is less then .300 display "keep swinging".
3) if there are no At-Bats, then this will result in a divide-by-zero calculation so set the batting average display to 0.00 and display the message "no at-bats".
 
The next one I have trouble creating is:
1) input a number and add a random number to it.
2) wait a prescribed n umber of msec (user input).
3) take the square root of the previous result and display the answer
 
THanks for your help in advanced.  I am sure it won't take long for someone to create this sample.  It would be greatly appretiated if they could upload it or even e-mail me there results.
 
Thanks!
 
Bob
0 Kudos
Message 1 of 29
(3,071 Views)
Why would someody randomly pick you to make some VIs? These are very simple and basic beginner problems. Are these homework in a LabVIEW course? 😉
 
I think you should try to solve them yourself! See how far you get. You can always come back with a more specific question in case you get stuck permanently. 🙂
 
 
Message 2 of 29
(3,043 Views)
I agree with the last writer. You're only doing yourself a disfavor as by asking someone else to do your homework is no way to learn.
0 Kudos
Message 3 of 29
(3,039 Views)

That is the problem it is not a course in labview.  I wish it was so we did have direction as well as a variety of examples.  It is a course but NOT in labview, there is no manual and very little instruction...it was pretty much given as here it is, now do the work, only VERY basic explainations which do not relate nor help what was asked to do.  This is why I am stuck.

If someone could provide at least some guidance It would be appretiated.  I am completly left in the cold on these.

 

0 Kudos
Message 4 of 29
(3,032 Views)

You're right. Both programs should only take a couple of minutes.

If you are going to need to do more stuff with LV, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.

If this will be your only contact with LV, we can probably help you.

As for your specific question:

#1 can be handled by placing 2 numeric controls (DBL) on the front panel and wiring them into a divide VI. 2 and 3 can be taken care of using correctly placed case structures and comparison functions.

The second one will need a couple of other functions (randon, wait, square root). In general, the functions you will need can be found in the following palletes: Structures, Numeric, Comparison, Time & Dialog. Now all you need is to find them and put them together correctly. If you click Ctrl+H (or the yellow question mark on the top right corner), you will get a floating window which will give you a short description of each function.

Like Altenbach said, this is fairly simple and is very good as a beginners exercise, so I also suggest you try it yourself.


___________________
Try to take over the world!
0 Kudos
Message 5 of 29
(3,029 Views)
tst,

I appretiate the help. SInce this isn't a class on labview, I won't be using the program.  I think the professor wanted us to just get a sense of it...though the class is not a programming class, thus the reason little support whatsover I literally have ~10 minutes of brief training of a a very basic example.  The rest I have learned from using tutorials as well as reading on my own.  Trust me, this is quite frustrating to say the least.  It's like learning to drive by just reading and then taking key and just trying it.  Sure you can learn, but it is not really the appropriate way. 
 
Before I begin, I do not understand the difference between a dbl, sgl, i16 indicator etc.  Why choose one over another. (I have yet to be able to reach our professor over the week to explain any of these problems.  We meet once a week, and the asignment is due the following week).
 
This is what I did for the first case, I wired a I16 indicator into a case structure to test for no at bats, when I tested it with a string indicator in it works where it tells me the correct information on the control panel, when set to greater then zero, the indicator is blank using an emptry string constant.  Outside of the indicator is where I divide the hits/at bats to come up with an average.  Now i'm stuck, I know I need to do a comparison of some sort, but cannot figure it out for the life of me.  I know it needs to be somethng like if greater then or equal to .300 then "potential..." or if less then .300 then..."keep practicing".
 
How do I go into a case structure from the first one, what type of devices do I use etc.  This is so hard to explain by typing...I couldn't find any similar examples anywhere so this is why i'm so stuck.
 
Thanks once again.  This certainly should be something the professor could help with ...IF I could get hold of him. 
0 Kudos
Message 6 of 29
(3,020 Views)

 


@bobl7777 wrote:
Before I begin, I do not understand the difference between a dbl, sgl, i16 indicator etc. 

Obviously, you don't have any experience in any other programming language, so this makes it a bit more complicated for you. Datatypes are a very important programming concept, so here's a tiny primer to get you going:

There are two main ways to represent numbers in a computer: (1) Integer and (2) floating point.

Integers are always whole numbers and are great for e.g. counting. How high you can count depends how many bits are reserved for each number. In LabVIEW, you can integers with 8, 16, or 32 bits, depending how high you need to count beforre running out of bits. If you assume that all numbers are positive, you can use all bits, but if you also want negative intergers you have to sacrifice one of the bits to represent the sign. We have U8, U16, U32 (unsigned) and I8, I15, I32 (signed). The most versatile is I32, which allows whole numbers from -2147483648 to 2147483647. Ignore all the others for now. Additions, subtractions and multiplications never have rounding errors, but you might overflow.

One limitation of integer data types is the fact that they cannot represent fractional numbers or very large or small numbers. Floating point types limit the resolution but use some bits for the exponent. Depending how much precision you need, you can use SGL (32 bits), DBL (64 bits), or EXT(bits depend on the platform). SGL is pretty useless because it only gives you about 6 decimal digits of precision. DBL gives you about 15 decimal digits, better than most handheld calculators. EXT is not worth the extra memory footprint. Stick with DBL! 🙂

You need to make divisions or take the square root, thus you need to use DBL for your math. The "n: for the wait in problem 2 should however be an integer.

(There are many other data types: strings, complex numbers, etc. Have a look at Application Note 154 for details).

For the comparison, there is a comparison pallette where you have e.g. "equal" "greater than", etc. Wire two inputs and you get the answer of the comparison out. The answer is yet another datatype, a boolean shown as green wire. This is the most simple type and it can only have two states, TRUE or FALSE (no MAYBE, UNDECIDED, or anything else ;)). This you can wire to a case structure and you ge a true case and a false case where you can place the appropriate operations as needed.

LabVIEW include an example browser (help...find examples). I suggest to look at a few simple examples to get a feeling how things are done. Good luck and have fun! 🙂

Message Edited by altenbach on 07-17-2005 11:19 AM

Message 7 of 29
(3,013 Views)

Ok...So I was never able to get the baseball program to work.  I turned in what I had.  I wasn't sure how to set it up.  What I did setup, it would not work

 I got the second one working though.  So how would someone do the first one?  Professor will only be available one more time to collect the last homework.  The wonders of spending over 1200.00 and having a professor underteach and get paid for it.  It woudl have been nice to see how it actually worked.

Is there anyone that can create the darn thing for me to see how it is suppost to work.  I have one last problem to do which is due next week, not sure how that will get done either since the professor won't be available for two weeks when the summer class ends.  

Once again, this is not a llabview class, it's a measurments class which I'm not sure why the 3 weeks this program was introduced has any bearing on the class.  Learning this program should be something that is like taking a C++ class or something.  It seems one thing that I have learned about universities is that professors seem to care less about actually teaching, they are more interested in their own projects and studies. 

Thanks,

Bob

0 Kudos
Message 8 of 29
(2,971 Views)


@bobl7777 wrote:

Is there anyone that can create the darn thing for me to see how it is suppost to work. 


Well, here's a literal translation of the problem (LabVIEW 7.0).

You could get fancy with event structures, etc. but this should give you an idea on how to this. Please study it! 🙂

In principle, you don't even need the while loop. Then you would need to run the VI after each entry manually.

0 Kudos
Message 9 of 29
(2,961 Views)

I hate to point this out, but the constant value of 300 should be just 0.3.  A batting average of 300 is 300 of 1000, or 30%, or 0.3.

I kind of like the program.  It's a good class exercise.

Hope that this helps,

Bob

0 Kudos
Message 10 of 29
(2,944 Views)