From: Kamil on
Hello,

Somebody knows how I can introduce a derivative block to Simscape? There is PS integral block but I need something like that but as derivative. Somebody know how I can write a code for that block?

Regards,
Kamil
From: Kamil on
Finally I think I found a simple solution:

component derivative
% derivative

% Copyright 2005-2009 The MathWorks, Inc.

inputs
I = { 0, '1' }; % :left
end

outputs
O = { 0, '1' }; % :right
end

equations
O == I.der * { 1, 's' };
end

end

Any different ideas will be appreciate :)

"Kamil " <kamil.chodzynski(a)umons.ac.be> wrote in message <hmlv12$29g$1(a)fred.mathworks.com>...
> Hello,
>
> Somebody knows how I can introduce a derivative block to Simscape? There is PS integral block but I need something like that but as derivative. Somebody know how I can write a code for that block?
>
> Regards,
> Kamil
From: Kamil on
Sometimes I have problem to start more complicated system with this derivative. The compiler does want to take initial conditions. Any ideas how to improve it?

"Kamil " <kamil.chodzynski(a)umons.ac.be> wrote in message <hmm286$6es$1(a)fred.mathworks.com>...
> Finally I think I found a simple solution:
>
> component derivative
> % derivative
>
> % Copyright 2005-2009 The MathWorks, Inc.
>
> inputs
> I = { 0, '1' }; % :left
> end
>
> outputs
> O = { 0, '1' }; % :right
> end
>
> equations
> O == I.der * { 1, 's' };
> end
>
> end
>
> Any different ideas will be appreciate :)
>
> "Kamil " <kamil.chodzynski(a)umons.ac.be> wrote in message <hmlv12$29g$1(a)fred.mathworks.com>...
> > Hello,
> >
> > Somebody knows how I can introduce a derivative block to Simscape? There is PS integral block but I need something like that but as derivative. Somebody know how I can write a code for that block?
> >
> > Regards,
> > Kamil
From: Arnaud Miege on
"Kamil " <kamil.chodzynski(a)umons.ac.be> wrote in message <hmmcc0$f9q$1(a)fred.mathworks.com>...
> Sometimes I have problem to start more complicated system with this derivative. The compiler does want to take initial conditions. Any ideas how to improve it?
>
Can I ask why you would need a derivative block? Even in Simulink, it is generally not recommended to use the derivative block, because it creates numerical problems. It's better to express the equations so that you use integrator blocks instead. I would have thought that you wouldn't need to do that in Simscape. Can you explain a bit more what you are using the derivative block for? You can't specify an initial condition for a derivative block, only for an integrator, this is basic maths.

HTH,

Arnaud
From: Kamil on
Hello Arnaud,

I know that I cannot specify an initial conditions for a derivative. Maybe I was not precisely I wanted to put a value which allows to start calculations for example for 5th first iterations.

I am trying to calculate a piston pump with addition pipes, valves etc. My piston pump it is a linear motor, with a cylinder and a membrane. And by changing positions of the linear motor I apply a difference of volume. The simplest equation looks like:

Qin - Qout = Sdh/dt then Qout = Qin - Sdh/dt

where:

Qin = inlet flow
qout = outlet flow
S = surface of the piston
dh/dt - change position of the piston in time (velocity)
h - position

My control loop is in position therefore I need to put derivative.

My whole system includes many "pieces of equipment" such as pipes, valves, a check valve, a piston pump. Addition pipes I modelled as electrical equivalents (resistor, capacitor and inductance) even more the pipes are segmented and depends on conditions they are divided in smaller pieces. For example for 1 m pipe's length I need about 10 capacitors, 10 resistors and 10 inductances. It creates addition equations and it makes the system more heavier to calculate. Therefore as I have a Simulink Control Design toolbox I wanted to make linearisation of the system and find a transfer function of the system. Unfortunately the linearisation of my system does not go well. It cannot find a right transfer function of my system. I tried an estimation frequency response as well but it does not work either. I received different answers for both methods. I thought that problem is because I mix simulink
blocks with Simscape blocks therefore I wanted to avoid algebraic loops and put everything in Simscape environment.

How I know that a transfer function is not correct? I did it in my own way which is similar to estimation frequency response. I put sinusoidal wave to linear motor as position (input signal) and I read a flow rate as an output. I save data and in Matlab thanks to theoretical equation I found magnitude and phase for the system. I am trying to get the same with Simulink but it does not work. Therefore step by step I am trying to find where I made a mistake.

I hope I explain my problem a little bit better.

Thanks
Kamil

"Arnaud Miege" <arnaud.miege(a)nospam.mathworks.co.uk> wrote in message <hn2tob$465$1(a)fred.mathworks.com>...
> "Kamil " <kamil.chodzynski(a)umons.ac.be> wrote in message <hmmcc0$f9q$1(a)fred.mathworks.com>...
> > Sometimes I have problem to start more complicated system with this derivative. The compiler does want to take initial conditions. Any ideas how to improve it?
> >
> Can I ask why you would need a derivative block? Even in Simulink, it is generally not recommended to use the derivative block, because it creates numerical problems. It's better to express the equations so that you use integrator blocks instead. I would have thought that you wouldn't need to do that in Simscape. Can you explain a bit more what you are using the derivative block for? You can't specify an initial condition for a derivative block, only for an integrator, this is basic maths.
>
> HTH,
>
> Arnaud