LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion from PSD to SPL

Solved!
Go to solution

Hello everyone,

 

 I have created a VI which converts PSD value to SPL. Formula used to convert PSD to SPL is 

 

SPL=10log(PSD/P^2) where P=2*10^-5

 

Problems facing:

1. Outer while loop is not terminating even if the condition is true? please refer the attachment( it has comments in block diagram to understand my VI, probe window)

2. Is my VI correct?

 

Please share your thoughts. Let me know if you need anymore explaination

 

Thanks in advance 

 

0 Kudos
Message 1 of 7
(6,504 Views)

Unfortunately you (very large) screen shot doesn't actually show the logic for stopping the outside loop.

 

Unless the problem is caused by the decrement of the array size. If the array size is 0, it will decrement to -1 which might cause the comparison (that you don't show) to fail and keep the loop running.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 7
(6,489 Views)

Its my bad, sorry for that.

 

My array size is not zero. I am away will attach it on wednesday

 

Thanks

0 Kudos
Message 3 of 7
(6,479 Views)

I attached 'vi' and screenshot of problem. 

 

1. Outer While loop is not terminating even though condition is true

2. Is there any direct conversion from PSD to SPL in Labview

 

 

Outer while loop keep tracks of number of channels selected. Here I am  displaying mutliple signals in real time.   
Inner while loop runs for (Sampling Rate * Block Length/2) times

 

 

 

Thanks

Download All
0 Kudos
Message 4 of 7
(6,426 Views)
Solution
Accepted by topic author Jagadeesh_1990

Are you sure the inner loop is stopping? The outer loop cannot stop until the inner llop has completed. The fact that the termination condition is true may simply mean that the condition was evaluated before the inner loop completed.

 

Since you did not save the input arrays with typical default data, we cannot run your VI. When using comparisons in while loops for stopping the loops, using Greater Than or Equal? or Less Than or Equal, depending on the logic, is much safer than just Equal? For example running the VI you posted (with empty input arrays) results in -1 at the array size -1 input to the Equal? comparisons in both loops. So neither loop will ever stop. Since you are only comparing to the size of the arrays, use a for loop with autoindexing.

 

Using Insert Into Array is almost always not the best way to do whatever you are trying to do and using Build Array in a loop results in multiple memory re-allocations as the array grows. Initialize the array to the final size (or something larger than the largest expected size if the exact size is not known) and use Replace Array Subset inside the loop.

 

(10^(-5)*2)^2 =  4E-10. Rather than recalulate this velu on every iteration of the inner loop, place a constant on the blockd diagram. Use a descriptive label or free label to describe how it is derived if that is significant. If it is necessary to calculate something which will never change while the program is running, move the calculation outside all loops.

 

I suspect that the code in the image below does everything you attempt to do in your VI.

 

Lynn

 

PSD to SPL.png

Message 5 of 7
(6,402 Views)

Thank you for elaborate explaination. It is perfectly working.

 

I am new to labview and I am implementing as I do in programming language (PL). Labview is different from what I do in PL. I will improve on memory efficiency areas.  

 

0 Kudos
Message 6 of 7
(6,375 Views)

NI has on-line tutorials available to help people get started with LabVIEW. I recommend that you work through some of them. They may help you understand the differences between LV and text-based programming languages.

 

Lynn

0 Kudos
Message 7 of 7
(6,364 Views)