06-08-2016 06:29 AM
Hi.
I am testing the frequency response of a device by using a function generator and an oscolloscope. The way I am doing it is as follows.
1. Generate Signal.
2. Wait an ammount of time for signal to settle on the scope.
3. Read level from oscilloscope and display.
4. Repeat.
I am using 1 second between each sample which makes it very slow. I have heard that using the the error lines is a much better way to do it. I always thought the error lines for each device should be kept seperate but I have seen some examples where the errors are merged.Can this be sped up by combining the error wires or is there a better way.
Thanks,
Mark.
06-10-2016 11:24 AM
Hello,
My name is Hakon I’m an application engineer at National Instruments. I have been looked into your problem. Am I correct in understanding that the issue is the time each iteration takes, but that your code is working except for this?
In the for loop in the “start” : Value Change event, you have functions in your while loop that is currently set to 1000ms. Since you root an array with 41 elements into the for loop, the start event will take at least 41 seconds. Does it take approximately this long, or does it take longer than that?
The Tick Count (ms) node is useful to check how long different parts of your vi takes to execute.
If the start event takes about 41 second, I would suggest reducing the wait time to check how long your signal needs to settle.
The error wires shouldn’t have a big impact on the execution time.
Kind Regards
Hakon
06-13-2016 03:42 AM
Hi Hakon.
Yes the code works fine except for the time it takes. The execution of each part of code is not a real concern but more with the hardware so I have to add a delay between writing to the fgen and reading from the scope. So I would use the error wire to control signal flow. It would be like that shown in the image below except that I am not sure how to handle the error in the close blocks. Or does it matter that they are all contained within one error wire?
Mark.
06-13-2016 04:28 AM
If you need delay between your signal generation and oscilloscope reading, try to use the sequence structure in between as follows and remove the delay which is given for the whole loop.
06-13-2016 04:34 AM - edited 06-13-2016 04:35 AM
Hi Mark,
on the former suggestion:
That's the reason why most advanced LabVIEW programmers have their own copy of "Wait" in their user-lib as a subVI with errorIO connectors. You even find this in the OpenG collection…
On your BD image:
- You should not put such a loop in an event case. Cases should be handled rather fast (within milliseconds)!
- You should not have "default if unwired" tunnels in the event structure: it's bad when references get lost!
- Why don't you use FormatIntoString to build your "WAVFREQ" string?
- Why do you create an array with just one element to wire it to your chart? Why not wire the scalar value to the chart?
- Using AutoCleanup from time to time would be nice too! 😉
06-14-2016 10:14 AM
Why would one have thier own wait vi when there is an abundance of time related vi's within labview. What is the advantage of that?
06-14-2016 10:27 AM - edited 06-14-2016 10:27 AM
06-15-2016 08:50 AM
@GerdW wrote:
That's the reason why most advanced LabVIEW programmers have their own copy of "Wait" in their user-lib as a subVI with errorIO connectors. You even find this in the OpenG collection…
I've seen a lot of code in my career where a programmer puts in a wait VI and assumes it occurs at the correct time in the code. If beginner programmers see those connectors in the primitive, it may make them think "data flow".
I too have created my own wait subVI. It seems like such an easy task for NI to add the IO connectors to the primitive rather than have us "advanced LabVIEW programmers" create their own subVI.