Frequency Response Analyzer with Bode Plots

Post discussions on applications you are writing
Post Reply
John Jebb
Newbie
Posts: 0
Joined: Fri Mar 20, 2015 9:02 am

Re: Frequency Response Analyzer with Bode Plots

Post by John Jebb »

Hi Aaron,

I found that if I set the lowest frequency to say 1Hz, the program generated a few lines in the log and then stopped with a fault message.
"Fatal error. Data capture timed out"

I then raised the lowest frequency and tried again and again till it worked.
When I got to 8Hz the program worked OK.

It did not matter whether I had AC or DC coupling on the scope.

For the application I have, 8Hz is OK. In future it may not be.

Thanks for your help.

Regards

John

hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Post by hexamer »

Thanks for the extra info - it definitely helps narrow down the problem. Since the PS4000 driver supports callbacks, I think the possibilities are (1) ps4000RunBlock may not be reliable in calculating timeIndisposedMs, or (2) WaitForSingleObject() does not implement its timeout accurately. I put a timeout safety factor of 1.5x on it, so I'm not sure what's going on. But to get a better clue, if you can spare the time, a simple way to debug this would be the following: try starting a FRA execution with a lower value of 1 Hz. As soon as you see a message saying something like this: "Status: Capturing X samples (16 cycles) at Y Hz takes Z sec.", start a timer. Then, stop the timer when you get the message: "Fatal error. Data capture timed out".

Please send the messages in the log as well as your timer value. Depending on the relationship between "Z" and the timer, it should help narrow it down further.

However, I will also say that when I tested this on my scope I was reminded that in this scenario Z should be about 16 seconds (16 cycles at 1 Hz). However, my scope's library is reporting 27.1 seconds. In this case however, reporting times higher than expected is safe. If the calculated times in your system are less than 16 seconds, then I could see a problem.

John Jebb
Newbie
Posts: 0
Joined: Fri Mar 20, 2015 9:02 am

Re: Frequency Response Analyzer with Bode Plots

Post by John Jebb »

Hi Aaron,

I noticed a few other things...

1/ There is a 'Tools/Calibrate' menu item. It does not appear to do anything.

2/ There is a 'Tools/Options' menu item. It does not appear to do anything.

3/ Is it possible to pre-set the vertical db scale by hand?
The program selects the vertical scale for you so that if the frequency response is flat, the program attempts to give you a magnified scale.
If you run the program with a slightly different device under test, you get a different scaling so cannot directly compare.
Just a thought...

Regards

John

hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Post by hexamer »

Feedback is much appreciated!

With respect to the first two items, they are not implemented yet. For #2, the alternative for now is to edit the xml configuration files directly (while the application is shutdown). There is some explanation of this in the Wiki. Unfortunately some of the parameters are really only documented in the code for now. I'll put together some documentation for those. In the meantime, feel free to ask.

I might not have explained this in the Wiki, but as of v0.3b there are a couple of means to change the plot scale. You can use the mouse to left click and drag a zoom rectangle in the plot area. Or, you can single left click in the plot area and it will present a dialog box with scaling options. Also, at the end of the day, if the on-screen plotting is still not meeting your needs, there is the option of exporting the data and using your own plotting tool.

Thanks again!

zolkow
Advanced
Posts: 0
Joined: Sun Apr 12, 2015 9:36 am
Location: Hungary

Re: Frequency Response Analyzer with Bode Plots

Post by zolkow »

Hello Hexamer!

First of all: I can't tell how much I appreciate this kind of works :) Actually I thought the PicoScope software has a built-in function for measuring such characteristics... but not really.

My problem: I try to use your program with my newly bought 2204A, but the plot always looks like it was sampled only random noise... :| I tried it with just connecting the probes+output wire together, and with real DUT too, and with very narrow freq settings, where the plot should have been quite simple, I even tried to edit the XML to get some result (I've read your instructions), but no success.
I 've read here that the 2204A is a bit different to the other members of the 2000 family, but I'm sure the hardware could do what I want: make some audio range bode plots..

Could you help me, what am I doing wrong?
I don't have any C or other SW IDE, so I can't build my own executables.

thanks in advance.

hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Post by hexamer »

Hello and thanks for the feedback.

As of v0.3b, the 2204A is now a supported scope, meaning that I've added the code to support it - but it's still untested, so thank you for giving a report. Back on post #2: topic14311.html#p42225 a user reported that he was trying it with a 2204A. But I didn't hear back, so maybe the code updates in 0.3b never worked.

If you could supply the log messages from the log in the application window, I can take a look and see if anything looks suspicious.

In the circumstance where you connect input to output, it actually may be expected that the plot looks noisy. In such a scenario, the gain should be 0dB and phase shift 0 deg. Due to actual noise these will be slightly off from 0/0. Because the application auto-scales the plot, this small noise looks amplified.

For the other DUT, is it something as simple as an RC filter? Can you check it out in the PicoScope Application to ensure that the I/O signals look as you would expect?

Finally, one potentially useful setting the the XML file for this situation is to turn on time domain plots. User DausB reported that turning on that setting caused the application to crash. So, maybe I broke something recently - I haven't tried that setting in a while. Did you try it? If you can get time domain plots, then at least we can see what the time domain data really looks like.

Again, thank you!

zolkow
Advanced
Posts: 0
Joined: Sun Apr 12, 2015 9:36 am
Location: Hungary

Re: Frequency Response Analyzer with Bode Plots

Post by zolkow »

Thanks for replying,
I tried the time domain setting too, but my copy crashed as well... It started sampling, but quit without an error message (I don't remember if it was right after starting the meas. or when finishing it).
If I got home, I'll post some screenshots and the log.
The plot always looked odd, as instead of 0 dB I got some random peaks at +/- 10-15dB, and the same with the phase line.. The circuit was also a simple preamp, set to ~flat response, so it still shoul have been around 0 dB.

zolkow
Advanced
Posts: 0
Joined: Sun Apr 12, 2015 9:36 am
Location: Hungary

Re: Frequency Response Analyzer with Bode Plots

Post by zolkow »

here's the screenshot and the log:
http://basszusmuhely.hu/picoscope/FRAdebug.zip

it was a simple 1:2 resistor divider, which should give a flat -6dB plot.

hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Post by hexamer »

Yes, given the circuit you described that graph definitely looks wrong - just as you described :) However, the log looks totally correct - the range seeking looks right, and the sampling numbers all look right. The range numbers are consistent with a 2x attenuation of a 2Vpp signal. I think next steps should be to look at the time domain plots, so I'll work on fixing that diagnostic feature. Just in case I have any problems reproducing it, could you tell me more about how it crashes? Does the app just disappear, or is there a dialog box with crash information? Thanks for the help!

zolkow
Advanced
Posts: 0
Joined: Sun Apr 12, 2015 9:36 am
Location: Hungary

Re: Frequency Response Analyzer with Bode Plots

Post by zolkow »

Hi!

I just tried it: after finishing the plot the program immediately quits (disappears), without any dialog box.

hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Post by hexamer »

Please nevermind my question about how it crashes. I see you answered it above. Since it seems to crash without a message my guess is that it's a problem with how I'm using plplot. For many cases, when plplot has an error, it calls abort(). I added code to support more graceful error handling for the main plotting feature but not for the time domain plots.

hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Post by hexamer »

I think I found the problem with diagnostic time domain plots. And if I'm right, thankfully it won't require an application code change to fix. The application tries to store the diagnostic plots in a subdirectory of the application's data directory called "diag". E.g. On my Win7 machine, this is: C:\Users\Aaron\Documents\FRA4PicoScope\diag. When I wrote the installer, I forgot to create this directory. I must have manually created it on my machine - the reason why I don't see the problem when I debug. If you also manually create this directory you might be able to get the diagnostic plots. They'll be files named something like stepXtryY.svg in the diag directory.

zolkow
Advanced
Posts: 0
Joined: Sun Apr 12, 2015 9:36 am
Location: Hungary

Re: Frequency Response Analyzer with Bode Plots

Post by zolkow »

OK, I'll try that as soon as I get back home.

zolkow
Advanced
Posts: 0
Joined: Sun Apr 12, 2015 9:36 am
Location: Hungary

Re: Frequency Response Analyzer with Bode Plots

Post by zolkow »

I created the directory, but the program keeps jumping out without any log written. :(

I don't have any other scopes at home, but with a DMM I checked the AC signal, it should be fine, compared to the manual AWG setting in the factory program.
(btw. the output doesn't stop even after the "plot" is done)
I think there must be something with the sampling or the peak detection, as the autorange doesn't seem to find the right setting. It keeps trying, even if it should be already high enough for the signal.
(of course I'm just guessing, but it's strange that a 1V p-p input signal is too high for the +/-1V input range.)
Or is the "autorangeTolerance" setting responsible for that?

anyway, here's my private mail, if you find it more comfortable: *myusername* at gmail...

Z.

hexamer
Advanced User
Advanced User
Posts: 5
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Post by hexamer »

Hmmm. Maybe it's another issue with plplot. What you're reporting is consistent with an uncaught exception which is what would happen if plplot had an error during plotting the diagnostic plots. I can provide an update to catch and report the exception. That might help us figure out why the diagnostic plots aren't working.

The issue with the function generator is logged as an issue in Bitbucket. Here's why it still exists: topic14569.html

I'm not understanding what you're saying about autoranging not working. The log you supplied seems to indicate that it is. A 2 Vpp input signal should be able to be sampled with a 1V range (although just barely). It seems like the app got to the 1V range and stayed there - Similarly for the 2x attenuated output. Are you talking about a different run?

Yes, the autorangeTolerance is a value used to form a hysteresis band so that the autoranging does not just jump back and forth between two adjacent ranges.

Post Reply