<?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; example</title>
	<atom:link href="http://www.dajac.com/blog/tag/example/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>Dajac Goes for a Ride &#8211; Baja Style</title>
		<link>http://www.dajac.com/blog/2010/07/30/dajac-baja-1000/</link>
		<comments>http://www.dajac.com/blog/2010/07/30/dajac-baja-1000/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 14:43:58 +0000</pubDate>
		<dc:creator>David Novak</dc:creator>
				<category><![CDATA[I/O Modules]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Expert I/O]]></category>
		<category><![CDATA[industrial]]></category>
		<category><![CDATA[pc based automation]]></category>

		<guid isPermaLink="false">http://www.dajac.com/blog/?p=434</guid>
		<description><![CDATA[Being headquartered near Indianapolis, it&#8217;s only fitting that Dajac be involved with racing. However, this will be a much different experience than the well controlled conditions at the Indianapolis Speedway. This year, Dajac&#8217;s Expert I/O 1000 will be put to the test in the rough and dirty Baja 1000 on the Baja peninsula November 17th [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_459" class="wp-caption alignright" style="width: 280px"><img src="http://www.dajac.com/blog/wp-content/uploads/2010/07/baja_1000.gif" alt="Taking PC Based Automation to the Extreme!" title="Baja 1000" width="270" height="90" class="size-full wp-image-459" /><p class="wp-caption-text">Taking PC Based Automation to the Extreme!</p></div></p>
<p>Being headquartered near Indianapolis, it&#8217;s only fitting that Dajac be involved with racing. However, this will be a much different experience than the well controlled conditions at the Indianapolis Speedway. This year, Dajac&#8217;s <a href="http://www.dajac.com/expert_io.php?aw=io">Expert I/O 1000</a> will be put to the test in the rough and dirty Baja 1000 on the Baja peninsula November 17th through the 21st.</p>
<p><span id="more-434"></span></p>
<p>The Baja 1000 is a thousand miles of the most grueling terrain. Racers and their vehicles endure water, sand, mud and wind as they careen through the course at top speeds up to 120 mph.</p>
<p>Dajac is teaming with <a href="http://www.dallasdesigntech.com">Dallas Design and Technology (DDT)</a>, a leading edge industrial integrator, to prove that PC based automation is a good choice for even the toughest projects. DDT will replace a large array of switches, gauges, a large format GPS and a laptop with a rugged touch screen PC and an Expert I/O 1000.</p>
<p><div id="attachment_464" class="wp-caption alignright" style="width: 460px"><img src="http://www.dajac.com/blog/wp-content/uploads/2010/07/baja_racer.jpg" alt="Dajac and Dallas Design and Technology team up to race in the Baja 1000." title="Baja Racer" width="450" height="255" class="size-full wp-image-464" /><p class="wp-caption-text">Dajac and Dallas Design and Technology team up to race in the Baja 1000.</p></div></p>
<p>A complete graphical user interface (GUI) and the data acquisition and control algorithms will be created for the PC using Visual Basic (VB.net). VB.net is a great tool for projects like this, but literally any PC software development environment could be used.</p>
<p>&#8220;The use of PC&#8217;s for industrial control is becoming more prevalent,&#8221; says Mark Stevens, Owner of DDT, &#8220;this project will allow us to prove the robustness of a properly integrated PC control system.&#8221; </p>
<p>I couldn&#8217;t agree more with Mark. A great deal of effort is being expended by the industrial controls market to design products that bolt PC features to outdated technology. Why not make your life simple and leap frog this intermediate step? It is only a matter of time before the PC is the de facto standard in industrial control.</p>
<p>Keep your eyes on the Dajac web site for updates! I will be posting more detailed information as we progress.</p>
<p>&nbsp;</p>
<hr />
<p><div id="attachment_375" class="wp-caption alignleft" style="width: 135px"><a href="http://www.dajac.com/usb-extension"><img src="http://www.dajac.com/blog/wp-content/uploads/2009/08/tied_in_knots.jpg" alt="Tied In Knots USB Extension Guide" title="Tied In Knots USB Extension Guide" width="125" height="152" class="size-full wp-image-375" /></a><p class="wp-caption-text">Tied In Knots USB Extension Guide</p></div></p>
<p style="font-weight:bold;">TIED IN KNOTS &#8212; A Must-Have Guide to Untangling USB Extension Options for PC Based Automation</p>
<p>Stop your USB devices from being shackled to a PC like the pretty boy on a chain gang (he can&#8217;t wait to get free!). <a href="http://www.dajac.com/usb-extension">By downloading this guide</a> you&#8217;ll instantly grow your USB toolbox to include multiple methods of extending USB connections and put yourself head and shoulders above the competition.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dajac.com/blog/2010/07/30/dajac-baja-1000/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PC Automated Pressure Measurements</title>
		<link>http://www.dajac.com/blog/2009/10/23/pc-automated-pressure-measurements/</link>
		<comments>http://www.dajac.com/blog/2009/10/23/pc-automated-pressure-measurements/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 18:18:01 +0000</pubDate>
		<dc:creator>David Novak</dc:creator>
				<category><![CDATA[I/O Modules]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Expert I/O]]></category>
		<category><![CDATA[measure]]></category>
		<category><![CDATA[pressure]]></category>
		<category><![CDATA[process control]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[sensor]]></category>

		<guid isPermaLink="false">http://www.dajac.com/blog/?p=342</guid>
		<description><![CDATA[One of the vivid memories from my childhood is working in the garden picking vegetables. We lived on a farm and it was common to have a big garden. My mother would can all types of food, such as tomatoes, pickles and green beans. Part of this canning process involved boiling the jars of food [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_354" class="wp-caption alignright" style="width: 105px"><img src="http://www.dajac.com/blog/wp-content/uploads/2009/10/pressure_cooker.png" alt="Pressure Cooker" title="Pressure Cooker" width="95" height="95" class="size-full wp-image-354" /><p class="wp-caption-text">Pressure Cooker</p></div></p>
<p>One of the vivid memories from my childhood is working in the garden picking vegetables. We lived on a farm and it was common to have a big garden. My mother would can all types of food, such as tomatoes, pickles and green beans. Part of this canning process involved boiling the jars of food in a pressure cooker. The release valve, with its hot hissing steam escaping, always intrigued me.</p>
<p>Canning food in the kitchen is a relatively simple process and easily controlled by the cook, but there are many other applications where it makes sense to automate the process.<span id="more-342"></span> For instance, you may have a process where it is important to know the exact pressure at a specific point in a process and, based on that pressure, control other parameters of the system.</p>
<p>Another example where automation would be ideal is monitoring pressure over time. You could manually take measurements at a given period over some number of hours, but it makes much more sense to automate and let the monitoring equipment record the measurements while you do other things. Because it is automated, this method is more precise and allows you to immediately analyze the data.</p>
<p>The first thing needed for measuring pressure is a pressure sensor. There are many sensors available with analog voltage outputs. These can be used with the Expert I/O 1000 by connecting the sensor&#8217;s analog output to an analog input on the Expert I/O 1000. The Expert I/O 1000 has six 0-5V analog inputs and it isn&#8217;t difficult to find pressure sensors with 0-5V outputs.</p>
<p>To properly specify the pressure sensor, the following parameters must be defined.</p>
<ul>
<li>Pressure range being measured.</li>
<li>Accuracy required.</li>
<li>Pressure fitting. How it attaches to the object being measured (1/4&#8243; pipe thread is the most common).</li>
<li>Electrical termination (connector or direct to cable).</li>
</ul>
<p>With these specifications in hand, you are now ready to shop for a sensor. Here are links to a few vendors that carry pressure sensors.</p>
<ul>
<li><a href="http://www.pewastore.com/index.asp?PageAction=VIEWCATS&#038;Category=11">PewaStore.com</a> </li>
<li><a href="http://www.omega.com/guides/pressXducers.html">Omega</a> (Choose output = Volt)</li>
<li><a href="http://stellartech.com/techsheets-press/pressuremodels.html">Stellar Technology</a></li>
<li><a href="http://www.emssensors.com/press/press.htm">Engineering and Manufacturing Services</a></li>
<li><a href="http://www.astsensors.com/pressure-sensor-products.php">American Sensor Technologies</a></li>
<li><a href="http://www.granzow.com/pressuretransmitters/">Granzow</a></li>
<li><a href="http://www.transducersdirect.com/HeleoCart/ProductCategory/Pressure+Transducer%2826%29.aspx">Transducers Direct</a></li>
<li><a href="http://devar.thomasnet.com/viewitems/level-and-pressure/level-and-pressure-transmitters?&#038;forward=1">DEVAR</a></li>
</ul>
<p>For easiest connection to the Expert I/O 1000, you&#8217;ll want to get a sensor with 0-5V analog output, but you probably noticed that another common output is 4-20mA. These can also be used with the Expert I/O 1000 by adding a 250 Ohm resistor from the output signal to ground. Adding the resistor converts the 4-20mA signal to a 1-5V signal. It&#8217;s not hard to deal with the 1V offset in software. The ground terminal next to each of the Expert I/O 1000 analog input terminals provide a convenient place to ground the 250 Ohm resistor.</p>
<p><div id="attachment_356" class="wp-caption aligncenter" style="width: 460px"><img src="http://www.dajac.com/blog/wp-content/uploads/2009/10/convert_4-20ma_to_1-5V.png" alt="Use a 250 Ohm resistor to ground to convert a 4-20mA output to 1-5V." title="Convert 4-20mA to 1-5V" width="450" height="310" class="size-full wp-image-356" /><p class="wp-caption-text">Use a 250 Ohm resistor to ground to convert a 4-20mA output to 1-5V.</p></div></p>
<p>Now that you have a sensor picked out, all that is left is to write a little software. Here is a snippet of code that initializes the Expert I/O 1000, samples an analog input and then exits.</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><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 /></div></td><td><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// Open the Expert I/O API.</span><br />
eioOpen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Scan the USB and gather descriptors.</span><br />
eioGetDescriptors<span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>DescriptorGroup <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Claim the interface.</span><br />
eioClaimInterface<span style="color: #009900;">&#40;</span> DescriptorGroup.<span style="color: #202020;">Descriptors</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>EioHandle <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Read analog input 1.</span><br />
eioAdcReadCount<span style="color: #009900;">&#40;</span> EioHandle<span style="color: #339933;">,</span> <span style="color: #0000dd;">3</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>AdcCount <span style="color: #009900;">&#41;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Release the interface.</span><br />
eioReleaseInterface<span style="color: #009900;">&#40;</span> EioHandle <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Close the Expert I/O API.</span><br />
eioClose<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>If you read <a href="http://www.dajac.com/blog/2009/10/10/expert-io-api/">Between Mac and PC: The Expert I/O API</a>, much of the code will be familiar to you. I&#8217;ll go through it again for those that didn&#8217;t read the article.</p>
<p>Lines 1 through 8 are initialization and only need to be executed once. The initialization starts with calling <code class="codecolorer c default"><span class="c">eioOpen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code>. This allows the API to configure its internal settings and ready itself for communicating on the USB.</p>
<p>The next step is to call <code class="codecolorer c default"><span class="c">eioGetDescriptors<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> to scan each USB bus and locate all Expert I/O devices. It returns a <code class="codecolorer c default"><span class="c">DescriptorGroup</span></code> which contains an array of <code class="codecolorer c default"><span class="c">Descriptors<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span></span></code>. Each descriptor in <code class="codecolorer c default"><span class="c">Descriptors<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span></span></code> describes an Expert I/O found connected to the USB.
<p>Descriptors contain a model ID and a serial number. By inspecting the descriptors, you can locate the specific Expert I/O you wish to access. For the purpose of this example, we simply choose the first device found on the bus. On line 8, we use the first descriptor to obtain a handle to the device.</p>
<p>A device&#8217;s handle is exactly as it sounds. It is a &#8220;handle&#8221; to grab hold of the Expert I/O to control it. The handle is used every time you perform an operation on the device.</p>
<p>Line 8 serves another purpose, it claims the Expert I/O&#8217;s interface for exclusive use by our application. This is important, because the last thing you want is 2 applications trying to control the same Expert I/O simultaneously. Applications can share access to an Expert I/O, but no more than one application at a time can claim it&#8217;s interface.</p>
<p>Now we are ready to read the analog input. Line 11 reads analog input 3 by calling <code class="codecolorer c default"><span class="c">eioAdcReadCount</span></code> and places the result into AdcCount. AdcCount contains a value between 0 and 255, linearly related to the input voltage. If the input voltage is 0V, AdcCount will be 0. If the input voltage is 5V, AdcCount will be 255. AdcCount will vary linearly with the input voltage between 0 and 5V. Notice how we use the handle to identify the Expert I/O.</p>
<p>At this point, you can use AdcCount as needed. For instance, you could make a decision, based on the value of AdcCount, to activate an output or you could plot the time and value on a chart. The possibilities are endless.</p>
<p>When finished accessing the Expert I/O and ready to relinquish control of its interface, call <code class="codecolorer c default"><span class="c">eioReleaseInterface<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> (line 14 in our example). With the interface released, it is now accessible to other applications that wish to claim it.</p>
<p>The last thing to do is to notify the API that we are finished using it. This is done on line 17 with a call to <code class="codecolorer c default"><span class="c">eioClose<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code>. Closing the API allows it to release any memory that it has allocated and to shut down in a structured manor.</p>
<p>That&#8217;s it. Now you know how to measure pressure using the Expert I/O 1000. It&#8217;s equally easy to monitor other characteristics. In a future article, I&#8217;ll go through the process of measuring temperature.</p>
<p>Please post questions and comments below.</p>
<hr />
<p><span style="font-weight:bold;">Think USB requires you to be shackled to a computer no more than 5 meters away?</span> Think again. This free guide and cheat sheet will show you the light: “TIED IN KNOTS – A Must-Have Guide to Untangling USB Extension Options for PC Based Automation”. <a href="http://www.dajac.com/usb-extension">Get it now!</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dajac.com/blog/2009/10/23/pc-automated-pressure-measurements/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Between Mac and PC: The Expert I/O API</title>
		<link>http://www.dajac.com/blog/2009/10/10/expert-io-api/</link>
		<comments>http://www.dajac.com/blog/2009/10/10/expert-io-api/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 02:50:22 +0000</pubDate>
		<dc:creator>David Novak</dc:creator>
				<category><![CDATA[I/O Modules]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Expert I/O]]></category>

		<guid isPermaLink="false">http://www.dajac.com/blog/?p=148</guid>
		<description><![CDATA[PC based automation doesn&#8217;t need to be difficult. Some application user interfaces are terribly complicated and take forever to learn. Often, even the simple interfaces prove difficult because they make some features impossible to use so that other features are simple.
I see this all the time in products. The Mac vs PC battle (which is [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_334" class="wp-caption alignright" style="width: 94px"><img src="http://www.dajac.com/blog/wp-content/uploads/2009/10/mac-pc-s.png" alt="Mac vs PC" title="Expert I/O API is Just Right" width="84" height="95" class="size-full wp-image-334" /><p class="wp-caption-text">Mac vs PC</p></div></p>
<p>PC based automation doesn&#8217;t need to be difficult. Some application user interfaces are terribly complicated and take forever to learn. Often, even the simple interfaces prove difficult because they make some features impossible to use so that other features are simple.</p>
<p>I see this all the time in products. The Mac vs PC battle (which is really Apple vs Microsoft) is a perfect example.<span id="more-148"></span> Both have essentially equivalent hardware power, but they take very different approaches to the user interface. Microsoft gives you access to every option under the sun, while Apple only gives you access to the options that 80% of people use regularly.</p>
<p>Microsoft products generally take longer to understand, but once you get it, you can do whatever you want. Apple gets you off the ground quickly, but if you are a power user, you will tend to be frustrated by a system that holds you back.</p>
<p>The Expert I/O application programmer&#8217;s interface (API) is a good mix between these two extremes. It is simple to learn and at the same time doesn&#8217;t hold you back.</p>
<p>Right from the start, your life is made easy by allowing you to use your favorite programming language. The only stipulation is that it must support the use of dynamic link libraries (DLL&#8217;s) and it&#8217;s hard to find a language that doesn&#8217;t. You can use Visual Basic, C, C++, Delphi, Pascal, etc. You can even use scripting languages such as PHP and Python. Wouldn&#8217;t that be cool, a remote accessible web application built with PHP to control a PC based automation system.</p>
<p>Here is a simple example of using C to set a digital output high.</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><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 /></div></td><td><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// Open the Expert I/O API.</span><br />
eioOpen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Scan the USB and gather descriptors.</span><br />
eioGetDescriptors<span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>DescriptorGroup <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Claim the interface.</span><br />
eioClaimInterface<span style="color: #009900;">&#40;</span> DescriptorGroup.<span style="color: #202020;">Descriptors</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>EioHandle <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Set digital output voltage high to 3.3V.</span><br />
eioDioSetPull<span style="color: #009900;">&#40;</span> EioHandle<span style="color: #339933;">,</span> 2<span style="color: #339933;">,</span> eioDIO_PULL_3_3 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Set bit 0 of port 2 high.</span><br />
eioDioSet<span style="color: #009900;">&#40;</span> EioHandle<span style="color: #339933;">,</span> 2<span style="color: #339933;">,</span> 1 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Release the interface.</span><br />
eioReleaseInterface<span style="color: #009900;">&#40;</span> EioHandle <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Close the Expert I/O API.</span><br />
eioClose<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Lines 1 through 8 are initialization and only need to be executed once. The initialization starts with calling <code class="codecolorer c default"><span class="c">eioOpen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code>. This allows the API to configure its internal settings and ready itself for communicating on the USB.</p>
<p>The next step is to call <code class="codecolorer c default"><span class="c">eioGetDescriptors<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> to scan each USB bus and locate all Expert I/O devices. It returns a <code class="codecolorer c default"><span class="c">DescriptorGroup</span></code> which contains an array of <code class="codecolorer c default"><span class="c">Descriptors<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span></span></code>. Each descriptor in <code class="codecolorer c default"><span class="c">Descriptors<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span></span></code> describes an Expert I/O found connected to the USB.
<p>Descriptors contain a model ID and a serial number. By inspecting the descriptors, you can locate the specific Expert I/O you wish to access. For the purpose of this example, we simply choose the first device found on the bus. On line 8, we use the first descriptor to obtain a handle to the device.</p>
<p>A devices handle is exactly as it sounds. It is a &#8220;handle&#8221; to grab hold of the Expert I/O to control it. The handle is used every time you perform an operation on the device.</p>
<p>Line 8 serves another purpose, it claims the Expert I/O&#8217;s interface for exclusive use by our application. This is important, because the last thing you want is 2 applications trying to control the same Expert I/O simultaneously. Applications can share access to an Expert I/O, but no more than one application at a time can claim it&#8217;s interface.</p>
<p>Now we are ready to start controlling the Expert I/O. Line 11 configures a digital output (port 2) to 3.3V logic high (<code class="codecolorer c default"><span class="c">eioDIO_PULL_3_3</span></code>). Notice how we use the handle to identify the Expert I/O.</p>
<p>Line 14 is the line that causes the digital output to change states. It sets bit 0 of port 2 high. Each port consists of 8 pins and each pin is associated with a bit in an 8-bit value. The 1 in this function call puts a 1 in the bit 0 position of the port (binary 1 is 00000001) and thereby forces its associated pin to logic high.</p>
<p>At this point, you can include code to control any other ports on the Expert I/O as you see fit.</p>
<p>When finished accessing the Expert I/O and ready to relinquish control of its interface, call <code class="codecolorer c default"><span class="c">eioReleaseInterface<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> (line 17 in our example). With the interface released, it is now accessible to other applications that wish to claim it.</p>
<p>The last thing to do is to notify the API that we are finished using it. This is done on line 20 with a call to <code class="codecolorer c default"><span class="c">eioClose<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code>. Closing the API allows it to release any memory that it has allocated and to shut down in a structured manor.</p>
<p>This is only a small example, but once it is in place and working, expanding it to control other I/O ports is very easy. There is a set of simple interface functions for each I/O type (motor, analog in, analog out, etc.). These are explained in complete detail in the <a href="http://www.dajac.com/files/eio_software_manual.pdf">software user manual</a>.</p>
<p>If you have questions or comments, please post them below.</p>
<p>&nbsp;</p>
<hr />
<p>Struggling with extending the USB connection? Be sure to check out <a href="http://www.dajac.com/usb-extension">TIED IN KNOTS – A Must-Have Guide to Untangling USB Extension Options for PC Based Automation</a>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dajac.com/blog/2009/10/10/expert-io-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
