Loader

Quarc Library Simulink

For safety, QUARC includes QUARC Shutdown blocks that can safely stop motors if an emergency condition is detected (e.g., encoder out of range or temperature sensor too high). You can programmatically halt the real-time code.


The Quarc Library appears as a standard library in the Simulink Browser. It is categorized into functional areas that handle data flow, hardware I/O, and communication protocols.

Connect your Quanser data acquisition board (e.g., Q2-USB) to your PC. Connect a DC motor’s encoder to channel 0 and PWM amplifier to channel 0.

| Feature | QUARC | Simulink Real-Time (SLRT) | Homegrown C-code | | :--- | :--- | :--- | :--- | | Target OS | Windows (with real-time patch), Linux | Dedicated target PC (DOS-like) | Any, but high dev time | | Hardware Support | Quanser, NI, Measurement Computing, Advantech, etc. | Speedgoat, some NI | Full control, but driver writing needed | | Ease of Use | Drag-and-drop blocks | Moderate (requires Speedgoat) | Very difficult | | Educational Focus | Strong (excellent documentation for control labs) | Industrial/Research | N/A | | Cost | Moderate (academic licenses available) | High | Low (but high effort) |

QUARC shines in teaching and rapid prototyping because you can run real-time control on a standard Windows laptop (using Real-Time Kernel) without requiring a second dedicated target computer.


For engineers and researchers in control systems, robotics, and mechatronics, the leap from a mathematical model to a physical prototype is often fraught with challenges. Simulink, by The MathWorks, has long been the gold standard for model-based design, allowing users to simulate complex dynamic systems. However, the final step—deploying that controller to real hardware—typically requires tedious manual coding, driver integration, and real-time scheduling.

Enter QUARC (Quanser Real-Time Control). Developed by Quanser Inc., the QUARC library for Simulink acts as a magic bridge. It extends Simulink’s capabilities by providing a suite of blocks that allow your models to communicate directly with physical hardware in real-time. Whether you are controlling a DC motor, an inverted pendulum, or a sophisticated omnidirectional robot, QUARC transforms Simulink from a simulation-only environment into a powerful real-time control prototyping platform.

This article provides an exhaustive exploration of the QUARC library for Simulink, covering its architecture, core components, practical applications, and best practices.


Quarc (Quantum Real-Time Control) is a high-performance software framework developed by Quanser Consulting Inc. designed to bridge the gap between Simulink simulations and real-time hardware implementation. It acts as a seamless extension to MATLAB and Simulink, allowing engineers and researchers to design control systems in a simulation environment and deploy them to physical hardware with a single click.

Unlike traditional hand-coding approaches (writing C/C++ code manually), Quarc automates code generation, compilation, and deployment, significantly accelerating the control design iteration process. It is primarily utilized in mechatronics, robotics, aerospace, and advanced control systems research.


The Quarc Library effectively turns Simulink into a real-time operating system interface. By abstracting the low-level complexities of hardware drivers, memory management, and thread scheduling, it allows engineers to focus entirely on control logic and system behavior.

The QUARC library is a suite of tools developed by Quanser that integrates with MATLAB and Simulink to enable rapid control prototyping and real-time hardware-in-the-loop (HIL) simulations. It allows users to generate real-time C code directly from Simulink models and run it on various hardware targets without manual programming. Key Papers and Documentation

Hardware-in-the-Loop Architecture with MATLAB/Simulink and QuaRC: This research paper explores the use of QUARC for rapid prototyping of CMAC neural network controllers, specifically for a ball-and-beam system.

MATLAB Simulink QUARC Primer: An authoritative guide from Quanser that introduces the basic functions of MATLAB, Simulink, and QUARC for first-time users.

QBOT: An educational mobile robot controlled in MATLAB/Simulink environment: This paper discusses the Quanser Mobile Robot Control Framework (QMRCF), which utilizes QUARC to accelerate mobile robot development and HIL testing. Core Capabilities of the QUARC Library QUARC Real-Time Control Software - Quanser

The QUARC Real-Time Control software from Quanser is a rapid control prototyping system that integrates deeply with Simulink. It is primarily used to bridge the gap between simulation and real-world hardware implementation. Core Capabilities

Seamless Integration: QUARC acts as an extension of Simulink, allowing you to run models in real-time on various targets—including 32-bit and 64-bit Windows and various embedded platforms—directly from the Simulink Development Environment.

No Manual Coding: It generates real-time C/C++ code automatically from your Simulink diagrams, eliminating the need to write manual code for digital signal processing or hardware drivers. quarc library simulink

External Mode Support: You can tune parameters on-the-fly while the model is running on a remote target and view real-time data streaming back to the MATLAB workspace or Simulink Scopes.

Hardware Support: It includes a dedicated library of Hardware-in-the-Loop (HIL) blocks for data acquisition cards, communication protocols (TCP/IP, UDP, Serial), and specific Quanser hardware like the QArm or QDrone 2. Library Highlights

The QUARC Targets Library adds specialized blocks to your Simulink Library Browser including:

Communication Blocks: Based on Universal Resource Identifiers (URIs), allowing you to swap protocols (e.g., from Serial to TCP/IP) by changing a single parameter.

Interactive Inputs: Blocks to use host system peripherals like a mouse, keyboard, or joystick as inputs for real-time models.

Advanced Plotting: Includes the XY Figure block, which offers better performance and multi-curve plotting compared to standard Simulink blocks. User Perspective & Limitations

Understanding the QUARC Targets Library for Simulink QUARC Real-Time Control Software is a powerful tool by that transforms

models into real-time applications without requiring manual code writing. While Simulink is typically used for simulation, the QUARC Targets Library

adds specialized blocksets that allow these models to interact directly with hardware in real-time. Core Components of the QUARC Library

The QUARC library introduces several unique blocksets designed for high-performance control and communication: Hardware-in-the-Loop (HIL) Blocks

: These allow you to interface with data acquisition (DAQ) cards. A key feature is the ability to swap out the physical hardware for a model by changing a single parameter in the block. Communications Blockset

: This set enables models to talk to each other or external devices using protocols like TCP/IP, UDP, Serial, or Shared Memory. It uses Universal Resource Identifiers (URIs)

to define protocols, making it easy to switch communication methods by simply updating a string. Asynchronous Thread Blocks

: Unlike standard Simulink models that are strictly periodic, QUARC allows you to create non-periodic threads

that run asynchronously for tasks like event-driven code or background communications. Advanced Plotting : Includes the XY Figure block

, which outperforms standard Simulink graphs and can be used to drive axes within a custom MATLAB GUI. Key Features and Workflow QUARC Real-Time Control Software - Quanser

QUARCTM is the most efficient way to design, develop, deploy and validate real-time applications on hardware using Simulink®. QUARC Targets Library - Unleashing the Power of QUARC For safety, QUARC includes QUARC Shutdown blocks that

In the context of Quanser's QUARC real-time control software for Simulink, "preparing a piece" (or setting up a project) generally refers to the workflow of configuring a Simulink model to communicate with real-time hardware. 1. Configure Model for QUARC

Before you can run any "piece" of code on hardware, you must configure the Simulink model to use the QUARC real-time target. Open Configuration Parameters: Press Ctrl+E in Simulink.

Set the Solver: Under the Solver pane, set the "Type" to Fixed-step and the "Solver" to a discrete solver (e.g., discrete (no continuous states)).

Select the QUARC Target: In the Code Generation pane, set the "System target file" to a QUARC target, such as quarc_win64.tlc for 64-bit Windows or the specific target for your hardware.

Enable External Mode: Go to the Interface sub-pane and ensure "External mode" is selected to allow real-time tuning and monitoring. 2. Access the QUARC Library

The QUARC Targets Library contains blocks specifically designed for hardware interfacing, such as reading sensors or writing to motors.

Open the Library Browser (click the icon or type slLibraryBrowser in MATLAB). Navigate to QUARC Targets to find hardware-specific blocks.

Quick Tip: You can quickly open specific sub-libraries by typing commands like qc_open_library('quarc_library/Sinks') in the MATLAB Command Window. 3. Essential Hardware Blocks

To make your "piece" functional with hardware, you typically need these blocks:

HIL Initialize: The "master" block. Drag this from QUARC Targets > Data Acquisition > Generic > Configuration. Double-click it to select your specific Quanser board (e.g., Q8-USB).

HIL Read/Write: Found under Generic > Immediate I/O, these blocks allow you to read encoders (sensors) and write voltages (actuators).

HIL Timebase: Used to ensure the model runs at a precise hardware clock rate. 4. Build and Run Once your model is assembled:

Connect to Target: Click the Monitor & Tune (or "Connect") button in the Simulink toolbar.

Build: Click the Build button (or Ctrl+B) to generate and compile the C-code for your real-time target.

Run: Click the Start button. You can now tune gain parameters in real-time or view data on Simulink scopes while the hardware moves.

For a deep dive into specific hardware setups, you can refer to the QUARC Library Guide or the Quanser Lab Workstation Support page on MathWorks. HIL Write :: QUARC Targets Library - Quanser

The QUARC Library for Simulink, developed by Quanser, is a comprehensive suite of real-time control software that bridges the gap between theoretical Simulink models and physical hardware implementation. It serves as a rapid control prototyping (RCP) and hardware-in-the-loop (HIL) environment, allowing users to generate real-time code directly from Simulink diagrams without writing a single line of manual code. Core Functionality and Architecture The Quarc Library appears as a standard library

QUARC operates on a host-target relationship, where the user designs controllers in the Simulink Development Environment (SDE) on a host PC and deploys them to a local or remote real-time target.

Real-Time Code Generation: Converts graphical Simulink models into optimized C-code that runs deterministically on platforms like Windows and Linux.

External Mode Support: Enables online parameter tuning and real-time data monitoring directly within the Simulink interface while the model is executing on the target hardware.

Dynamic Reconfiguration: Allows users to replace a running model with a new one without interrupting the hardware's execution. Key Blocksets in the QUARC Library

The QUARC Targets Library expands standard Simulink capabilities with specialized blocks:

Hardware-In-the-Loop (HIL) API: Provides a unified interface to access data acquisition (DAQ) cards from Quanser, National Instruments, and other third-party manufacturers.

Stream API: A protocol-independent communication framework supporting TCP/IP, UDP, serial, shared memory, and SPI.

Multimedia and Vision: Specialized blocks for interfacing with FLIR and PGR cameras, performing image processing, and handling video compression.

Advanced Robotics: Includes kinematic solvers and blocks for controlling specific robots like the Quanser QArm, Denso, and Kinova arms. Applications in Education and Research

QUARC is widely utilized across academic and industrial sectors due to its "academically appropriate abstraction," which allows students to focus on control theory rather than low-level coding.

Teaching Labs: Integrated into Quanser lab workstations to teach linear systems, rotary motion, and mechatronics.

Autonomous Systems: Powering research in multi-agent robotics using the QBot 2, QCars, and QDrones.

High-Performance Prototyping: Used in large-scale projects, such as the Challenging Environment Assessment Lab (CEAL), for complex motion platform control. Getting Started and Troubleshooting

To use the library, ensure that QUARC Real-Time Control software is installed after MATLAB. If blocks are missing with a quarc_library error, you can run quarc_setup in the MATLAB Command Window to refresh the paths. For existing models, use the Upgrade blocks utility under the QUARC menu to resolve broken links from older versions. Quanser Lab Workstation Support from Simulink - MathWorks

QUARC is widely considered the "gold standard" for real-time control prototyping within the MATLAB/Simulink environment, particularly in academic and high-end research settings.

The general consensus from users and researchers is that it is a powerful, reliable tool that bridges the gap between theoretical modeling and physical hardware, though its high performance comes with specific hardware requirements and potential performance trade-offs in certain modes. Core Strengths

Quanser Real-Time Control (Software) アルテックス | IPROS


Overall Verdict:
An excellent, high-performance real-time extension for Simulink—essential for anyone using Quanser hardware (e.g., QUBE, IP02, Aero) but too specialized and costly for general-purpose real-time tasks.

Rating: ⭐⭐⭐⭐☆ (4/5)