0
\$\begingroup\$

I have a mathematical model of two dynamic systems which I need to implement in PLC, but I don't know how to implement differential equations in structured text language. Any suggestions on that will be helpful.

I have been thinking of converting differential equations to difference equation, but I don't have any idea how to do this.

$$\ddot{\Theta}=\dfrac{1-K_d\cdot\dot{\Theta}}{J} \tag {1} $$

$$\dot{i} = \dfrac{1}{L}(V-K_g k_f \dot{\Theta}-R i) \tag {2}$$

theta_dot_dot = 1/J*(1 - Kd*(theta_dot)) -------> Equation 1
i_dot = 1/L*(V - (Kg)(kf)(theta_dot) - R*i) --------> Equation 2

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Post the equation to be converted. (Hit the edit link below your question.) It might not be possible. What brand and model of PLC too. \$\endgroup\$
    – Transistor
    Jan 28, 2020 at 18:20
  • 3
    \$\begingroup\$ There are some things that PLC's are not really geared towards, such as multi-dimensional systems modeling. The best thing to do is to use something geared towards running this in C or Matlab and using a connector (some Fieldbus implementation) to tell the PLC what to do with the physical IO. \$\endgroup\$
    – Ron Beyer
    Jan 28, 2020 at 18:35
  • \$\begingroup\$ Almost the same as in C, even more similar is turbo pascal. There is also a PLC coder option in MATLAB. Show the equations of your system first, then make express them in Z-transform,... \$\endgroup\$ Jan 28, 2020 at 20:33
  • \$\begingroup\$ @Transistor Im using OpenPLC and I will have to use that model in structured text language. \$\endgroup\$
    – Rajesh10
    Jan 28, 2020 at 21:28
  • \$\begingroup\$ @RonBeyer I have modelled the system with PID controller in Simulink and it is working there. But I don't know how to write the equivalent one in structured text. \$\endgroup\$
    – Rajesh10
    Jan 28, 2020 at 21:30

1 Answer 1

1
\$\begingroup\$

$$\ddot{\Theta}=\dfrac{1-K_d\cdot\dot{\Theta}}{J} $$

$$J\ddot{\Theta}+K_d\cdot\dot{\Theta}-1=0 $$ $$\ddot{\Theta}+\dfrac{K_d}{J}\cdot\dot{\Theta}-\dfrac{1}{J}=0 $$ Discriminant : \$ \dfrac{K_d^2}{J^2} -\dfrac{4}{J}\$ is it positive?

$$\dot{i} = \dfrac{1}{L}(V-K_g k_f \dot{\Theta}-R i)$$

$$i = \dfrac{1}{L}\int(V-K_g k_f \dot{\Theta}-R i)dt$$ You solve the second equation with trapz rule.

$$Sample_{act}=\dfrac{1}{L}(V-K_g k_f \dot{\Theta}-R i)$$ $$i = i+\dfrac{1}{2}\cdot T_{sample}\cdot (Sample_{act}+Sample_{old})$$ $$Sample_{old}=Sample_{act}$$

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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