MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
quarc_hil_watchdog_demoQUARC Hardware-In-Loop Watchdog Demo
This example demonstrates how to use the HIL Watchdog block from the QUARC Targets library as a safety feature when performing operations that may take too much time to compute and eventually freeze the system. For details of this block, please refer to the HIL Watchdog block reference page in the QUARC documentation.
An analog loopback system is included in the model to demonstrate the fact that the HIL Watchdog block stops all outputs of the hardware-in-loop card from being written any values once its timer expires. For details about this loopback configuration, you can refer to the QUARC Analog Loopback Demo.
The model computes a matrix multiplication of two 10x10 random matrices in a loop. The number, N, of iterations of the loop is controlled by the Slider Gain. Without the use of the HIL Watchdog block, the model might freeze your PC as the slider gain is adjusted and the number of computations increases. In the QUARC Computation Time Demo, this block is not included. The HIL Watchdog block forces the Enabled Subsystem to stop executing once the model starts to miss sampling instants due to long computation time of this subsystem.
System Requirements
This demonstration requires hardware supported by the HIL blockset, such as the Q2-USB or Q8-USB hardware-in-the-loop card.
Configuring the Demonstration
To set up the demonstration, double-click on the Slider Gain to open the Slider Gain dialog, as shown below:
Set the initial gain to 0 in the middle field so that the computation time will be zero initially.
To set up the demonstration for your data acquisition card, double-click on the HIL Initialize block and select the correct board type from the Board type combo box. If you have more than one board of the same type in your computer, change the Board number field to the board you wish to use. Boards are numbered from 0 such that board 0 is the first board recognized by the HIL blockset.
While the HIL Initialize block parameters dialog is open, navigate to the Analog Outputs pane and make sure that the Set the analog outputs when a watchdog timer expires option is disabled. Disabling this option causes the analog outputs to keep the last value (before watchdog timer expiry) once the timer expires.
Now wire analog output channel #0 to analog input channel #0. For the Q2-USB and Q8-USB hardware-in-the-loop cards, simply connect an RCA cable from analog output #0 to analog input #0 on the terminal board.
Demonstration
Building, deploying and starting the model
Refer to One Step Process in QUARC Basic Procedures to build, deploy and start the model.
Running the model
Double-click on the "Tc(ms)" Scope block to display the computation time of the Function-Call Subsystem inside the Enabled Subsystem. In addition, double-click on the "Analog Output Value" Scope block to monitor the value of analog output channel #0.
Adjust the slider gain upward to change the computation time until it exceeds 15 ms. At that point the watchdog will activate and the analog output will go flat. The "Tc(ms)" and "Analog Output Value" Scopes will trace signals similar to the following figures:
Stopping the model
Refer to One Step Process in QUARC Basic Procedures to stop the model.
Set the slider gain back to zero.
Double-click on the HIL Initialize block and navigate to the Analog Outputs pane. Enable the Set the analog outputs when a watchdog timer expires option by clicking on its checkbox. Next, specify the value you want to be written to the analog outputs once the watchdog timer expires using the Analog outputs on watchdog expiry parameter's field. In our demonstration, we have set this parameter to 0.
Go through the steps mentioned earlier to build, connect to and run the model.
This time, the value of analog output channel #0 is set to zero once the watchdog timer expires.
Refer to One Step Process in QUARC Basic Procedures to stop the model.
Disable the Set the analog outputs when a watchdog timer expires option by clicking on its checkbox, set the slider gain to zero and save the model.
Running the example on a different target
To run the example on a different target, refer to the instructions on the Running QUARC Examples on Remote Targets page.
Be sure to configure the HIL Initialize block's board type for the board on the new target, as per the instructions in the Configuring the Demonstration section above.
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.