<?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>PC Based Automation &#187; access</title>
	<atom:link href="http://www.dajac.com/blog/tag/access/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dajac.com/blog</link>
	<description>Exploring all aspects of PC based automation.</description>
	<lastBuildDate>Sun, 29 Aug 2010 16:25:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use Microsoft Office for Your Next Automation Project</title>
		<link>http://www.dajac.com/blog/2010/08/29/microsoft-office-automation/</link>
		<comments>http://www.dajac.com/blog/2010/08/29/microsoft-office-automation/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 16:02:02 +0000</pubDate>
		<dc:creator>David Novak</dc:creator>
				<category><![CDATA[I/O Modules]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Expert I/O]]></category>
		<category><![CDATA[Macro]]></category>
		<category><![CDATA[Microsoft Office]]></category>
		<category><![CDATA[pc based automation]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[Visual Basic for Applications]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://www.dajac.com/blog/?p=475</guid>
		<description><![CDATA[If a software development platform can call a DLL, it can be used to control the Expert I/O 1000. Microsoft Office with Visual Basic for Applications (VBA) is no exception.
For most people, Office would be the last tool they would consider for PC based automation, but in some cases it might be the best. For [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_488" class="wp-caption alignright" style="width: 130px"><img src="http://www.dajac.com/blog/wp-content/uploads/2010/08/ms_office_logo.jpg" alt="Microsoft Office" title="Microsoft Office" width="120" height="103" class="size-full wp-image-488" /><p class="wp-caption-text">Automate with Office</p></div></p>
<p>If a software development platform can call a DLL, it can be used to control the Expert I/O 1000. Microsoft Office with Visual Basic for Applications (VBA) is no exception.</p>
<p>For most people, Office would be the last tool they would consider for PC based automation, but in some cases it might be the best. For example, you could easily log data to an Excel spreadsheet or Access database as you collect it and once it&#8217;s in these applications, it&#8217;s simple to manipulate, plot and report the data.</p>
<p><span id="more-475"></span></p>
<p>Office provides two big advantages.</p>
<ol>
<li>Low start up cost.</li>
<li>Short learning curve.</li>
</ol>
<p>The main advantage of Office is its low start up cost. Practically every computer in existence has Microsoft Office installed. If you don&#8217;t need the features of a full fledged software development suite, you can save a bunch of money by using a tool that is already on your computer.</p>
<p>The other big advantage of Office is that many people who aren&#8217;t software engineers know a great deal about VBA. It is used all the time for office automation by non-engineers. Microsoft has given us a development tool that can be used by everyone, not just geeky software engineers.</p>
<p>Controlling the Expert I/O using VBA in Excel is very easy. Here is the entire code of a VBA macro I created. The entire subroutine is only about a dozen lines.
<div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br /></div></td><td><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #008000;">' Expert I/O API.<br />
</span> &nbsp; &nbsp; <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> eioOpen <span style="color: #000080;">Lib</span> <span style="color: #800000;">&quot;eio.dll&quot;</span> () <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span><br />
&nbsp; &nbsp; <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> eioClose <span style="color: #000080;">Lib</span> <span style="color: #800000;">&quot;eio.dll&quot;</span> () <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span><br />
&nbsp; &nbsp; <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> eioClaimInterfaceEz <span style="color: #000080;">Lib</span> <span style="color: #800000;">&quot;eio.dll&quot;</span> (<span style="color: #000080;">ByVal</span> ModelId <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>, <span style="color: #000080;">ByVal</span> SerialNumber <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, <span style="color: #000080;">ByRef</span> Handle <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span><br />
&nbsp; &nbsp; <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> eioReleaseInterface <span style="color: #000080;">Lib</span> <span style="color: #800000;">&quot;eio.dll&quot;</span> (<span style="color: #000080;">ByVal</span> Handle <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span><br />
&nbsp; &nbsp; <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> eioDioSetPull <span style="color: #000080;">Lib</span> <span style="color: #800000;">&quot;eio.dll&quot;</span> (<span style="color: #000080;">ByVal</span> Handle <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, <span style="color: #000080;">ByVal</span> Port <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, <span style="color: #000080;">ByVal</span> PullLevel <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span><br />
&nbsp; &nbsp; <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> eioDioSet <span style="color: #000080;">Lib</span> <span style="color: #800000;">&quot;eio.dll&quot;</span> (<span style="color: #000080;">ByVal</span> Handle <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, <span style="color: #000080;">ByVal</span> Port <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, <span style="color: #000080;">ByVal</span> PinLevels <span style="color: #000080;">As</span> <span style="color: #000080;">Byte</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span><br />
&nbsp; &nbsp; <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> eioDioGet <span style="color: #000080;">Lib</span> <span style="color: #800000;">&quot;eio.dll&quot;</span> (<span style="color: #000080;">ByVal</span> Handle <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, <span style="color: #000080;">ByVal</span> Port <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, <span style="color: #000080;">ByRef</span> PinLevels <span style="color: #000080;">As</span> <span style="color: #000080;">Byte</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">' Constants<br />
</span> &nbsp; &nbsp; <span style="color: #000080;">Const</span> MODEL_ID <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span> = 1<br />
&nbsp; &nbsp; <span style="color: #000080;">Const</span> SERIAL_NUMBER <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span> = 99<br />
&nbsp; &nbsp; <span style="color: #000080;">Const</span> INPUT_PORT <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span> = 0<br />
&nbsp; &nbsp; <span style="color: #000080;">Const</span> OUTPUT_PORT <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span> = 2<br />
&nbsp; &nbsp; <span style="color: #000080;">Const</span> eioDIO_PULL_3_3 <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span> = 1<br />
&nbsp; &nbsp; <span style="color: #000080;">Const</span> eioDIO_PULL_GND <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span> = 2<br />
&nbsp; &nbsp; <br />
<span style="color: #000080;">Sub</span> DigitalIo()<br />
&nbsp; &nbsp; <span style="color: #000080;">Dim</span> Handle <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span><br />
&nbsp; &nbsp; <span style="color: #000080;">Dim</span> PinLevels <span style="color: #000080;">As</span> <span style="color: #000080;">Byte</span><br />
&nbsp; &nbsp; <span style="color: #000080;">Dim</span> ReturnCode <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">' Open API and get handle. Normally, this would be done only once at the<br />
</span> &nbsp; &nbsp; <span style="color: #008000;">' beginning of the program. It has been included here to keep the<br />
</span> &nbsp; &nbsp; <span style="color: #008000;">' example as simple as possible.<br />
</span> &nbsp; &nbsp; ReturnCode = eioOpen()<br />
&nbsp; &nbsp; ReturnCode = eioClaimInterfaceEz(MODEL_ID, SERIAL_NUMBER, Handle)<br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">' Set digital pulls.<br />
</span> &nbsp; &nbsp; ReturnCode = eioDioSetPull(Handle, INPUT_PORT, eioDIO_PULL_3_3)<br />
&nbsp; &nbsp; ReturnCode = eioDioSetPull(Handle, OUTPUT_PORT, eioDIO_PULL_3_3)<br />
<br />
&nbsp; &nbsp; <span style="color: #008000;">' Set output levels equal to cell in spreadsheet.<br />
</span> &nbsp; &nbsp; PinLevels = Cells(3, 5)<br />
&nbsp; &nbsp; ReturnCode = eioDioSet(Handle, OUTPUT_PORT, PinLevels)<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008000;">' Get input levels and set spreadsheet cell to the value read.<br />
</span> &nbsp; &nbsp; ReturnCode = eioDioGet(Handle, INPUT_PORT, PinLevels)<br />
&nbsp; &nbsp; Cells(5, 5).Value = PinLevels<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #008000;">' Clean up. Normally, this would be done only once at the end of the<br />
</span> &nbsp; &nbsp; <span style="color: #008000;">' program. It has been included here since we included eioOpen() and<br />
</span> &nbsp; &nbsp; <span style="color: #008000;">' eioClaimInterfaceEz() in this subroutine.<br />
</span> &nbsp; &nbsp; ReturnCode = eioReleaseInterface(Handle)<br />
&nbsp; &nbsp; ReturnCode = eioClose()<br />
<br />
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></div></td></tr></tbody></table></div>
<p>Lines 27 and 28 initialize the Expert I/O API. Lines 31 and 32 set the output voltage level and input pull up state. These lines would normally be placed in a subroutine that runs once at the beginning of the macro. The initialization does not need to be performed for every I/O access.</p>
<p>Lines 35 and 36 set a digital output port to the value in the spreadsheet at E3.</p>
<p>Lines 39 and 40 read a digital input port and write its value to the spreadsheet at E5.</p>
<p>The interface is released and the API is closed with lines 45 and 46. As with the initialization, this cleanup only needs to be performed once at the end of the macro.</p>
<p>As you can see, writing a VBA macro to control the Expert I/O is an incredibly simple task. So for your next automation project, don&#8217;t forget to consider Microsoft Office. It might be just what you need.</p>
<p><a href="http://www.dajac.com/files/excel_vba_digital_io.zip">Click here</a> to download the Excel file that contains this macro.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dajac.com/blog/2010/08/29/microsoft-office-automation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Expert I/O 1000 Access Times</title>
		<link>http://www.dajac.com/blog/2009/08/14/understanding-expert-io-1000-access-times/</link>
		<comments>http://www.dajac.com/blog/2009/08/14/understanding-expert-io-1000-access-times/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 19:06:38 +0000</pubDate>
		<dc:creator>David Novak</dc:creator>
				<category><![CDATA[I/O Modules]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[Expert I/O]]></category>
		<category><![CDATA[rate]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[timing]]></category>

		<guid isPermaLink="false">http://www.dajac.com/blog/?p=56</guid>
		<description><![CDATA[I often get questions about the Expert I/O 1000&#8217;s access time characteristics. The short answer is that you can change outputs at a rate of 100Hz and you can read inputs at 50Hz. However, the complete answer is more complicated.
When dealing with MS Windows on a PC, it&#8217;s not possible to get absolute realtime results. [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_168" class="wp-caption alignright" style="width: 79px"><img src="http://www.dajac.com/blog/wp-content/uploads/2009/08/timing.jpg" alt="Expert I/O Timing" title="Timing Diagram" width="69" height="57" class="size-full wp-image-168" /><p class="wp-caption-text">Expert I/O Timing</p></div></p>
<p>I often get questions about the Expert I/O 1000&#8217;s access time characteristics. The short answer is that you can change outputs at a rate of 100Hz and you can read inputs at 50Hz. However, the complete answer is more complicated.</p>
<p>When dealing with MS Windows on a PC, it&#8217;s not possible to get absolute realtime results. You will always have some variability in timing. However, Dajac&#8217;s USB implementation directly associates the timing to guaranteed values in the USB specification. Therefore, we know the guaranteed worst case access times at the USB level. <span id="more-56"></span></p>
<p>Nothing prevents Windows from providing faster access, but it&#8217;s not guaranteed and will depend on such things as processor load and software implementation techniques.</p>
<p>Obviously, the Expert I/O 1000 is not the fastest device you&#8217;ll find, but we knew that would be the case when we designed it. A very large number of applications exist where the Expert I/O 1000 is plenty fast enough and in our experience, guaranteed latency has always been more important than raw speed. You&#8217;ll also pay a great deal more for faster solutions.</p>
<p>Here are access time test results. I included ADC inputs and digital I/O, but these numbers will hold for all inputs and outputs. </p>
<p><strong>Sample an Analog Input</strong><br />
Number of Accesses:  1000<br />
Minimum Access Time: 9475.5 us (105.54 Hz)<br />
Maximum Access Time: 23847 us (41.935 Hz)<br />
Average Access Time: 21519 us (46.47 Hz)</p>
<p><strong>Set a Digital Output Port</strong><br />
Number of Accesses:  1000<br />
Minimum Access Time: 3430.1 us (291.54 Hz)<br />
Maximum Access Time: 15876 us (62.987 Hz)<br />
Average Access Time: 10673 us (93.697 Hz)</p>
<p><strong>Sample a Digital Input Port</strong><br />
Number of Accesses:  1000<br />
Minimum Access Time: 15210 us (65.745 Hz)<br />
Maximum Access Time: 23915 us (41.815 Hz)<br />
Average Access Time: 21527 us (46.452 Hz)</p>
<p>If you have concerns about timing, keep in mind that if the Expert I/O 1000 doesn&#8217;t work for you, return it within 30 days and we&#8217;ll give you a full refund.</p>
<p>What other aspects of the Expert I/O 1000 would you like more detail about? Put your suggestions in the comments below and I&#8217;ll address them in future articles.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dajac.com/blog/2009/08/14/understanding-expert-io-1000-access-times/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
