2
$\begingroup$

I have a continuous state space model for dc motor. I get a wrong step response when I use continuous model and I get the right response when I discretize the model using a different method. Can anyone solve this problem?

enter image description here enter image description here

(* Defination of state space matrix  *)
       A = {{-833.3 ,-25.18} , {5193 ,-7.145}}   ;
       B = { {303.03},{0}}  ; 
       c={{ 0 , 60/(2*\[Pi])  }}; 
       d= {{0}} ; 
(* Response to 12 volt supply ( Analog ) *)
   ssmC= StateSpaceModel[{A, B, c, d } ]
   Res=OutputResponse[ssmC , 12 , t ]   ;
   PlotA=Plot[ {Res}, {t,0, 15 },PlotLabel-> {" step Response "}, PlotRange-> 1500] 



(* Response to 12 volt supply (ZOh) *)

   DssmZoH= ToDiscreteTimeModel [ssmC , 0.020 ,Method -> "ZeroOrderHold"]

   Res  = OutputResponse[DssmZoH ,12*UnitStep[n], n ]

   PlotB= DiscretePlot[{ Res },{n,0,80} , PlotLegends -> {"ZoH " }, PlotRange-> 1500] 

(* Response to 12 volt supply (FD) *)
   add= {{1,0} , {0,1}} + 0.0020*A 
   ddd= 0.0020*B 
   ssmC=StateSpaceModel[{add, ddd , c, d },SamplingPeriod->0.0020 ]  
   Res6=OutputResponse[ssmC ,12*UnitStep[n], n ] ; 
   PlotC= DiscretePlot[{ Res6 },{n,0,40} , PlotLegends -> {"Forword diff" }, PlotRange-> 1500] 
$\endgroup$
2
$\begingroup$

I am not convinced that the above behaviour is expected, but here is what works. Rationalize the State-Space matrices and then use WorkingPrecision option inside Plot.

A = Rationalize[{{-833.3, -25.18}, {5193, -7.145}}, 0];
B = Rationalize[{{303.03}, {0}}, 0];
c = {{0, 60/(2*\[Pi])}};
d = {{0}};

ssmC = StateSpaceModel[{A, B, c, d}]
Res = OutputResponse[ssmC, 12, t]

PlotA = Plot[{Res}, {t, 0, 15}, PlotLabel -> {" step Response "}, 
  PlotRange -> 1500, WorkingPrecision -> 20]

enter image description here

$\endgroup$
1
$\begingroup$

I agree with @Lotus. I think he has a good general solution to this issue. I answer here only to suggest what went wrong.

On version 12, I get a different, but also wrong, result in the plot of the continuous model.

(*Defination of state space matrix*)
A = {{-833.3, -25.18}, {5193, -7.145}};
B = {{303.03}, {0}};
c = {{0, 60/(2*\[Pi])}};
d = {{0}};

(*Response to 12 volt supply (Analog)*)
ssmC = StateSpaceModel[{A, B, c, d}];

Res = OutputResponse[ssmC, 12, t]

enter image description here

I paste an image above so we can see the form of the output response.

(* Plot returns a wrong result *)

PlotA = Plot[{Res}, {t, 0, 15}, PlotLabel -> {" step Response "}, 
  PlotRange -> 1500]

enter image description here

But we see that for values of t greater than about 1, we encounter underflow:

(* due to underflow *)

Res /. t -> 1

enter image description here

(* simplifying Res brings the problem within the available precision *)

Res2 = Res // Simplify

enter image description here

Res2 /. t -> 1

 (* {1318.999525814868`} *)

PlotA2 = Plot[{Res2}, {t, 0, 15}, PlotLabel -> {" step Response "}, 
  PlotRange -> 1500]

enter image description here

So I suggest that underflow was the root problem, and that the answer by Lotus provides a good general solution.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.