Labview code interface reference manual




















The MLPI is divided into different "toolboxes". Other product or brand names may be trademarks or registered trademarks of their respective holders. National Instruments products are protected by one or more U. Before you start working with the mlpi4LabVIEW toolbox in combination with a real machine, make sure you have read and understood the safety precautions for using electric drives and controls. This 8-bit integer can range from 0 to based on the light level.

Since there are no units for this value, the value is represented as a percent of A reading of 0 is no light sensed and a reading of is the maximum light the PmodALS can sense. Download the VI below and open it. On the front panel, make sure the CS channel is 10, the serial port you found for the WF32 is selected, and the SPI channel is set to 0.

Reply 6 years ago. So to answer your question, LINX knows what channels because of your question 3 where you say that you are using SPI0 which corresponds to pins on the board based on the its reference manual. I'm not sure what you mean by data bundle inside the loop? If you mean why does the data get returned in an array, that has to do with the way SPI works.

Once we get the data via SPI we then have to convert that data back to useful information. I'd be happy to help better answer your question if you give a little bit more details on what you mean.

Oh so that is because I was packaging up this code into subVIs after making this Instructable so that other uses can read from this Pmod easily. What that is doing is taking the cluster that includes the CS channel and the active logic level at the very top left of your picture and then overwriting the CS channel with whatever the user selects as their CS channel. This is useful so that others can select the CS channel they are using but they don't need to know if it is active high or active low in order to get a reading.

For this code, it actually doesn't need to be in the while loop and can be outside but it was necessary to have it in the while loop when packaging it into a subVI. If you were making your own code, you would just enter the correct values in the cluster and you wouldn't have to do the CS overwrite that I did.

By Sudharsan Sukumar Follow. This will cause each function VI that is no longer referenced from anywhere to be unloaded. The "Function Manager" shows the use count of privately registered function VIs. Upwards compatibility is ensured by preserving existing connector pane inputs and outputs as well as their connector positions.

Additional outputs or optional inputs might be added to an API VI as these will not affect existing use. When an API VI has a typedef input or output, corresponding diagram constants should remain connected to that typedef. This allows enums to be extended and elements to be added to clusters.

Clusters should be bundled and unbundled by name. They are likely to change and should not be used. The user interface related sub VIs and the VIs in the "library" directory are not part of the API either, though the latter are unlikely to change much.

Before doing so, the public functions used by that script must have been registered, e. A flexible means of starting Lua from your LabVIEW application is to run a bootstrap script and arrange for all further registration and script execution from inside that script. Convenience functions are provided that encapsulate the opening of a Lua for LabVIEW state, and subsequent script compilation, and execution.

These functions accept scripts either as strings or as paths pointing to script files. Script search directories can be configured for the resolution of relative script paths. It is advisable to use unique filenames for scripts even when these reside in separate directories.

This avoids ambiguity when multiple script search directories are specified. Also, the name of script files is used when reporting errors but the path is omitted for brevity. Using unique filenames makes sure that the offending script can be tracked down given an error message. It can be desirable to manage the execution of scripts, or to use an autonomous script to implement some process or series of actions think of a script containing test steps.

Also, a powerful strategy is to split an application architecture into multiple asynchronous contexts. This prevents operations that should be independent from blocking each other, and provides a further means of dividing up the implementation so as to conquer its complexity.

Lua for LabVIEW tasks allow for the easy creation of stand-alone script execution contexts and are provided with functionality for communication and management. A "Task Manager" graphical user interface is provided that allows tasks be run and managed manually.

Note that scripts that normally execute via "Do Script" can also be run as tasks, e. The reverse is not necessarily the case since task scripts can make use of the task infrastructure and by doing so become incompatible with the simple execution context offered by Do Script. The execution context of a task is created by instantiating a VI and running it. Several aspects of the execution environment of tasks are configurable.

Since such configuration has to take place before the task script is executed, it cannot be set through executing the script. Still, it is desirable to make the task configuration part of the task script so that all information that determines the task's behaviour is grouped. To this end, Lua for LabVIEW has a pre-processor that extracts task configuration keywords from the task script before it is run.

This also serves to import additional scripts such as Lua function libraries. Though the standard Lua C libraries contain functions that perform similar actions at run time e. This difference in philosophy stems from the fact that Lua is designed to run well on embedded systems with small amounts of memory. Lua for LabVIEW, on the other hand, is guaranteed to be running on hardware that can handle the LabVIEW runtime so that the extra memory required for early compilation and script caching is likely to be small relative to the available memory.

The list of tasks shown in the "Task Manager" displays a mode for each task. A task can determine it's own mode via the task. Tasks can be in one of the following modes:. Tasks can handle the following management signals. These can be sent programmatically or manually via the "Task Manager":. Several options exist to allow or disallow signals and to implement custom handling of signals in Lua.

There is no obligation to use tasks and their features. If you do not require the extra functionality offered by tasks, simply run scripts in-line, e. Swapping a task involves replacing its script s without removing the task from the task list.

Though a task can be stopped after which a new script is run, swapping a task minimizes downtime and provides better opportunities for continuation of service. This is of importance when the task monitors, polls, or controls some critical resource or provides a message-based service that must remain available.

When a task is swapped, the new script and any import scripts are first loaded and compiled. Only when this succeeds will the task be switched into swapping mode and sent the swap signal. The default handling of this signal causes script execution to be interrupted and any cleanup functions to be run. Next, the virtual machine instance on which the old script s ran is closed.

What is retained is the task execution context and message queue. The new script or scripts are then executed under a fresh virtual machine instance. The task remains in swapping mode for as long as it would remain in initializing mode when run normally: by default the task switches to running or executing mode when the first line of the main script is executed; when the defer pre-processor keyword is used, this is postponed until the task task.

Some task scripts cannot be swapped because there is no conceivable means of cleaning up and restoring their service. Such scripts will want to disallow the swap signal. Other scripts will need to actively participate in the swapping process in order to be swappable. For example, a script that manages some external instrument will want to avoid resetting the instrument when it is swapped.

Swapping is one of several features designed for applications that need to keep on running while allowing for changes to the implementation of services that are in use. Other features that fall into this category are the ability to override Lua for LabVIEW functions with alternate implementations and the ability to close and re open a module without breaking ongoing calls to its export functions. They can be adjusted at initialisation time. The default values were chosen to work well for most kinds of use.

To learn more about individual parameters, read their description strings. It allows the configuration to be set via an initialisation script. Many languages have an exception mechanism for error handling. This causes the ongoing function call to be interrupted and the error to be passed up through the various calling contexts until a context is encountered that catches the error.

This allows error handling to be separated from the code that defines normal execution. The data-flow nature of LabVIEW makes it unlikely that it will ever be able to support such an exception mechanism. Lua on the other hand can throw and catch errors. On the LabVIEW side, error handling is done in the usual manner by passing error clusters via dataflow.

On the Lua side, errors are strings that are passed implicitly to the catching context. When an error occurs when executing a Lua script, the error is by default propagated to the context from which the script was started. Script execution is interrupted and the virtual machine instance and related state of the script is closed. It is up to the surrounding context to decide whether to process or further propagate the error.

The cleanup mechanism was implemented so as to remove the main reason for having to catch errors. When it comes to errors, running tasks are special since they are part of an asynchronous context that is detached from the launching context. Since the launching context might no longer exist, errors thrown by running tasks cannot be propagated.

On the other hand, the launching context will often want to make sure that the task it runs makes it safely through its initialisation. To accommodate both needs, tasks that are programmatically run start out in initializing mode. While in this mode, the launching context is blocked and any errors that the task throws are passed back to it. This covers the often error prone but brief initialisation actions. After the task switches from initializing to running or mode, the launching context is unblocked.

Any errors thrown by the task from that time onwards cause the task to switch to error mode. Manually run tasks always switch to error mode on an error. Though no longer running, a task in error mode remains accessible via the "Task Manager" for post-mortem analysis until the error is confirmed by a user. If you want such errors to be logged somewhere, specify a logging task via the "task error logger" global configuration setting. If instead you want to programmatically handle errors of a running tasks, it is possible to specify an error handler via the -- handler pre-processor keyword.

Only when the error occurs inside some standard LabVIEW VI or node are error codes used, but such errors, when occurring as part of script execution, are immediately explained by means of the error code database. This was done so as to be able to return the specific cause and context of the error instead of being limited to some generic error as specified via a code: an error stating "could not open file" is pretty useless; it is much more useful to be presented with an error message that includes the path to the file that could not be opened, identifies the script that failed, and specifies the line number on which the offending call occurred.

To indicate that these errors already are self explanatory, the special user-defined error code is used so that the handler displaying the error can be customized to skip access to the error code database.

When an error occurs, not all information required to fully describe its cause and effect is available. For this reason, an error is progressively enhanced as it is propagated through the calling contexts up to the catching context.

This implies that the explanation of the root cause can be found in the middle of the error string before the first stack trace or call chain.

Stack traces provide similar information for Lua: a list of nested function calls with function names and line numbers. An error can include multiple call chains and stack traces when it occurs inside nested calling contexts that refrain from catching it. This informs the user of all subsystems that were halted because of the error. Square brackets enclose script or function names and are followed by a semicolon and line number. This allows the script lines involved in an error to be located.



0コメント

  • 1000 / 1000