Thread Subject: Using finite signals in Simulink

Subject: Using finite signals in Simulink

From: Justin

Date: 4 Nov, 2009 02:05:22

Message: 1 of 4

We are using simulink in order to play a finite file. We converted an audio file into a sample and time array and are using the from workspace simulink block in order to upload the needed data. However, before we can see the data on a scope, the signal has already passed through the system, and therefore we cannot see anything but 0. What we want to do is to essentially trigger the sending of the signal whenever we so choose (i.e. a switch). However, whenever we use a switch the signal is sent in the background. Is there a way to permanently save the signal from workspace into the simulink model and then trigger it when we want it to send? We have already attempted to use an embedded matlab function in order to load the data from workspace but it gives an error about command duality.

Subject: Using finite signals in Simulink

From: Idin Motedayen-Aval

Date: 4 Nov, 2009 23:02:09

Message: 2 of 4

Justin wrote:
> We are using simulink in order to play a finite file. We converted an audio file into a sample and time array and are using the from workspace simulink block in order to upload the needed data. However, before we can see the data on a scope, the signal has already passed through the system, and therefore we cannot see anything but 0. What we want to do is to essentially trigger the sending of the signal whenever we so choose (i.e. a switch). However, whenever we use a switch the signal is sent in the background. Is there a way to permanently save the signal from workspace into the simulink model and then trigger it when we want it to send? We have already attempted to use an embedded matlab function in order to load the data from workspace but it gives an error about command duality.

Justin,
Three things come to my mind:
1. Why don't you set the "From Workspace" block to "Cyclic repetition"
after the data runs out?
2. If cyclic repetition is not an option, you can use an enabled
subsystem (i.e. put the source block inside an enabled subsystem, and
enable that subsystem when you need the data to be sent).
3. If you have Signal Processing Toolbox, you can read audio files
directly using a "From Wave file" or "From multimedia file" blocks.

btw, Embedded MATLAB is probably complaining because you're using a
syntax like this:
load foo.mat
This is a command-line type syntax that is not allowed; you must use
function-style syntax for everything:
load('foo.mat')
And if you use load, remember to declare the "load" function as
eml.extrinsic since it's not supported natively in Embedded MATLAB.

HTH,
Idin

--
Idin Motedayen-Aval
The MathWorks, Inc.
zq=[4 2 5 -15 -1 -3 24 -57 45 -12 19 -12 15 -8 3 -7 8 -69 53 12 -2];
char(filter(1,[1,-1],[105 zq])), clear zq

Subject: Using finite signals in Simulink

From: Justin

Date: 5 Nov, 2009 04:05:36

Message: 3 of 4

On Nov 4, 3:02 pm, Idin Motedayen-Aval
<run.signat...@MATLAB.for.email> wrote:
> Justin wrote:
> > We are using simulink in order to play a finite file. We converted an audio file into a sample and time array and are using the from workspace simulink block in order to upload the needed data. However, before we can see the data on a scope, the signal has already passed through the system, and therefore we cannot see anything but 0. What we want to do is to essentially trigger the sending of the signal  whenever we so choose (i.e. a switch). However, whenever we use a switch the signal is sent in the background. Is there a way to permanently save the signal from workspace into the simulink model and then trigger it when we want it to send? We have already attempted to use an embedded matlab function in order to load the data from workspace but it gives an error about command duality.
>
> Justin,
> Three things come to my mind:
> 1. Why don't you set the "From Workspace" block to "Cyclic repetition"
> after the data runs out?
> 2. If cyclic repetition is not an option, you can use an enabled
> subsystem (i.e. put the source block inside an enabled subsystem, and
> enable that subsystem when you need the data to be sent).
> 3. If you have Signal Processing Toolbox, you can read audio files
> directly using a "From Wave file" or "From multimedia file" blocks.
>
> btw, Embedded MATLAB is probably complaining because you're using a
> syntax like this:
> load foo.mat
> This is a command-line type syntax that is not allowed; you must use
> function-style syntax for everything:
> load('foo.mat')
> And if you use load, remember to declare the "load" function as
> eml.extrinsic since it's not supported natively in Embedded MATLAB.
>
> HTH,
> Idin
>
> --
> Idin Motedayen-Aval
> The MathWorks, Inc.
> zq=[4 2 5 -15 -1 -3 24 -57 45 -12 19 -12 15 -8 3 -7 8 -69 53 12 -2];
> char(filter(1,[1,-1],[105 zq])), clear zq

thanks for replying. I have tried all of your suggestions. However,
the from .wav file block is not compatible with the mpc555 blockset
that we are using (this will be placed on an embedded system).
Additionally, the cyclic repetition is not an option since the signal
needs to be triggered by an input (logical 1). The enabled system
seemed promising, however, the signal still sends out even if it is
not enabled ( once it is triggered, it stays at a zero output).
However, when the trigger was left on and then the simulation was
carried out, the audio signal played as usual, however we could not
trigger it. We tried the embedded matlab function, but it will not
allow us to output the values located in the loaded file it returns an
error telling us that the output is not numeric. Is this a problem
with syntax?

Subject: Using finite signals in Simulink

From: Shane

Date: 20 Nov, 2009 01:20:36

Message: 4 of 4

I had the same issue and just figured it out. Here's the solution:

Assuming a fixed step solver...

1) Add your time and data vectors into a lookup table.
2) Feed the lookup table with an enabled subsystem (where the enable
signal is your "trigger").
3) On your Enable block, set "states when enabling:" to "reset" so
that each time the enable signal goes high, the waveform is replayed
from the beginning.
4) In the enabled subsystem,
     - add a constant block that is set to you system's timestep
     - feed the constant block into a discrete time integrator (set to
accumulator mode)
     - feed the integrator block into the subsystem's output

The enabled subsystem outputs a signal equal to the time elapsed since
the last time the enabled signal went high.

--Shane



On Nov 4, 9:05 pm, Justin <enigma.dark....@gmail.com> wrote:
> On Nov 4, 3:02 pm, Idin Motedayen-Aval
>
>
>
> <run.signat...@MATLAB.for.email> wrote:
> > Justin wrote:
> > > We are using simulink in order to play a finite file. We converted an audio file into a sample and time array and are using the from workspace simulink block in order to upload the needed data. However, before we can see the data on a scope, the signal has already passed through the system, and therefore we cannot see anything but 0. What we want to do is to essentially trigger the sending of the signal  whenever we so choose (i.e. a switch). However, whenever we use a switch the signal is sent in the background. Is there a way to permanently save the signal from workspace into the simulink model and then trigger it when we want it to send? We have already attempted to use an embedded matlab function in order to load the data from workspace but it gives an error about command duality.
>
> > Justin,
> > Three things come to my mind:
> > 1. Why don't you set the "From Workspace" block to "Cyclic repetition"
> > after the data runs out?
> > 2. If cyclic repetition is not an option, you can use an enabled
> > subsystem (i.e. put the source block inside an enabled subsystem, and
> > enable that subsystem when you need the data to be sent).
> > 3. If you have Signal Processing Toolbox, you can read audio files
> > directly using a "From Wave file" or "From multimedia file" blocks.
>
> > btw, Embedded MATLAB is probably complaining because you're using a
> > syntax like this:
> > load foo.mat
> > This is a command-line type syntax that is not allowed; you must use
> > function-style syntax for everything:
> > load('foo.mat')
> > And if you use load, remember to declare the "load" function as
> > eml.extrinsic since it's not supported natively in Embedded MATLAB.
>
> > HTH,
> > Idin
>
> > --
> > Idin Motedayen-Aval
> > The MathWorks, Inc.
> > zq=[4 2 5 -15 -1 -3 24 -57 45 -12 19 -12 15 -8 3 -7 8 -69 53 12 -2];
> > char(filter(1,[1,-1],[105 zq])), clear zq
>
> thanks for replying. I have tried all of your suggestions. However,
> the from .wav file block is not compatible with the mpc555 blockset
> that we are using (this will be placed on an embedded system).
> Additionally, the cyclic repetition  is not an option since the signal
> needs to be triggered by an input (logical 1). The enabled system
> seemed promising, however, the signal still sends out even if it is
> not enabled ( once it is triggered, it stays at a zero output).
> However, when the trigger was left on and then the simulation was
> carried out, the audio signal played as usual, however we could not
> trigger it. We tried the embedded matlab function, but it will not
> allow us to output the values located in the loaded file it returns an
> error telling us that the output is not numeric. Is this a problem
> with syntax?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink Justin 3 Nov, 2009 21:09:05
signal control Justin 3 Nov, 2009 21:09:05
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com