Accessing Hardware Using Devices navigation bar

Table of Contents > QUARC > User's Guide

Communications

QUARC provides a set of blocks to make it possible for models to communicate with each other. These blocks are called the communications blocks and can be found under the QUARC Targets/Communications library in the Simulink Library Browser. They may be used with any of the QUARC communications protocols. The communication protocol and protocol parameters are specified with a Universal Resource Identifier or URI. Refer to QUARC Communications Protocols for a discussion of the different communications protocols available.

For using the QUARC communications protocols and other features in external applications, such as C/C++, .NET, or Java refer to the QUARC External Interfaces documentation.

For performing communications from a MATLAB script, refer to the QUARC MATLAB functions for communications.

The QUARC Communications blockset for Simulink ranges from Basic blocks to Advanced blocks based on their simplicity. The Basic communication blocks are the easiest to use but do not provide the full flexibility of the QUARC communications architecture. However, for most applications they are more than adequate and greatly simplify communications. There are the Intermediate blocks which are more advanced than the Basic blocks and provide more flexibility, but they are still easier to use than the Advanced blocks. The Advanced communication blocks provide the full flexibility of the QUARC communications framework but are lower-level blocks that require a more sophisticated knowledge of communications to be used.

The Advanced blocks support two modes: blocking and non-blocking. In blocking mode, the blocks do not return until the requested operation is complete. As such, blocking mode is typically used in an asynchronous thread running at a lower priority so that the blocking I/O does not interfere with the sample time performance of the main diagram. Blocking mode should not be used in the main diagram because it can prevent the diagram from running at the sample rate requested. In non-blocking mode, the blocks always return immediately and thus may be used in the main diagram without compromising sample time performance. However, a simple state machine is generally required to keep track of when a connection is established and data may be transmitted or received.

The Basic blocks are always non-blocking and may be used in the main diagram. The Basic blocks may be configured to use blocking I/O or non-blocking I/O internally. However, when using blocking I/O, they do the I/O in separate threads so that the blocks themselves never wait for the operation to complete and may always be used in the main diagram.

The Intermediate blocks are also non-blocking, making it possible to use them in the main diagram. Since some protocols do not support non-blocking I/O, it is not possible to use the Intermediate blocks with all communications protocols. However, the Basic and Advanced blocks may be used in this case.

Hint Note that you can save yourself a lot of headaches by reading the documentation fully and carefully with respect to the particular communications protocol that you are using. For example, the TCP/IP protocol has an option for enabling or disabling the Nagle algorithm which can significantly affect its performance depending on your application. Refer to the help page for the TCP/IP protocol for details.

There is also another set of blocks for communicating using Mavlink and the Multiwii Serial Protocol (MSP). These protocols are specialized protocols designed for auto-pilots. In QUARC, the Mavlink and Multiwii blocks are based on the Quanser Stream API, just like the other communications blocks.

This section provides information about these five types of communications blocks (Basic, Intermediate, Advanced, Mavlink and Multiwii) and how to use them in models to make it possible for them to communicate with each other. Use the following list to refer to each topic:

 

navigation bar