<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Risto H. Kurppa &#187; work</title>
	<atom:link href="http://risto.kurppa.fi/blog/tag/work/feed/" rel="self" type="application/rss+xml" />
	<link>http://risto.kurppa.fi/blog</link>
	<description>random words..</description>
	<lastBuildDate>Fri, 03 Feb 2012 15:19:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using a HP multimeter the lazy.. no, smart way</title>
		<link>http://risto.kurppa.fi/blog/2009/07/using-a-hp-multimeter-the-lazy-no-smart-way/</link>
		<comments>http://risto.kurppa.fi/blog/2009/07/using-a-hp-multimeter-the-lazy-no-smart-way/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 18:13:05 +0000</pubDate>
		<dc:creator>Risto H. Kurppa</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[planet-fnoss]]></category>
		<category><![CDATA[planet-ubuntu]]></category>
		<category><![CDATA[planet-vapaasuomi]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://risto.kurppa.fi/blog/?p=1842</guid>
		<description><![CDATA[At my work I need to measure various things every now and then. I mostly use a DAQ card of a Linux computer with comedilib. Today I also needed to store the values of a multimeter (HP 34401A) that measured &#8230; <a href="http://risto.kurppa.fi/blog/2009/07/using-a-hp-multimeter-the-lazy-no-smart-way/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ul>
<li><a href='http://risto.kurppa.fi/blog/2011/06/matlab-image-save-speed/' rel='bookmark' title='Matlab image save speed'>Matlab image save speed</a> <small>I use Matlab at my work to analyze measurements. This...</small></li>
<li><a href='http://risto.kurppa.fi/blog/2008/12/calendar-1912/' rel='bookmark' title='19.12.'>19.12.</a> <small>Tämä viesti on osa vuoden 2008 adventtikalenteria. This post is...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p><a  href="http://risto.kurppa.fi/blog/wp-content/uploads/2009/07/multimeter.jpg" class="thickbox no_icon" rel="gallery-1842" title="HP multimeter"><img class="alignright size-medium wp-image-1844" title="HP multimeter" src="http://risto.kurppa.fi/blog/wp-content/uploads/2009/07/multimeter-300x225.jpg" alt="HP multimeter" width="210" height="158" /></a>At my work I need to measure various things every now and then. I mostly use a <a  href="http://en.wikipedia.org/wiki/Data_acquisition">DAQ</a> card of a Linux computer with <a  href="http://www.comedi.org/">comedilib</a>.</p>
<p>Today I also needed to store the values of a multimeter (HP 34401A) that measured the voltage over something the DAQ card also measured (PCI-DAS4020/12) measurement  &#8211; I wanted to see how the values change during a longer period of time so I plot the data from both the DAQ card and the multimeter and see how the correlate.</p>
<h3>Version 0.1 &#8211; the old fashion way..</h3>
<p>I take pen &amp; paper and write down the reading of the multimeter at the same time when I run the DAQ measurement. It&#8217;s time consuming and requires me to stay at the setup all the time. I also have to use time to move my notes from paper to the computer. Works for shorter measurements.</p>
<h3>Version 0.2 &#8211; the simple digital way</h3>
<p>I write the numbers directly to the computer. Makes it easier to start processing the data, but still requires me to stay around the whole time.</p>
<h3>Version 0.3 &#8211; half-automated</h3>
<p>We connected a Canon SX100IS camera with a USB cable on the Linux computer. Then we wrote a small script to run the DAQ card measurement every 30s &#8211; and using <a  href="http://www.gphoto.org/">gphoto2</a> to tell the camera to take a photo of the multimeter Gphoto2 is an awesome tool to control about any digital camera! Then when the measurement was done, I wrote the values from the photos to a text file and was ready to analyze the data. I don&#8217;t have to stay around the whole time waiting for the next 30s period, the camera does the work for me.</p>
<p>Here&#8217;s the script:<br />
<code><br />
#gphoto2 --delete-all-files -R # this removes all files from camera.. be careful..<br />
#<br />
for i in {1..40};<br />
do<br />
echo "#################"<br />
echo "MEASUREMENT $i"<br />
date<br />
echo "#################"<br />
#<br />
#capture a photo<br />
gphoto2 --capture-image &amp;<br />
#<br />
#run the DAQ measurement<br />
/home/administrator/comedilib-0.7.22/demo/mmap &gt; mittaus$i<br />
#<br />
sleep 30<br />
done<br />
#<br />
#download all photos and rename them to photo1.jpg photo2jpg etc..<br />
gphoto2 --get-all-files -R --filename=photo%n.jpg</code></p>
<p>But I still have to copy manually the multimeter values from the photos. Doesn&#8217;t work for long measurements, say 2000 photos or more..</p>
<h3>Version 0.5 &#8211; automated version</h3>
<p>We were discussing already earlier today the option of using <a  href="http://en.wikipedia.org/wiki/IEEE-488">GPIB</a> to read the numbers. There&#8217;s <a  href="http://linux-gpib.sourceforge.net/">linux-gpib</a> package available as well as <a  href="http://pyvisa.sourceforge.net/">python-visa</a> so it shouldn&#8217;t be too bad. However since I&#8217;ve never done anything on python nor GPIB I decided to try the RS-232 aka. serial interface. Google gave me the <a  href="http://centrum.feld.cvut.cz/?download=_/hp34401a/hp34401">HP34401A manual</a> that told me what kind of commands the multimeter understands and how to connect there. After playing around a while I had a bash script to do the work for me. It uses standard linux commands like echo, head, sleep, for and stty so it should work on any Linux box with no additional software or hardware required.</p>
<p><code>delay=30<br />
measurements=240<br />
#<br />
#Initialize the serial port<br />
stty -F /dev/ttyS0 ispeed 9600 ospeed 9600 -echo cs8<br />
#<br />
#Set the multimeter to remote mode:<br />
echo "SYST:REM" &gt; /dev/ttyS0<br />
#<br />
#Reset the multimeter<br />
echo "*CLS" &gt; /dev/ttyS0<br />
echo "*RST" &gt; /dev/ttyS0<br />
#<br />
#Show 'LOADING..' text on the screen<br />
echo "DISP:TEXT 'LOADING..'" &gt; /dev/ttyS0<br />
sleep 5<br />
#<br />
echo "########" &gt;&gt; values<br />
date &gt;&gt; values<br />
echo "Points $measurements" &gt;&gt; values<br />
echo "Delay $delay" &gt;&gt; values<br />
#<br />
for ((i=1;i&lt;=$measurements;i+=1));<br />
do<br />
#<br />
echo "#################"<br />
echo "Measurement $i/$measurements"<br />
date<br />
echo "#################"<br />
#<br />
#Show text on multimeter screen<br />
echo "DISP:TEXT 'MEASURING..'" &gt; /dev/ttyS0<br />
#<br />
sleep 1<br />
#<br />
#Measure the DC voltage with the multimeter<br />
echo "MEAS:VOLT:DC?" &gt; /dev/ttyS0<br />
#<br />
sleep 2<br />
#<br />
#Read the value<br />
head -n 1 /dev/ttyS0 &gt;&gt; voltit &amp;<br />
#<br />
#Run the DAQ measurement<br />
/home/administrator/comedilib-0.7.22/demo/mmap &gt; mittaus$i<br />
#<br />
#Show counter<br />
echo "DISP:TEXT '$i/$measurements'" &gt; /dev/ttyS0<br />
#<br />
sleep $delay<br />
done<br />
#<br />
#Clear display<br />
echo "DISP:TEXT:CLEAR" &gt; /dev/ttyS0<br />
#<br />
#Return to local mode<br />
echo "SYST:LOC" &gt; /dev/ttyS0<br />
</code><br />
Now I had it all automated. This simple bash script controls both the DAQ card and the multimeter and saves the multimeter values in a text file. No need for me to wait at the setup nor write or copy the values anywhere. It also shows the number of the current measurement on the screen of the multimeter. The commands to send to the multimeter are very simple, <a  href="http://en.wikipedia.org/wiki/Standard_Commands_for_Programmable_Instrumentation">SCPI</a> commands so the same commands work for ~any hardware. The same commands also work with GPIB.</p>
<p>I know the same could be done with &#8216;real&#8217; programming languages like Python or  C or GUI tools like LabView (<a  href="http://sine.ni.com/nips/cds/view/p/lang/en/nid/14216">starting from 780€</a>). But 30 simple lines of bash (the rest&#8217;s comments &amp; empty space) does it for me. I just love Linux.</p>

<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fristo.kurppa.fi%2Fblog%2F2009%2F07%2Fusing-a-hp-multimeter-the-lazy-no-smart-way%2F" layout="standard" show_faces="true" width="450" action="recommend" colorscheme="light"></fb:like></p>
<p><a  class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fristo.kurppa.fi%2Fblog%2F2009%2F07%2Fusing-a-hp-multimeter-the-lazy-no-smart-way%2F&#038;linkname=Using%20a%20HP%20multimeter%20the%20lazy..%20no%2C%20smart%20way" title="Facebook" rel="nofollow" target="_blank"><img src="http://risto.kurppa.fi/blog/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a  class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fristo.kurppa.fi%2Fblog%2F2009%2F07%2Fusing-a-hp-multimeter-the-lazy-no-smart-way%2F&#038;linkname=Using%20a%20HP%20multimeter%20the%20lazy..%20no%2C%20smart%20way" title="Twitter" rel="nofollow" target="_blank"><img src="http://risto.kurppa.fi/blog/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a  class="a2a_button_identi_ca" href="http://www.addtoany.com/add_to/identi_ca?linkurl=http%3A%2F%2Fristo.kurppa.fi%2Fblog%2F2009%2F07%2Fusing-a-hp-multimeter-the-lazy-no-smart-way%2F&#038;linkname=Using%20a%20HP%20multimeter%20the%20lazy..%20no%2C%20smart%20way" title="Identi.ca" rel="nofollow" target="_blank"><img src="http://risto.kurppa.fi/blog/wp-content/plugins/add-to-any/icons/identica.png" width="16" height="16" alt="Identi.ca"/></a><a  class="a2a_button_digg" href="http://www.addtoany.com/add_to/digg?linkurl=http%3A%2F%2Fristo.kurppa.fi%2Fblog%2F2009%2F07%2Fusing-a-hp-multimeter-the-lazy-no-smart-way%2F&#038;linkname=Using%20a%20HP%20multimeter%20the%20lazy..%20no%2C%20smart%20way" title="Digg" rel="nofollow" target="_blank"><img src="http://risto.kurppa.fi/blog/wp-content/plugins/add-to-any/icons/digg.png" width="16" height="16" alt="Digg"/></a><a  class="a2a_button_google_reader" href="http://www.addtoany.com/add_to/google_reader?linkurl=http%3A%2F%2Fristo.kurppa.fi%2Fblog%2F2009%2F07%2Fusing-a-hp-multimeter-the-lazy-no-smart-way%2F&#038;linkname=Using%20a%20HP%20multimeter%20the%20lazy..%20no%2C%20smart%20way" title="Google Reader" rel="nofollow" target="_blank"><img src="http://risto.kurppa.fi/blog/wp-content/plugins/add-to-any/icons/reader.png" width="16" height="16" alt="Google Reader"/></a><a  class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fristo.kurppa.fi%2Fblog%2F2009%2F07%2Fusing-a-hp-multimeter-the-lazy-no-smart-way%2F&#038;linkname=Using%20a%20HP%20multimeter%20the%20lazy..%20no%2C%20smart%20way" title="Delicious" rel="nofollow" target="_blank"><img src="http://risto.kurppa.fi/blog/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a  class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fristo.kurppa.fi%2Fblog%2F2009%2F07%2Fusing-a-hp-multimeter-the-lazy-no-smart-way%2F&#038;title=Using%20a%20HP%20multimeter%20the%20lazy..%20no%2C%20smart%20way" id="wpa2a_2">Share</a></p><p>Related posts:<ul>
<li><a href='http://risto.kurppa.fi/blog/2011/06/matlab-image-save-speed/' rel='bookmark' title='Matlab image save speed'>Matlab image save speed</a> <small>I use Matlab at my work to analyze measurements. This...</small></li>
<li><a href='http://risto.kurppa.fi/blog/2008/12/calendar-1912/' rel='bookmark' title='19.12.'>19.12.</a> <small>Tämä viesti on osa vuoden 2008 adventtikalenteria. This post is...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://risto.kurppa.fi/blog/2009/07/using-a-hp-multimeter-the-lazy-no-smart-way/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

