Author Topic: LCR Impedance Viewer for Picoscope+Keysight+R&S Bode Plot Data (open source)  (Read 28887 times)

0 Members and 1 Guest are viewing this topic.

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
I have been a big fan of using the app FRA4Picoscope to generate bode plots. This for me makes the Pico products much more useful.

By using a reference resistor in series with a DUT, it is possible to calculate the impedance from the DUT.  For this a made a small tool to do the calculation automatically, and also to allow the user to more easy compare different bode plots in once view. Currently, you can open the CSV-files generated by FRA4Picoscope, Keysight & R&S (more to come in the future), and view and compare them easily in the different impedance views.

I programmed automatic cursors, a zoom function for each individual axis, and both logarithmic and linear frequency axis. When a CSV file is opened, the used reference resistor is requested. This can be different for each file (to allow the user to choose the optimal value for the DUT) in the same plot view.  You can also copy pictures/data to the clipboard (data can be pasted in excel directly), or save them to a file.

Attached is the program, including some test data to allow non-Pico/Keysight/R&S users to have a go also. If some other scopes can generate bode plot data (frequency, gain and phase), it should be no problem to make an import functionality for these also. I am still cleaning up a bit of my code, once finished the code will be available as open source also.

Enjoy! Feedback is off course much appreciated. 

Installation is not required, just unzip the package and run the exe. It does need dotNet 4.6.1 or higher. The software was written in Visual Studio20172019 community edition, using the standard chart component of dotNet (no external libraries used for charting).

Edit: changed to VS2019 for the latest small update

Full source code is available at:
https://github.com/WimHuyghe/FRA-Impedance-Viewer
« Last Edit: September 12, 2021, 02:47:01 pm by _Wim_ »
 
The following users thanked this post: egonotto, thm_w, edavid, Andreas, doktor pyta, ogden, The Soulman, threephase, vmax

Offline threephase

  • Regular Contributor
  • *
  • Posts: 205
  • Country: gb
Re: LCR Impedance Viewer for Picoscope Bode Plot Data
« Reply #1 on: February 10, 2019, 02:31:56 pm »
Interesting project, I'll download it and transfer over to a Windows PC to have a play with.

Thanks for posting,

Kind regards.
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Re: LCR Impedance Viewer for Picoscope Bode Plot Data
« Reply #2 on: February 10, 2019, 03:52:54 pm »
Thanks! If somebody could post a bode plot export (CSV preffered if possible) from a Keysight of Siglent scope, I can have a look to make an import function for these also.
 

Offline 2N3055

  • Super Contributor
  • ***
  • Posts: 6407
  • Country: hr
Re: LCR Impedance Viewer for Picoscope Bode Plot Data
« Reply #3 on: February 10, 2019, 04:26:43 pm »
Thanks! If somebody could post a bode plot export (CSV preffered if possible) from a Keysight of Siglent scope, I can have a look to make an import function for these also.
Nice work!
Thanks for the offer, in attachment FRA CSV form Keysight MSOX3000T.
If you need more let me know.

Thanks and best regards.
Sinisa
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #4 on: February 10, 2019, 07:22:21 pm »
Keysight import works also! I do not know what your file was, but I can import it and display it.

Now still a Siglent file, R&S and...  :)

EDIT: last version added in first post
« Last Edit: February 11, 2019, 02:02:57 pm by _Wim_ »
 

Offline 2N3055

  • Super Contributor
  • ***
  • Posts: 6407
  • Country: hr
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #5 on: February 10, 2019, 08:31:09 pm »
Wow it works really well!
Great work, really!

The file is standard FRA.csv from scope. I had to rename it to .txt to upload it to EEVBLOG (it doesn't let you upload .csv).

A suggestion: it would be nice to show what R was used for calculation. Maybe a chance to change it later + recalc ?

Thanks again.

Regards,
Sinisa.
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #6 on: February 10, 2019, 08:57:33 pm »
Thanks for the feedback.

I will make a property windows were all file info can be seen (ref resistor, path, file name, number of datapoints, max freq, min freq...).

Changing the ref resistor value once displayed is not very easy (I would have to delete the series and add them again) and normally also not necesarry I think (if the wrong value was entered, the user can remove the file by right clicking on the legend and add it again using the correct value.

I have already added the following options:
- allow for printing a chart
- allow the user to choose to display the legend inside or outside the chart (both have benefits)

Currently working on the property window...
 
The following users thanked this post: 2N3055

Offline Hydron

  • Frequent Contributor
  • **
  • Posts: 978
  • Country: gb
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #7 on: February 10, 2019, 09:27:32 pm »
Looks like a useful bit of software, thanks for writing and sharing it!
If nobody else supplies a R&S file then I can oblige, but I'll wait a bit first (scope is setup for some other measurements right now and prefer to leave it be).
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #8 on: February 10, 2019, 09:33:24 pm »
Looks like a useful bit of software, thanks for writing and sharing it!

Thanks! Updated version added to first post. Now with print support and file properties window.
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #9 on: February 10, 2019, 09:47:31 pm »
If anybody has some good info how a calibration can be calculated (like performing an "open" and "short" bode measurement first with the testjig alone). This could be a usefull feature to include to increase accuracy.

Will not be for today however...
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #10 on: February 11, 2019, 02:05:11 pm »
New version in first post: some small bugfixes and cosmetic changes. Source code file is to big to attach here (4MB). @Moderator, is it possible to attach bigger files somehow in first post?
 

Offline Hydron

  • Frequent Contributor
  • **
  • Posts: 978
  • Country: gb
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #11 on: February 11, 2019, 02:23:41 pm »
Maybe put it on something like github/lab etc? Would also allow people to see changes in the code over time.
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #12 on: February 11, 2019, 05:33:44 pm »
Maybe put it on something like github/lab etc? Would also allow people to see changes in the code over time.

That crossed my mind also, but I first have to read a bit to see how exactly that works with integration in VS2017.
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data
« Reply #13 on: February 11, 2019, 07:43:58 pm »
Ok, finally success I think. Apparently there is an issue with VS2017 on Win7 with github (error "user cancelled certificate check"). This links "easy fix" was indeed the solution for my problem: https://github.com/github/VisualStudio/issues/1532

So normally the full source code should be available here:
https://github.com/WimHuyghe/FRA-Impedance-Viewer

Please report back if you were able to compile it using this source code, and off course also if you would like to contribute to the code.
« Last Edit: February 11, 2019, 07:50:13 pm by _Wim_ »
 

Offline Hydron

  • Frequent Contributor
  • **
  • Posts: 978
  • Country: gb
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data (open source)
« Reply #14 on: February 11, 2019, 10:22:42 pm »
So I did a quick bode plot on the RTB2k, both channels (3 and 4) connected directly to the sig gen so results are a bit boring (other than a bit of phase/amplitude shift from the cables/reflections up towards 25MHz) but should give an idea of file format (which is nice and simple). Note that this is 100points/decade but it can go up to 500, so potentially quite a few points for a wide sweep at 500/dec.
The standard output seems to be a CSV (attached with filetype changed to txt); there is also a "live data" directory with a bunch of other formats that can be accessed when the unit is plugged into the PC as a USB device - this is in the zip file (also attached) but probably not important to support that as it's far more complicated than the standard output - it's probably more for when the unit is used in an automated rather than interactive fashion.
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Re: LCR Impedance Viewer for Picoscope+Keysight Bode Plot Data (open source)
« Reply #15 on: February 12, 2019, 09:56:27 pm »
So I did a quick bode plot on the RTB2k, both channels (3 and 4) connected directly to the sig gen so results are a bit boring (other than a bit of phase/amplitude shift from the cables/reflections up towards 25MHz) but should give an idea of file format (which is nice and simple).

R&S now also supported. Update attached to first post. Any other tools that generate bode plots? :-)
 

Offline 2N3055

  • Super Contributor
  • ***
  • Posts: 6407
  • Country: hr
SC from Github compiled on first try on VS2017..
 
The following users thanked this post: _Wim_

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
SC from Github compiled on first try on VS2017..

Thanks for the feedback, good to know.
 
The following users thanked this post: 2N3055

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Added direct measurement of a plot using a picoscope (no more need to save to CSV first). This uses the API DLL from the FRA4Picoscope app.

Updated version attached to first post, source code on Github.

Known bugs: status log picoscope does not work yet.
 

Offline HalFET

  • Frequent Contributor
  • **
  • Posts: 512
  • Country: 00
What did you have in mind as calibration? Do you actually want to calculate the error throughout the curve?
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
I was thinking of something is the line of measuring a "known" resistor with using the known reference resistor. This way both gain and phase can be predicted, and actual measured gain and phase can be used somehow as a correction. Similarly, I could measure with an open jig and a shorted jig like is typically done with an LCR meter.

But I am not sure this will be very useful, as the inaccuracy of using a scope in the first place or probably much worse that not performing a calibration on the test jig/cables.

 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Updated version again in first post, now you can define the reference resistor when taking a measurement with the picoscope directly (forgot to remove the test code were is was default at 1K  :) )
 

Offline HalFET

  • Frequent Contributor
  • **
  • Posts: 512
  • Country: 00
That should be doable if you measure it in a range where the phase difference is high enough. You could probably also go for a Q-meter approach, though that would require additional components which might not be very attractive.
 

Offline _Wim_Topic starter

  • Super Contributor
  • ***
  • Posts: 1514
  • Country: be
Finally fixed the problem with the message log. Updated version in first post. Also added some more options and small functionality.
 

Offline HalFET

  • Frequent Contributor
  • **
  • Posts: 512
  • Country: 00
Quick try at the error calculation, haven't yet investigated your code so not sure how applicable this is.

So operating on the assumption that we can see the circuit as follows:

V2  o------+
           |
          | |
          | | Z_REF
          | |
           |
V1  o------+
           |
          | |
          | | Z_DUT
          | |
           |
          ___
GND        -


Then we can assume: Z_DUT = Z_REF * V1 / (V2 - V1)
If we split each bit up as imaginary number: Z_DUT = R_DUT + j * X_DUT, Z_REF = R_REF + 1i * X_REF, V1 = V1_Re + 1i * V1_Im and V2 = V2_Re + 1i * V2_Im

At that point:
Code: [Select]
R_DUT = - ((V1_Im - V2_Im)*(R_REF*V1_Im + V1_Re*X_REF))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - ((V1_Re - V2_Re)*(R_REF*V1_Re - V1_Im*X_REF))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)
Code: [Select]
X_DUT = ((V1_Im - V2_Im)*(R_REF*V1_Re - V1_Im*X_REF))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - ((V1_Re - V2_Re)*(R_REF*V1_Im + V1_Re*X_REF))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)
If we then set the error of each input variable: R_REF_Error X_REF_Error V1_Re_Error V1_Im_Error V2_Re_Error V2_Im_Error

Then the errors become:
Code: [Select]
R_DUT_Error = (V1_Im_Error^2*((X_REF*(V1_Re - V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - (R_REF*(V1_Im - V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - (R_REF*V1_Im + V1_Re*X_REF)/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + ((V1_Im - V2_Im)*(R_REF*V1_Im + V1_Re*X_REF)*(2*V1_Im - 2*V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2 + ((V1_Re - V2_Re)*(R_REF*V1_Re - V1_Im*X_REF)*(2*V1_Im - 2*V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2)^2 + V1_Re_Error^2*((R_REF*V1_Re - V1_Im*X_REF)/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + (R_REF*(V1_Re - V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + (X_REF*(V1_Im - V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - ((V1_Im - V2_Im)*(R_REF*V1_Im + V1_Re*X_REF)*(2*V1_Re - 2*V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2 - ((V1_Re - V2_Re)*(R_REF*V1_Re - V1_Im*X_REF)*(2*V1_Re - 2*V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2)^2 + V2_Im_Error^2*(((V1_Im - V2_Im)*(R_REF*V1_Im + V1_Re*X_REF)*(2*V1_Im - 2*V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2 - (R_REF*V1_Im + V1_Re*X_REF)/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + ((V1_Re - V2_Re)*(R_REF*V1_Re - V1_Im*X_REF)*(2*V1_Im - 2*V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2)^2 + V2_Re_Error^2*(((V1_Im - V2_Im)*(R_REF*V1_Im + V1_Re*X_REF)*(2*V1_Re - 2*V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2 - (R_REF*V1_Re - V1_Im*X_REF)/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + ((V1_Re - V2_Re)*(R_REF*V1_Re - V1_Im*X_REF)*(2*V1_Re - 2*V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2)^2 + R_REF_Error^2*((V1_Im*(V1_Im - V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + (V1_Re*(V1_Re - V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2))^2 + X_REF_Error^2*((V1_Re*(V1_Im - V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - (V1_Im*(V1_Re - V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2))^2)^(1/2)
Code: [Select]
X_DUT_Error = (V1_Im_Error^2*((R_REF*(V1_Re - V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - (R_REF*V1_Re - V1_Im*X_REF)/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + (X_REF*(V1_Im - V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + ((V1_Im - V2_Im)*(R_REF*V1_Re - V1_Im*X_REF)*(2*V1_Im - 2*V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2 - ((V1_Re - V2_Re)*(R_REF*V1_Im + V1_Re*X_REF)*(2*V1_Im - 2*V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2)^2 + V1_Re_Error^2*((R_REF*V1_Im + V1_Re*X_REF)/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - (R_REF*(V1_Im - V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + (X_REF*(V1_Re - V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + ((V1_Im - V2_Im)*(R_REF*V1_Re - V1_Im*X_REF)*(2*V1_Re - 2*V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2 - ((V1_Re - V2_Re)*(R_REF*V1_Im + V1_Re*X_REF)*(2*V1_Re - 2*V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2)^2 + V2_Im_Error^2*((R_REF*V1_Re - V1_Im*X_REF)/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - ((V1_Im - V2_Im)*(R_REF*V1_Re - V1_Im*X_REF)*(2*V1_Im - 2*V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2 + ((V1_Re - V2_Re)*(R_REF*V1_Im + V1_Re*X_REF)*(2*V1_Im - 2*V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2)^2 + V2_Re_Error^2*((R_REF*V1_Im + V1_Re*X_REF)/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + ((V1_Im - V2_Im)*(R_REF*V1_Re - V1_Im*X_REF)*(2*V1_Re - 2*V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2 - ((V1_Re - V2_Re)*(R_REF*V1_Im + V1_Re*X_REF)*(2*V1_Re - 2*V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2)^2)^2 + R_REF_Error^2*((V1_Re*(V1_Im - V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) - (V1_Im*(V1_Re - V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2))^2 + X_REF_Error^2*((V1_Im*(V1_Im - V2_Im))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2) + (V1_Re*(V1_Re - V2_Re))/((V1_Im - V2_Im)^2 + (V1_Re - V2_Re)^2))^2)^(1/2)
It ain't pretty, but doable I would say.
 
The following users thanked this post: 2N3055


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf