Table of Contents
quanser.hardware.hil Class
The quanser.hardware.hil class provides methods to access data acquisition hardware in a variety of ways. However, in order to use a board, it must first be opened using the static quanser.hardware.hil.open method. The open function returns an instance of the hil class whose methods may then be used to access the data acquisition hardware. When the board is no longer needed it should be closed using the close method.
The methods of the hil class may be grouped into the following categories:
To build and run scripts involving hardware access in real-time on Quanser targets, refer to the Basic Procedures for Scripts.
Static Functions
The quanser.hardware.hil class has the following static functions:
Gets the Quanser HIL API version. |
|
Opens a HIL board. |
|
Closes all open HIL devices. |
|
Generates a PWM output value suitable for an ESC command. |
The first function is used to check the version information for the hil class itself. The version will match the version of the HIL API to which the class belongs. Version information can be useful to determine what features, drivers or updates may be available.
The second method is used to open a data acquisition card. This method returns an instance of the class, whose methods may then be used to access the hardware. When the board is no longer in use it must be closed using the close method. A board is first opened using the static quanser.hardware.hil.open method of the class as follows:
board = quanser.hardware.hil.open('qpid_e', '0');
This opens the first instance of a QPIDe data acquisition card. Refer to the documentation for the quanser.hardware.hil.open method for more details with regards to the arguments.
Configuration Functions
Once the board is open, the configuration functions are used to configure features of the card, such as setting the analog input ranges, or the directions of digital I/O channels. For cards that have reconfigurable I/O, such as digital outputs that can be reconfigured as PWM outputs, the set_card_specific_options method may be used. Since it can reconfigure pins on the board, it should be called immediately after the board is opened.
The following methods of the board instance may be used to configure the hardware:
Closes the given HIL device. |
|
Get the values of the given double properties of the board. |
|
Get the values of the given integer properties of the board. |
|
Get the values of the given string properties of the board. |
|
Indicates whether the given board represents a valid open board. |
|
Sets the configuration of the specified analog input channels(e.g. single-ended versus differential). |
|
Sets the voltage ranges of the specified analog input channels. |
|
Sets the voltage ranges of the specified analog output channels. |
|
Sets options that are specific to this particular card. |
|
Sets the frequencies of the specified hardware clocks. |
|
Sets the modes of the specified hardware clocks. |
|
Sets the directions (input or output) of the specified digital channels. |
|
Set the values of the given double properties of the board. |
|
Sets the count values of the specified encoder channels. |
|
Sets the filter frequencies of the specified encoder channels. |
|
Sets the quadrature modes of the specified encoder channels. |
|
Set the values of the given integer properties of the board. |
|
Sets the configuration, alignment and polarity of the specified PWM channels. |
|
Sets the deadband employed for the specified PWM channels. |
|
Sets the duty cycles of the specified PWM channels. |
|
Sets the frequencies of the specified PWM channels. |
|
Sets the mode of the specified PWM channels. |
|
Set the values of the given string properties of the board. |
Immediate I/O Functions
The immediate I/O functions perform an immediate read and/or write to the hardware. Only a single sample is read and/or written, although a sample may consist of multiple channels of different types. Since a single sample is read and/or written, the immediate I/O functions are more suited for control applications where single-point access is generally required.
The immediate I/O functions are as follows:
Reads the specified channels. |
|
Reads the specified analog channels. |
|
Reads the specified analog channels immediately, returning raw integer analog codes instead of voltages. |
|
Reads from the specified analog input channels and writes to the specified analog output channels. |
|
Reads the specified digital channels. |
|
Reads from the specified digital input channels and writes to the specified digital output channels. |
|
Reads the specified encoder channels. |
|
Reads from the specified encoder input channels and writes to the specified PWM output channels. |
|
Reads the specified other channels. |
|
Reads from the specified other input channels and writes to the specified other output channels. |
|
Reads from the specified input channels and writes to the specified output channels. |
|
Writes to the specified channels. |
|
Writes to the specified analog channels. |
|
Writes to the specified analog channels. The raw integer analog codes are used instead of voltages. |
|
Writes to the specified digital channels. |
|
Writes to the specified other channels. |
|
Writes to the specified PWM channels. |
Buffered I/O Functions
The buffered I/O functions are used to read and/or write a buffer of samples at a fixed sampling rate. Multiple samples are read and/or written, where each sample may consist of multiple channels of different types. Buffered I/O reflects the more traditional use of a data acquisition card. Hence, the buffered I/O functions are mmore suitable for data acquisition applications rather than control because they process inputs in bulk as opposed to one sample at a time.
The buffered I/O functions are as follows:
Reads the specified number of samples from the analog channels at the indicated sampling rate. |
|
Reads from the specified analog input channels and writes to the analog output channels at the given sampling rate, for the indicated number of samples. |
|
Reads the specified number of samples from a combination of channels at the indicated sampling rate. |
|
Reads the specified number of samples from the digital channels at the indicated sampling rate. |
|
Reads from the specified digital input channels and writes to the digital output channels at the given sampling rate, for the indicated number of samples. |
|
Reads the specified number of samples from the encoder channels at the indicated sampling rate. |
|
Reads from the specified encoder input channels and writes to the PWM output channels at the given sampling rate, for the indicated number of samples. |
|
Reads the specified number of samples from the other channels at the indicated sampling rate. |
|
Reads from the specified encoder input channels and writes to the PWM output channels at the given sampling rate, for the indicated number of samples. |
|
Reads from the specified input channels and writes to the specified output channels at the given sampling rate, for the indicated number of samples. |
|
Writes the specified samples to the analog channels at the indicated sampling rate. |
|
Writes the specified samples to the selected channels at the indicated sampling rate. |
|
Writes the specified samples to the digital channels at the indicated sampling rate. |
|
Writes the specified samples to the other channels at the indicated sampling rate. |
|
Writes the specified samples to the PWM channels at the indicated sampling rate. |
Task I/O Functions
The task functions are used for performing I/O in the background at a fixed sampling rate. They are useful for applications such as control systems or streaming of data. Tasks are first created using one of the task_create methods. The task instance that is returned is then used to start and stop the task and to generate or collect samples using the task.
The functions for creating tasks are as follows. For the operations that may be performed on tasks, refer to the quanser.hardware.task class.
Deletes all tasks associated with the board. |
|
Creates a task to read the specified analog channels. |
|
Creates a task to read the specified analog channels and write to the specified analog channels. |
|
Creates a task to write to the specified analog channels. |
|
Creates a task to read the specified digital channels. |
|
Creates a task to read the specified digital channels and write to the specified digital channels. |
|
Creates a task to write to the specified digital channels. |
|
Creates a task to read the specified encoder channels. |
|
Creates a task to read the specified encoder channels and write to the specified PWM channels. |
|
Creates a task to read the specified other channels. |
|
Creates a task to read the specified other channels and write to the specified other channels. |
|
Creates a task to write to the specified other channels. |
|
Creates a task to write to the specified PWM channels. |
|
Creates a task to read the specified channels. |
|
Creates a task to read the specified channels and write to the specified channels. |
|
Creates a task to write the specified channels. |
|
Stops all tasks associated with the board. |
Watchdog Functions
The watchdog functions are used to control the watchdog timer on data acquisition cards that support one. Once a watchdog timer is started, it must be reloaded before it expires to prevent the watchdog from expiring. When it expires, the outputs of the card are reset to the watchdog expiration states and the card enters the watchdog state. In the watchdog state, outputs cannot be written. The watchdog state must be cleared in order to resume writing to the outputs of the card. Watchdogs are used for safety considerations as they can detect when a software failure occurs because the watchdog does not get reloaded before expiry.
The watchdog functions are as follows:
Clears the watchdog state. |
|
Indicates whether the watchdog timer has expired. |
|
Reloads the watchdog timer. |
|
Sets the watchdog expiration state of the specified analog channels. |
|
Sets the watchdog expiration state of the specified digital channels. |
|
Sets the watchdog expiration state of the specified other channels. |
|
Sets the watchdog expiration state of the specified PWM channels. |
|
Starts the watchdog timer. |
|
Stops the watchdog timer. |
Interrupt Functions
The interrupt functions are used to monitor interrupts from the card. Interrupts may be polled directly or a monitor may be created to track interrupts in the background. Monitors are first created using one of the monitor_create_interrupt_reader method. The monitor instance that is returned is then used to start and stop the monitor and to read the interrupt states using the monitor.
The interrupt functions are as follows. For the operations that may be performed on monitors, refer to the quanser.hardware.monitor class.
Deletes all monitors associated with the board. |
|
Creates a monitor to read the specified interrupt channels. |
|
Stops all monitors associated with the board. |
|
Polls the specified interrupt sources. |
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.