Jump to content


  • Content count

  • Joined

  • Last visited

About RoKet

  • Rank
    Advanced Member

Profile Information

  • Gender
  • Country
  • Are you University user?

Recent Profile Visitors

378 profile views
  1. RoKet

    Animated plot in 2D

    Thanks, L Moretti. That's a really cool and useful example with a time delay in drawing and repainting in different colors. BR, Ronald
  2. Hi Yugang, The model is setup with Activate 2019. Which version are you using? More information about the Modelica custom block and how to use it you can get from "Activate Extended Definitions", a pdf with very helpful information about Activate. It is linked in the help of the custom block (Activate Extended Topics Guide). BR Ronald
  3. RoKet

    Using C Block for Event Activation

    Hi Saurya, I misunderstood the function of evout. It is the relative time between current activation and output of activation (and not the signal itself as I supposed). Best regards, Ronald
  4. RoKet

    Automated simulation and capturing data

    Hi Syurya, I have no exact solution for your task, but look at the example "moonlanding_opt.scm" in Demo Browser, Activate, Games. The combination of elements in super block "next last" and "Restart" in "optimize" allows you to run a defined number of simulations. The ToCSV block overwrites the file at every new simulation . I suggested a modification to the development team, but expect it not before next release. You can try to write your own C block with fopen(filename, 'a') (or similar). It should be easier than the output of an event activation Best regards, Ronald
  5. Just a few seconds too late ...
  6. In palette ActivationOperations component SimulatorInfo. Possible infos are (according to help): step-size: provides last accepted step-size in the simulator. hot-restart: if the solver is [re]started forgetting all past memory about the solution. phase: the phase with which the model is called/evaluated. effective-time-tolerance: the real value of "Time-Tolerance" used by the simulator if it is set to AUTO Best regards, Ronald
  7. RoKet

    To base, From base block question

    My understanding of 'Base' blocks is: - if they are not activated externally 'To Base' writes its input at the end of simulation run, 'From Base' reads the value at the beginning of a simulation run - if 'A' isn't defined in base context (see Variable Browser), the default value is used (first simulation run, after that the variable is defined automatically) - in case of external activation you can exchange values at certain events. In contrast 'Signal In' and 'Signal Out' exchange their values permanently.
  8. RoKet

    Using C Block for Event Activation

    I don't know the exact solution, but you start with definition of numer of output event ports: If you generate the skeleton of the c function code you get: #include "vss_block4.h" VSS_EXPORT void CBlockFunction(vss_block *block,int flag) { SCSREAL_COP *in=(SCSREAL_COP *)GetInPortPtrs(block,1); int min=GetInPortRows(block,1); int nin=GetInPortCols(block,1); SCSREAL_COP *out=(SCSREAL_COP *)GetOutPortPtrs(block,1); int mout=GetOutPortRows(block,1); int nout=GetOutPortCols(block,1); int nevprt=GetEventCode(block); SCSREAL_COP *evout=GetNevOutPtrs(block); switch (flag){ case VssFlag_Initialize: break; case VssFlag_Reinitialize: break; case VssFlag_Terminate: break; case VssFlag_OutputUpdate: break; case VssFlag_EventScheduling: break; } } Now *evout is the variable to be used for the event, e. g. *evout = 1;. It has to be set with flag == VssFlag_EventScheduling. I try to set up a small example, where I set the output event depending on an input value (x > const), but the event occurs sometime, but not at the expected point of time. Here I need the help of someone else.
  9. I found the solution at one of Thierry's demo model. The optimization block is communicating with Base variables, but you can read these variables in the Model context using ModelContextVariable = GetFromBase('BaseVariable',1); or in your case k = GetFromBase('k',3); The variables may have the same name.
  10. I see. That's the typical task of optimizing a parameter e. g. of a controller. But I can't find a way to set a Model variable without beeing reset at next simulation run. My idea was to use "From Base" and "To Base" with optimization block and write the result back to model variable with the custom block. But the definition in Model scope overwrite every change of the variable at initialization. Does someone else know a solution?
  11. Hi Seoksan, 'From Base' has to be used with 'To Base', they form a kind or pair. The variable is placed in base scope, not in 'Model' scope. You can see the variable in the 'Variable Browser', whereas 'Model' variables are not visible in the 'Variable Browser'. The demos in 'tutorial_models - Extended_Book_Models - Chapter_5_Optimization' show the usage of design variables for optimization. I hope that helps, regards, Ronald
  12. RoKet

    Difference between "Model" and "Diagram"

    Hi Seoksan, The difference is in the visibility/accessability. Variables defined in 'Model' can be accessed from everywhere, variables defined in 'Diagram' can only be accessed in the corresponding context of the model or below. It's only important when you use Supercomponents, otherwise you just have one context in your model. Every Supercomponent has its own context. Regards, Ronald
  13. RoKet

    Floating FFT

    As I understand it, fft calculates a spectrum in one step using 2^n elements. Does someone know a function or have a macro to calculate a floating fft with a given size of the fft and an overlapping for moving the analyzed part and set off against each other with peak hold? Example: Data with size 1000, fft with size 512, overlapping 60% -> fft(Data(1:512)), fft(Data(205:716)), fft(Data(409:920)) Thanks, Ronald
  14. RoKet

    Calculate envelope of curve

    Thanks, Manoj. Min/max are the basic functions to calculate the envelope. While they just deliver one scalar, I have to combine them with a loop and a piecewise min/max calculation. I hoped, I could use an existing function (or macro). Best regards, Ronald
  15. I have a file with measured data f(t). The data are sinusoidal with changing amplitudes over time. Now I want to get the envelope of that data, i.e. floating peak-to-peak value or max. amplitude over time. How can I achieve this? Thanks, Ronald