LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

derivative problem

Solved!
Go to solution

Hi everyone, 

 

I'm trying to derivate an edge-counting-signal using the derivative x(t) PtByPT VI. The problem is that I want dt to be exactely 1 second. It seems that setting the dt-Input to 1 doesn't mean that dt = 1 second. However, the derivative worked perfectely when I added a wait-function to my programm and set 1 second as waiting-time. It seems that the programm take the value I set in the wait function as "dt" of my derivative VI ? 


Now my problem is that my wait function dramatically delays the data-logging. 

 

any suggestions?

 

best regards 

 

 

Download All
0 Kudos
Message 1 of 14
(2,448 Views)

@Ezzow wrote:

 It seems that setting the dt-Input to 1 doesn't mean that dt = 1 second. However, the derivative worked perfectely when I added a wait-function to my programm and set 1 second as waiting-time. It seems that the programm take the value I set in the wait function as "dt" of my derivative VI ? 


Now my problem is that my wait function dramatically delays the data-logging. 


The dT you provide the derivative should match the real dT.

 

If you set it to 1 s, the dT should be 1 s.

 

If your dT isn't 1 s, derivative doesn't magically start working at 1 s (it is PtByPT, so each input has an output).

 

You can:

a) make a parallel loop that takes derivatives every 1 s, with a current value from the other loop,

b) provide the derivative with the real dT (time - previous time).

 


@Ezzow wrote:

I'm trying to derivate an edge-counting-signal using the derivative x(t) PtByPT VI. The problem is that I want dt to be exactely 1 second.


You need to explain this...

 

If you want dT to be exactly 1 s, you should sample at 1 s.

 

You can set dT to exactly 1 s, but the output will be wrong (unless dT is 1s).

 

In the end, the derivative is simply (x - x previous) / dT...

0 Kudos
Message 2 of 14
(2,438 Views)

@wiebe@CARYA

 

Thank you for your reply 😊

 

I tried to use parallel while loops but they didn't work simultaniously when any kind of data is transfered from one to anther loop. Did I miss something by doing this? 

 

It would be great if you could add another loop in my VI so I understand how it actually works. 

 

best regards 

ezzow 

0 Kudos
Message 3 of 14
(2,432 Views)

@Ezzow wrote:

I tried to use parallel while loops but they didn't work simultaniously when any kind of data is transfered from one to anther loop. Did I miss something by doing this? 


Probably. Hard to say without seeing any code.

 


@Ezzow wrote:

It would be great if you could add another loop in my VI so I understand how it actually works. 


We'd first need to know (and understand) your goal.

 

If you want 1 s derivatives, why would you sample faster?

 

If you don't need 1 s derivatives, why not use the actual dT?

 

If you want to split loops, why split the DAQ and derivative? Why not split the 2 DAQ devices?

0 Kudos
Message 4 of 14
(2,385 Views)

@wiebe@CARYA

 

If you want 1 s derivatives, why would you sample faster?

 

If you don't need 1 s derivatives, why not use the actual dT?

 

I think you're right. My dt must be the real dt. Please forget about what I said about 1s. I think it was just a random value. 

 

My goal is to calculate a normal derivative: (X(i+1) - X(i)) / dt  

 

So I need the actual dt. That's why I tried the attached solution. Now my dt must be real. However, the part my X(i) is not saved after every iteration so I can build the difference (X(i+1) - X(i)). With this my X(i) is always equal 0. 

 

how can I save my X(i) ? 

 

If you want to split loops, why split the DAQ and derivative? Why not split the 2 DAQ devices?

 

Because the wait functions delays my data logging. If I split the 2 DAQ devices I have to put the wait function in their loop. Which will delays the data. 

 

 

0 Kudos
Message 5 of 14
(2,374 Views)
Solution
Accepted by topic author Ezzow

@Ezzow wrote:

@wiebe@CARYA

 

If you want 1 s derivatives, why would you sample faster?

 

If you don't need 1 s derivatives, why not use the actual dT?

 

I think you're right. My dt must be the real dt. Please forget about what I said about 1s. I think it was just a random value. 

 

My goal is to calculate a normal derivative: (X(i+1) - X(i)) / dt  

 

So I need the actual dt. That's why I tried the attached solution. Now my dt must be real. However, the part my X(i) is not saved after every iteration so I can build the difference (X(i+1) - X(i)). With this my X(i) is always equal 0. 

 

how can I save my X(i) ? 


wiebeCARYA_0-1665403211455.png

With a shift register (or feedback node).

 

 

0 Kudos
Message 6 of 14
(2,364 Views)

@Ezzow wrote:

If you want to split loops, why split the DAQ and derivative? Why not split the 2 DAQ devices?

 

Because the wait functions delays my data logging. If I split the 2 DAQ devices I have to put the wait function in their loop. Which will delays the data. 


If you have two DAQ loops, they can both run independent of each other. You wouldn't need waits, both DAQ loop can run as fast as they want.

 

Both loops would simply publish their most recent value, and another (3rd) loop could run any paste and get the most recent value.

 

But if you want them time synchronized, you wouldn't need two loops.

0 Kudos
Message 7 of 14
(2,361 Views)

Ezzow_0-1665403815143.png

 

I don't see from this picture where my X(i) output is? ( I'm quite new to labVIEW 🤓)

 

I only see how to calculate the real dT which I already did in the programm in my last reply (see attachement) 

0 Kudos
Message 8 of 14
(2,352 Views)

I got your point. But I want them synchronized 

0 Kudos
Message 9 of 14
(2,350 Views)

It worked perfectely with the feedback node. Many thanks @wiebe@CARYA 

 

However, I would like to understand how you did it with the screenshot you sent 😄 

Message 10 of 14
(2,330 Views)