<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6775833</id><updated>2011-11-27T23:40:01.310Z</updated><category term='parallel'/><category term='RS485'/><category term='Visual Studio'/><category term='reentrant'/><category term='LabVIEW'/><category term='DAQ'/><title type='text'>Swinders programming bits</title><subtitle type='html'>Just my thoughts and experiences in programming. Program mostly using LabVIEW and use MS SQL for database. Trying to get to grips with Visual Studio with the .net framework when I get chance but usually end up supporting older VB6 and VC++6 apps. Dabble with scripting in php and like the look of Ruby.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.swindley.co.uk/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6775833/posts/default'/><link rel='alternate' type='text/html' href='http://blog.swindley.co.uk/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Swinders</name><uri>http://www.blogger.com/profile/08076576693331019561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6775833.post-6319763707406130042</id><published>2010-05-30T09:27:00.000+01:00</published><updated>2010-05-30T09:27:50.011+01:00</updated><title type='text'>Moving house</title><content type='html'>&lt;div style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font: normal normal normal 13px/19px Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.6em; padding-left: 0.6em; padding-right: 0.6em; padding-top: 0.6em;"&gt;&lt;div id="_mcePaste"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial;"&gt;&lt;span class="Apple-style-span" style="line-height: normal;"&gt;Busy day:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Removal van arrived 8:40, left 11:30&lt;/li&gt;&lt;li&gt;Call from estate agents saying we could collect keys 12:45&lt;/li&gt;&lt;li&gt;Arrived at house 13:40&lt;/li&gt;&lt;li&gt;Picked kids up from schools and got back to new house at 15:40&lt;/li&gt;&lt;li&gt;Removal van left 16:00&lt;/li&gt;&lt;li&gt;Kids beds up by 19:30&lt;/li&gt;&lt;li&gt;Chinese at 20:00&lt;/li&gt;&lt;li&gt;All kids in bed 21:00&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;span class="Apple-style-span" mce_fixed="1" style="border-collapse: collapse; color: #500050; font-family: arial, sans-serif; line-height: normal;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;blockquote type="cite"&gt;&lt;div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;Everybody loves the new house, plenty of space and kids can get to sleep without the older one disturbing the younger ones. Martin went around the house looking at everything saying 'That's perfect!' to everything when he first got here.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;BT line installed on Friday by about 11:00, called Orange and they can't do anything about broadband until line has been active for 2 working days so said call back Tues eve. Also could take upto 10 working days to active. So I'm paying for broadband for about two weeks with no service and it's my fault for moving house!&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Using mobile broadband on the 3 network with a USB dongle. Seems reasonable but not sure how long 1Gb will last, not going to visit iPlayer for a while.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6775833-6319763707406130042?l=blog.swindley.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.swindley.co.uk/feeds/6319763707406130042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6775833&amp;postID=6319763707406130042' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6775833/posts/default/6319763707406130042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6775833/posts/default/6319763707406130042'/><link rel='alternate' type='text/html' href='http://blog.swindley.co.uk/2010/05/moving-house.html' title='Moving house'/><author><name>Swinders</name><uri>http://www.blogger.com/profile/08076576693331019561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6775833.post-3202356195386540342</id><published>2009-08-10T22:21:00.012+01:00</published><updated>2009-08-13T22:50:58.557+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DAQ'/><category scheme='http://www.blogger.com/atom/ns#' term='reentrant'/><category scheme='http://www.blogger.com/atom/ns#' term='LabVIEW'/><category scheme='http://www.blogger.com/atom/ns#' term='RS485'/><category scheme='http://www.blogger.com/atom/ns#' term='parallel'/><title type='text'>Multi threaded LabVIEW execution</title><content type='html'>&lt;div&gt;Using four different RS485 serial ports to communicate with four data acquisition devices, each with four channels it should be possible to sent commands to the each device in turn while waiting for a response from the first. This will greatly reduce the time required to poll all channels. So why is it taking over 40 seconds for all channels on all ports when it takes less than 10 seconds to poll all channels on one device. LabVIEW should be able to run each port in a separate thread.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://2.bp.blogspot.com/_DBFalsk3Nus/SoSGl9L0lqI/AAAAAAAAAvo/_XthZRICEAE/s1600-h/Read+Serial.png"&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_DBFalsk3Nus/SoSIc6KzR-I/AAAAAAAAAvw/6xO59FUkqUc/s1600-h/Read+Serial.png"&gt;&lt;img id="BLOGGER_PHOTO_ID_5369566685964748770" style="FLOAT: left; MARGIN: 0px 10px 10px 0px; WIDTH: 320px; CURSOR: hand; HEIGHT: 129px" alt="" src="http://1.bp.blogspot.com/_DBFalsk3Nus/SoSIc6KzR-I/AAAAAAAAAvw/6xO59FUkqUc/s320/Read+Serial.png" border="0" /&gt;&lt;/a&gt;We created a VI to handle the communication with the serial device. This would construct the command string, flush the receive buffer, write the command string to the serial port and wait for the response from the DAQ device. When the require data had been received the response string is decoded and the measured value is passed to the calling VI. Using four of these VI's wired to run in parallel, each with a different serial port set this VI worked.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Next we wanted to take ten samples from each channel of each device and run some basic statistical filtering to eliminate noise. We have our VI to take a single measurement so just putting this in a FOR loop to iterate ten times should give us the data we need. Now the communications appear to be taking too long. We are only taking ten readings from each channel and as we are running each serial port in parallel we should not be seeing the execution time increase we are. A quick check, ten readings from four channels with the communication specification stating that each channel should return within 250ms should give us around 10 seconds not the 40+ seconds we are getting.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Logging was added to the read from serial port VI using a little VI I use all the time. It allows me to log a string of data to a text file with a time stamp. Analysing this in Excel and plotting the timestamps by serial port showed some interesting results. The parallel execution was only in the layout of the block diagram, not the execution. Each serial port was accessed in turn only after all readings for that port were taken. So how did that happen?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;img id="BLOGGER_PHOTO_ID_5368487122581507442" style="FLOAT: right; MARGIN: 0px 0px 10px 10px; WIDTH: 320px; CURSOR: hand; HEIGHT: 170px" alt="" src="http://1.bp.blogspot.com/_DBFalsk3Nus/SoCymDK6zXI/AAAAAAAAAu0/iyqakW0ZOcM/s320/VI-Properties_Execution_Reentrant.PNG.jpg" border="0" /&gt;The problem turned out to be that the part of the code that does the communication was not enabled for reentrant execution. Opening the VI Properties dialogue and selecting the Execution category allows us to set Reentrant execution.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Now we are able to take all the required measurements within about 12 seconds. This just leaves the filtering of each channel. A Producer-Consumer loop architecture was chosen for this so the measurements were taken in the Producer loop which were placed on a queue. Filtering was done in the Consumer which waited for data to appear on the queue before processing it. This prevented the filtering affecting the timing of the data acquisition.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6775833-3202356195386540342?l=blog.swindley.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.swindley.co.uk/feeds/3202356195386540342/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6775833&amp;postID=3202356195386540342' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6775833/posts/default/3202356195386540342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6775833/posts/default/3202356195386540342'/><link rel='alternate' type='text/html' href='http://blog.swindley.co.uk/2009/08/multi-threaded-labview-execution.html' title='Multi threaded LabVIEW execution'/><author><name>Swinders</name><uri>http://www.blogger.com/profile/08076576693331019561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_DBFalsk3Nus/SoSIc6KzR-I/AAAAAAAAAvw/6xO59FUkqUc/s72-c/Read+Serial.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6775833.post-4375188985847305552</id><published>2008-10-21T22:27:00.010+01:00</published><updated>2009-08-12T23:34:30.474+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DAQ'/><category scheme='http://www.blogger.com/atom/ns#' term='LabVIEW'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>Running LabVIEW as a Windows Service</title><content type='html'>Today I finally got around to using Visual Studio to create a Windows Service that will call a LabVIEW executable every 10 minutes to log temperature to a database.&lt;br /&gt;&lt;br /&gt;We have been running a LabVIEW application as a service using a free version of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;FireDemon&lt;/span&gt; but found today that our corporate anti virus software marks the executable as a &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;Trojan&lt;/span&gt;. Getting an exception for this will take ages so after &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;referring&lt;/span&gt; to google I found an article on &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;MSDN&lt;/span&gt; with the title &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc301845.aspx"&gt;Windows Services: New Base Classes in .NET Make Writing a Windows Service Easy&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In under an hour I had created a service, installed and tested it as described in the above article.&lt;br /&gt;&lt;br /&gt;Our application requires an up-to-date temperature to be &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_6"&gt;available&lt;/span&gt; to a number of machines. To measure the temperature we are using a &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;USB&lt;/span&gt; data &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_8"&gt;acquisition&lt;/span&gt; device connected to a thermocouple which is polled by one PC periodically and then updates a database. We have the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;LabVIEW&lt;/span&gt; code to take the measurements and log the temperature as we were using &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;FireDemon&lt;/span&gt; to run this as a service.&lt;br /&gt;&lt;br /&gt;We have Measurement Studio which allows us to use our data &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_12"&gt;acquisition&lt;/span&gt; devices under Visual Studio but as we have LabVIEW code already in place to do the data acquisition and updating the database I will use this for now. Rewriting in Visual Studio is a job for another day.&lt;br /&gt;&lt;br /&gt;After a few modifications to the example code in the MSDN article I managed to get our LabVIEW code executing every 10 minutes.&lt;br /&gt;&lt;br /&gt;Since implementing this NI have produced a network attached DAQ device which we are currently looking at for future projects.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6775833-4375188985847305552?l=blog.swindley.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.swindley.co.uk/feeds/4375188985847305552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6775833&amp;postID=4375188985847305552' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6775833/posts/default/4375188985847305552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6775833/posts/default/4375188985847305552'/><link rel='alternate' type='text/html' href='http://blog.swindley.co.uk/2008/10/today-i-finally-got-around-to-using.html' title='Running LabVIEW as a Windows Service'/><author><name>Swinders</name><uri>http://www.blogger.com/profile/08076576693331019561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
