Xcos CLOCK_c Period Setting

Hello,

Enclosed, please find a screenshot along with the xcos model.

I am seeking clarification on why the scope output varies with changes in the period time of CLOCK_c.

I’m unsure where my approach might be incorrect. The model with a period time of 0.001 aligns with my measured data, which was obtained with a sampling rate of 10 milliseconds.

I would greatly appreciate any insights or feedback. Thank you!

p = [0.1472152   13.846622   0.301877   3.]
xcos("X:\Period.zcos")

Period.zcos (4.1 KB)

Please increase the buffer of “To Workspace sim Variable”

I tried to compare my results between the Xcos Simulation and Scilab.
After you run the above simulation, it exports the data to the Workspaxe variable ‘sim’

Unfortunately the results do not fit. What is it, that I am doing wrong?

// run xcos Model in Scilab
importXcosDiagram("X:\Period.zcos")
typeof(scs_m) //The diagram data structure
scs_m.props.context //the embedded definition
xcos_simulate(scs_m, 4);

t=0:0.01:15;
p = [0.1472152   13.846622   0.301877   3.]
yfit = p(1)+p(2) * (1 - exp(-t / p(3))).^p(4); 

// sim variable created by the xcos model

//compare model with yfit function

plot2d(sim.time,sim.values)
plot2d(td,yfit,-1)

Hello, I might get it wrong but it looks ok to me.

With a 0.1 period made from scratch, I got:
image

With your schema and minor tweaks to render the same, I got:
image

They both looks alright to me. Might be different from the Scilab result which is not using a solver for dynamic systems.

Thank you, davidcl, for your insight. It’s now working for me as well.

Here’s the method I used:

I fitted some measurements using the following formula:
p = [0.1472152 13.846622 0.301877 3.]
yfit = p(1) + p(2) * (1 - exp(-t / p(3))).^p(4);

I then applied the Laplace transform to this function to develop the model shown in the Period.zcos (as mentioned in my initial post).

However, I’m puzzled as to why the results from the model don’t align with the yfit function.

Next, I plan to conduct tests using Matlab and also attempt to convert the function into StateSpace using Scilab.

Okay, i have to rethink the transfer function. Simulink online got the same result.

I am currently experiencing some confusion. It’s possible that I have incorrectly identified the transfer function. Could Scilab be used to generate the transfer function for the system’s behavior in the time domain? The equations are:

[ y(t) = p2 \times (1 - e^{-t/p3})^3 ]
[ TF = \frac{p2}{(1 + p3 \times s)^3} ]

There is defnitly something wrong in my Transferfunction. Hope to figure it out, soon. In the following I minimized the problem to a PT1 model system.

function PT1model()

    t=0:0.01:2;
    T1 = 0.2;
    K = 5;
    yfit = K*(1-exp(-t/T1));
    plot(t,yfit,'r-')
    
    s=poly(0,'s')
    g = K/(1+T1*s)
    g = syslin('c',g) // define tf
    gs = csim('step',t,g);
    plot(t,gs,'g-.');
    title('PT1model')
endfunction


function PT3model()

    t=0:0.01:2;
    T1 = 0.2;
    K = 5;
    yfit = K*(1-exp(-t/T1)).^3;
    plot(t,yfit,'r-')
    
    s=poly(0,'s')
    g = K/(1+T1*s)^3
    g = syslin('c',g) // define tf
    gs = csim('step',t,g);
    plot(t,gs,'g-.');
    title('PT3model')
endfunction

PT1model
PT3model

Hello,

Which is the target, the signal in the time domain or the transfer function ? Because the ones you have defined above cannot match. A product in the frequency domain amounts to a convolution in the time domain.

S.

I have analyzed the step responses from my measurements and discovered that the function
yfit = K*(1-exp(-t/T1)).^3;
accurately describes the behavior.

I am realizing now that I seem to have lost my expertise after what feels like 20 years of practice.

Perhaps I need to reformulate yfit in order to develop a PT3 model for the Laplace domain. I think I might have a conceptual error here.

1 Like

Sure, i’ve forgotten about this page. Thanks for the hint :slight_smile: