Table of Contents
LED Strip Simulation
Simulates an LED strip.
Library
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/Devices/Third-Party/Displays')Description
The LED Strip Simulation block simulates an LED strip. It implements a server which is designed to communicate with an LED Strip block. The outputs of the LED Strip Simulation block are the LED colors generated by the LED Strip block.
To identify the communications protocol with which to communicate with the LED strip, the block takes a URI as an argument or as an input. Universal Resource Identifiers (URI), such as tcpip://localhost:18000?nagle=0, are used by QUARC for all its communications because it provides a uniform, extensible and flexible means of identifying the communication protocol to use and the associated communication parameters. Refer to Universal Resource Identifiers for more information.
The URI may be specified in the dialog parameters or via an input port. Which option is used is determined by the Source of URI parameter. When the URI is specified via an input, the input is typically driven by a Model Argument block, which allows a model argument to be used to assign the URI at runtime.
If the URI is specified via an input port, the LED Strip Simulation block only samples the input when the model is first started. Hence, the URI cannot be changed while the model is running. |
The number of input ports depends on the Source of URI parameters. If the Source of URI parameter is set to or then no uri input is provided. Refer to the documentation on these two parameters below for more details.
The block can output either a 3xN matrix or three vectors. To have vector outputs, check the Vector outputs option in the dialog parameters. For vector outputs, the three outputs represent the red, green and blue components of the LED colors respectively. For a matrix output, each column represents the red, green and blue components of the LED color for the LED corresponding to that column.
The maximum number of LEDs in the strip is specified via the Maximum number of LEDs parameter. The size of the output is equal to the maximum number of LEDs.
The data type of the output(s) determines how the color components are interpreted. The supported data types are double, single, uint8, uint16, uint32 and boolean. For the floating-point types, color component values range from 0.0 to 1.0. For the unsigned integer types, color component values range from 0 to the maximum unsigned integer value for that type. Boolean values are interpreted as either 0.0 or 1.0 so only primary colors will be achievable in that case.
Use the Initial values to specify the color of all the LEDs when the model starts. The last element of each vector will be used for the remaining LEDs if the vectors are shorted than the maximum number of LEDs. The vector elements are expected to be color component values according to their data type, just like the outputs. Typically, these parameters are doubles so the color components should range from 0.0 to 1.0.
Helpful Hints
Firewall
If remote clients will be communicating with the server then be sure to configure the server machine's firewall to allow incoming access on the port being used.
Input Ports
uri
A string specifying the URI upon which to listen and service client connections. The string
must be a null-terminated vector of characters represented as a vector of uint8
quantities.
It may be variable-sized. This string is typically provided either directly or indirectly by a
Model Argument
block or String Constant block.
This input is only available if the Source of URI parameter is
set to External input port
. Refer to the documentation below on the
Source of URI parameter for details.
Output Ports
colors
A 3xN matrix signal containing the color components for each LED, where N is the maximum number of LEDs. The first row contains the red color component, the second row the green and the third row the blue color component. Each column contains the color for the corresponding LED in the strip. This output is only available when the Vector outputs option is unchecked.
r
A vector containing the red color component for the corresponding LED. This output is only available when the Vector outputs option is checked.
g
A vector containing the green color component for the corresponding LED. This output is only available when the Vector outputs option is checked.
b
A vector containing the blue color component for the corresponding LED. This output is only available when the Vector outputs option is checked.
new
Indicates whether new colors have been received since the last sampling instant.
Data Type Support
The output(s) may only be double, single, uint8, uint16, uint32 or boolean signals.
Parameters and Dialog Box
LED type
The type of LED strip.
Source of URI
Indicates whether the URI should be determined from the dialog parameters or an
input port. If this field is set to Specify via dialog (do not evaluate)
then
the URI is specified via the URI
parameter. In this case, the URI is not evaluated as a MATLAB expression but is
interpreted as a literal string. However, format specifiers are recognized. Refer
to qc_perform_substitutions
for a list of the format specifiers available.
If format specifiers which change frequently, such as '%{time}' or
'%{instance}', are used in the URI then the LED Strip Simulation block cannot be placed
in a referenced model, because the URI will change from the time the code is built to when
the code is run. As a result, Simulink will insist that the code be rebuilt because block
parameters in referenced models are inlined. Instead, specify the source of the URI as
External input port
and pass the URI from the top-level model. Use a
String Constant block
in the top-level model to generate the URI.
If this field is set to Specify via dialog (evaluate)
then the URI is also specified
via the URI parameter. However, in this case,
the URI is evaluated as a MATLAB expression. This option is convenient for using a variable
in the MATLAB workspace for the URI.
If this field is set to External input port
then the URI
parameter is ignored and an extra input port is provided which determines the URI.
URI (tunable offline)
Identifies the URI upon which to listen. This parameter identifies the communication protocol
and associated parameters. For example, a URI of tcpip://localhost:18000
will cause the LED Strip Simulation block to use TCP/IP and listen for connections on port
18000. This field is only used if the Source of URI
parameter is set to Specify via dialog (do not evaluate)
or Specify via dialog (evaluate)
.
Refer to Universal Resource Identifiers for
more information about URIs and the communications protocols supported by QUARC.
Initial values / Red (tunable offline)
The red component of the color to which the LEDs are set when the model starts. If fewer elements are provided than the maximum number of LEDs than the last element provided is used for the remaining LEDs. The vector elements are expected to be color component values according to their data type, just like the outputs. Typically, these parameters are doubles so the color components should range from 0.0 to 1.0.
Press the browse button next to the edit field to add a color using a color dialog.
Initial values / Green (tunable offline)
The green component of the color to which the LEDs are set when the model starts. If fewer elements are provided than the maximum number of LEDs than the last element provided is used for the remaining LEDs. The vector elements are expected to be color component values according to their data type, just like the outputs. Typically, these parameters are doubles so the color components should range from 0.0 to 1.0.
Press the browse button next to the edit field to add a color using a color dialog.
Initial values / Blue (tunable offline)
The blue component of the color to which the LEDs are set when the model starts. If fewer elements are provided than the maximum number of LEDs than the last element provided is used for the remaining LEDs. The vector elements are expected to be color component values according to their data type, just like the outputs. Typically, these parameters are doubles so the color components should range from 0.0 to 1.0.
Press the browse button next to the edit field to add a color using a color dialog.
Sample time
The sample time of the block. A sample time of 0 indicates that the block will be treated as a continuous time block. A positive sample time indicates that the block is a discrete time block with the given sample time.
To set the sample time to the fundamental sampling time of the model, use the qc_get_step_size function, which is a QUARC function that returns the fundamental sampling time of the model. The fundamental sampling time of the model is the sampling time entered in the Fixed step size field of the Solver pane of the Configuration parameters dialog. This is the default.
Vector outputs
Check this option to enable the color components to be output using separate red, green and blue vector outputs. If this option is unchecked then colors are specified using a single 3xN matrix output.
Active during normal simulation (tunable offline)
Indicates whether this block should execute during normal simulation. If this option is not checked then the block will not write to the LED strip during normal simulation. Note that the LED strip must be connected to the host PC to drive the display during normal simulation so this option is usually unchecked.
Output data type
The data type of the color output(s). For the floating-point types, color component values range from 0.0 to 1.0. For the unsigned integer types, color component values range from 0 to the maximum unsigned integer value for that type. Boolean values are interpreted as either 0.0 or 1.0 so only primary colors will be achievable in that case.
Targets
Target Name |
Compatible* |
Model Referencing |
Comments |
---|---|---|---|
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
Last fully supported in QUARC 2018. |
|
Rapid Simulation (RSIM) Target |
Yes |
Yes |
|
S-Function Target |
No |
N/A |
Old technology. Use model referencing instead. |
Normal simulation |
Yes |
Yes |
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.