08-16-2012 01:50 PM
Hello all,
I have a code that is outputting our Power Spectral Density (PSD) from an FFT. A frequency is input and then stepped at a user input value. I would like to find the PSD difference between each frequency step. Attached is what I would like to happen. To avoid any confusion, I don't want to output a file that looks like that. I just want to display the "delta" column as an indicator on the front panel so I can monitor my change in PSD. I don't need the whole array, just the delta between the current iteration and the previous iteration. I've tried using a loop with shift registers, but I'm unsure of where to go from there. I figured that since shift registers pass data from loop to loop, that I could output the value before it went into the next iteration, but I'm having no luck. Any help is appreciated. Unfortunately, I am unable to post code due to company policy. I know this makes things much more difficult.
Thanks.
Solved! Go to Solution.
08-16-2012 02:02 PM - edited 08-16-2012 02:07 PM
Hi,
This is a method to use shift registers to analyse consecutive iterations. You can replace with any analysis process. Pull down on a regular shift register to store previous iterations of data ( it makes the second register box appear).
You might want to do more with the initial values. If you want to do the analysis post process, then the solution is a loop reading the array and you can specify the indices and so no shift register needed.
08-16-2012 02:11 PM
@Szklanam wrote:
Hello all,
I figured that since shift registers pass data from loop to loop, that I could output the value before it went into the next iteration, but I'm having no luck. Any help is appreciated. Unfortunately, I am unable to post code due to company policy. I know this makes things much more difficult.
Thanks.
Shift Registers Don't pass data from loop to loop, they pass data from iteration to iteration for the loop. If you have two loops running parallel use 'Que's based (e.g. producer consumer) architecture. If the loops are running sequentially, then you can use the shift register on the first loop that executes to store all the data at the output tunnel of that loop. Use that data as an input to the next loop, and use auto indexing to perform operation on each point.
It is very difficult to diagnose the problem without a vi. If this doesn't solve your problem post a anapshot of vi or something that is similar to what you are doing and may be we can help.
08-16-2012 02:36 PM
I feel dumb. I meant to say iteration to iteration seeing as I'm only dealing with one loop for this question anyway 😛 but thank you for the suggestions. I will try them and see how they work.
08-17-2012 07:51 AM
The suggestions didn't seem quite right, but I have found a way to do it. Attached is the way I did it.
08-17-2012 08:08 AM
Why didn't you just put the shift registers on the FOR loop and remove the while loop? That would be a lot simpler.
08-17-2012 10:02 AM
08-17-2012
10:08 AM
- last edited on
05-20-2025
10:23 PM
by
Content Cleaner
A feedback node might make your life a little simpler.
08-17-2012 02:41 PM
What you have posted looks like the program already has the data and you are feeding it to a one run loop that only holds the shift register to store the values. If you already have the data you can use arrays.
If you are creating the data and then comparing to the previous iteration you can use the shift registers as I put above in a while loop or in a for loop. The only reason I put dice outside the loop was to init the shift registers.
Feedback nodes work fine too, you can put them in a loop and attach the initial values to the loop edge.
08-17-2012 04:24 PM
@Szklanam wrote:
The suggestions didn't seem quite right, but I have found a way to do it. Attached is the way I did it.
Be careful, your solution may work the first time but you have an uninitialized shift register. This may cause you problems if theis loop gets executed multiple times. An uninitialized shift register will remember the value from the last time the loop was executed, not just the last iteration.
Also, you mentioned some scary things in your post regarding your code. It sounds like your code could use some cleaning up. Sequence structures, large amount of code before/after, etc are the types of comments made regarding poorly designed code. If you code requires more than a screen to display it is most likely in dire need of some cleanup.