Mistakes in Simulink simulation

Discussion in 'Programmer's Corner' started by el_cupido, Feb 15, 2010.

  1. el_cupido

    Thread Starter New Member

    Feb 15, 2010
    4
    0
    hi colleagues,

    I have some doubts about some mistakes when i run one program in Simulink.
    The problem is i'm not sure what produced these mistakes.
    The diagnostic say: "scope---out of memory" and "model error---"data logging exceeded available memory"...and others
    I guess that is because the step size is very small, and the true i dont have RAM enough...then how could i fix this problem??...how could i calculate the size of the step?...
    o the reason of my problems is others??...please help me!! i need deliver one project in one week!!

    attached the simulation diagnostics window
     
  2. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469

    This error is often the result of using scopes without decimating the data.

    For example, lets say your timestep is 1e-6, then each scope will be recording 1 million data items per second of simulation time. Some quick calculations will show you can run out of ram very easily.

    The scopes have a decimation control that allows you to record the data at a reduced same time. For example, setting DECIMATION to 1000 will result in a data point every 1 ms rather than every 1 us, in this example.
     
  3. el_cupido

    Thread Starter New Member

    Feb 15, 2010
    4
    0
    Hey thanks Steve!!...im not really an expert in simulink, but ur support helped me to correct those mistakes .. now i have another questions ... can i calculate exactly the number of samples can be taken to not saturate the memory of the scope ... or i must to try the found that value testing? ...
    another thing is about the simulation/configuration parameters/solver ...i have the step sizes "auto" u recommend to me choose a specific value? and there in "data import/export...save options" has the option to choose the "decimation" too...i must change this "decimation" too or not?
    And now the last question is, can i start a simulation of a function in t=20 sec for example? I say this cuz i have a subsystem that the initial conditions arent what i want, but i need its behavior after 20 sec ... then is possible start first this subsystem and after 20 sec start the complete system??....

    thanks for ur help again!
     
  4. steveb

    Senior Member

    Jul 3, 2008
    2,433
    469
    I think you can estimate it. I sometimes do that. The way I do it is to realize that 8 bytes are needed for every double precision number that you store. If you store both time and data in an array, then you have 16 bytes per datapoint. So, you can use the following formula to estimate.

    Num_Bytes=16*Nvariables*Tsim/Tstep

    where

    Num_Bytes is the number of RAM bytes needed
    Nvariables is the number of variable you store in ram
    Tsim is the simulation time
    Tstep is the time step

    What I don't know how to do is to estimate how much usable RAM you have available. You probably know how much RAM is installed on your computer, but I'm not sure how to estimate how much is being used by your operating system and other programs that are running. If you have 2 Gbytes of ram, you can probably safely say that over 1 Gbytes is available to you, but if you have 0.5 GBytes, you may find that your operating system needs much of this.


    I'm not an expert on this issue, but I can tell you what I typically do. I usually use the fixed time step solvers (ODE1 and ODE4 typcally) and I manually set the time step, rather than use auto. I just seem to run into fewer problems when I do this.

    As far as the number to use, it really depends on the response time of your system. Generally, you want to have the time step at least 1000 times smaller than the system response time. So if you have a 1 kHz type of system, you want 1 microsecond or smaller time steps. This rule is very approximate and you can experiment.

    For very simple systems and math problems the AUTO feature seems OK, but whenever I do complex physical system modeling, it just gets me into trouble.

    I've never used that before, but looking at it now, I'd say it's useful. It certainly is not required to use this feature, but it may be a nice convenience. I'm going to play around with this myself now that I'm aware of it.

    I'm not aware that you can start at any time other than 0, but it shouldn't be necessary. The time is relative. You can establish initial conditions by developing a model carefully. Look at any block you use to see if initial conditions are allows (for example delay elements and integrators). Often the intial condition is automatically set to zero, but you are allowed to change it to a number, or even a formula that can be calculated. Sometimes you can change an option so that the intial condition comes in as a block input, rather than a number in setup. This takes some experience, but it can be done easily once you get used to it.

    Before trying to implement a system with nonzero intial conditions, make sure you carefully write out all of the equations mathematically and carefully specify the intial conditon values or formulas that are physically correct. This is not always trivial to do.
     
    el_cupido likes this.
  5. el_cupido

    Thread Starter New Member

    Feb 15, 2010
    4
    0
    Hi Steve!...
    i'll try to use all ur advise...and if i have more doubts i'll post again!!

    Thanks man!
     
Loading...