Table of Contents
Circular Buffer Write
Writes to a circular buffer.
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/Advanced/Asynchronous')Description
The Circular Buffer Write block writes to a circular buffer. Unlike the FIFO Write block, there may be any number of Circular Buffer Write blocks in the model, all referring to the same circular buffer. However, be aware that it can be difficult to discern which Circular Buffer Write block last wrote to the circular buffer if the buffer is written to from multiple threads. Multiple Circular Buffer Write blocks are typically only used in conditionally-executed subsystems within a single thread, or at different stages within the execution of an asynchronous thread.
To read from a circular buffer, use the Circular Buffer Read block. It is also possible to clear the contents of the circular buffer using the Circular Buffer Clear block.
The Circular Buffer Write block is more flexible than the FIFO Write block. It may be configured to discard the input data if the circular buffer is full, after a timeout interval, or it may be configured to overwrite the oldest data in the buffer with the new data instead. The timeout interval may be zero, in which case the block never waits for space to become available. Or, the timeout may be infinite, in which case the block will wait indefinitely for space to become available whenever the circular buffer becomes full. If the block is configured to overwrite the oldest data in the buffer in the event the buffer is full then it will not do so until the timeout interval has expired.
Input Ports
data
The data to write to the circular buffer.
Output Ports
This block has one optional output port: an overflow flag.
over
An overflow flag. This boolean flag is normally false (0), but will go high (1) if there is no space left in the buffer when the block attempts to write the value of its input signal to the circular buffer. It will go low again the next time the block succeeds in writing to the circular buffer without overwriting other data.
Data Type Support
This block supports any data type at its input.
Parameters and Dialog Box
Go to Circular Buffer blocks using this buffer
Opens a dialog that lists all the Circular Buffer blocks in the model which are currently using the same interface selected in the Buffer name parameter. The dialog may be used to go to another Circular Buffer block in the model just by double-clicking on the name of the block in the dialog box.
Buffer name
The name of the circular buffer. This list of buffer names is derived from all the Circular Buffer Initialize blocks in the model.
Timeout
The amount of time in seconds to wait for enough space to become available in the circular buffer to write the data at the block's input to the buffer. The timeout may be zero, in which case the block does not wait. The resolution of the timeout depends on the resolution of the system timer. For the Windows target, the resolution is only one millisecond.
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.
A sample time of -1 indicates that the block inherits its sample time from its input.
To use the fundamental sampling time of the model, set the sample time to qc_get_step_size, which is a QUARC function that returns the fundamental sampling time of the model.
The default sample time is set to -1 because this block is typically used in a Function Call Subsystem attached to a Asynchronous Thread block.
Output overflow flag
If this option is checked then the block is given an extra output called "over" that indicates when the circular buffer has overflowed. Overflow occurs when the Circular Buffer Read block fails to read the circular buffer before the buffer becomes full. Whether the input is discarded or overwrites the oldest data in the circular buffer in this situation is determined by the Overwrite oldest data if no space available parameter.
Overwrite oldest data if no space available
If this flag is checked then the block will allow the circular buffer to "wrap" and overwrite the oldest data in the buffer if the buffer is full and the timeout expires. If this option is not checked then the new data is discarded when the buffer is full instead.
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.