Frequency Response Analyzer with Bode Plots

Post discussions on applications you are writing
Post Reply
sbabic44
User
User
Posts: 3
Joined: Thu Nov 30, 2017 10:17 pm

Re: Frequency Response Analyzer with Bode Plots

Post by sbabic44 »

hexamer wrote:
Sat Apr 04, 2020 2:04 pm
sbabic44 wrote:
Sat Apr 04, 2020 10:01 am
Hello!
I have 3046D MSO and 4262 and Rigol DG1062Z and Siglent 6052X.
I do know C++ and C# but my programmer-fu is very weak(not really actively programming in many years) , but would be willing to test and maybe fix minor things..
If I may make a suggestion: SCPI is just string exchange protocol, and it is the same over serial, USB, and Ethernet.
I think, maybe direct telnet to instruments and just exchange strings. Nothing to enumerate or anything, Just IP, port and SCPI strings set for different instruments.
Best regards, and again, thanks Hexamer for all the effort!
Very good point about SCPI. I see lots of examples that boil down to that. As of now I'm still learning the alphabet soup of standardized instrument programming!

Your comment about enumeration makes me realize there is something I should explain. While the plugin interface shows enumeration and instrument ID capabilities, they are optional. In the example plugin project, they are not supported.

Another related topic is the Initialization function and the string parameters it can be passed. In the example plugin project, I use it as sort of an id/address in leiu of enumeration: it's just the COM port id for the Arduino in my signal generator.
That sounds OK to me. That kind of architecture (a sort of a gateway function that converts macro functions like start, stop, frequency, amplitude being sent from FRA to module, and module does the proper thing for the generator in question) is what I had in mind...

As I said, I can't work on this full time, but be happy to help as much as I can. Having two instruments that are very common is a good thing for testing. I'm not sure about Rigol, but Siglent siggens literally share programmers manual. It is a good chance that with those two I have we could cover most of the development for both Rigol and Siglent, apart from some difference in models capabilities.....

Drop me PM if you need something, and I'll try to do my best.
That's the least I could do...

Regards,
Sinisa

_Wim_
Advanced
Posts: 0
Joined: Sun Nov 12, 2017 11:31 am

Re: Frequency Response Analyzer with Bode Plots

Post by _Wim_ »

hexamer wrote:
Sat Apr 04, 2020 1:08 am
Here is the interface file: ExtSigGen.h

The application does use a separate thread from the UI for carrying out the FRA activities, and another thread with timeout is used for the data collection. But there is no separate thread and timeout for signal generator calls. So, the application is relying on the plugin to not hang. In the plugin I made there are communication timeouts.

The plugin header I linked above has shows the methods which I think are are intuitively named, but the methods are documented in the plugin project which is here EME165-R2 Plugin

Finally, here is an initial release candidate for the app with external signal generator capability: FRA4PicoScope_0.7.0b_RC1.msi

Since there are new settings, it will delete your old settings. After you install, you should check in help->about that it says 0.7.0b RC1. To install a plugin, just place the new DLL in the same directory as FRA4PicoScope.exe

Let me know if something doesn't make sense.
I have downloaded all files to a local source tree folder, currently having a first look how to implement a dll in C# that can be called by your C++ interface. The interface definition is indeed self explanatory.

_Wim_
Advanced
Posts: 0
Joined: Sun Nov 12, 2017 11:31 am

Re: Frequency Response Analyzer with Bode Plots

Post by _Wim_ »

_Wim_ wrote:
Wed Apr 08, 2020 6:45 am
I have downloaded all files to a local source tree folder, currently having a first look how to implement a dll in C# that can be called by your C++ interface. The interface definition is indeed self explanatory.
Hello Aaron,

Can you have a brief look at the section "C++/C# Interoperability" at the bottom of this page:
https://en.wikipedia.org/wiki/C%2B%2B/CLI

By using the "using" statement it should be possible to directly use a managed dll without any modifications on the C# side.

Is this something that would be possible in your application to implement? Other common solutions seems to be by exposing a com interface used on both sides, but this already seems quite a bit more complex than the solution above.

_Wim_
Advanced
Posts: 0
Joined: Sun Nov 12, 2017 11:31 am

Re: Frequency Response Analyzer with Bode Plots

Post by _Wim_ »

sbabic44 wrote:
Sat Apr 04, 2020 10:01 am
Hello!
I have 3046D MSO and 4262 and Rigol DG1062Z and Siglent 6052X.
I do know C++ and C# but my programmer-fu is very weak(not really actively programming in many years) , but would be willing to test and maybe fix minor things..
If I may make a suggestion: SCPI is just string exchange protocol, and it is the same over serial, USB, and Ethernet.
I think, maybe direct telnet to instruments and just exchange strings. Nothing to enumerate or anything, Just IP, port and SCPI strings set for different instruments.
Best regards, and again, thanks Hexamer for all the effort!
This would indeed be a possibility. I have a working C# application that uses SCPI via Telnet for a power analyzer I use.

Works perfectly for my rigol signal generator also (on port 5555, not port 23).
Attachments
Rigol Telnet.JPG

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 »

_Wim_ wrote:
Wed Apr 08, 2020 7:55 am
_Wim_ wrote:
Wed Apr 08, 2020 6:45 am
I have downloaded all files to a local source tree folder, currently having a first look how to implement a dll in C# that can be called by your C++ interface. The interface definition is indeed self explanatory.
Hello Aaron,

Can you have a brief look at the section "C++/C# Interoperability" at the bottom of this page:
https://en.wikipedia.org/wiki/C%2B%2B/CLI

By using the "using" statement it should be possible to directly use a managed dll without any modifications on the C# side.

Is this something that would be possible in your application to implement? Other common solutions seems to be by exposing a com interface used on both sides, but this already seems quite a bit more complex than the solution above.
Wim,

From what I can tell it seems this sort of C++/CLI support for accessing a managed DLL (though the most modern way) is limited to supporting access to static methods in C#. The interface I made is based on a C++ class interface where an object is instantiated (like a factory pattern). I also tried to turn on the /clr flag to see how far I could get but I kept running into other incompatible flags (e.g. EHsc, MTd) that I don't think I could easily undo.

It does seem that COM (also factory like) would be another more flexible way, but definitely more complex.

But in all the searching, I see a few ideas based on what you mention above that would work like this:

Native C++ (FRA4PicoScope) -> C++/CLI DLL -> C# DLL.

In this model, since the calls to C# would still be static mehods, if you wanted to handle multiple instruments and enumeration, you'd probably have to use a handle as a parameter to these functions (like the Pico SDK).

I was briefly thinking about creating a standardized version of the middle DLL with an initialization parameter identifying the rightmost DLL. Unfortunately, since the #using technique points to a specific DLL, that wouldn't work.

Aaron.
Last edited by hexamer on Thu Apr 09, 2020 1:46 am, edited 1 time in total.

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 »

_Wim_ wrote:
Wed Apr 08, 2020 8:11 am
sbabic44 wrote:
Sat Apr 04, 2020 10:01 am
Hello!
I have 3046D MSO and 4262 and Rigol DG1062Z and Siglent 6052X.
I do know C++ and C# but my programmer-fu is very weak(not really actively programming in many years) , but would be willing to test and maybe fix minor things..
If I may make a suggestion: SCPI is just string exchange protocol, and it is the same over serial, USB, and Ethernet.
I think, maybe direct telnet to instruments and just exchange strings. Nothing to enumerate or anything, Just IP, port and SCPI strings set for different instruments.
Best regards, and again, thanks Hexamer for all the effort!
This would indeed be a possibility. I have a working C# application that uses SCPI via Telnet for a power analyzer I use.

Works perfectly for my rigol signal generator also (on port 5555, not port 23).
Very nice!

_Wim_
Advanced
Posts: 0
Joined: Sun Nov 12, 2017 11:31 am

Re: Frequency Response Analyzer with Bode Plots

Post by _Wim_ »

hexamer wrote:
Thu Apr 09, 2020 1:41 am
In this model, since the calls to C# would still be static mehods, if you wanted to handle multiple instruments and enumeration, you'd probably have to use a handle as a parameter to these functions (like the Pico SDK).

I was briefly thinking about creating a standardized version of the middle DLL with an initialization parameter identifying the rightmost DLL. Unfortunately, since the #using technique points to a specific DLL, that wouldn't work.

Aaron.
What if we would use socket communication instead of DLL/Interface/Com? This way we are only tied to a specific port, but not any specific dll any longer.

Your app would then have to do two things:
- look if an instance of this new exe (socket server) is already running, and if not, start it (for example signalgenerator.exe in the installation folder of FRA)
- communicate with this socket server via 127.0.0.1 and port XXX

Communication could be SCPI like. I would write this socket server which translates the "FRA-SCPI" commands to "Signal Generator X" commands. In other words, from the FRA side it seems like it is communicating to a generic/virtual signal generator, which in his turns translates this to actual signal generator commands.

The implementation of another signal generator could be fairly easy, as only minor modifications to this socket server will be necessary (just translation from and to different SCPI commands).

marcov
Newbie
Posts: 0
Joined: Mon Apr 20, 2020 7:13 am

Possible bug

Post by marcov »

I've built last version and running in within VS in debug caused message box 'Could not read or initialize device settings file.' (line 354 of PicoScopeFraApp.cpp)
It seems like the settings subdirectory C:\Users\\AppData\Roaming\FRA4PicoScope was never created by code. When I manually created it, application started correctly. Pico 4227 here.
Thanks for your nice software.

Akram
Newbie
Posts: 0
Joined: Wed May 06, 2020 9:57 am

Re: Frequency Response Analyzer with Bode Plots

Post by Akram »

Dear hexamer,

I have a question (I precise I am a newbie), i want to add in the interface some button and box, and those buttons and boxes will be used to make some new mathematical calculation according to the measurement of the signal get it.

I am using VS 2019, I downond all the files, but i do not well understand how can I add extra button and boxes to the interface, please could you give some explanation, indication, links, document or any thing else that may help me.

Thank you for your help in advance.
Best regards.
Akram

mnni
Newbie
Posts: 1
Joined: Mon Oct 09, 2017 7:33 am

Re: Frequency Response Analyzer with Bode Plots

Post by mnni »

Fra4picoImpedance.png
Hey Akram i compiled my own version of the FRA and changed some things in this nice code to work as a multi channel impedance analyser together with some hardware i build around the picoscope for use on fuelcell stack impedance testing and as my own LCR meter.
anyway
have a look at the resource folder and open the .rc file of the project Fra4PicoScope there you find the gui dialogs - its more less all win api but i suspect you are kind of new to c++ and windows GUI programming so maybe start by google vc++ gui programming and win api and do some tutorials
and then dig into the code its pretty well organized and well self explained code.
perhaps start by getting the solution to compile i use vc++2015
and then you have a look in PicoScopeFraApp this is where the gui is made and from there on you dig down into the picoScopeFRA class and so on...

Roberto Boucht
Newbie
Posts: 0
Joined: Fri Sep 30, 2016 9:33 am
Location: Argentina

Re: Frequency Response Analyzer with Bode Plots

Post by Roberto Boucht »

Hi Aaron,

I am a 2205A user with your FRA (Ver 0.6.2b RC4) and I appreciate your effort in doing such application.

Is any place where I can get the information about the parameters stated in Setting?
Some of them are not clear for me, especially those related to noise reject.
Thanks.
Roberto

Rumpel
Newbie
Posts: 0
Joined: Wed Jun 10, 2020 8:52 pm

Re: Frequency Response Analyzer with Bode Plots

Post by Rumpel »

Hi.
First of all THANKS A LOT for such an extremely useful tool which saved my PSU development :)

Secondly I would like to share my Python script which I have made for converting exported data into excel. It groups data into books and sheets and plots multiple data variants on one chart so it is simplier to compare different configurations. Hope it will be useful to someone.

Can't attach files to this message for some unknown reason so uploaded then on Google Drive:
FRAplotter_v1.0.py
FRAplotter_example.xlsx (better open with proper app, not in web view)

How to use:
You can simply drag and drop exported data files onto this script (this feature needs to be enabled in explorer for python files). If dataGrouping is enabled it will group data files into excel books and sheets according to grouping criteria based on filenames, if not it will simply plot all data into one chart. Almost all formatting can be changed in excelBook -> format section. All format explanations (except what is explicitly explained in coments) is given in xlsxwriter documentation.

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 »

Roberto Boucht wrote:
Tue Jun 09, 2020 9:44 pm
Hi Aaron,

I am a 2205A user with your FRA (Ver 0.6.2b RC4) and I appreciate your effort in doing such application.

Is any place where I can get the information about the parameters stated in Setting?
Some of them are not clear for me, especially those related to noise reject.
Thanks.
Roberto
Hi Roberto,

I was about to point you back to an earlier post where I explained all this. But when it took me a while to find it myself, I decided it's probably a good time to document it on the Wiki: https://bitbucket.org/hexamer/fra4picos ... umentation

Let me know if any of it's confusing and I can work to improve it.

Thanks!

Aaron.

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 »

mnni wrote:
Wed May 27, 2020 6:14 pm
Fra4picoImpedance.png

Hey Akram i compiled my own version of the FRA and changed some things in this nice code to work as a multi channel impedance analyser together with some hardware i build around the picoscope for use on fuelcell stack impedance testing and as my own LCR meter.
anyway
have a look at the resource folder and open the .rc file of the project Fra4PicoScope there you find the gui dialogs - its more less all win api but i suspect you are kind of new to c++ and windows GUI programming so maybe start by google vc++ gui programming and win api and do some tutorials
and then dig into the code its pretty well organized and well self explained code.
perhaps start by getting the solution to compile i use vc++2015
and then you have a look in PicoScopeFraApp this is where the gui is made and from there on you dig down into the picoScopeFRA class and so on...
Very nice work. Happy to hear you were able to build on it! I try to comment things very well because otherwise I'd be coming back and wondering why I did things the way I did :)

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 »

Rumpel wrote:
Fri Jun 12, 2020 2:26 pm
Hi.
First of all THANKS A LOT for such an extremely useful tool which saved my PSU development :)

Secondly I would like to share my Python script which I have made for converting exported data into excel. It groups data into books and sheets and plots multiple data variants on one chart so it is simplier to compare different configurations. Hope it will be useful to someone.
Very well done and thank you for sharing your data analysis tools! If you like programming with Excel, there is an API version of the FRA application along with a VBA application example which you might find useful.

If this data is based on a commercially available PSU, would you mind sharing what it is? If it's a proprietary design, I understand if you can't share. I'm mainly interested in comparing to any published stability plots.

Also, did you need to use adaptive stimulus mode? If you did, how did you find it to use? (easy/hard? effective/ineffective?)

Thank You,

Aaron.
Last edited by hexamer on Tue Jul 14, 2020 3:18 pm, edited 1 time in total.

Post Reply