Keithley 2015 THD with FFT and Harmonic graphs - Page 1
Forum section: electronics / testgear

author: 2bluesc
author_rank: Contributor
timestamp: May 31, 2017, 01:57:31 am
content: Hey all,After getting my Keithley 2015 THD for some small amplifier projects I was shocked that nobody had put together some tools to automate the beast. The DMM is simple to get THD or THD+N numbers on the display, but that never tells the whole pictures. After some digging around I managed to extract the first FFT plot (make a WAG at the bin bandwidth, manual doesn't say) and plot some graphs. I haven't seen anyone share FFT spectrum plots from the device, so I'm hear to share!The first screenshot (read title on plot) is with the internal source generator generating a 1kHz sine wave at 1Vrms. The internal generator isn't that amazing, and as others have pointed out: A sound card on a PC can probably do better if you can eliminate the noise of the PC. The 2015's gen spec is "-64dB THD+N with harmonics 2-5" which calculates out to 0.063%. It measures 0.02% THD+N, which should include all harmonics and be more pessimistic. Seems well within spec.The second screenshot is my FIIO D03K optical to analog DAC generating the same 1kHz sine wave with the volume at -3.0 dB according to the software mixer in Linux. The D03K DAC is rated for "Total harmonic distortion: <0.008%" and the Keithley measures it at 0.003% on the THD+N setting (assuming they measure and calculate the same). Impressive for both the DAC and the 2015. The spec sheet for the 2015 lists the THD+N residual distortion at 0.056% from 20-20kHz, so this is well within that spec (at least at 1kHz and 0.5Vrms) as well. I'm not sure if I'm reading the spec sheet right in this department, what is actually described in the Keithley 2015 spec sheet for "Residual distortion"?In short it works as expected and I'm assuming that the Keithley 2015 meter is reading well beyond what my ears can hear (audiophoolery aside).That said I have a few comments:The Keithley 2015 SCPI command reference describes the :FFTransform:BINS command, but it doesn't discuss the bandwidth of each bin. From my own empirical measurements, bin measures from 61-121Hz and bin measures from 19915-19983Hz. That means the first bin is 60 Hz wide and the last bin is 68 Hz wide. Does anyone have ideas on how this actually works? Is it really not documented anywhere? My graphs are plotting bins 1-500 which is approximately 0-34.2kHz. The plots place the data at the center of each bin and that's why 1kHz doesn't line up with the grid lines. I don't think I can do much better without a finer grain FFT. I assume this is the limit of the Keithley 2015. Also, if bin = 34.2kHz, it's unfortunate that I can't define a small bin width to zoom in on certain frequencies instead of measuring out to 1023 * 60 = 61.3kHz which seems only useful for catching higher harmonics at higher frequencies. The docs for the Keithley 2015-P (note the P for peak) seems to have definable bin width or ambiguous documentation, neither would surprise me.A Keithley 2015 quick reference guide (doc #2015-903-01 Rev. A, Dec 2001) mentions a :DISTortion:BNoIse SCPI command and the user manual (Doc #2015-900-01 Rev. F, Aug 2003) doesn't even mention the command. The ref guide describes it as "Background noise is the residual voltage after the input signal’s fundamental and harmonics are removed." for frequencies greater then 61 Hz. Are there any more forgotten commands?Hopefully one to reisze binsThis is my first time playing with a SCPI over UART, but it seems after I send the "*RST" command the first letter of almost any command I send next is dropped. Not sure if this is my RS232-USB converter (seems unlikely) or a firmware bug.My device responds to *IDN? command with "KEITHLEY INSTRUMENTS INC.,MODEL 2015,1051478,B15 /A02" for those interested.Next steps, clean-up the horrendous hacky code and try go make it easy to spit out graphs for a handful of common tasks:Automated FFT spectrum plot with harmonics. First attempt is done as attachedSweep frequencies using internal generator and measure the THD+N at a number of points and plot. I fear the internal source may not be good enough for devices I want to test.Sweep frequencies using the internal generator to build a frequency response plot. Would be handy to overlay multiple tests to do channel mappingMeasure noise floor. I don't know how to do this on the Keithley 2015, any ideas?

author: 1audio
author_rank: Frequent Contributor
timestamp: May 31, 2017, 03:23:49 am
content: My 2015 can measure as low as .001% on a really clean sinewave. I'm not sure how much I trust that since its also on the verge of .000% occasionally which is nonsense. Still if you have some code I'm all ears. Are you using serial or GPIB to talk to it?I have looked around for app to do this and there are few. I can send you code from one effort by another guy for a traditional analyzer (Boonton 1120) that has addressed a lot of the issues of getting useful measurements but doesn't know how to talk to the Keithley. It was written in visual basic so Windows oriented. Let me know if you are interested. It does have routines for THD vs. level and Level vs. frequency. It uses a VB link to Excel for output.Measuring SNR would be a several stage process. I believe the 2015 has some filters coded into it. (Necessary for the cell phone biz, which is what paid for them). You would need to establish a reference level and then "zero" the input (watch for source Z issues) and then measure the level with the filter for meaningful info.

author: 1audio
author_rank: Frequent Contributor
timestamp: May 31, 2017, 03:25:53 am
content: One more thing- displaying discrete harmonics as a bar graph seems easier to grasp. The instruments that can do that graphically all seem to use bar graphs.

author: 2bluesc
author_rank: Contributor
timestamp: May 31, 2017, 03:27:05 am
content: Yeah, I need to fix the harmonic graph. If I just output a bar graph I'll be upside down. So I need to work on it a bit more. Everything needs more work though.

author: Ash
author_rank: Regular Contributor
timestamp: May 31, 2017, 03:58:45 am
content: Nice work, this is one of the items on my list as well. Albeit, quite a ways down the list..I'd be interested in the code for sure.. would you publish it on GitHub, that way others can contribute easily.ThanksAsh.

author: 2bluesc
author_rank: Contributor
timestamp: May 31, 2017, 04:39:47 am
content: Quote from: Ash on May 31, 2017, 03:58:45 amI'm going to host it on a Github repo after it's more organized. So far it's a hacked mess to see if the hardware works. Check itout at this gist.

author: Ash
author_rank: Regular Contributor
timestamp: May 31, 2017, 05:42:34 am
content: Hi 2bluesc,I'm not sure if you have seen it, but a bit of googling and I found a document from Keithley on AC signal analysis that seems to have data on the bin.https://www.testequity.com/documents/pdf/keithley/2015-2015-P-2016-rg.pdfOn page 16 - I believe that this is #2015-903-01 Rev. A, Dec 2001:QuoteHave you tried this?This all seems to be designed for the "P" options.. I know mine is a straight 2015 THD, not a "P" variant. I have B17 A02 firmware I believe, so when I get a chance (weekend?) I'll fire it up and see if the commands run for me.Cheers,Ash.

author: 2bluesc
author_rank: Contributor
timestamp: May 31, 2017, 06:01:57 am
content: Quote from: Ash on May 31, 2017, 05:42:34 amHi Ash,I did try that and the way it's described seems very confusing, because that document disagrees with the User's Manual definition for the SENSe:DISTortion:FREQuency command. The command on my meter forces the meter to use the given frequency for the reference magnitude of the FFT, and as a result the rest of the FFT is garbage. The description sounds like something I want for the smaller bins, but the semantics of the command name and the user manual doc match what it actually appears to do. I suspect it's either a typo, or as you said, only available on the "P" variants.I'd love to hear what your tests show, the code I have posted thus far can easily be hacked to run the test quickly. I bet the FFT plot with turn to garbage. Give it a shot!- Kyle

author: 1audio
author_rank: Frequent Contributor
timestamp: May 31, 2017, 03:51:08 pm
content: Docs on this stuff always seems to be everywhere and nowhere. There is a Keithley support forum where you may get better answers:https://forum.tek.com/viewforum.php?f=64and here:https://forum.tek.com/viewforum.php?f=67Other users have trouble getting good answers from Keithley judging from reading through that forum.What would be great is 2015-p firmware if anyone has a way to get it. The distortion analysis supposedly is only available on the -p version. keithley says its upgradable (by them for a fee).

author: 2bluesc
author_rank: Contributor
timestamp: May 31, 2017, 04:05:15 pm
content: Quote from: 1audio on May 31, 2017, 03:51:08 pmInteresting. Didn't even think to check out a Keithley forum, the 2015 forum looks very quiet, but I think I'll post there when I get a little further along and the code is more presentable. Thanks for sharingQuote from: 1audio on May 31, 2017, 03:51:08 pmThis would be an awesome hack. The distortion analysis is in the 2015, the 2015-P is supposed to add "peak analysis" which appears to be just an easy way to iterate through peak harmonics programmatically, but I haven't studied enough. I assume the extra ':PEAK" SCPI commands are of particular use for automated factory testing setups and may not provide much more information then downloading the FFT bin output directly. I to stumbled upon thepost that you mentioned where the 2015 could be upgraded to a 2015-P model. The 2015-P options sound like they are nothing more then software, and may not provide much value, but if the FFT bin size is configurable on the 2015-P, that alone may be worth checking out.

author: G0HZU
author_rank: Super Contributor
timestamp: May 31, 2017, 08:57:10 pm
content: QuoteI bought mine a few years ago and created some automated apps for it within a few days of it arrivinghttps://www.eevblog.com/forum/testgear/keithley-2015thd-initial-tests/All the apps are fairly crude but they work well. I did the THD UI first, followed by a fairly decent 'Toneohm' app where the pitch of the audio from the PC speakers depends on the resistance of the device being measured. It worked quite well as the GPIB interface is quite quick.I also did a quick and dirty logger program to measure PSU stability. Not exactly modern or pretty but it works.QuoteThanks for this. I missed the FFT plot command so I may have a play with this at some pointHow quickly can it create and refresh the spectrum plots using this command?

author: 2bluesc
author_rank: Contributor
timestamp: May 31, 2017, 09:17:26 pm
content: Quote from: G0HZU on May 31, 2017, 08:57:10 pmI stumbled on your app, but saw that it was Windows based and realized that wouldn't work for me on Linux.Did you ever release it to the public?As for the spectrum plots, I'm using the RS232 interface, and the data moves quite slow at 19.2kb/s which seems to be the highest speed (unless a new firmware improves this or there are undocumented features). I need to explore changing the ':FORMat:DATA` command to transfer the numbers as binary IEE754 floating point which should happen several times faster (think ~14 bytes as ASCII vs 8 bytes for a double). It takes maybe 5 seconds to just receive the FFT data over serial. I think the actual conversion time for the internal DSP is the considerably faster, and should be the same as you experience with your app.

author: 2bluesc
author_rank: Contributor
timestamp: May 31, 2017, 09:20:37 pm
content: After I get done exploring with my THD tests, I'm curious if I can make something like your DMM app. I'd like to see if it's possible to write a driver forsigrokandpulseviewand if the sigrok UI tools like pulseview are useable to justify the effort vs a standalone app that suits my needs.

author: 2bluesc
author_rank: Contributor
timestamp: June 01, 2017, 08:55:58 pm
content: Played around a bit more with the FFT binning. It appears the `DIST:FREQ` command does modify the width of the bins on my 2015 as described for the 2015-P.If I set the 'DIST:FREQ' (apparently bin width in special cases) to 20 Hz and read all 1023 samples I get the attached plot. The original plots were with the frequency set to auto acquire and only reading the first 500 samples (at 60Hz bin width). The THD and THD+N numbers appear to be garbage, and this led me to believe it wasn't working earlier as it sets the 0 magnitude reference to whatever noise it reads at 20 Hz. After some normalization of the FFT plot values I get the attached graph with 20 Hz bandwidth per bin. I assume that I can easily sum the harmonics and derive my own THD and THD+N values with higher resolution for lower frequencies (there's no data past 20kHz for harmonic calculations). I will need to test the 20Hz vs automatic 60 Hz bin width and see if they agree for test values of 1kHz.Seems odd that Keithley wouldn't calculate intelligent THD, THD+N, SINAD values after adding a new SCPI bin width command that doesn't overlap the DIST:FREQ command.The Harmonics graph is a mess still, please ignore.

author: 1audio
author_rank: Frequent Contributor
timestamp: September 05, 2017, 06:46:54 pm
content: I'm almost done with a VB app for the Keithley that I'll be sharing. If you have the code for the harmonics it would be helpful. That's the next challenge. I'm using GPIB and its pretty quick. Supposedly it can make a lot of measurements very quickly if the internal processor is used to do the sequencing.One limitation is the internal source. I can't find a schematic to come up with ideas on improving it. I'm sure its the 12 bit DAC but its not a simple DAC upgrade if there's only 12 bits to drive it.

author: dvb
author_rank: Newbie
timestamp: January 11, 2018, 06:41:10 pm
content: Hi guys! Any progress in this matter? I bought a 2015 few months ago and I'm still shocked by the lack of apps for this instruments...Take care!@GOHZU - I've tried to PM you but no luck, seems your PM service is disabled...

author: frankmhowell
author_rank: Newbie
timestamp: May 06, 2019, 11:49:31 pm
content: G0HZU has incoming blocked/disabled everywhere...including his YouTube channel.

author: frankmhowell
author_rank: Newbie
timestamp: May 06, 2019, 11:51:30 pm
content: Any chance of sharing this?Frank

author: emartine
author_rank: Contributor
timestamp: April 14, 2022, 02:13:29 pm
content: I will purchase this meter and upload an app to github, so anyone can use it..Im already working on it.This is my github page if you wanna help:https://github.com/andmarti1424

author: 1audio
author_rank: Frequent Contributor
timestamp: April 15, 2022, 05:21:30 am
content: Feel free to use whatever you can from this:https://github.com/1audio/Keithley-Windows-10Its mostly working. Integrating the harmonics analysis with the rest of the package would make it very useful. Adding control for an external oscillator (the internal source is not very good) would enhance its utility.

author: emartine
author_rank: Contributor
timestamp: April 15, 2022, 09:10:46 am
content: Thanks! Will check it out.

author: emartine
author_rank: Contributor
timestamp: July 25, 2022, 10:44:42 pm
content: I have been working on my app lately. In case anyone is interested, you can find it here:https://github.com/andmarti1424/free_keithleyAny help is always welcome!Thanks.

author: dvb
author_rank: Newbie
timestamp: January 27, 2023, 10:59:52 am
content: Hi, thanks for sharing!Now, can you write a few words about hardware setup? What kind of cable, interface, settings... ?Best regards!

author: emartine
author_rank: Contributor
timestamp: January 27, 2023, 12:31:26 pm
content: I dont know what you mean but ask whatever you need.

author: dvb
author_rank: Newbie
timestamp: January 27, 2023, 01:27:07 pm
content: "Is the instrument linked to the computer via serial interface?" sort of thing...Thanks

author: emartine
author_rank: Contributor
timestamp: January 27, 2023, 01:28:14 pm
content: RS232 port.I use an RS232 to USB cable.

author: dvb
author_rank: Newbie
timestamp: January 27, 2023, 01:51:53 pm
content: ... and yet another stupid question before trying to download the required software: is this software suite Windows or Linux? Say it is Windows, please!Thanks

author: emartine
author_rank: Contributor
timestamp: January 27, 2023, 01:56:06 pm
content: I use it on Linux. But it should work on Windows as well if you download the requirements..python 3.10+matplotlibpython-pyserialtkinterDIdnt try it myself though cause windows is sh#t.(I use it at work)

author: dvb
author_rank: Newbie
timestamp: January 27, 2023, 02:55:08 pm
content: Unfortunately I don't have the time to fiddle with installation under Win10 right now but it's very good you wrote these apps! A more compact Windows version (like an executable) will have a bigger success in the future than a Linux one, just my opinion...Best regards, take care!Later edit: I did figure out how to setup all requirements sooner than I thought but I receive the following (same) error in command prompt (same from IDLE Python utility) when I try to launch the modules" File "C:\Users\Dorin\AppData\Local\Programs\Python\Python311\free_keithley-main\thd.py", line 28, in <module>import pandas as pdModuleNotFoundError: No module named 'pandas' "

author: dvb
author_rank: Newbie
timestamp: January 27, 2023, 05:07:09 pm
content: Are these Keithley 2015 RS232 settings OK?- BAUD: 19.2k- FLOW: NONE- TX TERM: CR

author: dvb
author_rank: Newbie
timestamp: January 27, 2023, 11:28:49 pm
content: I have installed "pandas" and "serial" as a result of errors I received but now I have:" File "C:\Users\Dorin\AppData\Local\Programs\Python\Python311\free_keithley-main\thd.py", line 38, in __init__self.ser = serial.Serial()AttributeError: module 'serial' has no attribute 'Serial' "The settings of serial port are to be edited in module?I have 3 COM ports, the last one called "ATEN USB to Serial Bridge (COM5)" in Device Manager, used by Keithley - communication tested OK with Putty at both 9600 and 19200 baud.How does the module know which one to use?Thanks!

author: zrq
author_rank: Frequent Contributor
timestamp: January 28, 2023, 09:02:42 am
content: Are you sure you have the correct serial package installed? It appears to requirehttps://pypi.org/project/pyserial/. There can be python packages that have a same name.

author: dvb
author_rank: Newbie
timestamp: January 28, 2023, 09:44:11 am
content: I think so, I have just checked and..." C:\Users\Dorin\AppData\Local\Programs\Python\Python311>pip install pyserialRequirement already satisfied: pyserial in c:\users\dorin\appdata\local\programs\python\python311\lib\site-packages (3.5) "I can only imagine that not being yet tested for Windows (as Andres/emartine said) a lot of little things are still to be sorted out (as I was affraid of)

author: emartine
author_rank: Contributor
timestamp: January 28, 2023, 09:01:40 pm
content: Quote from: 1audio on April 15, 2022, 05:21:30 amHello. I made some progress. You can take a look at it:https://github.com/andmarti1424/free_keithleyThe thing is I cannot find anything regarding FFT on your code. As im having trouble to interpret the bins after I issue:':DIST:FFT:BINS? 1,1023'It is also very slow over RS232..Thanks for your help.

author: dvb
author_rank: Newbie
timestamp: January 31, 2023, 01:26:42 am
content: An alternative to Keithley's internal generator can be a relatively cheap Focusrite 2i2 (2nd gen) set to 0.5Vrms headphone output, for which Keithley reads "000.001 THD" (10 harmonics).For 0.2Vrms line output directly from soundcard Keithley reads "000.000 THD" while the soundcard's ADC reads 0.0006%(via Waveforms software from Digilent, but other programs give the same results)My conclusion here is that Keithley 2015 shouldn't be disregarded so easily, still has its use!

author: 1audio
author_rank: Frequent Contributor
timestamp: January 31, 2023, 01:59:43 am
content: emartine RE the code I shared on Github- It did not have any FFT stuff. We weren't clear if it was even supported on the non-p version. The student who crafted that code for me (from the original from the web) has since gone on to real work. I sort of know what it does and directed what I wanted it to do.I'll download your code to see what you have. We never put effort into RS232 since I have GPIB all over here.

author: emartine
author_rank: Contributor
timestamp: January 31, 2023, 12:26:46 pm
content: Hello there. I managed to have some progress based on this info:https://www.eevblog.com/forum/testgear/continuing-the-keithley-2015-2015p-saga/I still want to compare the FFT that my program generate with the one that my scope do.I do still want to know if the bin width of 20hz is the onlly way to set it..Some more comments:yes, FFT works on 2015 model (not only the p one)I could make FFT little quicker changing baudrate in the rs232 communication to 19200.Changing format data from ascii to binary would make it quicker as well but the only format allowed for data over rs232 is ascii. Cannot change it to binary as you would do with GPIB.

author: emartine
author_rank: Contributor
timestamp: January 31, 2023, 01:22:54 pm
content: Quote from: dvb on January 28, 2023, 09:44:11 amI am afraid is not the case. See here:https://pythonhosted.org/pyserial/shortintro.html#opening-serial-portsit opens the serial port just as my app:ser = serial.Serial('/dev/ttyUSB0') # open serial portThere must be something wrong with the pyserial installation or version.