<?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>modelrail.otenko &#187; N Scale Models</title>
	<atom:link href="http://modelrail.otenko.com/category/n-scale-models/feed" rel="self" type="application/rss+xml" />
	<link>http://modelrail.otenko.com</link>
	<description>trains....</description>
	<lastBuildDate>Sat, 04 Sep 2010 06:53:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Adding LEDs to a Japanese Shop</title>
		<link>http://modelrail.otenko.com/my-layout/adding-leds-to-a-japanese-shop</link>
		<comments>http://modelrail.otenko.com/my-layout/adding-leds-to-a-japanese-shop#comments</comments>
		<pubDate>Tue, 17 Aug 2010 04:44:49 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[My Layout]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[N Scale]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=1179</guid>
		<description><![CDATA[Pictures speak louder than words, so below is a quick tutorial on how to get an off-the-shelf TomyTec Japanese Shop Building lit with LED lighting. In total, this building received 6 LEDs; lantern, side-door, top floor (x2), bottom floor (x2). Interior Lighting + Side Door The trickiest part of this installation was the lantern that [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />Pictures speak louder than words, so below is a quick tutorial on how to get an off-the-shelf TomyTec Japanese Shop Building lit with LED lighting. In total, this building received 6 LEDs; lantern, side-door, top floor (x2), bottom floor (x2).</p>
<h3>Interior Lighting + Side Door</h3>
<p><a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04886.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04886.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04896.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04896.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04891.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04891.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a></p>
<p>The trickiest part of this installation was the lantern that hangs out the front. I actually sliced it in half and bored out the middle to fit an LED inside. I also trimmed down the LED with a file to get it to fit a little more easily. This was done with my pocket-knife and I stopped when I felt it grinding metal. <img src='http://modelrail.otenko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Note that I borrowed ideas <a href='http://tounosawa.exblog.jp/12016741/'>from this blog</a> and I <b>strongly recommend</b> you check out the work the author has done on their layout!</p>
<h3>Front Lantern</h3>
<p><a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04871.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04871.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04872.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04872.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04877.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04877.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a><br />
<a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04879.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04879.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04882.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04882.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a> </p>
<p>And finally, everything is wired up. You can see the huge hole I accidently drilled in the side of the shop... luckily the lantern covers it over pretty well.</p>
<h3>Finished Product</h3>
<p><a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04901.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04901.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04904.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04904.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Lighting-up-a-Building/DSC04908.JPG" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Lighting-up-a-Building/DSC04908.JPG" width="200" height="113" alt="Model Railway" title="Model Railway"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/my-layout/adding-leds-to-a-japanese-shop/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cheap and easy Streetlights</title>
		<link>http://modelrail.otenko.com/my-layout/cheap-and-easy-streetlights</link>
		<comments>http://modelrail.otenko.com/my-layout/cheap-and-easy-streetlights#comments</comments>
		<pubDate>Mon, 09 Aug 2010 11:52:44 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[My Layout]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[N Scale]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=1094</guid>
		<description><![CDATA[I'd previously bulk purchased a large amount of LEDs from LED-Switch with the intent to light up my entire model railway. I'd already bought a few of the MAX7219 ICs, which control up to 64 LEDs each, and knew how to control these via the Arduino. My article on the IC and using it was [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />I'd previously bulk purchased a large amount of LEDs from <a href='http://www.led-switch.com/'>LED-Switch</a> with the intent to light up my entire model railway. I'd already bought a few of the MAX7219 ICs, which control up to 64 LEDs each, and knew <a href='http://www.arduino.cc/playground/Main/MAX72XXHardware'>how to control these via the Arduino</a>. <a href='http://modelrail.otenko.com/n-scale-models/controlling-lots-of-leds-with-your-arduino'>My article on the IC and using it was here</a>.</p>
<p>Anyway, streetlights were high on the agenda, as they exist in every town in Japan and, based on a very simple idea, weren't going to be too hard to make. Following are the steps involved with creating the street lights that have been visible in my prior articles.</p>
<h2>Ingredients</h2>
<ul>
<li>0.25mm Copper winding wire (or as thin as possible.)</li>
<li>1.6mm LEDs White/Yellow (<a href='http://www.led-switch.com/1.6%20LED.htm'>as available here</a>)</li>
<li>Metal tubing for the main pole. (I used '3/64 x .006' brass tubing)</li>
<li>Soldering iron</li>
<li>Paint</li>
</ul>
<p><a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02868.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02868.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02870.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02870.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02908.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02908.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a></p>
<h2>Construction</h2>
<p><a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02872.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02872.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02876.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02876.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02880.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02880.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a><br />
Firstly, cut the pole to your desired length. I have to admit here that I never once measured any of the poles and just prototyped one against a reference (in this case it was a standard Greenmax building) and then made them all the same size. Make sure you take in to account where you will bend the pole and how much extra length will be required. Use a file to smoothen out the ends so that you don't damage the winding wire when fed through.<br/><br />
<a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02934.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02934.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02930.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02930.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02923.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02923.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a><br />
Once you have the poles made, simply cut the leads of the LED right down and solder one end to the pole itself. Finally, if you haven't already, feed the wire through the pole and tin one end (melt it with a little bit of solder to strip away the insulation.) Once done, trim away any excess tinned lead and then solder it to the other lead of the LED.<br/></p>
<p><a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02935.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02935.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC02941.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC02941.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC04869.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC04869.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a></p>
<p>Note that the final version there was the best I'd made. I'd trimmed the LEDs right down after folding one leg over the top and used a very small amount of solder.</p>
<h2>Finished Product</h2>
<p>Better night shots of the taller version in action<br />
<a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC04854.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC04854.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/model-mods/Streetlights/DSC04855.JPG?m=1281352113" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/model-mods/Streetlights/DSC04855.JPG?m=1281352113" width="200" height="113" alt="Model Railway" title="Model Railway"></a></p>
<p>The only thing these really require now is some form of cover/compartment/housing for the bulb to live in. Currently, with a big enough blob of paint, I can get the ends to look round-ish enough to look acceptable and I'm happy with this. But any comments/suggestions for anoff-the-shelf product that might have the right shape to cover the ends are welcome!</p>
<p>I'd also bought red, yellow and green LEDs and found that they had fit into the Greenmax Signals. I haven't gotten around to finishing them, but I will post another article once done.</p>
<p>Meanwhile, <a href='http://modelrail.otenko.com/my-layout/latest-on-the-model-railway'>in my previous post</a>, I also added both a red and blue LED to a Bachmann N-Scale Signal. I actually cut it off its usual pole/base and mounted them as shunting signals. See the pictures. I'll post a more detailed explanation along with the other signals once finished.</p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/my-layout/cheap-and-easy-streetlights/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Latest on the Model Railway</title>
		<link>http://modelrail.otenko.com/my-layout/latest-on-the-model-railway</link>
		<comments>http://modelrail.otenko.com/my-layout/latest-on-the-model-railway#comments</comments>
		<pubDate>Sun, 08 Aug 2010 07:53:39 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Japanese Trains]]></category>
		<category><![CDATA[My Layout]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[N Scale]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=1083</guid>
		<description><![CDATA[So, something that was just meant to turn into a test layout has now become one of my greatest creations... It's not much as yet, but the scenery and electronics involved is a lot more complex than I thought I would ever create and I'm really glad as to how it's coming along. Here's a [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />So, something that was just meant to turn into a test layout has now become one of my greatest creations... It's not much as yet, but the scenery and electronics involved is a lot more complex than I thought I would ever create and I'm really glad as to how it's coming along.</p>
<p><a href='http://modelrail.otenko.com/photo-album/?itemid=10'>Here's a gallery of the initial track plan</a> I intended on using and then 3 evolutions of it. The final layout is not actually listed there. You can see that it started as a single level basic loop, with options for expansion. As I realised the time required for building just this module, I decided to do away with the extension options (although things can always change) and then added a second level. This was just to be a ridge down the middle of the board, but it now has transformed into 1/4 of the overall surface area. A town has now grown on top and a nice siding for single-car vehicles.</p>
<p>Underneath the board is a birds-nest of wiring for all the tricks I've tried with the Arduino (see all the previous posts...) and I'll show you this in a later post.</p>
<p>For now, just check out the photos and I'll get back with more information as I create it. I'm currently working on street lights for the top town and also automation of the points. I've been through around 5 iterations for the control circuit for the points and damaged quite a few TomyTec FineTrack Points in the process. Not fun.</p>
<p><a href='http://modelrail.otenko.com/photo-album?itemid=7399'>Here's a link to the whole album</a>.</p>
<p><a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04819.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04819.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04821.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04821.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04822.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04822.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a><br />
<a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04823.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04823.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04825.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04825.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04826.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04826.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a><br />
<a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04827.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04827.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04829.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04829.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a></p>
<p><u><b><i>Update</i></b></u>: The streetlights are painted and in... I still need to work on the light end, they need some sort of cover/compartment.<br />
<a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04835.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04835.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04839.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04839.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a> <a href="http://www.otenko.com/gallery3/var/albums/2010-Model-Railway/DSC04842.JPG?m=1281250802" rel="lightbox[g2image]" title="Model Railway"><img src="http://www.otenko.com/gallery3/var/thumbs/2010-Model-Railway/DSC04842.JPG?m=1281250802" width="200" height="113" alt="Model Railway" title="Model Railway"></a></p>
<p>Meanwhile, I also need to learn nighttime photography <img src='http://modelrail.otenko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
More to come as I light up all of the houses; although one is already lit!</p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/my-layout/latest-on-the-model-railway/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Multiplexing &#8216;Photodetectors&#8217; to detect train occupancy.</title>
		<link>http://modelrail.otenko.com/n-scale-models/multiplexing-photodetectors-to-detect-train-occupancy</link>
		<comments>http://modelrail.otenko.com/n-scale-models/multiplexing-photodetectors-to-detect-train-occupancy#comments</comments>
		<pubDate>Wed, 12 May 2010 13:05:21 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[N Scale]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=769</guid>
		<description><![CDATA[Right, I wasn't impressed whilst using the Sharp distance detectors and so went back to the age-old method of light-detection between the sleepers. As this is N Scale, I didn't want the standard, large and bulky Light Dependent Resistors and went for these smaller 'Photodetectors' found on eBay from a Taiwanese reseller. These were chosen [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />Right, I wasn't impressed whilst using the Sharp distance detectors and so went back to the age-old method of light-detection between the sleepers. As this is N Scale, I didn't want the standard, large and bulky Light Dependent Resistors and went for these smaller 'Photodetectors' found on eBay from a Taiwanese reseller.</p>
<p><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69805&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" rel="lightbox[g2image]" title="Single detector" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69806&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" width="200"  height="113"  alt="Single detector" title="Single detector" class="g2image_normal" /></a></p>
<p>These were chosen based on the fact that they have a flat lens/front and are clear. They fit nicely between sleepers of Tomix FineTrack and, since I'd already laid and ballasted my main loop, could be retrofitted by drilling up and through the base.</p>
<p><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69781&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" rel="lightbox[g2image]" title="Track wired up" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69782&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" width="200"  height="113"  alt="Track wired up" title="Track wired up" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69784&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" rel="lightbox[g2image]" title="Rear of detector" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69785&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" width="200"  height="113"  alt="Rear of detector" title="Rear of detector" class="g2image_normal" /></a><br />
<a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69790&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" rel="lightbox[g2image]" title="Detector between sleepers" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69791&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" width="200"  height="113"  alt="Detector between sleepers" title="Detector between sleepers" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69787&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" rel="lightbox[g2image]" title="Detectors between sleepers" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69788&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" width="200"  height="113"  alt="Detectors between sleepers" title="Detectors between sleepers" class="g2image_normal" /></a></p>
<p>Now, since I bought these in bulk, I started going crazy and sticking them everywhere I could. The goal was to put one everywhere that would become a good trigger-point for automation. I started with all of my stabling areas and put one at the start, middle and end of the sidings. I would use the 'trigger' from these to know when to slow to an engine to 50% throttle, 25% throttle and then stop. I then also put some in the tunnel entrances, station/platforms and also where signals should probably be (around points.)</p>
<p><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69796&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" rel="lightbox[g2image]" title="Detector installed and ballasted" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69797&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" width="200"  height="113"  alt="Detector installed and ballasted" title="Detector installed and ballasted" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69799&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" rel="lightbox[g2image]" title="Another installed detector" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69800&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" width="200"  height="113"  alt="Another installed detector" title="Another installed detector" class="g2image_normal" /></a></p>
<p>It started dawning on me that I would require one analog input pin on my Arduino per photodetector. This would've gotten very expensive very quickly, but then I remembered that there was a <a href='http://www.arduino.cc/playground/Learning/4051'>simple tutorial on multiplexing analog inputs on the Arduino Playground (based on the 4051 IC)</a>. This IC would save me a lot of time and resources: with a little more wiring it could potentially give me 64 analog inputs for a total of 6 digital pins and one analog. </p>
<p>Here's the basic idea of wiring up a single 4051.<br />
<a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69776&#038;g2_GALLERYSID=a41804724fae220ea686b8fbfe24a625" rel="lightbox[g2image]" title="Basic Multiplexer with Photodetectors" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69777&#038;g2_GALLERYSID=a41804724fae220ea686b8fbfe24a625" width="200"  height="152"  alt="Basic Multiplexer with Photodetectors" title="Basic Multiplexer with Photodetectors" class="g2image_normal" /></a></p>
<p>Here's how you can use multiple 4051s and reduce pin consumption:<br />
<a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69779&#038;g2_GALLERYSID=a41804724fae220ea686b8fbfe24a625" rel="lightbox[g2image]" title="Advanced Multiplexer with Photodetectors" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69780&#038;g2_GALLERYSID=a41804724fae220ea686b8fbfe24a625" width="164"  height="200"  alt="Advanced Multiplexer with Photodetectors" title="Advanced Multiplexer with Photodetectors" class="g2image_normal" /></a></p>
<p>Notes on the options in the above image:</p>
<ul>
<li>Option 1: Take the wires in the first rectangle and wire them to one analog pin and three digital. This will give you a total of 8 detector inputs.</li>
<li>Option 2: Take the 8 analog wires and put them into analog input pins. You then also need to connect up the 3 digital pins. For all inputs you'll only ever need 3 digital pins. But for the analog pins you'll need 1 pin for each 8 inputs. (i.e. 8:1, 16:2, 24:3, 32:4, etc... there is no upper limit, as long as you have the analog inputs.)</li>
<li>Option 3: Take the single analog pin and then the 6 digital pins. This will give you a total of 64 inputs and will use more digital than analog pins.</li>
</ul>
<p>As you can see, you can interface with a lot of analog detectors, based on what pins you have available. As you may be aware, analog inputs are more 'expensive' on the Arduino than digital outputs as there are less available.</p>
<p>The process to control the above circuit is to set the digital pins to the desired address and then read the analog pin(s). You then need to set the next address and read the same pin (depending on your setup.) As changing through a lot of inputs and reading can take time, you need to be careful how many detectors you end up implementing. I have no exact numbers; but reading 64 inputs can easily be done in under a second. The goal is to make sure that a train does not pass a detector before it has been read!</p>
<p>So we have our detectors installed and circuitry built; we could now write software to manage it all. The basic idea was to read the value, adjust the min/max of that single detector and then check if it exceeded a threshold. Since these detectors required light to function, they would be effected by the amount of ambient light in the room and therefore the code would need to be smart enough to work out what was 'covered' (i.e. vehicle blocking light) and what was 'open'.</p>
<p>This code was also noted in <a href='http://modelrail.otenko.com/electronics/properly-reading-values-from-a-sharp-gp2d12'>my previous post where I used the Sharp detectors</a>. These detectors produced a lot of noise and had to be filtered so that my code wouldn't simply trigger when a high/low value broke a threshold.</p>
<p>Here is the basic idea for reading one detector:</p>
<pre class="brush: c++">&nbsp;read value of detector
&nbsp;if (detector value is greater than recorded maximum) then record new maximum value
&nbsp;if (detector value is lower than recorded minimum) then record new minimum value
&nbsp;if (either min or max has changed)
&nbsp;&nbsp;then update range of this detector [max - min]
&nbsp;&nbsp;adjust threshold [max - (range*0.25)]
&nbsp;end if
&nbsp;if (detector value is greater than threshold) then
&nbsp;&nbsp;report that this detector is 'active'
&nbsp;else
&nbsp;&nbsp;report that this detector is 'inactive'
&nbsp;end if</pre>
<p>Right, so the above concept uses a 25% threshold below the maximum-read-value to see if the value read from the detector is 'active'. It is also constantly updating it's valid reading range so that it can adapt to the environmental changes. The main issue with this concept is that if the environment drastically changes (lights are turned on/off, curtains opened/closed, etc...) then this code would not adapt, as it never has a chance to 'retract' the limits. Therefore the following adjustment needs to be made:</p>
<pre class="brush: c++">&nbsp;store the last 32 values of detector in circular array
&nbsp;read value of detector and push last into array, popping off the first value
&nbsp;find the lowest value in the array and store as the minimum extremity
&nbsp;find the highest value in the array and store as the maximum extremity
&nbsp;if (either min or max has changed)
&nbsp;&nbsp;then update range of this detector [max - min]
&nbsp;&nbsp;calculate the average from the last 32 read values
&nbsp;&nbsp;adjust threshold [average + (max-min*0.10)]
&nbsp;end if
&nbsp;if (detector value is greater than this threshold) then
&nbsp;&nbsp;report that this detector is 'active'
&nbsp;else
&nbsp;&nbsp;report that this detector is 'inactive'
&nbsp;end if</pre>
<p>Here you can now see that we only care about the last 32 read values (instead of the max and min since the code was running.) We are also using a new threshold calculation: 10% above the average of the last 32 values. This therefore means that we will receive an active notification if the value increases 10% above the 'stable' value of which we have been observing.</p>
<p>Of course, we are always able to introduce new issues; the above code, if run at processor-speed will read 32 values in a under once second and, dependent on environment changes, may well not be able to cope. We therefore need to only test the detector at a specific interval (your mileage (kilometre'age) may vary!) of say, 100ms. This then means that the 32 values are taken over the course of 3.2 seconds. If this doesn't suit, then you can also increase the buffer size or decrease the polling delay.</p>
<p>But I bet you haven't seen the main issue? If a vehicle is stationary on the detector for too long then the range will/should drop to zero and therefore the detector will always be 'active'.<br />
Wait, that would be correct? Wouldn't it?<br />
It would, but it would also then report active for a certain time span until the range had expanded again once the vehicle had moved on. Note this can also be simulated by a long train traversing the detector and blocking the light (even with intermittent gaps of light) for a long period of time.</p>
<p>To prevent this? Adjust the polling delay and the buffer size...</p>
<p>Another good trick for limiting environmental effects is to add lights/LEDs to your layout around the detectors to ensure they always have a good source of UV. That way, when those curtains close, the ranges of your detectors wont drop too low.</p>
<p>What's next... well, what do you want to do with all this new information? You need to read it, pass it to the methods we've described above to filter the data and then act on it. Since we're multiplexing, we need to first tell our 4051 IC(s) which input we want to read and then read it. The following classes operate the multiplexers and detectors:</p>
<pre class="brush: c++">
class DetectorCollection {
	private:
		struct Detector {
			int dValues[32];
			int dMax;
			int dMin;
			int dRange;
			int dAverageValue;
			int dCurrentValue;
			int dThreshold;
			int dCurrentIndex;
			bool dFullArray;
			int dAnalogPin;
			int dBitIndex;
			bool dIsActive;
		} detectors[32];
		int numDetectors;
		int digPins[3];
	public:
        DetectorCollection(int _digPin1, int _digPin2, int _digPin3);
        bool AddDetector(int _aPin, int _bit);
        void UpdateDetector(int detector);
        void UpdateAllDetectors();
        bool IsActive(int detector);
        void DebugInformation(int detector);
        int GetCurrentValue(int detector);
};

DetectorCollection::DetectorCollection(int _digPin1, int _digPin2, int _digPin3) {
	numDetectors = 0;
	digPins[0] = _digPin1;
	digPins[1] = _digPin2;
	digPins[2] = _digPin3;
}

bool DetectorCollection::AddDetector(int _aPin, int _bit) {
	//initialise a detector. the array contains "zero'd" detectors
	//by default
	if (numDetectors < 32) {
		detectors[numDetectors].dAnalogPin = _aPin;
		detectors[numDetectors].dBitIndex = _bit;
		for (int idx = 0; idx < 32; idx++)
			detectors[numDetectors].dValues[idx] = 0;
		detectors[numDetectors].dMax = 0;
		detectors[numDetectors].dMin = 999;
		detectors[numDetectors].dRange = 0;
		detectors[numDetectors].dAverageValue = 0;
		detectors[numDetectors].dThreshold = 0;
		detectors[numDetectors].dCurrentIndex = 0;
		detectors[numDetectors].dFullArray = false;
		detectors[numDetectors].dIsActive = false;
		numDetectors++;
		return true;
	} else return false;
}

void DetectorCollection::UpdateDetector(int detector) {
	//set digital pins
    for (int pin = 0; pin < 3; pin++)
      digitalWrite(digPins[pin],
        ((detectors[detector].dBitIndex >> abs(pin-2)) &#038; 0x01) == true ? HIGH : LOW);

	//read analog pin.
	detectors[detector].dCurrentValue =
        analogRead(detectors[detector].dAnalogPin);
	detectors[detector].dValues[detectors[detector].dCurrentIndex] =
        detectors[detector].dCurrentValue;

	//find the lowest and highest values in the array and store as
	//the minimum and maximum extremities.
	int tempVal, newValue = 0;
	bool extremitiesChanged = false;
	for (int idx = 0; idx < 32; idx++) {
		tempVal = detectors[detector].dValues[idx];
		if (tempVal < detectors[detector].dMin || detectors[detector].dMin == 0) {
			detectors[detector].dMin = tempVal;
			extremitiesChanged = true;
		}
		if (tempVal > detectors[detector].dMax) {
			detectors[detector].dMax = tempVal;
			extremitiesChanged = true;
		}
		//used for average calculated below.
		newValue += tempVal;
	}

		//update range of this detector [max - min]
		detectors[detector].dRange =
		    detectors[detector].dMax - detectors[detector].dMin;
		if (newValue > 0) {
			if (detectors[detector].dFullArray)
                          detectors[detector].dAverageValue = newValue / 32;
			else detectors[detector].dAverageValue =
                          newValue / (detectors[detector].dCurrentIndex + 1);
			//adjust threshold [average + (max-min*0.10)]
			detectors[detector].dThreshold =
                          detectors[detector].dAverageValue +
                          (detectors[detector].dRange * 0.35);
			//adjust active flag:
			detectors[detector].dIsActive =
                          (detectors[detector].dCurrentValue >
                           detectors[detector].dThreshold);
		}

	//finally update the next location to store the next incoming value...
	//we're using a circular buffer, so just point to the start of the
	//array instead of shifting everything along.
	detectors[detector].dCurrentIndex++;
	if (detectors[detector].dCurrentIndex >= 32) {
		detectors[detector].dCurrentIndex = 0;
		//for calculating the average, we need to know once
                //we have a full buffer. Once it's full we will always
                //have a full set of NUM_READINGS values, otherwise
		//we only have as many as dCurrentIndex
		detectors[detector].dFullArray = true;
	}
}

void DetectorCollection::UpdateAllDetectors() {
  for (int d = 0; d < numDetectors; d++) UpdateDetector(d);
}

bool DetectorCollection::IsActive(int detector) {
  return detectors[detector].dIsActive;
}

int DetectorCollection::GetCurrentValue(int detector) {
  return detectors[detector].dCurrentValue;
}

void DetectorCollection::DebugInformation(int detector) {
  Serial.print("Detector: ");
  Serial.print(detector);
  Serial.print(", APin: ");
  Serial.print(detectors[detector].dAnalogPin);
  Serial.print(", DBit: ");
  Serial.print(detectors[detector].dBitIndex);
  Serial.print(", Min: ");
  Serial.print(detectors[detector].dMin);
  Serial.print(", Max: ");
  Serial.print(detectors[detector].dMax);
  Serial.print(", Range: ");
  Serial.print(detectors[detector].dRange);
  Serial.print(", Threshold: ");
  Serial.print(detectors[detector].dThreshold);
  Serial.print(", Average: ");
  Serial.print(detectors[detector].dAverageValue);
  Serial.print(", Current: ");
  Serial.print(detectors[detector].dCurrentValue);
  Serial.print(", FullArray: ");
  Serial.print(detectors[detector].dFullArray);
  Serial.print(", CurrentIndex: ");
  Serial.println(detectors[detector].dCurrentIndex);
  /*for (int idx = 0; idx < 32; idx++) {
    Serial.print("|");
    if (idx == detectors[detector].dCurrentIndex) Serial.print("*");
    Serial.print(detectors[detector].dValues[idx]);
  }
  Serial.println("|");*/
}</pre>
<p>And now, use it in your main program. Note I've created custom characters for the <a href='http://www.arduino.cc/en/Reference/LiquidCrystal'>Arduino Liquid Crystal library</a> via <a href='http://icontexto.com/charactercreator/'>this website</a>.</p>
<pre class="brush: c++">#define multiplexerPinBitA  40
#define multiplexerPinBitB  41
#define multiplexerPinBitC  42

#define pwmPin  			2
#define dirPin1 			3
#define dirPin2 			4

#define lcdRSPin			30
#define lcdENPin			31
#define lcdD4Pin			32
#define lcdD5Pin			33
#define lcdD6Pin			34
#define lcdD7Pin			35

#include &lt;LiquidCrystal.h&gt;
LiquidCrystal lcd(lcdRSPin, lcdENPin, lcdD4Pin, lcdD5Pin, lcdD6Pin, lcdD7Pin);

//cool hack! create characters for the LiquidCrystal Library!
//see here: http://icontexto.com/charactercreator/
byte trainCharFrontOn[8] =
{B11111,B10001,B10001,B11111,B10101,B11111,B01010,B11111};
byte emptyChar[8] =
{B00000,B00000,B00000,B00000,B00000,B00000,B11111,B10101};

DetectorCollection dCol = DetectorCollection(multiplexerPinBitA,
    multiplexerPinBitB, multiplexerPinBitC);

void setup() {
  Serial.begin(9600);
  pinMode(multiplexerPinBitA, OUTPUT);
  pinMode(multiplexerPinBitB, OUTPUT);
  pinMode(multiplexerPinBitC, OUTPUT);

  for (int d = 0; d < 24; d++) {
    //analogpin is 0, 1, 2 [so DIV 8].
    //(where 0 is detectors 1-8, 1 is 9-16 and 2 is 17-24)
    //bit is the 0-7 on that analog pin [so MOD 8].
    dCol.AddDetector(d/8, d%8);
  }

  //start a train: direction
  digitalWrite(dirPin2, HIGH);
  digitalWrite(dirPin1, LOW);
  //speed (out of 255 [where ~50 is stopped])
  analogWrite(pwmPin, 85);

  lcd.createChar(0, emptyChar);
  lcd.createChar(1, trainCharFrontOn);
  lcd.begin(16, 2);
}

void loop() {
  //output to the LCD (16x2) the status of all the detectors:
  lcd.clear();
  lcd.setCursor(0, 0);	//top left

  for (int d = 0; d < 16; d++) {
    dCol.UpdateDetector(d);
    lcd.write(dCol.IsActive(d) ? 1 : 0);
  }
  lcd.setCursor(8, 0);
  for (int d = 16; d < 25; d++) {
    dCol.UpdateDetector(d);
    lcd.write(dCol.IsActive(d) ? 1 : 0);
  }

  //we still have 8 characters to draw other stuff... no idea what yet though.
  delay(333);
}</pre>
<p>And then the detectors in action. Note it was at night time and I'm surprised the result was this good!<br />
<a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69793&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" rel="lightbox[g2image]" title="LCD showing train location" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69794&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" width="200"  height="113"  alt="LCD showing train location" title="LCD showing train location" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69802&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" rel="lightbox[g2image]" title="Amtrak testing detectors" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69803&#038;g2_GALLERYSID=f7bed5ac6620e07ae77db52c118c92ea" width="200"  height="113"  alt="Amtrak testing detectors" title="Amtrak testing detectors" class="g2image_normal" /></a></p>
<p><object id="pla123123sadfadsf1yer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="pl123123ayer" width="640" height="352"><param name="movie" value="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D69808%26g2_serialNumber%3D3" /><embed type="application/x-shockwave-flash" id="pla1212asdfasdfdasfsd3123yer2" name="play123asfdasdf124242523er2" src="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" width="640" height="352" allowscriptaccess="always" allowfullscreen="true" flashvars="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D69808%26g2_serialNumber%3D3"/></object></p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/n-scale-models/multiplexing-photodetectors-to-detect-train-occupancy/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kato Amtrak 13002 (Seibu E851?)</title>
		<link>http://modelrail.otenko.com/n-scale-models/kato-amtrak-13002-ef81</link>
		<comments>http://modelrail.otenko.com/n-scale-models/kato-amtrak-13002-ef81#comments</comments>
		<pubDate>Sat, 24 Apr 2010 01:24:50 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Japanese Trains]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[Japan]]></category>
		<category><![CDATA[N Scale]]></category>
		<category><![CDATA[Prototypes]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=741</guid>
		<description><![CDATA[So, I was browsing eBay and saw advertised a Kato Amtrak 4+4+4 Electric Locomotive... For all I'd known Amtrak America had never had any such an engine and therefore clicked the item to investigate... In front of me appeared (what looked like) an EF81 in Amtrak livery! It seems that, back in the day, Kato [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />So, I was browsing eBay and saw advertised a Kato Amtrak 4+4+4 Electric Locomotive... For all I'd known Amtrak America had never had any such an engine and therefore clicked the item to investigate... In front of me appeared (what looked like) an EF81 in Amtrak livery!</p>
<p><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69590&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="Kato Amtrak 13002" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69591&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="Kato Amtrak 13002" title="Kato Amtrak 13002" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69587&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="Kato Amtrak 13002" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69588&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="Kato Amtrak 13002" title="Kato Amtrak 13002" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69583&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="Kato Amtrak 13002" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69584&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="Kato Amtrak 13002" title="Kato Amtrak 13002" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69580&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="Kato Amtrak 13002" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69581&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="Kato Amtrak 13002" title="Kato Amtrak 13002" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69577&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="Kato Amtrak 13002" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69578&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="Kato Amtrak 13002" title="Kato Amtrak 13002" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69573&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="Kato Amtrak 13002" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69574&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="Kato Amtrak 13002" title="Kato Amtrak 13002" class="g2image_normal" /></a></p>
<p>It seems that, back in the day, Kato didn't want to put money in to actually designing the models for America and therefore just repainted a (very slightly) remodeled EF81. Of course, it could be an exact copy of another Japanese electric locomotive, but I haven't had the time yet to do further research.</p>
<p><b>Update:</b><br />
Toni Babelony of the <a href="http://www.jnsforum.com/">JNS Forum</a> <a href="http://www.jnsforum.com/index.php/topic,2897.msg29017.html#msg29017">posted a message in the thread I created on this locomotive</a> that indicated that this is much closer to a Seibu E851. Thanks for pointing this out! <a href="http://www.katomodels.com/product/nmi/e851.shtml">Here is the Kato page on the Seibu E851</a>. You'll notice that the Seibu has port holes, and other differences, but is obviously what Kato used as a base for this Amtrak locomotive.</p>
<p><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69601&#038;g2_GALLERYSID=366f84d671a16df046fd51f037d0d6be" rel="lightbox[g2image]" title="Kato Seibu E851" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69602&#038;g2_GALLERYSID=366f84d671a16df046fd51f037d0d6be" width="200"  height="92"  alt="Kato Seibu E851" title="Kato Seibu E851" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69599&#038;g2_GALLERYSID=366f84d671a16df046fd51f037d0d6be" rel="lightbox[g2image]" title="Seibu E851 in Japan" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69600&#038;g2_GALLERYSID=366f84d671a16df046fd51f037d0d6be" width="200"  height="150"  alt="Seibu E851 in Japan" title="Seibu E851 in Japan" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69593&#038;g2_GALLERYSID=366f84d671a16df046fd51f037d0d6be" rel="lightbox[g2image]" title="Kato Seibu E851" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69594&#038;g2_GALLERYSID=366f84d671a16df046fd51f037d0d6be" width="200"  height="150"  alt="Kato Seibu E851" title="Kato Seibu E851" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69595&#038;g2_GALLERYSID=366f84d671a16df046fd51f037d0d6be" rel="lightbox[g2image]" title="The real E851 in Japan" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=69596&#038;g2_GALLERYSID=366f84d671a16df046fd51f037d0d6be" width="150"  height="200"  alt="The real E851 in Japan" title="The real E851 in Japan" class="g2image_normal" /></a></p>
<p>Meanwhile, here are some photos I've taken of EF81s in Japan:</p>
<p><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45473&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45474&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45482g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45483&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45498&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45499&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><br />
<a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=67465&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=67466&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=67541&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=67542&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45529&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45530&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><br />
<a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45751&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45752&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34019&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34020&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34016&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34017&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><br />
<a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45570&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=45571g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34133&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34134g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34226&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34227g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a><br />
<a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34223&#038;g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" rel="lightbox[g2image]" title="EF81" ><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&#038;g2_itemId=34224g2_GALLERYSID=9d221e39030e3bcff88750c97f72f7f5" width="200"  height="113"  alt="EF81" title="EF81" class="g2image_normal" /></a></p>
<p>And, of course, if this locomotive really does exist, then please comment and tell me!</p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/n-scale-models/kato-amtrak-13002-ef81/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>InfraRed + Arduino revisited</title>
		<link>http://modelrail.otenko.com/n-scale-models/infrared-arduino-revisited</link>
		<comments>http://modelrail.otenko.com/n-scale-models/infrared-arduino-revisited#comments</comments>
		<pubDate>Wed, 31 Mar 2010 11:49:08 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[N Scale]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=663</guid>
		<description><![CDATA[Ok, after failing (more-or-less miserably) with the previous attempt at IR distance detection, I went out and purchased 4 of the Sharp GP2D12 from an eBay Store and put them to work. Finally I had a detection system working, but before this I had also attempted another method using larger IR emitter/detectors that I'd bought [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />Ok, after failing (more-or-less miserably) with the previous attempt at IR distance detection, I went out and purchased 4 of the Sharp GP2D12 from an eBay Store and put them to work. Finally I had a detection system working, but before this I had also attempted another method using larger IR emitter/detectors that I'd bought from <a href='http://www.dipmicro.com/'>Dip Micro</a>.</p>
<h3>Attempt 1: QRD1114, and other smaller IR detectors</h3>
<p><a href='http://modelrail.otenko.com/my-layout/detecting-trains-with-infrared-arduino'>See the previous blog post here</a></p>
<h3>Attempt 2: IR Emitter/Detector pairing</h3>
<p>Since my previous attempt had failed, I'd decided that if the smaller emitters could not produce enough light to avoid sunlight/roomlight interference, then boosting both the emitter and detector should help. I'd accidently purchased a collection of 10x emitter/collector pairs of IR diodes and so I put these to work in the typical setup and tested them out. These were both 3mm in diameter and, depending on the resistors used, could emit a lot more light (tested via my digital camera.)</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69269" title="3mm IR Diodes on board" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69268&amp;g2_serialNumber=2" width="200" height="113" id="IFid13" class="ImageFrame_none" alt="3mm IR Diodes on board"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69272" title="3mm IR Diodes in position" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69271&amp;g2_serialNumber=2" width="200" height="113" id="IFid14" class="ImageFrame_none" alt="3mm IR Diodes in position"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69251" title="Trial spacing" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69250&amp;g2_serialNumber=2" width="200" height="113" id="IFid15" class="ImageFrame_none" alt="Trial spacing"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69275" title="Separator to stop light direct to collector" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69274&amp;g2_serialNumber=2" width="200" height="113" id="IFid16" class="ImageFrame_none" alt="Separator to stop light direct to collector"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69278" title="Completed" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69277&amp;g2_serialNumber=2" width="200" height="113" id="IFid17" class="ImageFrame_none" alt="Completed"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69254" title="Lit" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69253&amp;g2_serialNumber=2" width="200" height="113" id="IFid18" class="ImageFrame_none" alt="Lit"/></a></div>
<p><br/><br />
The setup was the same as per usual... mounted horizontally at the end of the tracks to ensure that the light would reflect (as much as possible) off the approaching train.</p>
<p>Working with IR at night-time has it's benefits. Your room is usually lit under artificial light and so the amount of IR in the 'air' is low. I therefore had some pretty good results with this setup, but of course, come daylight, everything went out the window (or in the window, as the case may be.) Since this detector was to be in the back of an engine shed, I'd thought that I could block out the windows and make a little dark room, but my detectors were still too unreliable.</p>
<p>Here's a few more pictures of the experiment... It was, in the end, functional, but not to the degree that I'd wanted and so I therefore opted for the off-the-shelf Sharp detector.</p>
<p><b>Note</b>: The goal here was to use the pair at the end of the track to sense distance. It now seems that the best method will be to detect 'occupation' and I will again test this method with a series of emitter/detector pairs along the track to sense when a train is approaching.</p>
<h3>Attempt 3: Sharp GP2D12</h3>
<p>After being concerned about sizing and the minimum distance that these detectors would work from, I decided I'd just bite the bullet and try them out. </p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69257" title="Sharp GP2D12" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69256&amp;g2_serialNumber=2" width="200" height="113" id="IFid19" class="ImageFrame_none" alt="Sharp GP2D12"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69260" title="Sharp GP2D12 mounted" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69259&amp;g2_serialNumber=2" width="200" height="113" id="IFid20" class="ImageFrame_none" alt="Sharp GP2D12 mounted"/></a></div>
<p><br/><br />
I ended up purchasing 4 quite cheaply on eBay and they arrived from the UK in a short amount of time. I then realised that the versions I'd bought were optimised for detection between 10cm and 70cm. This really sucks, as I'd want the range to be much closer to the detector, as 10cm is a long way for a no-detection zone. I then looked at the graphs showing the voltage compared to distance:</p>
<div style='vertical-align:top'>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69246" title="GP2D12: Voltage vs Reflection Distance" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69245&amp;g2_serialNumber=2" width="200" height="173" id="IFid21" class="ImageFrame_none" alt="GP2D12: Voltage vs Reflection Distance"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69247" title="GP2D12: Voltage vs Detection Distance" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69248&amp;g2_serialNumber=2" width="200" height="176" id="IFid22" class="ImageFrame_none" alt="GP2D12: Voltage vs Detection Distance"/></a></div>
</div>
<p><br/></p>
<p>It turns out that <a href='http://www.acroname.com/robotics/parts/sharp_guide.pdf'>this datasheet shows you the comparison of the various detectors</a> that Sharp makes. There seems to be one detector better suited for my project, but.. as they say... hindsight is a bitch. Even worse is that <a href='http://toysdownunder.com/infrared-proximity-sensor-30.html'>Toys Downunder currently has them in stock!</a></p>
<p>Although the 'optimum' detecting distance for unit is around 10cm, the detector still gives valid voltage results right down to around 3cm. The only issue here is that the voltage difference is not always increasing! I therefore have to take the value and use it in different scenarios (i.e. when cruising, braking, stopped, etc...)</p>
<p>The setup was the same as usual:</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69263" title="Sharp GP2D12 in testing" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69262&amp;g2_serialNumber=2" width="200" height="113" id="IFid23" class="ImageFrame_none" alt="Sharp GP2D12 in testing"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69266" title="Sharp GP2D12 in testing" rel="lightbox[663]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=69265&amp;g2_serialNumber=2" width="200" height="113" id="IFid24" class="ImageFrame_none" alt="Sharp GP2D12 in testing"/></a></div>
<p><br/></p>
<p>So, to deal with this, I needed to work on the voltage change... in steps of around 0.25v. If you happen to implement this yourself, you'll notice straight away that the voltage returned by this unit is not constant when the vehicle is stopped or approaching... it's perpetually flitting around +-0.5v and this can be a real nightmare. Due to this I only choose to detect larger changes which means only reading the sensor if it is +-25 of the current read value.</p>
<p>The basic idea is to determine the deceleration of the vehicle dependent on it's distance from the wall. The final testing code is listed next. Note that this also contains my <a href='http://modelrail.otenko.com/electronics/multiplexing-controlling-points-or-other-high-current-devices-with-an-arduino'>multiplexer</a>, <a href='http://modelrail.otenko.com/electronics/controlling-your-trains-with-an-arduino'>thottle</a> and also an <a href='http://www.arduino.cc/playground/Code/LCD4BitLibrary'>off-the-shelf LCD for which you can find tutorials here</a>.</p>
<pre class="brush: c++">#define&nbsp;MIN_SPEED&nbsp;50
#define&nbsp;CRAWL_SPEED&nbsp;85
#define&nbsp;MAX_SPEED&nbsp;125
&nbsp;
#include&nbsp;&lt;LiquidCrystal.h&gt;
LiquidCrystal&nbsp;lcd(30,&nbsp;31,&nbsp;40,&nbsp;41,&nbsp;42,&nbsp;43);
&nbsp;
#define&nbsp;STROBE_PIN&nbsp;50
#define&nbsp;INHIBIT_PIN&nbsp;51
&nbsp;
#define&nbsp;BIT1_PIN&nbsp;21
#define&nbsp;BIT2_PIN&nbsp;23
#define&nbsp;BIT3_PIN&nbsp;25
#define&nbsp;BIT4_PIN&nbsp;27
&nbsp;
#define&nbsp;DIRECTION1_PIN&nbsp;52
#define&nbsp;DIRECTION2_PIN&nbsp;53
&nbsp;
void&nbsp;initMultiplexer()&nbsp;{
&nbsp;&nbsp;//set the output mode.
&nbsp;&nbsp;pinMode(INHIBIT_PIN,OUTPUT);
&nbsp;&nbsp;pinMode(STROBE_PIN,OUTPUT);
&nbsp;&nbsp;pinMode(BIT1_PIN,OUTPUT);
&nbsp;&nbsp;pinMode(BIT2_PIN,OUTPUT);
&nbsp;&nbsp;pinMode(BIT3_PIN,OUTPUT);
&nbsp;&nbsp;pinMode(BIT4_PIN,OUTPUT);
&nbsp;&nbsp;pinMode(DIRECTION1_PIN,OUTPUT);
&nbsp;&nbsp;pinMode(DIRECTION2_PIN,OUTPUT);
&nbsp;&nbsp;//initial&nbsp;state
&nbsp;&nbsp;digitalWrite(INHIBIT_PIN,&nbsp;HIGH);&nbsp;//high&nbsp;=&nbsp;off.
&nbsp;&nbsp;digitalWrite(STROBE_PIN,&nbsp;LOW);&nbsp;//toggle&nbsp;low&nbsp;-&gt;&nbsp;high&nbsp;-&gt;&nbsp;low&nbsp;to&nbsp;set&nbsp;output.
&nbsp;&nbsp;digitalWrite(BIT1_PIN,&nbsp;LOW);
&nbsp;&nbsp;digitalWrite(BIT2_PIN,&nbsp;LOW);
&nbsp;&nbsp;digitalWrite(BIT3_PIN,&nbsp;LOW);
&nbsp;&nbsp;digitalWrite(BIT4_PIN,&nbsp;LOW);
}
&nbsp;
void&nbsp;change(int&nbsp;out)&nbsp;{
&nbsp;&nbsp;//work&nbsp;out&nbsp;bits
&nbsp;&nbsp;Serial.print((out&nbsp;&gt;&gt;&nbsp;3)&nbsp;&&nbsp;0x01);
&nbsp;&nbsp;if&nbsp;((out&nbsp;&gt;&gt;&nbsp;3)&nbsp;&&nbsp;0x01)&nbsp;digitalWrite(BIT4_PIN,&nbsp;HIGH);
&nbsp;&nbsp;else&nbsp;digitalWrite(BIT4_PIN,&nbsp;LOW);
&nbsp;&nbsp;if&nbsp;((out&nbsp;&gt;&gt;&nbsp;2)&nbsp;&&nbsp;0x01)&nbsp;digitalWrite(BIT3_PIN,&nbsp;HIGH);
&nbsp;&nbsp;else&nbsp;digitalWrite(BIT3_PIN,&nbsp;LOW);
&nbsp;&nbsp;Serial.print((out&nbsp;&gt;&gt;&nbsp;2)&nbsp;&&nbsp;0x01);
&nbsp;&nbsp;if&nbsp;((out&nbsp;&gt;&gt;&nbsp;1)&nbsp;&&nbsp;0x01)&nbsp;digitalWrite(BIT2_PIN,&nbsp;HIGH);
&nbsp;&nbsp;else&nbsp;digitalWrite(BIT2_PIN,&nbsp;LOW);
&nbsp;&nbsp;Serial.print((out&nbsp;&gt;&gt;&nbsp;1)&nbsp;&&nbsp;0x01);
&nbsp;&nbsp;if&nbsp;((out)&nbsp;&&nbsp;0x01)&nbsp;digitalWrite(BIT1_PIN,&nbsp;HIGH);
&nbsp;&nbsp;else&nbsp;digitalWrite(BIT1_PIN,&nbsp;LOW);
&nbsp;&nbsp;Serial.println((out&nbsp;&gt;&gt;&nbsp;0)&nbsp;&&nbsp;0x01);
&nbsp;&nbsp;//toggle&nbsp;strobe
&nbsp;&nbsp;digitalWrite(STROBE_PIN,&nbsp;HIGH);
&nbsp;&nbsp;delay(50);
&nbsp;&nbsp;digitalWrite(STROBE_PIN,&nbsp;LOW);
}
&nbsp;
void&nbsp;setup()&nbsp;{
&nbsp;&nbsp;initMultiplexer();
&nbsp;&nbsp;Serial.begin(9600);
&nbsp;&nbsp;lcd.begin(16,&nbsp;2);
}
&nbsp;
void&nbsp;updateSensorValue(int&&nbsp;tgt,&nbsp;int&nbsp;latest)
{
&nbsp;&nbsp;&nbsp;int&nbsp;threshold&nbsp;=&nbsp;25;
&nbsp;&nbsp;&nbsp;if&nbsp;((latest&nbsp;&lt;&nbsp;(tgt&nbsp;-&nbsp;threshold))&nbsp;||&nbsp;(latest&nbsp;&gt;&nbsp;(tgt&nbsp;+&nbsp;threshold)))&nbsp;tgt&nbsp;=&nbsp;latest;
}
&nbsp;
void&nbsp;pulseMultiplexer()&nbsp;{
&nbsp;&nbsp;//toggle&nbsp;inhibit&nbsp;to&nbsp;low&nbsp;to&nbsp;actually&nbsp;output&nbsp;power
&nbsp;&nbsp;digitalWrite(INHIBIT_PIN,LOW);&nbsp;
&nbsp;&nbsp;delay(125);&nbsp;//25ms&nbsp;is&nbsp;long&nbsp;enough.
&nbsp;&nbsp;digitalWrite(INHIBIT_PIN,HIGH);&nbsp;
&nbsp;&nbsp;delay(1500);&nbsp;//now&nbsp;delay&nbsp;before&nbsp;going&nbsp;to&nbsp;next&nbsp;point.
}
&nbsp;
int&nbsp;thresholds[4]&nbsp;=&nbsp;{9999,0,9999,0};
&nbsp;
int&nbsp;t&nbsp;=&nbsp;millis();
int&nbsp;oldT&nbsp;=&nbsp;millis(),&nbsp;dirT&nbsp;=&nbsp;oldT;
int&nbsp;a1;
int&nbsp;a2;
int&nbsp;spd&nbsp;=&nbsp;0;
int&nbsp;dir&nbsp;=&nbsp;0;
&nbsp;
int&nbsp;train_status&nbsp;=&nbsp;0;
int&nbsp;sensor&nbsp;=&nbsp;0;
int&nbsp;point&nbsp;=&nbsp;0;
&nbsp;
void&nbsp;loop()&nbsp;{
&nbsp;&nbsp;t&nbsp;=&nbsp;millis();
&nbsp;&nbsp;
&nbsp;&nbsp;if&nbsp;((t&nbsp;-&nbsp;oldT)&nbsp;&gt;&nbsp;50)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;updateSensorValue(a1,&nbsp;analogRead(0));
&nbsp;&nbsp;&nbsp;&nbsp;updateSensorValue(a2,&nbsp;analogRead(1));
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;sensor&nbsp;=&nbsp;a1;
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(point&nbsp;==&nbsp;1)&nbsp;sensor&nbsp;=&nbsp;a2;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;switch(train_status)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;0:&nbsp;//accelerating
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(spd&nbsp;&lt;&nbsp;MIN_SPEED)&nbsp;spd&nbsp;=&nbsp;MIN_SPEED;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spd&nbsp;+=&nbsp;2;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(spd&nbsp;&gt;&nbsp;MAX_SPEED)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;train_status&nbsp;=&nbsp;1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spd&nbsp;=&nbsp;MAX_SPEED;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;1:&nbsp;//travelling
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;2:&nbsp;//braking
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spd&nbsp;-=&nbsp;10;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(spd&nbsp;&lt;&nbsp;CRAWL_SPEED)&nbsp;spd&nbsp;=&nbsp;CRAWL_SPEED;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;3:&nbsp;//paused
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spd&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(dir&nbsp;==&nbsp;1)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;((t&nbsp;-&nbsp;dirT&nbsp;&gt;&nbsp;1250)&nbsp;&#038;&&nbsp;(train_status&nbsp;==&nbsp;0&nbsp;||&nbsp;train_status&nbsp;==&nbsp;1))&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;train_status&nbsp;=&nbsp;2;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dirT&nbsp;=&nbsp;t;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;((t&nbsp;-&nbsp;dirT&nbsp;&gt;&nbsp;2000)&nbsp;&#038;&&nbsp;train_status&nbsp;==&nbsp;2&nbsp;&#038;&&nbsp;spd&nbsp;==&nbsp;CRAWL_SPEED)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;train_status&nbsp;=&nbsp;3;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dirT&nbsp;=&nbsp;t;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;((t&nbsp;-&nbsp;dirT&nbsp;&gt;&nbsp;500)&nbsp;&#038;&&nbsp;train_status&nbsp;==&nbsp;3)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;train_status&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dir&nbsp;=&nbsp;!dir;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dirT&nbsp;=&nbsp;t;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//switch&nbsp;point
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;change(3);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(point&nbsp;==&nbsp;0)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(DIRECTION1_PIN,&nbsp;HIGH);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(DIRECTION2_PIN,&nbsp;LOW);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Serial.println(0);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;if&nbsp;(point&nbsp;==&nbsp;1)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(DIRECTION1_PIN,&nbsp;LOW);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(DIRECTION2_PIN,&nbsp;HIGH);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Serial.println(1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pulseMultiplexer();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point&nbsp;=&nbsp;!point;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(dir&nbsp;==&nbsp;0)&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//we&nbsp;should&nbsp;be&nbsp;checking&nbsp;which&nbsp;point&nbsp;we're&nbsp;about&nbsp;to&nbsp;hit&nbsp;first?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*if&nbsp;(a1&nbsp;&gt;&nbsp;400&nbsp;&#038;&&nbsp;dir&nbsp;==&nbsp;0)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spd&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dir&nbsp;=&nbsp;!dir;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;train_status&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;if&nbsp;(a1&nbsp;&gt;&nbsp;300&nbsp;&#038;&&nbsp;dir&nbsp;==&nbsp;0)&nbsp;spd&nbsp;=&nbsp;70;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(a1&nbsp;&gt;&nbsp;200&nbsp;&#038;&&nbsp;dir&nbsp;==&nbsp;0)&nbsp;spd&nbsp;=&nbsp;90;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(a1&nbsp;&gt;&nbsp;150&nbsp;&#038;&&nbsp;dir&nbsp;==&nbsp;0)&nbsp;spd&nbsp;=&nbsp;110;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;spd&nbsp;=&nbsp;125;*/
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(train_status&nbsp;!=&nbsp;3)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(sensor&nbsp;&gt;&nbsp;400)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;train_status&nbsp;=&nbsp;3;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dirT&nbsp;=&nbsp;t;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;if&nbsp;(sensor&nbsp;&gt;&nbsp;300)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;train_status&nbsp;=&nbsp;2;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;if&nbsp;(t&nbsp;-&nbsp;dirT&nbsp;&gt;&nbsp;500&nbsp;&#038;&&nbsp;train_status&nbsp;==&nbsp;3)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;train_status&nbsp;=&nbsp;0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dir&nbsp;=&nbsp;!dir;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dirT&nbsp;=&nbsp;t;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;lcd.clear();
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(0,&nbsp;0);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print("");
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(0,&nbsp;0);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print(a1);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(0,&nbsp;1);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print("");&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(0,&nbsp;1);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print(a2);
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(5,&nbsp;0);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print(thresholds[0]);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(7,&nbsp;0);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print(thresholds[1]);
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(5,&nbsp;1);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print(thresholds[2]);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(7,&nbsp;1);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print(thresholds[3]);
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(11,&nbsp;0);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print(spd);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(11,&nbsp;1);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print(dir);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.setCursor(15,&nbsp;1);
&nbsp;&nbsp;&nbsp;&nbsp;lcd.print(train_status);
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;oldT&nbsp;=&nbsp;t;
&nbsp;&nbsp;}
&nbsp;
&nbsp;&nbsp;if&nbsp;(a1&nbsp;&lt;&nbsp;thresholds[0])&nbsp;thresholds[0]&nbsp;=&nbsp;a1;
&nbsp;&nbsp;if&nbsp;(a1&nbsp;&gt;&nbsp;thresholds[1])&nbsp;thresholds[1]&nbsp;=&nbsp;a1;
&nbsp;&nbsp;if&nbsp;(a2&nbsp;&lt;&nbsp;thresholds[2])&nbsp;thresholds[2]&nbsp;=&nbsp;a2;
&nbsp;&nbsp;if&nbsp;(a2&nbsp;&gt;&nbsp;thresholds[3])&nbsp;thresholds[3]&nbsp;=&nbsp;a2;
&nbsp;&nbsp;
&nbsp;&nbsp;if&nbsp;(dir&nbsp;==&nbsp;0)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(3,&nbsp;HIGH);
&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(4,&nbsp;LOW);
&nbsp;&nbsp;}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(4,&nbsp;HIGH);
&nbsp;&nbsp;&nbsp;&nbsp;digitalWrite(3,&nbsp;LOW);
&nbsp;&nbsp;}&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;analogWrite(2,&nbsp;spd);
}</pre>
<p>From the above, we get the following action... note that the whole process here is automated (throttle, detection, point switching):</p>
<p><object id="play456456545er" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="playe7686786867867r" width="640" height="352"><param name="movie" value="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D69279%26g2_serialNumber%3D2" /><embed type="application/x-shockwave-flash" id="player2776756756756" name="player24525345345477777" src="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" width="640" height="352" allowscriptaccess="always" allowfullscreen="true" flashvars="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D69279%26g2_serialNumber%3D2"/></object></p>
<h3>Conclusion</h3>
<p>This sensor worked much better than the previous attempts... but it's still not the best. I think I might now just grab one of the GP2D120s (as it would simply be plug-and-play) and see what happens. Also lighting plays an affect here too, it might just be easier in the end to have a strip of LDRs to work out where the train is... but everything has it's good and bad side!</p>
<p>The other option will be to have a spaced strip of detectors down one side of the track and emitters on the other. This will be like your tandy/radio-shack store that beep-beeps when you trip the beam... we'll see how well it works.<br />
<br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/n-scale-models/infrared-arduino-revisited/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Controlling lots of LEDs with your Arduino</title>
		<link>http://modelrail.otenko.com/n-scale-models/controlling-lots-of-leds-with-your-arduino</link>
		<comments>http://modelrail.otenko.com/n-scale-models/controlling-lots-of-leds-with-your-arduino#comments</comments>
		<pubDate>Thu, 18 Mar 2010 10:56:22 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[N Scale]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=620</guid>
		<description><![CDATA[There's a great article on the MAX7219/MAX7221 LED Drivers on arduino.cc that details how to utilise these chips to control a large amount of LEDs (MAX7219/7221 Datasheet.) The layout I've been working on was always going to have a lot of scenery lighting and I'd decided this time to use LEDs over traditional 12v DC [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />There's a <a href='http://www.arduino.cc/playground/Main/MAX72XXHardware'>great article on the MAX7219/MAX7221 LED Drivers</a> on <a href='http://www.arduino.cc/'>arduino.cc</a> that details how to utilise these chips to control a large amount of LEDs (<a href='http://datasheets.maxim-ic.com/en/ds/MAX7219-MAX7221.pdf'>MAX7219/7221 Datasheet</a>.) The layout I've been working on was always going to have a lot of scenery lighting and I'd decided this time to use LEDs over traditional 12v DC Bulbs as they draw less current and can often be a lot brighter. Also, Japan does use a lot more 'white light' when lighting streets and train/traffic signals, so it fits in close enough to the prototype.</p>
<p>LED Drivers are specific intergrated circuits that are designed to control a large amount of LEDs wired up in a matrix. This means that, in the case of the MAX7219/7221, the LEDs will be in rows and columns of 8 for a total of 64 LEDs per chip. The exact wiring dictates that each column contains 8 cathodes and each row 8 anodes. This therefore means that if you apply power to one row, and then ground a column, you will light the associated LED. Of course, this means that if you power two rows and two columns you will in fact have 4 LEDs lit. This is because the matrix is limited in only being able to light specific LEDs on a row-by-row basis.</p>
<p>Fortunately, the Drivers are fast enough to light row after row (selecting the exact LEDs to light by grounding certain columns) making it look like all LEDs are on at the same time. Therefore, you can specify the exact LEDs to light and, in the case of an 8x8 matrix, you can draw pictures, scroll text, etc...</p>
<p>Of course, you are not limited to controlling a matrix. These chips fundamentally just light up 64 LEDs and, for my layout, this should be enough for my scenery requirements. The main issue is actually building a 'distribution point' for getting the 64 pairs of wires out to the LEDs from the chip. </p>
<p>Note: PLEASE make sure you have a 'clean' power supply and it's connected cleanly and solidly. I just spent a day diagnosing why my LEDs stopped working... it was because my 12v power distribution had a dry solder joint... totally frustrating!</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68834&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" title="How to wire up a MAX7219 LED Driver" rel="lightbox[620]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68835&amp;g2_serialNumber=4&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" width="200" height="154" id="IFid1" class="ImageFrame_none" alt="How to wire up a MAX7219 LED Driver"/></a></div>
<p>As the chip only has 16 pins (8 rows, 8 columns), one has to split these out into inidividual wires to LEDs. </p>
<p>If you happen to have your LEDs in groups/clusters of 8 then you will have a lot less trouble wiring everything up... otherwise you'll need to tediously create a 'distribution board' like I've done here:</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68839&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" title="MAX7219 board" rel="lightbox[620]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68840&amp;g2_serialNumber=2&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" width="200" height="113" id="IFid2" class="ImageFrame_none" alt="MAX7219 board"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68848&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" title="Awesome soldering" rel="lightbox[620]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68849&amp;g2_serialNumber=2&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" width="200" height="113" id="IFid3" class="ImageFrame_none" alt="Awesome soldering"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68845&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" title="Close up of 'distribution board'" rel="lightbox[620]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68846&amp;g2_serialNumber=2&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" width="200" height="113" id="IFid4" class="ImageFrame_none" alt="Close up of 'distribution board'"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68842&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" title="Plugs to connect LEDs to" rel="lightbox[620]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68843&amp;g2_serialNumber=2&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" width="200" height="113" id="IFid5" class="ImageFrame_none" alt="Plugs to connect LEDs to"/></a></div>
<p><br/><br />
So, once this was together I put some plugs on the end of the ribbon wire and then added header pins to my LED wiring. This then meant I could simply plug the LEDs in as no resistors are required. Trying to work out which way around to put them was quite easy, as they seem to get full voltage if you put them the wrong way! So, be careful, if this happens then quickly reverse the LED.</p>
<p>I then wrote some code to turn my well-lit footpath into a flashing mess... </p>
<pre class="brush: c++">//pins for the MAX7219
#define CLK_PIN 31
#define LOD_PIN 33
#define DIN_PIN 35
&nbsp;
//pins for my L298N throttle
#define THROTTLE_ENABLE 2
#define PWM1_PIN 3
#define PWM2_PIN 4
&nbsp;
//library required from:
//http://www.arduino.cc/playground/uploads/Main/LedControl.zip
#include "LedControl.h"
&nbsp;
//LED CONTROL... 3 pins and then the number of devices
LedControl lcl=LedControl(DIN_PIN,CLK_PIN,LOD_PIN, 1);
&nbsp;
//currently connected lights:
//ROW 0:   NONE.
//ROW 1:&nbsp;Building, Building, Building, Building,
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Streetlight, Streetlight, Streetlight, Streetlight
//ROW 2-3: NONE.
//ROW 4:&nbsp;Streetlight, Streetlight, Streetlight, Streetlight,
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Streetlight, Streetlight, Building
//ROW 4-7: NONE.
&nbsp;
void setup() {
&nbsp;&nbsp;//initialise the led driver...
&nbsp;&nbsp;lcl.shutdown(0, false);   //turn off shutdown..
&nbsp;&nbsp;lcl.setIntensity(0, 8);   //set the intensity, you can also use the potentiometer.
&nbsp;
&nbsp;&nbsp;//set initial throttle, direction and speed
&nbsp;&nbsp;pinMode(THROTTLE_ENABLE, OUTPUT);
&nbsp;&nbsp;digitalWrite(PWM2_PIN, HIGH);
&nbsp;&nbsp;digitalWrite(PWM1_PIN, LOW);
&nbsp;&nbsp;analogWrite(THROTTLE_ENABLE, 200);
&nbsp;
&nbsp;&nbsp;//turn on the building lights.
&nbsp;&nbsp;for (int i = 0; i < 4; i++) lcl.setLed(0,1,i,true);
&nbsp;&nbsp;lcl.setLed(0,4,6,true);
}
&nbsp;
int MS_DELAY = 300; //timing, close enough to train speed.
&nbsp;
void loop() {
&nbsp;&nbsp;//the streetlights are in a bit of a jumbled order:
&nbsp;&nbsp;//ROW 4: 5,4,3,2,1 and then ROW 1: 4,5,6,7.
&nbsp;
&nbsp;&nbsp;//turn them all on
&nbsp;&nbsp;for (int x = 5; x >= 0; x--){
&nbsp;&nbsp;&nbsp;&nbsp;lcl.setLed(0, 4, x, true);
&nbsp;&nbsp;&nbsp;&nbsp;delay(MS_DELAY);
&nbsp;&nbsp;}
&nbsp;&nbsp;for (int x = 4; x < 8; x++){
&nbsp;&nbsp;&nbsp;&nbsp;lcl.setLed(0, 1, x, true);
&nbsp;&nbsp;&nbsp;&nbsp;delay(MS_DELAY);
&nbsp;&nbsp;}
&nbsp;
&nbsp;&nbsp;//now turn them back off
&nbsp;&nbsp;for (int x = 5; x >= 0; x--){
&nbsp;&nbsp;&nbsp;&nbsp;lcl.setLed(0,4,x,false);
&nbsp;&nbsp;&nbsp;&nbsp;delay(MS_DELAY);
&nbsp;&nbsp;}
&nbsp;&nbsp;for (int x = 4; x < 8; x++){
&nbsp;&nbsp;&nbsp;&nbsp;lcl.setLed(0,1,x,false);
&nbsp;&nbsp;&nbsp;&nbsp;delay(MS_DELAY);
&nbsp;&nbsp;}
}</pre>
</p>
<p>And here was the result, with my homemade street lights:</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68851&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" title="DSC03123" rel="lightbox[620]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68852&amp;g2_serialNumber=2&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" width="200" height="113" id="IFid6" class="ImageFrame_none" alt="DSC03123"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68854&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" title="DSC03126" rel="lightbox[620]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68855&amp;g2_serialNumber=2&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" width="200" height="113" id="IFid7" class="ImageFrame_none" alt="DSC03126"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68857&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" title="DSC03127" rel="lightbox[620]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68858&amp;g2_serialNumber=2&amp;g2_GALLERYSID=be3e0d821bc7a11a405db6ba3c8aa9a0" width="200" height="113" id="IFid8" class="ImageFrame_none" alt="DSC03127"/></a></div>
<p><br/><br /> <br />
<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="640" height="360"><param name="movie" value="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D68860%26g2_serialNumber%3D2" /><embed type="application/x-shockwave-flash" id="player2242342" name="player22342342" src="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" width="640" height="360" allowscriptaccess="always" allowfullscreen="true" flashvars="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D68860%26g2_serialNumber%3D2"/></object></p>
<p>The best thing about these chips is that they can be daisy-chained together to control a total of 512 LEDs off 3 pins. If you think you'll need more than that for your project, then you're crazy... but it can be done. Simply utilise another 3 digital pins of your Arduino to control another 512 LEDs... I shudder to think of something lit that brightly.</p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/n-scale-models/controlling-lots-of-leds-with-your-arduino/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Detecting trains with InfraRed + Arduino</title>
		<link>http://modelrail.otenko.com/my-layout/detecting-trains-with-infrared-arduino</link>
		<comments>http://modelrail.otenko.com/my-layout/detecting-trains-with-infrared-arduino#comments</comments>
		<pubDate>Wed, 24 Feb 2010 11:23:34 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[My Layout]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[N Scale]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=580</guid>
		<description><![CDATA[You've probably seen a lot of reversing/stopping circuits around, but the majority of these run on occupancy detection in track blocks. This can work very well but, due to the differences in train engines, you can have issues with how quickly to slow/stop individual locomotives. There are other ways of detecting a train coming to [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />You've probably seen a lot of <a href='http://home.cogeco.ca/~rpaisley4/AutoRevCheap.html'>reversing/stopping circuits</a> around, but the majority of these run on occupancy detection in track blocks. This can work very well but, due to the differences in train engines, you can have issues with how quickly to slow/stop individual locomotives. There are other ways of detecting a train coming to a dead-end, and here I'll show a method using Infrared Light.</p>
<p>Infrared light can't be seen by the human eye, but can be picked up by electronic devices. Due to this, it can be used freely around your layout (with the exception that direct sunlight/room-light can cause interference) for detecting your trains. One of the more common usages is to put an emitter/detector combination in a buffer to stop a train as it comes to the end of the line.</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68792&amp;g2_GALLERYSID=4f8de674fc313de782dc51ec46725d71" title="IR Detector" rel="lightbox[580]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68793&amp;g2_serialNumber=2&amp;g2_GALLERYSID=4f8de674fc313de782dc51ec46725d71" width="200" height="67" id="IFid1" class="ImageFrame_none" alt="IR Detector"/></a></div>
<p><br/><br />
Note that there are two emitter/detector devices! Each 'black box' in that diagram contains both an emitter and a detector. The benefit of using the QRD1114 means that these are neatly packaged in one unit!</p>
<p>In this set up the emitter and detector are both facing towards an approaching vehicle. The detector will receive the infrared light reflected off the vehicle as it approaches and it's internal resistance will rise accordingly. This means we can read the resistance of the detector to know how close the train is getting to the buffer and therefore slow the train down. We can ensure the train does not hit the buffer as long as we check the value of the detector and updating the speed of the train quickly.</p>
<p>Firstly, here's the circuit for wiring up both the <a href='http://toysdownunder.com/infrared-emmitter-detector.html'>'Infrared Emitters and Detectors'</a> and the <a href='http://toysdownunder.com/optical-detector-photo.html'>Optical Detector / Phototransistor (recommended)</a> from <a href='http://toysdownunder.com/'>Toys Downunder</a>. And <a href='http://www.sparkfun.com/datasheets/BOT/QRD1114.pdf'>Here's the datasheet</a> for the latter QRD1114.</p>
<p>Note: I happened to test out both setups as I destroyed my first QRD1114 by applying 5v directly to the emitter... <i>You must only apply 1.7v max!</i></p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68795&amp;g2_GALLERYSID=4f8de674fc313de782dc51ec46725d71" title="Wiring up the detector" rel="lightbox[580]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68796&amp;g2_serialNumber=2&amp;g2_GALLERYSID=4f8de674fc313de782dc51ec46725d71" width="200" height="87" id="IFid2" class="ImageFrame_none" alt="Wiring up the detector"/></a></div>
<p><br/></p>
<p>And then the detector set up on the engine shed roads:</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68816&amp;g2_GALLERYSID=4f8de674fc313de782dc51ec46725d71" title="Engine shed siding with Infrared" rel="lightbox[580]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68815&amp;g2_serialNumber=2&amp;g2_GALLERYSID=4f8de674fc313de782dc51ec46725d71" width="200" height="113" id="IFid3" class="ImageFrame_none" alt="Engine shed siding with Infrared"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68819&amp;g2_GALLERYSID=4f8de674fc313de782dc51ec46725d71" title="Engine shed siding with Infrared" rel="lightbox[580]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68818&amp;g2_serialNumber=2&amp;g2_GALLERYSID=4f8de674fc313de782dc51ec46725d71" width="200" height="113" id="IFid4" class="ImageFrame_none" alt="Engine shed siding with Infrared"/></a></div>
<p><br/><br />
The two roads above will eventually be located inside an engine shed. Due to the potential interference from one emitter to the other, I will put a separator down the middle of the tracks.</p>
<p>The maxmimum read distance I could achieve was just under 6cm during testing**. This wasn't exactly what I was expecting and would've liked around 10-12cm for this purpose, but I worked around this. It seems that there is a more expensive detector at Toys Downunder: <a href='http://toysdownunder.com/infrared-proximity-sensor.html'>Sharp GP2Y0A21YK</a> that can detect object up to 84cm away. I imagine it would be as simple as obtaining larger IR LEDs to boost the light output and therefore the light reflection.</p>
<p>Once the two detectors were in place, I set about automating a quick shunting process. I'd started noticing that, depending on room light, the readers weren't doing the best job; down to around 20mm distance was all that was being detected. This would not be enough to measure the speed as I wanted to, but I kept going anyway.</p>
<p>Programming the detector was the same as the potentiometer throttle done previously. The detector acted as a variable resistor and the reading would be from +1000 to 0 depending on the reflectivity of the object. It turned out that 0 was when the object was closest to the detector. Unfortunately, this only started changing once the object came within 30mm.</p>
<p>Here's a video of my quick shunt automation in action. First with the QRD1114 and then with the separate emitter/detector:</p>
<p><object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="640" height="360"><param name="movie" value="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D68806%26g2_serialNumber%3D3"/><embed type="application/x-shockwave-flash" id="player2ssdddss" name="player2ssdddssss" src="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" width="640" height="360" allowscriptaccess="always" allowfullscreen="true" flashvars=type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D68806%26g2_serialNumber%3D3"/></object></p>
<p>You can see that the separate emitter/detector doesn't function as well as the train actually hits it:</p>
<p><object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="640" height="360"><param name="movie" value="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D68810%26g2_serialNumber%3D3"/><embed type="application/x-shockwave-flash" id="player2ssss" name="player2ssssss" src="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" width="640" height="360" allowscriptaccess="always" allowfullscreen="true" flashvars="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D68810%26g2_serialNumber%3D3"/></object></p>
<h3>Results</h3>
<p>I ended up stopping progress on this as the detector didn't respond as well as I'd have wanted. After getting a 6cm read distance during test I thought it would feasible, but this dropped to a max of 15mm when actually installed on the track. There would be too much re-adjusting to get either of the types of infrared detectors to work.</p>
<p>The only option from here is to purchase the Sharp detector mentioned above and see if it really can detect 84cm!</p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/my-layout/detecting-trains-with-infrared-arduino/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tracking trains with an Arduino and RFID : Implemented</title>
		<link>http://modelrail.otenko.com/n-scale-models/tracking-trains-with-an-arduino-and-rfid-implemented</link>
		<comments>http://modelrail.otenko.com/n-scale-models/tracking-trains-with-an-arduino-and-rfid-implemented#comments</comments>
		<pubDate>Thu, 18 Feb 2010 10:29:36 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Japanese Trains]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[N Scale]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=566</guid>
		<description><![CDATA[Right, after telling you all about how the RFID setup works (and how to do it yourself), I thought I'd actually test it on my work-in-progress layout. Just for a recap, this setup uses the Arduino Mega, an ID-12 RFID Reader (plus RFID Button) from Toys Downunder and the code provided in the article listed [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />Right, after <a href='http://modelrail.otenko.com/n-scale-models/tracking-trains-with-an-arduino-and-rfid'>telling you all about how the RFID setup works (and how to do it yourself)</a>, I thought I'd actually test it on my work-in-progress layout. Just for a recap, this setup uses the <a href=''>Arduino Mega</a>, an <a href='http://toysdownunder.com/rfid-id12.html'>ID-12 RFID Reader</a> (plus <a href='http://toysdownunder.com/rfid-button.html'>RFID Button</a>) from <a href='http://www.toysdownunder.com.au/'>Toys Downunder</a> and <a href='http://modelrail.otenko.com/n-scale-models/tracking-trains-with-an-arduino-and-rfid'>the code provided in the article listed here</a>.</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68782&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" title="Full layout so far" rel="lightbox[566]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68781&amp;g2_serialNumber=2&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" width="200" height="113" id="IFid1" class="ImageFrame_none" alt="Full layout so far"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68776&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" title="Station put back, reader invisible" rel="lightbox[566]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68775&amp;g2_serialNumber=2&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" width="200" height="113" id="IFid2" class="ImageFrame_none" alt="Station put back, reader invisible"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68779&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" title="Thunderbird tests the reader" rel="lightbox[566]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68778&amp;g2_serialNumber=2&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" width="200" height="113" id="IFid3" class="ImageFrame_none" alt="Thunderbird tests the reader"/></a></div>
<p>I knew the ID-12 reader had a 60mm optimal read distance, so I wanted it pretty close to the track for extra reliability. I decided on mounting it inside the platform, as it would be close to the track and I could perform actions/events once a train reached the platform.</p>
<p>First I had to rewire the reader, as previously I'd used component wires (surplus resistor legs, etc...) so that I could easily test it on the Arduino. Now that it was to go through the baseboard I needed lengthy wires: </p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68767&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" title="Re-wiring for cables this time" rel="lightbox[566]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68766&amp;g2_serialNumber=2&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" width="200" height="113" id="IFid4" class="ImageFrame_none" alt="Re-wiring for cables this time"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68770&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" title="Fiddly business" rel="lightbox[566]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68769&amp;g2_serialNumber=2&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" width="200" height="113" id="IFid5" class="ImageFrame_none" alt="Fiddly business"/></a></div>
<p><br/><br />
And then I mounted it into the station platform:</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68761&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" title="Station base with area cut for reader" rel="lightbox[566]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68760&amp;g2_serialNumber=2&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" width="200" height="113" id="IFid6" class="ImageFrame_none" alt="Station base with area cut for reader"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68764&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" title="Foam removed for reader" rel="lightbox[566]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68763&amp;g2_serialNumber=2&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" width="200" height="113" id="IFid7" class="ImageFrame_none" alt="Foam removed for reader"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68773&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" title="Reader in place" rel="lightbox[566]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68772&amp;g2_serialNumber=2&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" width="200" height="113" id="IFid8" class="ImageFrame_none" alt="Reader in place"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68758&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" title="Station setup" rel="lightbox[566]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68757&amp;g2_serialNumber=2&amp;g2_GALLERYSID=101584f30ff74aadba823d6791f26e8a" width="200" height="113" id="IFid9" class="ImageFrame_none" alt="Station setup"/></a></div>
<p><br/><br />
And then, it just worked!</p>
<p><object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="640" height="360"><param name="movie" value="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D68783%26g2_serialNumber%3D3" /><embed type="application/x-shockwave-flash" id="player232412342" name="player2123432142" src="http://www.otenko.com/gallery2/modules/flashvideo/lib/G2flv.swf" width="640" height="360" allowscriptaccess="always" allowfullscreen="true" flashvars="type=video&#038;file=http%3A%2F%2Fwww.otenko.com%2Fgallery2%2Fmain.php%3Fg2_view%3Dcore.DownloadItem%26g2_itemId%3D68783%26g2_serialNumber%DD3" /></object><br /> <br />
<br/><br />
What you can't see is the readout on the computer screen of the unique id on the button. This is what will allow me to perform actions (maybe sounds, path settings or signal settings) per each train I have with a button installed.</p>
<p>What's next? I might try some proximity detection; as you can see, I have a 2-road yard just to the right of the station which will be an engine shed and it'll require that trains don't smash through the rear wall <img src='http://modelrail.otenko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/n-scale-models/tracking-trains-with-an-arduino-and-rfid-implemented/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tracking trains with an Arduino and RFID</title>
		<link>http://modelrail.otenko.com/n-scale-models/tracking-trains-with-an-arduino-and-rfid</link>
		<comments>http://modelrail.otenko.com/n-scale-models/tracking-trains-with-an-arduino-and-rfid#comments</comments>
		<pubDate>Wed, 17 Feb 2010 12:04:35 +0000</pubDate>
		<dc:creator>stevenh</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[N Scale Models]]></category>
		<category><![CDATA[N Scale]]></category>

		<guid isPermaLink="false">http://modelrail.otenko.com/?p=549</guid>
		<description><![CDATA[So, you're now controlling your trains with your Wii Nunchuck and an Arduino... What if you get tired and want them to run by themselves? This next project will help you with one piece of the puzzle, as long as the trains are still moving Whilst looking for the Wii Nunchuck Adapter at Toys Downunder, [...]]]></description>
			<content:encoded><![CDATA[<p id="top" />So, you're now <a href='http://modelrail.otenko.com/electronics/wii-nunchuck-arduino-mega-model-railway-fun'>controlling your trains with your Wii Nunchuck and an Arduino</a>... What if you get tired and want them to run by themselves? This next project will help you with one piece of the puzzle, as long as the trains are still moving <img src='http://modelrail.otenko.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Whilst looking for the <a href='http://toysdownunder.com/wiichuck.html'>Wii Nunchuck Adapter</a> at <a href='http://toysdownunder.com/'>Toys Downunder</a>, I came across <a href='http://toysdownunder.com/rfid-button.html'>RFID 'buttons'</a> and <a href='http://toysdownunder.com/rfid-id12.html'>an RFID reader</a> that were compatible with the Arduino. Since I have the <a href='http://arduino.cc/en/Main/ArduinoBoardMega'>Arduino Mega</a>, I knew I'd have pins/serial lines to spare, so I went ahead and added them to my order.</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68742&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="RFID 'Buttons'" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68741&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="200" height="113" id="IFid1" class="ImageFrame_none" alt="RFID 'Buttons'"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68727&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="RFID Reader ID-12" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68726&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="200" height="113" id="IFid2" class="ImageFrame_none" alt="RFID Reader ID-12"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68730&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="RFID Reader ID-12 from below" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68729&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="200" height="113" id="IFid3" class="ImageFrame_none" alt="RFID Reader ID-12 from below"/></a></div>
<p><br/><br />
I bought the ID-12 RFID Reader and 2 RFID Buttons. I chose against purchasing the <a href='http://toysdownunder.com/rfid-breakout.html'>breakout board</a>, as after reading the comments it didn't look like it would fit the ID-12 (only fitting the ID-20.) I've since asked Toys Downunder to correct this comment in case it really does, as soldering these readers is a pain. (Note, they have since updated the notes and the ID-12 does indeed fit. They also offered me a free one! I might act on that next time I go shopping there!)</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68746&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="RFID IC Pinout" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68747&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="132" height="200" id="IFid4" class="ImageFrame_none" alt="RFID IC Pinout"/></a></div>
<p><br/><br />
Wiring up the reader was going to be pretty simple. I'd see examples <a href='http://opensourceprojects-torchris.blogspot.com/2009/02/rfid-arduino-door-lock.html'>of it wired here for a door lock</a> and in <a href='http://www.sparkfun.com/datasheets/Sensors/ID-12-Datasheet.pdf'>the datasheet</a>. I was a little confused as to which 'output' to use; there are two provided and I guessed right the first time (pin 9: Inverted TTL Data.) This output was fed into an RX port on one of the 3 surplus Serial ports on the Arduino Mega (Serial1).</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68736&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="Set up and functional" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68735&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="200" height="113" id="IFid5" class="ImageFrame_none" alt="Set up and functional"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68739&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="RFID Reader wiring" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68738&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="200" height="113" id="IFid6" class="ImageFrame_none" alt="RFID Reader wiring"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68733&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="Soldering pins" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68732&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="200" height="113" id="IFid7" class="ImageFrame_none" alt="Soldering pins"/></a></div>
<p><br/><br />
After a quick bit of coding, I had the RFID reader picking up the RFID button reliably. You can find <a href='http://www.arduino.cc/playground/Learning/PRFID'>instructions on this from the Arduino site for another type of reader</a>, but below is a quick code listing for getting it to work on the Arduino Mega. I wrote this with guidance from the previous door lock link and <a href='http://www.arduino.cc/en/Serial/Begin'>the Arduino site as well</a>.</p>
<pre class="brush: c++">bool newData = false;
int cardData[16];
int idx=0;
void setup() {
&nbsp;&nbsp;Serial.begin(9600);  // Hardware serial for Monitor 9600bps
&nbsp;&nbsp;Serial.println("Starting Reader..."); //show some activity
&nbsp;&nbsp;Serial1.begin(9600); //ID-12 uses 9600!
}
void loop() {
&nbsp;&nbsp;while (Serial1.available() > 0) {
&nbsp;&nbsp;&nbsp;&nbsp;cardData[idx] = Serial1.read();
&nbsp;&nbsp;&nbsp;&nbsp;idx++;
&nbsp;&nbsp;&nbsp;&nbsp;if (idx == 16) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newData = true;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;idx = 0;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
&nbsp;&nbsp;if (newData){
&nbsp;&nbsp;&nbsp;&nbsp;newData = false;
&nbsp;&nbsp;&nbsp;&nbsp;Serial.print("Found RFID device: ");
&nbsp;&nbsp;&nbsp;&nbsp;for (int i = 0; i < 16; i++) Serial.print(cardData[i]);
&nbsp;&nbsp;&nbsp;&nbsp;Serial.println(".");
&nbsp;&nbsp;}
} </pre>
<p>I've since read that external antennas can be hooked up, but creating one of these seems to be quite involved. Even though this ID-12 was the smallest reader available on Toys Downunder, there (after reading the datasheet) seems to be a slightly smaller one. It happens to be smaller since it doesn't include an internal antenna. Either way, if you choose to make your own, you may well be able to lay it in the trackbed. Otherwise, you can just shove a reader like this ID-12 into a trackside building or at the back of a engine shed to know which loco has arrived.</p>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68745&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="Button mounted on carriage" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68744&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="200" height="113" id="IFid1" class="ImageFrame_none" alt="Button mounted on carriage"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68748&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="Reader in action through Tomix Finetrack" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68749&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="200" height="113" id="IFid2" class="ImageFrame_none" alt="Reader in action through Tomix Finetrack"/></a></div>
<div class="wpg2tag-image"><a href="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68751&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" title="Reader picking up train with Button" rel="lightbox[549]"><img src="http://www.otenko.com/gallery2/main.php?g2_view=core.DownloadItem&amp;g2_itemId=68752&amp;g2_serialNumber=2&amp;g2_GALLERYSID=42cc8a07aaabae15a250909b0cd053f1" width="200" height="113" id="IFid3" class="ImageFrame_none" alt="Reader picking up train with Button"/></a></div>
<p><br/><br />
Initial testing showed that the Buttons could be read through my Thunderbird B-Train Shorty with motorised chassis; although the chassis wasn't powered at the time. I'll show the reader installed on a model railway in a future article.<br />
<br/></p>
]]></content:encoded>
			<wfw:commentRss>http://modelrail.otenko.com/n-scale-models/tracking-trains-with-an-arduino-and-rfid/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
