<?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>wuetender-junger-mann.de &#187; Mechanik</title>
	<atom:link href="http://wuetender-junger-mann.de/wordpress/category/mechanik/feed/" rel="self" type="application/rss+xml" />
	<link>http://wuetender-junger-mann.de/wordpress</link>
	<description>Der Freiheit eine Gasse</description>
	<lastBuildDate>Tue, 20 Sep 2011 12:40:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Train Build Monitor</title>
		<link>http://wuetender-junger-mann.de/wordpress/2010/08/the-train-build-monitor/</link>
		<comments>http://wuetender-junger-mann.de/wordpress/2010/08/the-train-build-monitor/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 12:52:13 +0000</pubDate>
		<dc:creator>felix</dc:creator>
				<category><![CDATA[Mechanik]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://wuetender-junger-mann.de/wordpress/?p=1003</guid>
		<description><![CDATA[On our current project we came up with a model train build monitor. The objective was to have the train move, while the build is green and to stop, when it goes red. The whole thing looks some what like this: As a USB interface we chose to go for the Velleman K8055, which is [...]]]></description>
			<content:encoded><![CDATA[<p>On our current project <a href="http://clipboarded.blogspot.com/">we</a> came up with a model train build monitor. The objective was to have the train move, while the build is green and to stop, when it goes red. The whole thing looks some what like this:</p>
<p>
<a href="http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2010/08/train.jpg"><img src="http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2010/08/train.jpg" alt="" title="Build Monitor" width="770" height="451" class="aligncenter size-full wp-image-1005" /></a>
</p>
<p>
As a USB interface we chose to go for the  <a href="http://www.velleman.eu/distributor/products/view/?country=be&#038;lang=en&#038;id=351346">Velleman K8055</a>, which is available for about forty pounds and provides eight digital and two analogue outputs as well as two analogue and five digital inputs. The analogue outputs are provided as <a href="http://en.wikipedia.org/wiki/Pulse-width_modulation">pwm</a> signal.<br />
The outputs are all open-collectors. Being a good developer I did of course anticipate a few more use-cases and hence designed the controller, so we could actually control the speed as well as the direction in which the train in moving. Essentially it uses a transistor to switch the train (using the pwm) and a relay to reverse the direction (yes this is somewhat lame). Also there is two free-wheeling diodes to protect the electronics from the high inductivity of the relay and the trains motor. This is the circuit diagram of the controller that goes between the K8055 and the train:
</p>
<p><a href="http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2010/08/circuit-diagram.jpg"><img src="http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2010/08/circuit-diagram.jpg" alt="" title="circuit diagram" width="818" height="531" class="aligncenter size-full wp-image-1004" /></a></p>
<p>
The K0855-board ships with a DLL to control the IO. Apparently there is a linux driver, which is much better than the windows version, but we are in a bit of a windows shop, so we went with the DLL. It turned out wrapping a DLL in a ruby script is fairly trivial:
</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'Win32API'</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">open</span> = Win32API.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;K8055D&quot;</span>, <span style="color:#996600;">&quot;OpenDevice&quot;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'L'</span><span style="color:#006600; font-weight:bold;">&#93;</span> , <span style="color:#996600;">'L'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
outputAnalog = Win32API.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;K8055D&quot;</span>, <span style="color:#996600;">&quot;OutputAnalogChannel&quot;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'L'</span>,<span style="color:#996600;">'L'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#996600;">'V'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
outputDigital = Win32API.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;K8055D&quot;</span>, <span style="color:#996600;">&quot;WriteAllDigital&quot;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'L'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#996600;">'V'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
inputDigital = Win32API.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;K8055D&quot;</span>, <span style="color:#996600;">&quot;ReadAllDigital&quot;</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#996600;">'L'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">open</span>.<span style="color:#9900CC;">Call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
outputAnalog.<span style="color:#9900CC;">Call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># setting DA channel 1 to 10</span>
outputDigital.<span style="color:#9900CC;">Call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">128</span><span style="color:#006600; font-weight:bold;">&#41;</span>    <span style="color:#008000; font-style:italic;"># reversing</span></pre></div></div>

<p>Future plans include figuring out where the train currently is to stop in the station. The original plan was to use a reed switch, but that proved to be a bit unreliable, so the current thinking involves using a camera and something like <a href="http://www.wedesoft.demon.co.uk/hornetseye-api/files/HornetsEye-txt.html">hornetseye</a> to get the exact position of the train.</p>
]]></content:encoded>
			<wfw:commentRss>http://wuetender-junger-mann.de/wordpress/2010/08/the-train-build-monitor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rätselhafte Elektrogeräte</title>
		<link>http://wuetender-junger-mann.de/wordpress/2007/02/ratselhafte-elektrogerate/</link>
		<comments>http://wuetender-junger-mann.de/wordpress/2007/02/ratselhafte-elektrogerate/#comments</comments>
		<pubDate>Sun, 11 Feb 2007 21:08:58 +0000</pubDate>
		<dc:creator>felix</dc:creator>
				<category><![CDATA[Mechanik]]></category>

		<guid isPermaLink="false">http://wuetender-junger-mann.de/wordpress/?p=427</guid>
		<description><![CDATA[Nachdem ich neulich schonmal über mir neue Haushaltselektrogeräte geblogged hatte, gibt es heute ein paar Bilder von dem Trockner, der in unserer Waschküche steht. Ich habe erst geglaubt dieser Schrank sei Teil der Heizungsanlage: Dem ist aber nicht so. Vielmehr enthält der Schrank ein ausschwenkbares Wäschegestell: Von oben wird dann ordentlich warme Luft reingepumpt. Ein [...]]]></description>
			<content:encoded><![CDATA[<p>
Nachdem ich neulich <a href="http://wuetender-junger-mann.de/wordpress/?p=387">schonmal</a> über mir neue Haushaltselektrogeräte geblogged hatte, gibt es heute ein paar Bilder von dem Trockner, der in unserer <a href="http://wuetender-junger-mann.de/wordpress/?p=422">Waschküche</a> steht. Ich habe erst geglaubt dieser Schrank sei Teil der Heizungsanlage:
</p>
<p><a href='http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2007/02/trockner1.jpg' title='trockner1.jpg'><img src='http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2007/02/trockner1.jpg' alt='trockner1.jpg' /></a>
</p>
<p>
Dem ist aber nicht so. Vielmehr enthält der Schrank ein ausschwenkbares Wäschegestell:
</p>
<p>
<a href='http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2007/02/trockner2.jpg' title='trockner2.jpg'><img src='http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2007/02/trockner2.jpg' alt='trockner2.jpg' /></a>
</p>
<p>
Von oben wird dann ordentlich warme Luft reingepumpt. Ein bißchen feucht wird es in dem Raum natürlich schon&#8230;
</p>
<p>
<a href='http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2007/02/trockner3.jpg' title='trockner3.jpg'><img src='http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2007/02/trockner3.jpg' alt='trockner3.jpg' /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wuetender-junger-mann.de/wordpress/2007/02/ratselhafte-elektrogerate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Höllenmaschine</title>
		<link>http://wuetender-junger-mann.de/wordpress/2006/11/hollenmaschine/</link>
		<comments>http://wuetender-junger-mann.de/wordpress/2006/11/hollenmaschine/#comments</comments>
		<pubDate>Mon, 20 Nov 2006 10:23:18 +0000</pubDate>
		<dc:creator>felix</dc:creator>
				<category><![CDATA[Kochen]]></category>
		<category><![CDATA[Mechanik]]></category>

		<guid isPermaLink="false">http://wuetender-junger-mann.de/wordpress/?p=387</guid>
		<description><![CDATA[Von oben:]]></description>
			<content:encoded><![CDATA[<p><img id="image390" src="http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2006/11/hoellenmaschine11.jpg" alt="hoellenmaschine11.jpg" /></p>
<p>
Von oben:
</p>
<p>
<img id="image386" src="http://wuetender-junger-mann.de/wordpress/wp-content/uploads/2006/11/hoellenmaschine2.jpg" alt="hoellenmaschine2.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://wuetender-junger-mann.de/wordpress/2006/11/hollenmaschine/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

