04-19-2022 11:57 AM
Hello everyone
I need to do some calculations in a sinusoidal signal with 43kHZ, 200000 samples per second and 20000 samples.
For 1ms i have 200 samples and a overlap maximum of 50% so i develop two types of vi (based on other threads of community) but none of them have the desired behaviour.
In Teste Calculo RMS_teste.vi i have a method with calculation of RMS based on # of samples calculated for my desired integration time, but i can't do it with a overlap calculation.
In Teste CalculoRMS ARRAYS.vi i have a method with sampling a window and calc the RMS based on # of samples excluded with the window, but i need to do that calculation for various windows with the overlap set to the maximum of 50% of the values.
Someone have an idea how i can upgrade this VIs to my purpose?
Thanks in advance.
Solved! Go to Solution.
04-19-2022 12:55 PM - edited 04-19-2022 01:06 PM
Hi Simon,
@Simon_A wrote:In Teste Calculo RMS_teste.vi i have a method with calculation of RMS based on # of samples calculated for my desired integration time, but i can't do it with a overlap calculation.
@Simon_A wrote:
In Teste CalculoRMS ARRAYS.vi i have a method with sampling a window and calc the RMS based on # of samples excluded with the window,
Here several items apply again:
Why use the FXP datatype?
Why convert twice from DDT to 1D array?
Why are WindowStep/Length of DBL datatype when you want to handle integer samples/elements of the array?
Did you debug your VIs using probes and highlight execution?
@Simon_A wrote:
For 1ms i have 200 samples and a overlap maximum of 50% so i develop two types of vi (based on other threads of community)
Where do you applay that "50% overlap" in your VIs? There is no control/constant labelled similarly and no comment pointing to this requirement!?
Does that overlap apply in total or "50%" on both sides of your sliding window?
Why don't you simply apply the ArraySubset function on each 300 (or 400) samples of your array?
(Explanation: All those "Why…?" questions are intended to point you on parts of your code that needs to be improved. I tend to point people on (potentially) code errors instead of presenting a solution for free: this way most will easier/faster learn to write better LabVIEW code. So please don't take all those question as an offense, but as suggestions for improvement…)
04-19-2022 02:00 PM
Hello GerdW
@GerdW escreveu:(Explanation: All those "Why…?" questions are intended to point you on parts of your code that needs to be improved. I tend to point people on (potentially) code errors instead of presenting a solution for free: this way most will easier/faster learn to write better LabVIEW code. So please don't take all those question as an offense, but as suggestions for improvement…)
I appreciate your aproach and i'm compleatly cool with that. When i post something here is to think with some help and go through a solution with that. So i'm 100% with your approach.
A: My mistake, i think that in simple test programs it is possible to read the block diagram easy.
A: What do you mean with "glaring race condition"? I want that # of samples actualize if i change the integration time.
A: This isn't mandatory, but i only put that to execute the for entil end of the while loop, because the change in integration time in the mid of running
A: Here i only want to test the difference between de RMS calculation with RMS VI and RMS PtbyPt VI.
A: Honestly here i don't have idea why.
A: Only for test VIs because i think with RMS PtbyPt i can achive more easily the change in the integration time.
A: Because i think with PtByPt function i can change integration time and consequently change the # of samples in the sample length in of the VI.
A: Maybe i need to put it out of for loop. My itention is to initialize when i change integration time.
A: I think that PtByPt function need to run a for loop to calculate the RMS value of defined number of samples set by integration time. Am I wrong in that interpretation?
A: Ok, maybe i can put a wait function here to set a wait time.
Why use the FXP datatype?
A: Only because it is the output of signal generator.
Why convert twice from DDT to 1D array?
A: Only for test the difference between two VIs.
Why are WindowStep/Length of DBL datatype when you want to handle integer samples/elements of the array?
A: Ok, my mistake here. I need to correct this.
Did you debug your VIs using probes and highlight execution?
A: Yes, always.
Where do you applay that "50% overlap" in your VIs?
A: In this VI i don't have this overlap yet. My idea is the Window and the step define different sets of values which are calculated by the RMS VI and output the different values of RMS for different values of integration time (and number of samples).
There is no control/constant labelled similarly and no comment pointing to this requirement!?
A: Not yet.
Does that overlap apply in total or "50%" on both sides of your sliding window?
A: The goal is to put that in the two sides of window and the window moves in time (25% per side of window max). My idea is to have various windows in my set of data calculating each set of 200 samples (1ms integration time) with maximum limit of 50% of data overlaped (100 samples, 50 each side of window).
Why don't you simply apply the ArraySubset function on each 300 (or 400) samples of your array?
A: Maybe it's a better option, i will try.
The goal here is to acquire a large number of data in a train test, that data is writed in a TDMS file and then i will run that TDMS in a program where filtered and calculate the RMS with this requisits.
I will work in that VI's and made some changes with your inputs and i will comeback to you, but if you have more inputs to me i will apreciate.
Thank you so much.
04-20-2022 05:12 AM
Hello GerdW
I've made some changes in the VI for calculation the # of samples and to change it in the PtByPt function. But i have some doubts. The PtByPt VI, the RMS VI and the Amplitude and Level Measurements for RMS calculation have all the same value for RMS, but in the case of PtByPt i only have the calculation with # of samples (in that case 200) in the others i have 20000 samples. Why that value is the same in both VIs?
Now i'm going to correct and improve more to share with you.
04-20-2022 10:28 AM - edited 04-20-2022 10:34 AM
Hi André,
what's the point of placing another loop around the calculation of "#samples"?
Why do you still use a local variable of "#samples"? Why not use a simple wire to "OBEY DATAFLOW!"?
Do you really need a bandpass filter for 43kHz±0.15kHz?
Your simulated signal only comes with a Fs of 1kHz so you clearly miss the Nyquist criterion, when you want to create a 43kHz sine wave!!!
See this as inspiration:
04-20-2022 11:28 AM
@GerdW escreveu:
Hi André,
what's the point of placing another loop around the calculation of "#samples"?
Why do you still use a local variable of "#samples"? Why not use a simple wire to "OBEY DATAFLOW!"?
Do you really need a bandpass filter for 43kHz±0.15kHz?
Your simulated signal only comes with a Fs of 1kHz so you clearly miss the Nyquist criterion, when you want to create a 43kHz sine wave!!!
See this as inspiration:
Hi GerdW
I really need that filter, it is a imposition of european criteria for that calculation.
In concern of frequency of signal, i dont know why, when i save the vi, close and open again, the old values are reseted.
In other way i'm doing progress in the ARRAYS Calculation with overlap. Can you see and comment the new attached VI? Maybe it's near of purpose that i want, but know i'm stucked with doing that programatically and don't doing that with a million steps of blocks for splitting, deleting and Insert into arrays.
I appreciate very much your help and your time with that!
04-20-2022 01:24 PM - edited 04-20-2022 01:43 PM
HI André,
@Simon_A wrote:
Can you see and comment the new attached VI? Maybe it's near of purpose that i want, but know i'm stucked with doing that programatically and don't doing that with a million steps of blocks for splitting, deleting and Insert into arrays.
Well, whatever you define as "near"! 😄
See this for inspiration:
For all those array operations: I still don't see how that fits to your requirement of getting "overlapping subsets" of your array. You only use those "samples to retire"…
Can you describe the requirement with some pseudocode?
@Simon_A wrote:
In concern of frequency of signal, i dont know why, when i save the vi, close and open again, the old values are reseted.
When you want to set default values then you need to set default values!
Either right-click each control and use the context menu - or use the Edit menu to set all control values at once…
04-20-2022 02:11 PM
Hello GerdW
A: Well, i don't use ArraySubset because i want to throw away the first data that are out of overlap limit. For example, i'm building parts of arrays set up with at least 200 samples, when i go to the next 200 samples i need to have the 0% to 50% overlaped data plus the new set of 50% to 100% of the remaining elements in the original array, so i found easier to delete the data that i used in previous calculations.
A: Because i want to have 0% to 50% data of the previous array and 50% to 50% of the values in the new array. Basically i'm trying to do something like windows set by 200 samples which can be overlaped from 0% to 50% of the last values in the older array.
A: I need to do that, but i don't wonder how i can do it... I resume the code to six final values of RMS, but in the total i will have something like 150 or 200 sub arrays to calculate the RMS, depending on the overlaped setted up at the begining. Your image is clear and i'm sure that the fore cycle could help me. Tomorrow i will test it and get back to you with some news.
Thanks a lot for your help and your patience.
04-22-2022 09:45 AM
Hello GerdW
I was working on the code you sent to me and i noticed that the build array in connections needed to be changed. Otherwise i'm putting the first values of overlap in the end of the array i think.
I build a very simple VI attached here to debug that. Do you agree with that?
Although if i change that two connections, if i was reading 200000 samples per second, 20000 samples and arrays of 200 samples, the value of RMS is always the same and i don't have any clue why... (I think possible is for simulated waveforme that throw away the exact same values every period of 1ms).