On-board Programming in FlexMotion
- Determinism - You can determine the execution time of an on-board program more accurately than with a program on the host, because nothing competes for CPU time on the board.
- Independence from the host - If the host has some problem that completely uses up the CPU, the on-board program still continues to run.
The basic structure of an on-board program is as follows:
- Call the Begin Store function.
- Call the desired functions, such as any of the functions included in the FlexMotion driver. You cannot include functions that are specific to the programming language, such as while loops in LabVIEW.
- Call the End Store function.
When this program runs, it will be stored to the board and await a command from the user to run the onboard program.
The downside of using an on-board program is that it is not as easy to program as programs on the host. When programming an on-board program in LabVIEW, you can only use the functions available in the FlexMotion VIs. Other LabVIEW functions, such as while loops and arithmetic operations, generate an error. There are, however, functions that make it possible to do things such as loops and arithmetic operations. Certain LabVIEW functions, such as loops and sequence structures, are not downloaded to the board, but can be used to make the programming easier. For example, if you need to do a sequence of moves in an on-board program, you can use a loop to generate the commands necessary to create the sequence of moves. Keep in mind that on-board programming is not necessarily faster than standard programming. Determinism simply means that the amount of time can be determined, not that it will always be faster.
Communication with Host
On the FlexMotion board, you use the Return Data Buffer to communicate with the host. When programming with FlexMotion, you can set the return vector on several of the VIs to send data back to the host. The data that is set to be sent to the host is sent to the Return Data Buffer or RDB. The host has access to the RDB and can read the data that comes in to it.
Looping in On-board Programs
You can create loops in on-board programs by using the Insert Label function with the Jump to Label on Condition function. This is somewhat similar to how you create loops in BASIC with line numbers and GOTO statements. In an on-board program, you can insert a label somewhere in the program and when the Jump to Label on Condition is called, if the condition is met, the program will go to where the label is.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial 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 content with each new revision of related products and drivers. THIS TUTORIAL 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/).
