LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mass-Spring-Damper System and PID using difference equation in a formula node

Estoy intentando simular un controlador y la planta en simulink usando ecuaciones en diferencias. Este método se usa comunmente en arduino para implementar el PID y quiero hacer una simulación en Labview. En Simulink calculé Kp, Ki y Kd. Los datos de mi planta son: m=1 b= 4.5 k = 3. Así, la función de transferencia es:

1/(ms^2+bs+k)

Usando el PID tuner de MATLAB calculé Kp= 3368.5 Ki = 336.1 y Kd = 75.5

Quiero usar un tiempo de muestreo de 0.1 s o 0.01, siempre y cuando sea menor a 0.3s esta bien. He probado varios tiempos y la simulación no me da, siempre diverge cuando la hago en LAbview pero en simulink me funciona tanto en discreto como en contínuo. No sé si el problema sea por la forma en la que estoy haciendo la conexión de las variables o los shift registers mal puesto. Agradezco la ayuda y ojalá explicandome para entender que estoy haciendo mal. Muchas gracias, compartiré el archivo en anexos.

0 Kudos
Message 1 of 2
(101 Views)

@Marianita1212 wrote:

I'm trying to simulate a controller and the plant in Simulink using difference equations. This method is commonly used in Arduino to implement the PID, and I want to run a simulation in Labview. In Simulink, I calculated Kp, Ki, and Kd. My plant data is: m=1 b=4.5 k=3. Thus, the transfer function is:

1/(ms^2+bs+k)

Using the MATLAB PID tuner, I calculated Kp=3368.5, Ki=336.1, and Kd=75.5.

I want to use a sampling time of 0.1 s or 0.01 s; as long as it's less than 0.3 s, it's fine. I've tried various times, but the simulation doesn't work. It always diverges when I run it in Labview, but in Simulink, it works in both discrete and continuous modes. I don't know if the problem is due to the way I'm connecting the variables or the incorrectly placed shift registers. I appreciate the help and hopefully some explanations so I can understand what I'm doing wrong. Thank you very much. I'll share the file in the attachments.


If you place a Loop Frequency VI inside the loop, you will find out that the actual loop rate is just 4Hz. 

The formula node executes very slowly. You should replace the formula nodes with entire G code.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
0 Kudos
Message 2 of 2
(50 Views)