From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate numerically the derivative in a timed loop at cRIO

Solved!
Go to solution

Hello,

 

I'm trying to calculate the time derivative of water level difference in a timed loop, with NI-9074 cRIO.

I'm measuring the water level from a water level sensor dynamically in a timed loop, which gives one value in one iteration, but I also want to check the rising speed of the water level at the same time, shown in numeric indicator.

 

To make this happen, I tried to use Derivative.vi and thought the current value should be stored to take the difference with the next value. The initial value and next value should also be updated. Can I have a good solution for this?

0 Kudos
Message 1 of 4
(1,050 Views)
Solution
Accepted by seannavis

The derivative of a variable - i.e. its rate of change - can be calculated in a variety of ways, and different formulas for the calculation. The different formulas are different approximations of the continuous derivative (i.e. the real-world rate of change) and have different levels of accuracy and time delay / phase shift. Which calculation is best depends on how fast you are sampling relative to how fast the varaible is changing, and what you are using it for, e.g. in a control loop phase shift may be important.

 

The most basic approximation of the derivative of a variable y and can be programmed very easily in a timed loop with a few maths functions:

 

derivative of y = ( y(k) - y(k-1) ) / Ts

 

where k is the current sample, k-1 is the previous sample and Ts is the time between successive samples.

 

Consultant Control Engineer
www-isc-ltd.com
0 Kudos
Message 2 of 4
(1,012 Views)

Thank you for your reply. I know the basic for the derivative, but applying the knowledge to my loop in vi is another problem.

Anyway, I use shift register to keep the previous step value and obtain what I wanted.

0 Kudos
Message 3 of 4
(996 Views)

Good. The first step on LabVIEW programming is always the most difficult.

Consultant Control Engineer
www-isc-ltd.com
0 Kudos
Message 4 of 4
(988 Views)