Test and Measurement Forum

Frequency Response Analyzer with Bode Plots

Post discussions on applications you are writing

Re: Frequency Response Analyzer with Bode Plots

Postby DausB » Sat Oct 25, 2014 3:06 am

Hi hexamer,

I have get your code and add the ps6402D .... but I have two problems:
- At enumeration I get no serial number ( I have fix this by hardcoded desc .... )
- the GetValue calls return allway an overflow on both cannels

Status: 6402D S/N: CV312/057 successfully initialized.
Status: Starting frequency step 1, range try 1
Status: Setting input frequency to 10.000 Hz
Status: Setting input channel range to 50 mV
Status: Setting output channel range to 50 mV
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples
Status: Starting frequency step 1, range try 2
Status: Setting input channel range to 100 mV
Status: Setting output channel range to 100 mV
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples
Status: Starting frequency step 1, range try 3
Status: Setting input channel range to 200 mV
Status: Setting output channel range to 200 mV
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples
Status: Starting frequency step 1, range try 4
Status: Setting input channel range to 500 mV
Status: Setting output channel range to 500 mV
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples
Status: Starting frequency step 1, range try 5
Status: Setting input channel range to 1 V
Status: Setting output channel range to 1 V
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples
Status: Starting frequency step 1, range try 6
Status: Setting input channel range to 2 V
Status: Setting output channel range to 2 V
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples
Status: Starting frequency step 1, range try 7
Status: Setting input channel range to 5 V
Status: Setting output channel range to 5 V
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples
Status: Starting frequency step 1, range try 8
Status: Setting input channel range to 10 V
Status: Setting output channel range to 10 V
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples
Status: Starting frequency step 1, range try 9
Status: Setting input channel range to 20 V
Status: Setting output channel range to 20 V
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples
Status: Starting frequency step 1, range try 10
Status: Setting input channel range to 20 V
Status: Setting output channel range to 20 V
Status: Capturing 1025 samples (16 cycles) at 640 Hz takes 1.6 sec.
Status: Transferring 1025 samples

have you an idea?
DausB
Newbie
 
Posts: 0
Joined: Sat Oct 25, 2014 2:50 am

Re: Frequency Response Analyzer with Bode Plots

Postby hexamer » Sat Oct 25, 2014 1:35 pm

DausB wrote:Hi hexamer,

I have get your code and add the ps6402D .... but I have two problems:
- At enumeration I get no serial number ( I have fix this by hardcoded desc .... )
- the GetValue calls return allway an overflow on both cannels

...

have you an idea?


Hello! Thanks for giving this a try. I have a couple of thoughts on how to determine the issue:

1) The code has a diagnostics mode that I didn't mention in the Wiki. It outputs time-domain plots of the samples captured. In the XML settings file which I mention on the Wiki, there is a field called timeDomainPlots. With the application shut-down, set its value to true, save the file, then start the app. Then at the end of the FRA execution you should get plot files (in SVG format) in your Documents/FRA4PicoScope/diag directory. Inspect these to see if any of the samples are actually railed.

Edited (4-14-15): You also need to create a "diag" directory in your Documents\FRA4PicoScope directory. The actual location of the directory depends on the operating system version.

Edited (4-22-15): In v0.3b, it will also not work when the logged in username has characters that can't be represented in ASCII. A temporary workaround is to create a username with just ASCII characters and run the app under that account. Thanks to user Zolkow for helping me discover this.

2) If you could send me your code mods for the addition of the 6000 family, I could take a look and see if I spot anything. While I said it is trivial to add new families, admittedly this can be a tricky part of the code with all those token pasting macros - especially in "GetData". The PicoScope driver APIs often appear the same, but there are sometimes subtle differences.

Thanks,

Aaron.
Last edited by hexamer on Wed Apr 22, 2015 5:11 pm, edited 3 times in total.
hexamer
Advanced User
Advanced User
 
Posts: 62
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Postby hexamer » Sat Oct 25, 2014 3:03 pm

DausB wrote:Hi hexamer,

- At enumeration I get no serial number ( I have fix this by hardcoded desc .... )

have you an idea?


I notice that in ScopeSelector::GetAvailableScopes, I don't check the return value of the enumeration function. It's this line:

status = EnumerationFuncs[idx]( &count, (int8_t*)serials, &serialLength );

If you could tell me the value being returned in "status" when "idx" is 8 (PS6000), that may help. I assume "count" is coming back as 0.
hexamer
Advanced User
Advanced User
 
Posts: 62
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Postby DausB » Sat Oct 25, 2014 5:08 pm

Hello Hexame,

here are my changes. But sorry today I have not spend some time for the ploter :-(

Detlef
Attachments
FRA4PicoScope_Problem_changed files.zip
It´s not a zip is a z7 :-)
(11.29 KiB) Downloaded 57 times
DausB
Newbie
 
Posts: 0
Joined: Sat Oct 25, 2014 2:50 am

Re: Frequency Response Analyzer with Bode Plots

Postby DausB » Mon Nov 03, 2014 8:00 pm

Hi Hexamer,

I´ve spend some time this evening.

The enumeration works how you implement it. I don´t know what happen in the past.

I changed GetTimebase by factor 10, because the plot was one decade to high.

bool ps6000Impl::GetTimebase( double desiredFrequency, double* actualFrequency, uint32_t* timebase )
{
bool retVal = true;

if (desiredFrequency != 0.0 && actualFrequency && timebase)
{
*timebase = saturation_cast<uint32_t,double>((15625000.0/desiredFrequency) + 4.0); // ps6000abpg.en r1: p18
*timebase = max( *timebase, 5 ); // make sure it's at least 5
*actualFrequency = 156250000.0 / ((double)(*timebase - 4)); // ps5000abpg.en r1: p18
}
else
{
retVal = false;
}

return retVal;
}

But the overvoltage problem is still an isue. In lower frequency at everytime the scope change to 20V, in higher frequency at sometimes. I measure a simple 820R 470nF low pass filter. But the frequency and phase resopnse are OK. I check it manualy with the picoscope GUI.

Detlef
DausB
Newbie
 
Posts: 0
Joined: Sat Oct 25, 2014 2:50 am

Re: Frequency Response Analyzer with Bode Plots

Postby hexamer » Tue Nov 04, 2014 7:25 pm

DausB wrote:Hi Hexamer,

I´ve spend some time this evening.

The enumeration works how you implement it. I don´t know what happen in the past.

I changed GetTimebase by factor 10, because the plot was one decade to high.

bool ps6000Impl::GetTimebase( double desiredFrequency, double* actualFrequency, uint32_t* timebase )
{
bool retVal = true;

if (desiredFrequency != 0.0 && actualFrequency && timebase)
{
*timebase = saturation_cast<uint32_t,double>((15625000.0/desiredFrequency) + 4.0); // ps6000abpg.en r1: p18
*timebase = max( *timebase, 5 ); // make sure it's at least 5
*actualFrequency = 156250000.0 / ((double)(*timebase - 4)); // ps5000abpg.en r1: p18
}
else
{
retVal = false;
}

return retVal;
}

But the overvoltage problem is still an isue. In lower frequency at everytime the scope change to 20V, in higher frequency at sometimes. I measure a simple 820R 470nF low pass filter. But the frequency and phase resopnse are OK. I check it manualy with the picoscope GUI.

Detlef


Sorry for disappearing for a while, I got a little side tracked last week. I did take a brief look at the code and it looked to me that you pretty much did what I would have done to add the 6000 family. I still plan to take a deeper look, including inspecting the programming manual for small differences. Just a taking a step back, it would seem that in a low noise environment and with a passive filter, it should not be possible to be over-range on all ranges. To really get a clue of what might be going on, it would be helpful to get the diagnostic time domain plots I mentioned earier just to be sure the scope doesn't actually see railed samples - especially if your trial with the PicoScope GUI reveals nothing telling. Also, I don't think this is the cause, but be aware that the attenuation settings are ignored. This is fixed in a later version.
hexamer
Advanced User
Advanced User
 
Posts: 62
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Postby DausB » Thu Nov 06, 2014 4:51 pm

Hi Hexamer,

this and the next week I´m busy :-(

If I have activate the logging, the programm crashs in debug mode. I see what I can do, to send you log/timedomain data.

Detlef
DausB
Newbie
 
Posts: 0
Joined: Sat Oct 25, 2014 2:50 am

Re: Frequency Response Analyzer with Bode Plots

Postby RobinJS » Fri Feb 06, 2015 5:21 pm

Hi Aaron,
I've just purchased a 5444B and your application works fine. Just one thing that doesn't seem right. When the data file is exported into Excel, the Frequency data values are wrong. For example, if a response of 10Hz to 1kHz is measured (10 steps per decade), the frequency column displays figures of 1.0, 1.1, 1.2, 1.3, 1.4 etc up to 3.0 (values have been formatted and rounded up in Excel). Hence the correct number of entries, just the wrong values! Any ideas what is going on? Otherwise great job.

Regards,

Robin
Attachments
Test2.csv
(409 Bytes) Downloaded 41 times
RobinJS
Newbie
 
Posts: 0
Joined: Fri Feb 06, 2015 5:02 pm

Re: Frequency Response Analyzer with Bode Plots

Postby hexamer » Sat Feb 07, 2015 2:06 am

Hi Robin,

Thanks for the feedback. I'm glad to hear it's working for you. Since the frequency sweep is done in log base 10 mode, the frequencies reported are in units of log10. Excel has a log plotting option, which I was able to get to work with your data. Or if you want, you can convert the numbers to linear Hz in a cell formula, like "=power(10,A2)", then plot linearly. The kinds of FRA tools and Bode plots I'm familiar with plot frequency in log10. But, I understand that other applications might be different. E.g. I've read that audio applications might prefer to work in octaves. Maybe that is an option that could be supported in the future.

Thanks,

Aaron.
hexamer
Advanced User
Advanced User
 
Posts: 62
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Postby John Jebb » Fri Mar 20, 2015 9:19 am

Hi,
I will soon have an application that would be much easier with this package.
So I was pleased that it appeared in good time. Thank you.
But...
I have just loaded the Frequency Response Analyser application.
I have my Picoscope plugged in.
When I started FRA first time I got a display page as shown on the web site.
OK so far.
I exited from the FRA package and then started it again.
I got a message panel "Could not initialise application FRA execution thread".

I am using Win XP SP3 and a Picoscope 4226.

I then tried to use Picoscope 6.10.16.2 and got a message "No suitable device found".
The Picoscope was still plugged in.
I unplugged it and plugged in again.
Same result.
I re-started the computer and Picoscope worked again.

Can you help?

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

Re: Frequency Response Analyzer with Bode Plots

Postby hexamer » Sat Mar 21, 2015 3:34 pm

Hi John. Thanks for sharing what you found. From what I can tell I'd guess that somehow you accidentally launched the application while it was already running. One possibility is that you shut down the application, then re-launched it before the first instance was completely closed. I can reliably reproduce what you reported by just launching the application twice. That error apparently has something to do with the way I initialize the application and its threads. I have some guesses, but I don't know the full root cause. The more troubling aspect is that in some case the application does not properly release its access to the driver. I would have thought that re-connecting USB would have fixed that, but apparently not. I'll log an issue to investigate this further. In the meantime, I think you can avoid the issue by being careful not to open multiple instances of the application.

Have you tried to execute a FRA? Does that work? You could test it with a simple RC filter, or even connect input to output.

Thanks again - I hope we can get this working for your application!
hexamer
Advanced User
Advanced User
 
Posts: 62
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Postby John Jebb » Mon Mar 23, 2015 12:54 pm

Aaron,

Thanks for your reply.
I tried starting the FRA package, then waiting 5 minutes.
It still would not start.
I disconnected the USB and re-connected and it still would not re-start FRA.
It would re-start Picoscope though.
I looked in the Windows Task Manager and found a process FRA4Picoscope.exe that was still loaded.
I stopped that process and tried the FRA again from a shortcut.
It re-started OK.
It looks as if the 'Exit' command is not completely stopping the program.

Regards

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

Re: Frequency Response Analyzer with Bode Plots

Postby hexamer » Mon Mar 23, 2015 5:56 pm

John,

When you say you "started the FRA package", do you mean you launched the application, or do you mean you pressed the "Go" button?

Thanks,

Aaron.
hexamer
Advanced User
Advanced User
 
Posts: 62
Joined: Tue Aug 12, 2014 10:09 pm

Re: Frequency Response Analyzer with Bode Plots

Postby John Jebb » Tue Mar 24, 2015 11:47 am

Hi,
I mean that I launched it from Windows using a shortcut, then shut it down using File/Exit.
I waited 5 minutes then launched it again.
At that point it would not re-start.
I then found that the FRA4Picoscope process was still in memory.

As part of a completely different application not involving PicoScope, we have had the same trouble with XP processes not exiting properly.
This one looks very similar.
Now that I know, I can use Task Manager to kill the process.

I have used the application (using the Go button) and it worked fine, with the exception that it would not work at less that 8Hz.
This is not a problem for me.

Regards

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

Re: Frequency Response Analyzer with Bode Plots

Postby hexamer » Tue Mar 24, 2015 1:16 pm

Thanks, John. I'll take a closer look at shutdown and see what might to wrong. I'll also put in a more intentional guard against multiple instances of the application. Glad to hear that the FRA execution seems to work OK. Please let me know if you see any issues there. Also, I'm not sure why you'd be limited to 8 Hz. I'll have to think about that some more - there may be a bug. If you're in high noise mode, then you'd be limited to 125 Hz (though there's some potential to relax that). In low noise mode (the default), the application should let you go to the lowest frequency allowed by your generator. On a PS4226, I think that's about 4.6 milli-Hz.
hexamer
Advanced User
Advanced User
 
Posts: 62
Joined: Tue Aug 12, 2014 10:09 pm

PreviousNext

Return to Applications

Who is online

Users browsing this forum: No registered users and 0 guests