Project

General

Profile

Actions

Bug #412

closed

Simulink error: "[...] variable-size signal with a non-discrete sample time"

Added by Gianluca Corsini 23 days ago. Updated 16 days ago.

Status:
Closed
Priority:
Normal

Description

Hello,

I have encountered an error when using matlab-genomix and the genomix request block of the related Simulink library.

Here, the list of steps to reproduce the error.
- Take the genomix request block.
- Set the timings parameter value to either triggered(level) or triggered(rising edge).
- Select a request which takes at least one input argument.
- Add at least one of those input arguments to the list of signals. In this way, suitable input ports are added to the block.
- Feed a continuous-time signal to at least one of those input arguments.

The produced error is as follows:

The signal at 'port Output <N>' of '<block>' is a variable-size signal with a non-discrete sample time. The sample time for any variable-size signal must be discrete.

where <N> is the number of the output port associated to the port errmsg, and <block> the genomix request block raising that error.

The issue seems to be connected to the fact that the port errmsg has a variable size (see line 175 in genomix-mex.c) and the block sampling time is continuous, when the previous settings are used.

Reading line 205 of genomix-mex.c, the sample time is either set to INHERITED_SAMPLE_TIME, if the timings value is not periodic, or to a precise value (the one taken from the argument of the mask) if the timings is periodic.
In the first case (INHERITED_SAMPLE_TIME), Simulink takes as sampling time the one of the driving signals, ie those of the input ports. As at least one of them contains a continuous-time signal, then the sampling time is set internally to continuous.
In fact, if we replace the continuous-time signal with a discrete or infinite-time one, any problem arises.
Alternatively, to solve the issue, you can set the timings to periodic. This enforces Simulink to use a specific sampling time (see line 211 of genomix-mex.c), which is most likely treated as discrete.

Of course, this issue does not occur when using a port block because there are usually no input ports from which inheriting the sampling time.

This could cause a problem, if in future releases there would be the possibility to open and write to a port.

In attachment, you can find 3 Simulink files I realized for testing. Two show two working scenarios, while the third one shows the problem with the conditions listed above.

Here, a list of possible ideas I have to possibly fix this issue.
  1. Set the output port errmsg to be fixed-size. Being the output signal no more variable-size, Simulink can then use any sample time without problems. However, it requires to write every time 255 bytes in the output port, which is less performant than writing just the actual length of the error message of the genomix request.
  2. Use a discrete sampling time also in triggered mode. However, I think that this may create issues if the sampling time is not large enough to detect the triggers (high values) in the enabling signal. For instance, if the sampling time is 1s and in 1s the enabling signal transitions from low to high and then back to low, the block may not detect the trigger. So, this solution is not the best as the user should be aware of this aspect.
  3. Simply let the user be aware of this problem, and feed to the genomix blocks only discrete-time signals. In this case, Simulink provides a ZOH block that works well in discretizing continuous-time signals.

I have currently fixed this issue adopting solution no.1. If you like this strategy, you can find my fix at https://redmine.laas.fr/projects/matlab-genomix/repository/matlab-genomix/revisions/efe207a6a6b279636f114bdc7ccdb4b2367ebdbc


Files

test_working_2.slx (48.4 KB) test_working_2.slx Gianluca Corsini, 2024-04-25 16:57
test_working.slx (47.1 KB) test_working.slx Gianluca Corsini, 2024-04-25 16:57
test_not_working.slx (38.3 KB) test_not_working.slx Gianluca Corsini, 2024-04-25 16:57
clipboard-202405021104-wna0g.png (54.3 KB) clipboard-202405021104-wna0g.png Gianluca Corsini, 2024-05-02 11:04
Actions

Also available in: Atom PDF