Table of Contents > QUARC > User's Guide
Accessing Hardware
QUARC supports a variety of data acquisition cards, including Quanser's own Q4 and Q8 Hardware-in-the-Loop (HIL) boards, the National Instruments PCI-6259 and many more. Hardware connected to these boards can be accessed by simply placing the appropriate blocks in your Simulink diagram. More specifically, the blocks found in the Simulink Library Browser under the QUARC Targets/Data Acquisition/Generic library are designed such that once placed in a Simulink diagram, you are only a few clicks away from interacting with your hardware, whether it is reading one or more analog channels or writing to digital channels. In addition, as will be explained in detail, these blocks are board-independent, meaning that changing boards does not require replacing all the associated blocks in the Simulink diagram.
The blocks used to access hardware may be divided into three categories as listed below.
Before starting to explain each of the HIL block categories above, the HIL Initialize block needs to be explained since this block has to be placed in all models that require hardware access regardless of the type of board being used or the type of access required.
HIL Initialize Block
This block can be found in the Simulink Library Browser under the
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
qc_open_library('quarc_library/Data Acquisition/Generic/Configuration');
The HIL Initialize block associates a board name with a particular HIL board. For example, in the figure above the name HIL-1 has been assigned to the Q8 board. The name assigned to each board will appear in the list of boards for every other HIL block in the diagram. This naming scheme is actually a great advantage because this property of the HIL Initialize block makes switching between different HIL boards as simple as changing the board type in the dialog box for this block. All other HIL blocks are designed to be board-independent.
An important function of the HIL Initialize block is to configure the I/O on the card. For example, many cards allow the digital I/O lines to be programmed as inputs or outputs. The Digital Inputs and Digital Outputs tabs are used to configure which digital I/O lines are inputs and outputs respectively. Similarly, many cards permit the range of the analog inputs and outputs to be programmed. The Analog Inputs and Analog Outputs tabs are used for this purpose. Many other features of data acquisition cards are configured using the tabs of the HIL Initialize block. Be sure to check the settings on each tab carefully to ensure that your card is set up properly.
Please refer to the HIL Initialize block reference page for details on this block.
Immediate I/O HIL Blocks
These blocks are found in the Simulink Library Browser under the
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
qc_open_library('quarc_library/Data Acquisition/Generic/Immediate I//O');
As seen in the above figure, the HIL Read block has been used to read analog, encoder and digital channels of the connected data acquisition board. The immediate I/O blocks read these channels immediately every time they are executed. The values read are manipulated in the Controller Sub-system and the calculated control commands are written to the data acquisition board's analog and digital channels. Reading from and writing to the channels seen in the figure above could also have been done using the HIL Read Analog, HIL Read Encoder, HIL Read Digital, HIL Write Analog and HIL Write Digital blocks separately, as illustrated below. However, in situations where different channels are being read using the immediate I/O blocks, it is more efficient to have a single HIL Read block rather than using multiple immediate I/O blocks specific to each channel type. The same principle applies to writing to different channel types where having a single HIL Write block is more efficient than using channel specific immediate I/O blocks. Not all boards support the HIL Read and HIL Write blocks though.
For more information about each of the available immediate I/O blocks, please refer to the Immediate I/O section of the Generic HIL Blocks page.
Buffered I/O HIL Blocks
These blocks are found in the Simulink Library Browser under the
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
qc_open_library('quarc_library/Data Acquisition/Generic/Buffered I//O');If different channels such as analog, digital or encoder are to be read with the buffered I/O HIL blocks, it is more efficient to have a single HIL Read Buffer block rather than using multiple buffered I/O blocks specific to each channel type. The dialog box for the HIL Read Buffer block is depicted below.
As seen in the figure above, the dialog box gives you the ability to specify all the different channel types to be read at one time. Clearly the channel numbers to be read should be specified for each channel type under the appropriate field. As mentioned earlier, the buffer size can be specified under the Number of samples field. For more information about each of the available buffered I/O blocks, please refer to the Buffered I/O section of the Generic HIL Blocks page.
Timebase HIL Blocks
These blocks are found in the Simulink Library Browser under the
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
qc_open_library('quarc_library/Data Acquisition/Generic/Timebases');It should be noted that you can only have one timebase block in a Simulink model. More than one timebase block per Simulink model is not supported since using two separate timebases to interrupt the same model will result in incorrect execution and possible instability.
Similar to buffered and immediate I/O HIL blocks, if more than one channel type is being read using the HIL Timebase blocks, it is more efficient to use a single HIL Read Timebase block rather than using one timebase for a specific channel type and multiple immediate I/O read blocks specific to the other channel types. The same principle applies to writing to different channel types where having a single HIL Write Timebase block is more efficient than using one channel-specific HIL Timebase block and multiple immediate I/O blocks. The dialog box for the HIL Write Timebase block is shown below.
As seen in the figure above, the dialog box gives you the ability to specify all channel types to be written to at once. Clearly the channel numbers to be written to should be specified for each channel type under the appropriate field. For more information about each of the available HIL Timebase blocks, please refer to the Timebases section of the Generic HIL Blocks page.
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.