{"id":6236,"date":"2021-04-14T11:08:59","date_gmt":"2021-04-14T10:08:59","guid":{"rendered":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2021\/04\/14\/long-term-measurements-with-keithley-and-matlab\/"},"modified":"2021-04-14T11:08:59","modified_gmt":"2021-04-14T10:08:59","slug":"long-term-measurements-with-keithley-and-matlab","status":"publish","type":"post","link":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2021\/04\/14\/long-term-measurements-with-keithley-and-matlab\/?lang=en","title":{"rendered":"Long-term measurements with Keithley and Matlab"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_6236\" class=\"pvc_stats all  \" data-element-id=\"6236\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<div id=\"attachment_3104\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085430.jpg\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-3104\" class=\"wp-image-3104 size-medium\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085430-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085430-300x225.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085430-768x576.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085430-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-3104\" class=\"wp-caption-text\">Keithley2000 desk multimeter<\/p><\/div>\n<p style=\"text-align: justify\">The bench multimeter from Keithley is an old companion in the field of measuring instruments. The types of the 2000 series are predominantly used in our laboratories. They are available in different equipment variants with regard to the interfaces to the outside world. Here GBIP bus is of course a standard, as is RS232. The newer devices now have a LAN interface with which communication via the Internet protocol is possible. Each of these interfaces can be used to communicate with the device using &#8222;Standard Commands for Programmable Instruments&#8220; (SCPI). In this example I will control the Keithley 2000 via Matlab and read out measured values \u200b\u200bcyclically over a longer period of time, save them in Matlab and finally output them in a plot &#8211; virtually configure a simple data logger. The purpose of this setup is to record the voltage curve (or current) of a rechargeable battery or battery of a low-energy device.<\/p>\n<div id=\"attachment_3102\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085234.jpg\"><img decoding=\"async\" aria-describedby=\"caption-attachment-3102\" class=\"wp-image-3102 size-medium\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085234-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085234-300x225.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085234-768x576.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085234-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-3102\" class=\"wp-caption-text\">backside of the Keithley 2000<\/p><\/div>\n<div id=\"attachment_3105\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085254.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3105\" class=\"wp-image-3105 size-medium\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085254-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085254-300x225.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085254-768x576.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085254-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-3105\" class=\"wp-caption-text\">GPIB Interface (IEEE488)<\/p><\/div>\n<div id=\"attachment_3106\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085247.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3106\" class=\"wp-image-3106 size-medium\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085247-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085247-300x225.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085247-768x576.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085247-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-3106\" class=\"wp-caption-text\">RS232 interface<\/p><\/div>\n<p style=\"text-align: justify\">In this example I will use the serial data transmission via the classic RS232 interface, as this is completely sufficient for my application. In addition, I can save myself the installation of the driver packages for the GPIP-USB interface. \ud83d\ude42 Since many of the current computers and laptops no longer have any RS232 ports, a USB-RS232 adapter (e.g. FTDI232 etc.) is required.<\/p>\n<div id=\"attachment_3103\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085547.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3103\" class=\"wp-image-3103 size-medium\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085547-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085547-300x225.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085547-768x576.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/IMG_20180112_085547-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-3103\" class=\"wp-caption-text\">USB-RS232 Adaper am Keithley2000<\/p><\/div>\n<p style=\"text-align: justify\">Once the connection between the multimeter and the computer has been established, communication can take place via a Matlabscript, as in this example. The Keithley only needs to be told that it should &#8222;talk&#8220; over the serial interface. The following code snippets show how you can easily read out data via SCPI:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\nserialObject = instrfind('Type', 'serial', 'Port', 'COM26', 'Tag', '');\r\n%serialPort = 'COM23';\r\n%serialObject = serial(serialPort,'BaudRate',9600, 'DataBits',8);\r\n\r\nif isempty(serialObject)\r\nserialObject = serial('COM26','BaudRate',57600, 'DataBits',8);\r\nelse\r\nfclose(serialObject);\r\nserialObject = serialObject(1)\r\nend\r\n\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n%\r\n% Sourcemeter 2000 setup\r\n%\r\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\nfopen(serialObject)\r\n% fprintf(serialObject,':*RST')\r\n\r\ntime = now;\r\nvoltage = 0;\r\n%%\r\nfigureinstanz = figure('NumberTitle','off',...\r\n'Name','Spannungslogg',...\r\n'Color',&#x5B;0 0 0],'Visible','off');\r\nplotinstanz = plot(voltage,time,'Color','red');\r\n\r\n%% Messzeit und evtl Messintervall\r\nstoptime = 10; %60 seconds\r\ntimeInterval = 1; % brauch' ma jetzt nicht\r\n\r\n% Messgeraet einstellen\r\nfprintf(serialObject,':SOUR:FUNC:MODE CURR'); % current source selection.\r\nfprintf(serialObject,':SOUR:CURR:MODE FIXED'); % changes voltage mode to fixed\r\nfprintf(serialObject,':SOUR:CURR:LEV 0'); % sets current to 0\r\n\r\nfprintf(serialObject,':SENS:FUNC &amp;quot;VOLT&amp;quot;');\r\nfprintf(serialObject,':SENS:VOLT:PROT 4');\r\n%fprintf(serialObject,':SENS:CURR:RANG:AUTO ON');\r\nfprintf(serialObject,':SENS:VOLT:RANG 10');\r\nfprintf(serialObject,':FORM:ELEM VOLT');\r\n\r\n% %fprintf(serialObject,':TRAC:COUN 1');\r\n% %fprintf(serialObject,':TRAC:FEED:CONT NEV');\r\n%\r\n%\r\n% fprintf(serialObject,':TRAC:CLE');\r\n%\r\n% fprintf(serialObject,':TRAC:POIN 10');\r\n% fprintf(serialObject,'TRAC:FEED:SENS');\r\n% fprintf(serialObject,'TRAC:FEED:CONT NECT');\r\n% fprintf(serialObject,'TRIG:COUN 10');\r\n% fprintf(serialObject,':OUTP ON');\r\n%\r\n% fprintf(serialObject,':INIT');\r\n% fprintf(serialObject,':TRACE:DATA?');\r\n\r\n%% Daten abholen\r\ncount = 1; voltage(1)=4\r\ntic;\r\ntime=toc;\r\n% while time&amp;lt;=stoptime\r\nwhile voltage&amp;gt;=1.5\r\n% fprintf(serialObject,':INIT');\r\n% fprintf(serialObject,':TRAC:FEED SENS');\r\n% fprintf(serialObject,':TRAC:DATA?');\r\n%\r\nfprintf(serialObject,':READ?');\r\nvoltage(count) = fscanf(serialObject,'%f');\r\ntime(count) = toc;\r\nset(plotinstanz,'YData',voltage,'XData',time);\r\nset(figureinstanz,'Visible','on');\r\npause(timeInterval);\r\ncount = count +1;\r\nend\r\n\r\nfigure(1);\r\nplot(time,voltage);\r\ngrid on; hold on;\r\nxlabel('Zeit &#x5B;s]'); ylabel('Batteriespannung &#x5B;V]')\r\ntitle('Spannungsverlauf Batterie 3V Lithium (2032 mit Modul) im default mode');\r\n\r\n% fprintf(serialObject,':OUTP OFF');\r\n%% Put the instrument in local mode\r\nfprintf(serialObject,'SYSTEM:LOCAL');\r\nfclose(serialObject);\r\n<\/pre>\n<p style=\"text-align: justify\">The following plot shows what such a data log looks like. Here, the voltage curve of a nearly discharged battery is recorded over time until the consumer is switched off.<\/p>\n<p><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/Spannungsverlauf.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-6237 size-full\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/Spannungsverlauf.jpg\" alt=\"\" width=\"955\" height=\"602\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/Spannungsverlauf.jpg 955w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/Spannungsverlauf-300x189.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2018\/01\/Spannungsverlauf-768x484.jpg 768w\" sizes=\"(max-width: 955px) 100vw, 955px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_6236\" class=\"pvc_stats all  \" data-element-id=\"6236\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>The bench multimeter from Keithley is an old companion in the field of measuring instruments. The types of the 2000 series are predominantly used in our laboratories. They are available in different equipment variants with regard to the interfaces to the outside world. Here GBIP bus is of course a standard, as is RS232. The&hellip; <br \/> <a class=\"read-more\" href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2021\/04\/14\/long-term-measurements-with-keithley-and-matlab\/?lang=en\">Weiterlesen<\/a><\/p>\n","protected":false},"author":86,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[1506],"tags":[1837,1838,1844,1829,1836,1843,1828,1842,1840,1839,1845,1841],"class_list":["post-6236","post","type-post","status-publish","format-standard","hentry","category-electronics-hobbyist","tag-datalog-en","tag-datalogging-with-matlab","tag-ft232-en","tag-gpib-en","tag-keithley-en","tag-keithley2000-en","tag-matlab-en","tag-measurement-automation","tag-measurement-with-matlab-und-keitley","tag-rs232-en","tag-scpi-en","tag-tablemultimeter"],"a3_pvc":{"activated":true,"total_views":353,"today_views":0},"_links":{"self":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/6236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/comments?post=6236"}],"version-history":[{"count":0,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/6236\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/media?parent=6236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/categories?post=6236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/tags?post=6236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}