LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resample/ interpolate/ decimate array

Solved!
Go to solution

Hi, I am confused about the function that I should use for my program (VI attached below). So here it is - I am using two incremental encoders to calculate semi period and from this the RPM of two gearbox shafts. The gearbox is run from the differential side with a dyno. To calculate the difference in the RPM of a shaft from the theoretical speed calculated from the motor rpm, a third encoder is used to determine the rpm of the motor. But the problem is that the shaft IRC gives 720 pulses as Semi periods but the motor IRC gives only 120 pulses. So I would like to convert this 120 to 720, i.e., get four readings between each pulse to get the equivalent. 1 to 2 of motor readings is equivalent to 1 to 6 readings of shaft IRC. I need to get the motor rpm re-sampled continuously in order to use that data to calculate the other stuff in other loops. I am not sure how to do this, so any suggestion of help would be really appreciated! 🙂 Thank you in advance!

 

P.S - The method that I have used in the VI to align and resample is the wrong one which needs modification.

0 Kudos
Message 1 of 7
(2,836 Views)

First you need to fix your VI, it is full of deadlocks and race conditions.

  • Your three loops cannot run in parallel, the upper two can only start when the lowest has stopped. You'll never get more than one iteration out of the upper two loops.
  • Pressing "save 2" (save? OK) during a run would lock up your VI forever, because the event structure cannot be reached.
  • You are resetting the various stop booleans via locals in parallel to running the loops. No telling what happens first.
  • It is confusing to have several objects name  "stop", just with different letter case.
  • Why is "gear" a floating point value? Ever tries to switch to gear 2.3? Gear should probably be an enum.

Resampling a signal is trivial but I wouldn't even try to implement it in your VI because of all the other issues. Can you create a small VI with only the two signals you need to align?

0 Kudos
Message 2 of 7
(2,812 Views)

@altenbach wrote:

First you need to fix your VI, it is full of deadlocks and race conditions.

  • Your three loops cannot run in parallel, the upper two can only start when the lowest has stopped. You'll never get more than one iteration out of the upper two loops.
  • Pressing "save 2" (save? OK) during a run would lock up your VI forever, because the event structure cannot be reached.
  • You are resetting the various stop booleans via locals in parallel to running the loops. No telling what happens first.
  • It is confusing to have several objects name  "stop", just with different letter case.
  • Why is "gear" a floating point value? Ever tries to switch to gear 2.3? Gear should probably be an enum.

Resampling a signal is trivial but I wouldn't even try to implement it in your VI because of all the other issues. Can you create a small VI with only the two signals you need to align?


I changed the gear value to enum and re-did the stop also, but I could not remove one of them because I need both the loops to stop at the same time. I can directly wire it but in case my number of loops increase, local variable would be simpler. Please let me know if you have any alternative to this. For the save, I will try to modify it somehow. Also, if I have to run the three loops in parallel, how do I do it? I figured out that my upper loop is wrong but as mentioned above, I need instantaneous values of resampling data. 😞 I could not figure it out at all and that's the main issue I am facing now.

 

I'll get 6 readings in the lower loop within the time span of 1 reading in the upper most loop. But I need the resampled reading of the upper loop at the same time I get readings in the lower loops because only then other simultaneous calculations can be done. Can you suggest me what can be done, please?

0 Kudos
Message 3 of 7
(2,778 Views)

As I said, you need to remove the wired data dependency between the loops so they can run in parallel. Once you fixed all that, we can talk about the alignment.

0 Kudos
Message 4 of 7
(2,776 Views)
Solution
Accepted by topic author raghav06

@raghav06

I changed the gear value to enum and re-did the stop also, but I could not remove one of them because I need both the loops to stop at the same time. I can directly wire it but in case my number of loops increase, local variable would be simpler. Please let me know if you have any alternative to this.


Use one control bool element inside Loop 1, use a read local variable of that bool element in loop 2 and loop 3

 


@raghav06Also, if I have to run the three loops in parallel, how do I do it? I figured out that my upper loop is wrong but as mentioned above, I need instantaneous values of resampling data. 😞 I could not figure it out at all and that's the main issue I am facing now.

 

I'll get 6 readings in the lower loop within the time span of 1 reading in the upper most loop. But I need the resampled reading of the upper loop at the same time I get readings in the lower loops because only then other simultaneous calculations can be done. Can you suggest me what can be done, please?


Don't do that:

dontdothis.PNG

 

You may want to read this NI article about Queues and the Producer Consumer Pattern:

http://www.ni.com/white-paper/3023/en/

Message 5 of 7
(2,759 Views)

@alexderjuengere wrote:

@raghav06

I changed the gear value to enum and re-did the stop also, but I could not remove one of them because I need both the loops to stop at the same time. I can directly wire it but in case my number of loops increase, local variable would be simpler. Please let me know if you have any alternative to this.


Use one control bool element inside Loop 1, use a read local variable of that bool element in loop 2 and loop 3

 


@raghav06Also, if I have to run the three loops in parallel, how do I do it? I figured out that my upper loop is wrong but as mentioned above, I need instantaneous values of resampling data. 😞 I could not figure it out at all and that's the main issue I am facing now.

 

I'll get 6 readings in the lower loop within the time span of 1 reading in the upper most loop. But I need the resampled reading of the upper loop at the same time I get readings in the lower loops because only then other simultaneous calculations can be done. Can you suggest me what can be done, please?


Don't do that:

dontdothis.PNG

 

You may want to read this NI article about Queues and the Producer Consumer Pattern:

http://www.ni.com/white-paper/3023/en/


Thank you! I got the idea behind it 🙂

0 Kudos
Message 6 of 7
(2,742 Views)

@altenbach wrote:

As I said, you need to remove the wired data dependency between the loops so they can run in parallel. Once you fixed all that, we can talk about the alignment.


Thank you for the suggestion! 😄 I removed the interconnecting wires now. Do you have any other method for the resampling?

0 Kudos
Message 7 of 7
(2,740 Views)