01-07-2021 07:41 PM
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?
Solved! Go to Solution.
01-08-2021 05:12 PM
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.
01-13-2021 12:24 PM - edited 01-13-2021 12:25 PM
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.
01-13-2021 03:31 PM
Good. The first step on LabVIEW programming is always the most difficult.