Engee documentation

Signal processing by frames and samples

Terms used.
  • Calculation step (Sample time) is the time of a single data item.

  • Time step (Time step) is the time interval after which the solver updates calculations and model states.

  • Sample period (Sample period) is the time interval between consecutive measurements or data items.

  • *Sample is a single value resulting from the sampling of a signal.

    • In sample-based processing, a data item is a single value corresponding to a specific point in time defined by a calculation step.

    • In frame-based processing, a data item is a single value within a set of values collected during a sampling period and processed as a single frame.

Sample-based processing

Sample-based processing - signals are processed one data element at a time. This processing is characterised by data updates at each time step, which corresponds to the sampling period. Time step is equal to the Sample period, denoted as . Sample rate is defined as the inverse of the Sample period, i.e. - meaning that data is updated and processed at each step .

Sample-by-sample processing is better suited for real-time systems that require an immediate response to each new data measurement. Examples of such systems are:

  • Audio processing

  • Real-time monitoring

Frame-based processing

Frame-based processing - signals are processed in frames, where each frame contains multiple data elements. Frame-based processing updates the data at each time step equal to the frame period. The frame period is defined as the product of the number of elements in the frame ( ) by the sampling period, i.e. . Accordingly, Frame rate is equal to the sampling rate divided by the number of elements in the frame: - this allows processing large amounts of data in one time step.

Frame-by-frame processing is efficient for processing large amounts of data. Examples of usage:

  • Fourier transform

  • Digital filtering

  • Image and video processing

Comparison of sampling and frame-by-frame processing

For clarity, see the figure that shows an example of sample-by-sample and frame-by-frame signal processing:

based processing 1

Comparison table

Processing by counts

Processing by frames

  • Provides more detailed customisation of the operating logic by accurately processing each data element.

  • It is optimal for working with real equipment that requires precise control of memory and time intervals.

  • It is used at the stage of model realisation after its testing on frame-by-frame processing.

  • Code generation is fully supported by real systems such as FPGAs (FPGAs).

  • Suitable for the final stage of development where high accuracy and optimisation is required.

  • Suitable for prototyping and rapid algorithm development.

  • The model is represented in large blocks, making it more readable and easier to understand.

  • Processes frames in their entirety, making testing and debugging easier.

  • Suitable for the initial stage of development and demonstration of the system operation.

  • More often used for implementation on microcontrollers, where simplicity and speed of development are important.

Thus, it is recommended to start development with frame-by-frame processing, as it is convenient for rapid prototyping and demonstration of the system operation. Due to its simplicity and speed of development, frame-by-frame processing makes it easy to test and tune algorithms without worrying about the complexities of memory handling. Once one is satisfied that the algorithms and models are working correctly, one can move to frame-by-frame processing. This processing, although more complex to implement, provides the high accuracy and optimisation needed to deal with physical systems that require detailed signals and memory interactions. This approach allows you to maximise the benefits of both methods at different stages of development.

Examples

Build a model from blocks:

  • DSP Sine Wave - supplying a discrete sine wave.

  • Terminator - block closes the output port.

  • Buffer - forcibly stores the specified number of data elements in one frame. Block Buffer forcibly processes the signal frame-by-frame.

  • Unbuffer - forcibly turns any number of frames into samples. With the Unbuffer block, the signal is forced count-by-counts.

  • Enable signal recording signal logging 1 at the output of blocks DSP Sine Wave, Buffer and Unbuffer.

  • For clarity in the settings window lk 5 in the tab Debugging enable:

    • Line dimensions

    • Signal sampling rate

    • Highlighting

      sample frame based model 1

Set the following block parameters:

  • At block DSP Sine Wave

    • Sample time to 0.1;

    • Samples per frame to 5.

  • For block Buffer

    • Output buffer size (per channel) to 6.

  • Blocks Unbuffer and Terminator have no configurable parameters. In the settings window, the simulation interval and solver selection remain by default.

Run a simulation of the model start simulation button. The graphs will show the changes in the sine signal over time. The X axis represents the simulation time interval from 0 to 10 seconds, and Y shows the value of the sine wave. Then the graph window stateflow graphs button will display:

sample based buffer 1

The graph shows the result of the Buffer block, which forcibly stores the specified number of data elements in one frame. Each frame contains six data items, represented by coloured lines on the graph. These lines represent the state of each element in the frame.

The horizontal stepped sections of the lines show how the values of the data items remain constant during each frame. The values are updated every 0.6 seconds, which corresponds to the frame update interval (6 data items * 0.1 sec/item = 0.6 sec). The Buffer block groups the data items into 6 pieces and displays them as a single frame in which each colour corresponds to a particular data item.

In this example, count-by-colour processing is chosen, even though the Buffer block forcibly stores the data items into a single frame. This is done to demonstrate how the block works and to display each data item separately.


frame based unbuffer 1

The graph shows the output of the Unbuffer block, which turns any number of frames into samples. Each frame containing 6 data elements is split into individual data elements and passed to the output of the Unbuffer block one at a time. The resulting graph shows successive data elements of a sinusoidal signal returned to the original discrete form.

The graph is staggered because the values of the data elements change every 0.1 seconds. This corresponds to the time step specified for generating the sine signal. Consequently, the Unbuffer block converts the frame-by-frame signal back to a count, which illustrates the inverse process of data buffering.

To switch the graph from counts to frame-by-frame display, click the button Signal Menu signal menu 1 button in the top menu of the graph window and select Time domain frame frame based icon 1.

Thus, frame-by-frame and count-by-frame processing can affect the presentation and processing of signals in different ways. The Buffer block converts samples into frames, grouping data elements and making processing more efficient for tasks that require processing groups of data simultaneously. The Unbuffer block returns frames back to the samples format.