LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

Questions from a New User

I have just started using LabVIEW 7.1 Student Edition w/ NXT Toolkit.  I have a few questions I would like answered.
 
  • Loops:  In NXT-G, you could make a loop run a certian number of times.  How is that done in LabVIEW?
  • Variables:  In NXT-G, Variables could be easily created.  In LabVIEW, all I can find is the LOCAL variable.  I can't figure this out.
  • Documentation:  Where is a good user manual or set of tutorials?
  • How on Earth do arrays work?

I'd like it if someone can help me with these.

 

Team RoboSquad

http:\\teamrobosquad.blogspot.com

 

 

0 Kudos
Message 1 of 11
(9,420 Views)

Well, I just figured out how to run a loop for a certian number of times.  I didn't know the i in the loop stored the count.

 

Team RoboSquad

http:\\teamrobosquad.blogspot.com

0 Kudos
Message 2 of 11
(9,418 Views)
To run a loop a certain number of times wire a value to the big N.
The i is the loopcounter that indicates how many times the loop has been executed already.

An array can be indexed or autoindex (this is preferred becasue of speed)
To autoindex an array just wire it to a loop (for) and see the open square in the border of the loop.
Right click the open square and you can disable autoindexing.
greetings from the Netherlands
0 Kudos
Message 3 of 11
(9,413 Views)
New question: In a loop, I wire the distance from the US Sensor and the intentisity from light sensor into a cluster.  I then wire the cluster to a meter with 2 needles.  The meter grays out when I run it in debug.  Why is this happening? 
0 Kudos
Message 4 of 11
(9,401 Views)


@Albert Geven wrote:
To run a loop a certain number of times wire a value to the big N.
The i is the loopcounter that indicates how many times the loop has been executed already.

An array can be indexed or autoindex (this is preferred becasue of speed)
To autoindex an array just wire it to a loop (for) and see the open square in the border of the loop.
Right click the open square and you can disable autoindexing.



Where is the big N?

The NXT Toolkit only supports While loops, right?  I just need to know how to write data to an array and read it.  I need to write 144 vaules to two arrays.

0 Kudos
Message 5 of 11
(9,398 Views)
What is the Input dup etc.?
0 Kudos
Message 6 of 11
(9,397 Views)
Hi RoboSquad -

You certainly ask lots of questions -- a good characteristic for a beginner to have!  I don't have all the answers, but hopefully I can address some of your queries.

Loops: sounds like you've worked out the idea that you can watch the loop counter (i) of a while loop and wire a true value into the stop condition terminal when you've finished the number of iterations you want.  Albert's comments are correct for "for" loops in full LabVIEW, but you're correct that the NXT Toolkit only includes "while" loops.  Auto-indexing will still work; see my comment on arrays.

Variables: local variables are basically "references" to front panel indicators or controls, and can be read or written just like normal variables.  But depending on what you're really trying to do, just adding a constant to the block diagram or using wires to pass a value to different parts of your program may be a better solution.

Documentation: the LabVIEW help is pretty extensive and comes with LabVIEW.  You can also use the Example Finder to search for examples for a particular topic, including "while" and "array."

Arrays: from your post, it isn't clear to me whether you're completely unfamiliar with what an array is, or you're just confused by LabVIEW's implementation of them.  If it's the former (what is an array?), your best bet is to use Google or Wikipedia to build some basic knowledge.  If it's the latter (how do arrays work in LV?), try using the Example Finder to find and work through some examples.  If you're still confused, try to ask a more specific question.  One thing that may be confusing is that, by default, arrays don't have a type.  If you drop an array constant on the block diagram, you get an array of <nothings> with a black border.  To tell LV what types of values will be in that array, you have to drop a constant of that type inside the black box: a numeric constant, a boolean constant, a string constant, etc.  Then the array constant which change color to match the data type it will hold, and you'll be able to type in values for the different elements of the array.  Maybe that's the key realization you're missing?

Debug gray-out: when you turn on Execution Highlighting on a LV block diagram, LV will gray-out parts of the program it hasn't executed yet.  Once the sensors have been read and are ready to be displayed, the meter indicator should get "re-colorized."

Input dup: "dup" is an abbreviation for "duplicate," meaning you'll get back the same value that you wired into "Input."  This is purely an aesthetics thing; it makes block diagrams a little less messy.  Rather than wiring one value separately to a whole bunch of subVIs in your program (and having wires going around all of your subVIs), you can instead wire that same value "through" each of the subVIs.  This results in a clean-looking diagram where the subVIs look like traincars sitting on a "railroad track" of wires.

Whew!  That was certainly a long post, but I hope it gave you some new ideas to investigate.  Let us know when you have more questions!
------
James Blair
NI R&D
Message 7 of 11
(9,392 Views)



Variables: local variables are basically "references" to front panel indicators or controls, and can be read or written just like normal variables.  But depending on what you're really trying to do, just adding a constant to the block diagram or using wires to pass a value to different parts of your program may be a better solution.

Well, Im trying to save a data value without file access.

Documentation: the LabVIEW help is pretty extensive and comes with LabVIEW.  You can also use the Example Finder to search for examples for a particular topic, including "while" and "array."

I mean documentation specific to NXT Toolkit.

Debug gray-out: when you turn on Execution Highlighting on a LV block diagram, LV will gray-out parts of the program it hasn't executed yet.  Once the sensors have been read and are ready to be displayed, the meter indicator should get "re-colorized."

Gray-out only happens when I feed data from a cluster.


Arrays: from your post, it isn't clear to me whether you're completely unfamiliar with what an array is, or you're just confused by LabVIEW's implementation of them.  If it's the former (what is an array?), your best bet is to use Google or Wikipedia to build some basic knowledge.  If it's the latter (how do arrays work in LV?), try using the Example Finder to find and work through some examples.  If you're still confused, try to ask a more specific question.  One thing that may be confusing is that, by default, arrays don't have a type.  If you drop an array constant on the block diagram, you get an array of <nothings> with a black border.  To tell LV what types of values will be in that array, you have to drop a constant of that type inside the black box: a numeric constant, a boolean constant, a string constant, etc.  Then the array constant which change color to match the data type it will hold, and you'll be able to type in values for the different elements of the array.  Maybe that's the key realization you're missing?

 

It is the implementation of it that confuses me.  I want to add a new number to an array 72 times in a loop.  There will be 2 different arrays I will need. (I could use 2-d array?)




0 Kudos
Message 8 of 11
(9,382 Views)
How do you mean save data? like from loop iteration to loop iteration? from one part of the program to another? In labview, the wires are essentially variables from C, they hold the value during a single execution. If you want to save it from loop iteration to loop iteration, shift registers is what you want to look into. as for docs, I don't know about any nxt docs. As for the array thing, they are more like vectors than arrays, the size is not constant. Also, if both the arrays in your application will be built at the same time, I would suggest an array of clusters (given the data is related). It links the data in sets.
Message 9 of 11
(9,380 Views)

What is a shift register.  Is it available in the NXT Toolkit?

 

I just need to know how to build and add data to an array.  The Help files do not cover the differences in the NXT Toolkit.

0 Kudos
Message 10 of 11
(9,377 Views)