<?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>Culverson Software-Custom DAQ Software labVIEW &#187; Tips &amp; Tricks</title>
	<atom:link href="http://culverson.com/category/tipstricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://culverson.com</link>
	<description>Custom Labview Data Acquisition Software Maine</description>
	<lastBuildDate>Thu, 20 May 2010 20:02:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Virtual Devices</title>
		<link>http://culverson.com/virtual-devices/</link>
		<comments>http://culverson.com/virtual-devices/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 13:12:11 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://culverson.com/?p=284</guid>
		<description><![CDATA[When you don&#8217;t have the DAQ hardware you need&#8230;

Any version of NI-DAQ and the Measurement and Automation Explorer (MAX) released recently has provisions for &#8220;simulated&#8221; devices.  You choose which devices you want, and then NI-DAQ will pretend those devices are actually installed on your system, any calls to DAQ functions concerning that device will succeed [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><strong><em>When you don&#8217;t have the DAQ hardware you need&#8230;</em></strong></p>
<p style="text-align: center;">
<p>Any version of NI-DAQ and the Measurement and Automation Explorer (MAX) released recently has provisions for &#8220;simulated&#8221; devices.  You choose which devices you want, and then NI-DAQ will pretend those devices are actually installed on your system, any calls to DAQ functions concerning that device will succeed (or fail) just as if a real device was installed.</p>
<p>This lets you simulate a client&#8217;s setup without having their hardware shipped to you and do most (if not all) of the programming on your own terms without being at their site.  The data produced is, of course, simulated data.  For an analog input channel it&#8217;s a sine wave, for a digital port, it&#8217;s a counting pattern.  It&#8217;s enough for you to tell if your software is working correctly with NI-DAQ.</p>
<p>With their hardware simulated on your machine, you can handle the basic communication part to get data in and out. Then you can install conditional-compilation pieces to substitute data more realistic for your particular situation if you need to.</p>
<p>You can be reasonably confident that the DAQ part of a program you develop this way will work on the real hardware, the same as it did on your simulated hardware.  Of course, for any extreme cases (high sample rate, high channel count), the simulation will be less exact, but it&#8217;s a useful feature to develop faster with fewer headaches.</p>
]]></content:encoded>
			<wfw:commentRss>http://culverson.com/virtual-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What time is it, again?</title>
		<link>http://culverson.com/what-time-is-it-again/</link>
		<comments>http://culverson.com/what-time-is-it-again/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 17:36:08 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://culverson.com/?p=272</guid>
		<description><![CDATA[The TIMESTAMP indicator is smart enough to get you into trouble.
Just ran into what at first appeared to be a bug, but turned out to be proper, if misunderstood, behavior.
I have a project which records data files. When the actual recording starts, and again when it stops, I remember the time (by using a GET [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><em><strong>The TIMESTAMP indicator is smart enough to get you into trouble.</strong></em></p>
<p>Just ran into what at first appeared to be a bug, but turned out to be proper, if misunderstood, behavior.</p>
<p>I have a project which records data files. When the actual recording starts, and again when it stops, I remember the time (by using a GET DATE/TIME in SECONDS function) in a TIMESTAMP variable, which is stored in the data file. There might or might not be some calibration activity after the recording has stopped.  When the DONE button is finally clicked, I record the current time using a FORMAT DATE and TIME STRING function, into another string field called &#8220;TEST TIME&#8221;</p>
<p>I have a viewer which examines the data files and reports various info about them. The indicator that shows the TEST TIME is on a different window from the one that shows the START TIME and END TIME.</p>
<p>If there&#8217;s no CAL operations done, then the TEST TIME has always been just a few seconds later than the STOP time (enough time to react to the test being done and click the DONE button), or it could be a few minutes later.</p>
<p>However, I recently noticed that, on a data file sent from my client to me, that the TEST TIME was almost an hour EARLIER than the STOP time.  How could that be?  Further rummaging thru other files that I had from him shows the same thing: the TEST TIME was short of an hour EARLIER than the DONE time.  If there were CAL operations done, this difference was 45-55 minutes; if not, it was a few seconds short of an hour.</p>
<p>I have run thousands of tests on my machine without noticing this; my client has also run nearly a thousand, and has never brought it up.  Whay is that?</p>
<p><span id="more-272"></span></p>
<p>There&#8217;s one piece of info missing from the above description that&#8217;s critical to figuring out what&#8217;s happening: My client is on CENTRAL time, while I am on EASTERN time.</p>
<p>It took a while to figure out what was really happening:  The TIMESTAMP value was being sent whole: encoded with that value somewhere must be the TIMEZONE that it was recorded in.  When the file crossed the timezone line, the value (as it was displayed to me) actually changed.  I confirmed this with my client; a given file showed a START time of 9:39:20 on his machine, but the same file showed a START time of 10:39:20 on my machine.  Of course, those are the exact same moments, just expressed in different time zones.</p>
<p>The TEST TIME, however was recorded as a STRING, and as such, has no mechanism for changing.</p>
]]></content:encoded>
			<wfw:commentRss>http://culverson.com/what-time-is-it-again/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Beating the Jitters</title>
		<link>http://culverson.com/beating-the-jitters/</link>
		<comments>http://culverson.com/beating-the-jitters/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 16:10:42 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://culverson.com/?p=264</guid>
		<description><![CDATA[A shortcut to determinism in real-time applications
Determinism in software is the ability to ensure that any and all paths taken through the code take a consistent amount of time to execute.  Most desktop applications have no interest in this consistency because A) it doesn&#8217;t affect anything, and B) the existence of interrupts and preemptive multitasking [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><em><strong><span style="color: #888888;">A shortcut to determinism in real-time applications</span></strong></em></p>
<p><span style="color: #000000;"><span style="color: #888888;">Determinism in software is the ability to ensure that any and all paths taken through the code take a consistent amount of time to execute.  Most desktop applications have no interest in this consistency because A) it doesn&#8217;t affect anything, and B) the existence of interrupts and preemptive multitasking means that you cannot do anything about it anyway.<br />
</span> </span><span style="color: #000000;"><span style="color: #888888;"><br />
</span> </span><span style="color: #000000;"><span style="color: #888888;">In an embedded control application, or one running under a real-time OS however, determinism is often important because it is critical that the control outputs be changed at a consistent time with respect to the control input sampling time. On the input side, when a signal is changing at a relatively rapid rate, any error in the TIME of measurement is just as destructive to the measurement accuracy as an error in AMPLITUDE.  For applications such as PID loops, this is even more important, since derivative terms are adversely affected by timing inaccuracies.<br />
</span> </span><span style="color: #000000;"><span style="color: #888888;"><br />
</span> </span><span style="color: #888888;">Equally important, but not always equally recognized, is the fact that the timing of the output samples has exactly the same effect.  If your control output is not consistently timed, then loop stability is compromised.</span></p>
<p><span style="color: #000000;"><span id="more-264"></span><span style="color: #888888;"><br />
</span> </span><span style="color: #000000;"><span style="color: #888888;"><br />
</span> </span><span style="color: #000000;"><span style="color: #888888;">One way to make your code deterministic is to go through it and make sure that all path lengths are identical.  For example, if your code includes an option to scale the signal to percent of full scale or not, then the proper way to make this deterministic is to compute the full-scale percentage in all cases, then decide to use the scaled or the unscaled value depending on the option setting.  This goes against the programmer&#8217;s natural instinct to do work only when required; but it&#8217;s necessary to ensure that both paths consume an equal time.<br />
</span> </span><span style="color: #000000;"><span style="color: #888888;"><br />
</span> </span><span style="color: #000000;"><span style="color: #888888;">Beginners to real-time programming are rightly warned about this situation.  If you look at the larger picture, you realize that the goal of all this is to ensure that the outputs change at a consistent time relative to each other and to absolute time.  The assumption inherent in the idea of equalizing code paths is that you want the outputs to follow as soon as possible after the control inputs are sampled.<br />
</span> </span><span style="color: #000000;"><span style="color: #888888;"><br />
</span> </span><span style="color: #888888;">That assumption is true in some cases, but by no means all.  There is another way to achieve the same result (consistency of output timing), without the drudgery of counting cycles and finding all the places where such path decisions are made.</span></p>
<p><span style="color: #888888;">By building in a hardware-controlled delay, you can achieve rock-solid precision of output timing, without fretting over every single operation. One way to do this is to use the very same clock signal that drives the input timing to drive the output timing.  For example, in the following code, we:</span></p>
<ul>
<li><span style="color: #888888;">Create the task for the Analog Output channels</span></li>
<li><span style="color: #888888;">Set the AO SAMPLE CLOCK timing parameters to the AI clock signal</span></li>
<li><span style="color: #888888;">Start the task</span></li>
</ul>
<p><span style="color: #888888;"><img class="alignnone size-full wp-image-265" title="AO Config" src="http://culverson.com/site09/wp-content/uploads/2009/10/AO-Config.PNG" alt="AO Config" width="532" height="348" /></span></p>
<p><span style="color: #888888;">This instructs the OUTPUT task to use the same clock as the INPUT.  When you WRITE to the output task, the values you write will stay in the output buffer until the clock ticks; at that point they will be transferred to the actual analog output.</span></p>
<p><strong><span style="color: #888888;">What Does this Do for Me? </span></strong></p>
<p><span style="color: #888888;">By doing this, you have freed yourself from all constraints of cycle-counting and path-equalization. Your control output will change exactly one clock tick after the inputs that produce it. No more and no less.  You have only one constraint: you must get the job done in one clock cycle. If you are running at a loop rate of 100 Hz, then you have 10 mSec to get your work done. If it takes 10 microseconds or 9.99 mSec, it makes NO difference, the output will change at the same point in time either way. You do have to ensure that it&#8217;s 10 mSec or less, but that&#8217;s a constraint you have in any case.</span></p>
<p><span style="color: #888888;">In most cases, where you are waiting on a clock-controlled input sample, performing some control processing with the measured values and writing control values out, the delay you are introducing is not significant.  And a precisely controlled </span><span style="text-decoration: underline;"><span style="color: #888888;">constant</span></span><span style="color: #888888;"> delay is often more easily dealt with in a control loop than an unpredictable jitter, and easier to produce in hardware than in software.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://culverson.com/beating-the-jitters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Time Alignment of Signals</title>
		<link>http://culverson.com/time-alignment-of-signals/</link>
		<comments>http://culverson.com/time-alignment-of-signals/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 21:09:43 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://culverson.com/?p=230</guid>
		<description><![CDATA[A picture is worth 1024 words
I discussed the idea of a time-alignment scheme in the article Delays, Delays, Delays.  The idea is that signals which have a mechanical delay of some kind (gas transport time, for example) can be time-aligned with signals that have a lesser or no such delay by means of a &#8220;logical&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><strong><em>A picture is worth 1024 words</em></strong></p>
<p>I discussed the idea of a time-alignment scheme in the article <a title="Delays, Delays, Delays" href="http://culverson.com/delays-delays-delays/" target="_blank">Delays, Delays, Delays</a>.  The idea is that signals which have a mechanical delay of some kind (gas transport time, for example) can be time-aligned with signals that have a lesser or no such delay by means of a &#8220;logical&#8221; delay line inserted into all channels.  If the sum of all channel&#8217;s physical + logical delays is a constant, then the final output is time-aligned.</p>
<p>Here is a test of that concept, where three signals are generated, with different phases, and then fed thru that process. The outputs, as you can see, have been aligned.</p>
<p><img class="alignnone size-full wp-image-233" title="TimeAlignment" src="http://culverson.com/site09/wp-content/uploads/2009/09/TimeAlignment1.PNG" alt="TimeAlignment" width="568" height="528" /></p>
<p>You have to know the physical delay time, however; it does not guess.  You also have to account for the fact that some data is lost at the beginning, if that&#8217;s of concern, then start your recording early enough to account for that.</p>
<p>Even with those caveats, this scheme allows you to shift signals to account for mechanical delays, EVEN IN REAL TIME, if you need to.</p>
]]></content:encoded>
			<wfw:commentRss>http://culverson.com/time-alignment-of-signals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
