FOR Loop (Onboard Motion Control Programming)
SUMMARY:
This FlexMotion example demonstrates the implementation of a FOR loop data structure in an onboard program. The C equivalent of the data structure implemented here is:
for (loopVar = initialValue; loopVar <= finalValue; loopVar = loopVar + increment) {
// code to be repeated
}
THEORY OF OPERATION:
The flow of the FOR loop data structure goes as follows:
(1) Program storage is begun.
(2) The FOR loop is set up. (Loop Variable, Final Value, and Increment are each defined and initialized.)
(3) A code delimiter is set using label #1.
(4) Because the FOR loop is a pretest condition loop, we go ahead and verify that the loop variable does not satisfy the exit condition. If the exit condition is not satisfied, we execute subsequent commands until the loop variable is incremented and we are forced back to label #1 with a Jump command.
(5) If the exit condition is satisfied, then we jump to label #2 (the point AFTER the FOR loop in the program.
(6) Program storage is ended.
DEVELOPMENT DETAILS:
Application Software: LabVIEW 5.0.x
Hardware: FlexMotion controller
Driver Software: FlexMotion Software 4.0
REQUIRED HARDWARE:
(controller only)
INSTRUCTIONS:
(0) Initialize the FlexMotion controller before running this VI.
(1) Add the FlexMotion functions you want to execute into the block diagram where noted.
(2) Run the VI to store the program. (The program will not be executed at this time.)
(3) You can then run the program you have stored by calling the run_prog.flx function with the appropriate program number.
ADDITIONAL NOTES:
(a) You should read the following items before writing FlexMotion onboard programs:
(1) The Onboard Programs section of the FlexMotion Hardware User Manual (page 4-9 in the November 1998 edition).
(2) The section about onboard variables in your FlexMotion Software Reference Manual (pages 4-11 and 4-12 in the November 1998 edition)
(3) You will find the chapter of the FlexMotion Software Reference Manual concerning the Onboard Programming functions to be an invaluable reference resource (Chapter 12 of the November 1998 edition) along with the online help for the VI functions.
(b) If you have multiple FOR loops in one onboard program, you may recycle the Loop Variable, Increment Variable, and Final Variable numbers for the different loops in your program if they will not be needed by a previous or subsequent loop while the current loop executes and are not integrated into any other aspect of the program.
(c) This example assumes the the final value of the loop variable should be greater than the initial value (i.e. positive value for increment variable). If the final value of the loop variable is less than the initial value (i.e. decrement instead of increment), then you should modify the Jump condition in the loop variable test to be "Less Than" instead of "Greater Than".
Requirements
Filename: 3665.zip
Software Requirements
Application Software: LabVIEW Full Development System 5.0.1
Language(s): LabVIEW
Hardware Requirements
Hardware Group: Motion Control
Driver: NI-Motion 6.0
Reader Comments | Submit a comment »
Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
