<?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>Random notes &#38; other stuff... &#187; projects</title>
	<atom:link href="http://leucos.lstilde.org/wp/category/electronics/projects/feed/" rel="self" type="application/rss+xml" />
	<link>http://leucos.lstilde.org/wp</link>
	<description>...about Linux, electronics, digital photography, whatever...</description>
	<lastBuildDate>Wed, 16 Dec 2009 00:29:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bat Detector with adjustable gain</title>
		<link>http://leucos.lstilde.org/wp/2009/05/bat-detector-with-adjustable-gain/</link>
		<comments>http://leucos.lstilde.org/wp/2009/05/bat-detector-with-adjustable-gain/#comments</comments>
		<pubDate>Fri, 22 May 2009 13:51:00 +0000</pubDate>
		<dc:creator>leucos</dc:creator>
				<category><![CDATA[electronics]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[bat]]></category>
		<category><![CDATA[detector]]></category>
		<category><![CDATA[ultrasonic]]></category>

		<guid isPermaLink="false">http://leucos.lstilde.org/wp/?p=254</guid>
		<description><![CDATA[While I stumbled upon Tony Messina's Simple Bat Detector pages long time ago,I really decided to build one only when I saw that Bre Pettis could :). This ultrasonic bat detector is simple to build, and pretty efficient.]]></description>
			<content:encoded><![CDATA[<div id="attachment_271" class="wp-caption alignleft" style="width: 160px"><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/image75.jpg"><img class="size-thumbnail wp-image-271" title="BatDetector" src="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/image75-150x150.jpg" alt="Bat Detector" width="150" height="150" /></a><p class="wp-caption-text">Bat Detector</p></div>
<p>While I stumbled upon Tony Messina&#8217;s <a href="http://home.earthlink.net/~bat-detector/SBD2.html">Simple Bat Detector</a> pages long time ago,I really decided to build one only when I saw that Bre Pettis <a href="http://blog.makezine.com/archive/2006/09/make_podcast_weekend_projects_7.html">could</a> <img src='http://leucos.lstilde.org/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>So I barely used Tony&#8217;s schematics and instructions, but spiced the circuit a bit by adding a gain adjustement potentionmeter, a on/off switch driven by the volume potentiometer, and a LED witness light.</p>
<p>It&#8217;s pretty easy to build : thru-hole components, some wires, &#8230;. You can use the eagle schematics included below to build yours. The latest version is single sided, and doesn&#8217;t need the flying wire on the top side like mine.</p>
<p>The most difficult part is to find the right compononents for the switch capable potentiometer (I choosed a push/push type : push to turn on, push again to turn off) and the box.</p>
<p>The push/push 10kΩ potentiometer used is a tyco Electronics 17PCSA103MC19P. You can grab it at <a href="http://fr.farnell.com/jsp/search/productdetail.jsp?SKU=1174114">Farnell</a>.<br />
The other potentionmeter is just a standard 10kΩ one, like the <a href="http://fr.farnell.com/jsp/search/productdetail.jsp?SKU=350072">Tyco Electronics 23ESA103MMF50NF</a><br />
The enclosure is a Boss Enclosure, model BIM RETEX 551 (Betabox Series), also available at <a href="http://fr.farnell.com/boss-enclosures/bim-retex-551/coffret-portatif/dp/1171601">Farnell</a>.</p>
<p>What I didn&#8217;t find at Farnell is the <a href="http://www.gotronic.fr/catalog/audio/ecouteurs.htm">piezo-ceramic earplug</a>. Unfortunately, I don&#8217;t remember if I got the high (E10P) or low (S83) impedance earplug.</p>

<a href='http://leucos.lstilde.org/wp/2009/05/bat-detector-with-adjustable-gain/image72/' title='BatDetector Circuit'><img width="150" height="150" src="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/image72-150x150.jpg" class="attachment-thumbnail" alt="Poorly routed initial prototype" title="BatDetector Circuit" /></a>
<a href='http://leucos.lstilde.org/wp/2009/05/bat-detector-with-adjustable-gain/image71/' title='BatDetector Inside'><img width="150" height="150" src="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/image71-150x150.jpg" class="attachment-thumbnail" alt="Inside view" title="BatDetector Inside" /></a>
<a href='http://leucos.lstilde.org/wp/2009/05/bat-detector-with-adjustable-gain/image74/' title='BatDetector Outside'><img width="150" height="150" src="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/image74-150x150.jpg" class="attachment-thumbnail" alt="Outside view : volume, gain and LED" title="BatDetector Outside" /></a>

<p>Grab the schematic and board here :</p>
<p><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/bat_en_1.sch">BatDetector Schematic</a></p>
<p><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/bat_en_1.brd">BatDetector Board</a></p>
<p>On the board, there is no connector to plug the potentiometer push/push switch. So you&#8217;ll have to wire one pin of the switch to the battery clip, and the other pin to the &#8216;+&#8217; connector on the board. For ground, just wire directly.</p>
<p>To test your detector, if you don&#8217;t have a bat under your hand, just open a water tap and aim the detector at it : it should make lots of noise. If not, try to adjust the gain settings. If nothing works, well&#8230; something is wrong <img src='http://leucos.lstilde.org/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now, just make it and go out listen for the bats. They&#8217;re pretty easy to find in semi-urban area : bats love city lights (well, they love the insects that love the city lights), especially  mercury vapor bulbs (white lights), which attract more insects. Unfortunately, most towns are now installing high pressure sodium lamps (orange), which insects doesn&#8217;t like as much. The most common bats, <a href="http://en.wikipedia.org/wiki/Common_Pipistrelle">Pipistrelle</a>, emit two kind of calls :</p>
<ul>
<li>echolocation for hunt, around 48KHz, you&#8217;ll hear those with the detector</li>
<li>social calls, around 20KHz; you can hear them without any device if you&#8217;re lucky enough (or young enough)</li>
</ul>
<p>Finally, but you probably already know that : do not wake up hinernating bats. If you do so, they have to fly, waste energy and even if they come back to sleep again, they will get hungry too early in the season. They will have to wake up to hunt, but too early means no insects, and the bat will probably die by waking too early.</p>
<p>Have fun !</p>
]]></content:encoded>
			<wfw:commentRss>http://leucos.lstilde.org/wp/2009/05/bat-detector-with-adjustable-gain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>High-power TVBGone</title>
		<link>http://leucos.lstilde.org/wp/2009/05/high-power-tvbgone/</link>
		<comments>http://leucos.lstilde.org/wp/2009/05/high-power-tvbgone/#comments</comments>
		<pubDate>Sat, 16 May 2009 20:33:14 +0000</pubDate>
		<dc:creator>leucos</dc:creator>
				<category><![CDATA[electronics]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[gadgets]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[tvbgone]]></category>

		<guid isPermaLink="false">http://leucos.lstilde.org/wp/?p=188</guid>
		<description><![CDATA[High power TVBGone. This infrared device will turn off most TVs out there, from approximately 100ft (30m). ]]></description>
			<content:encoded><![CDATA[<p>This TVBG has been done a long time ago, but I never took time to write about it. It&#8217;s quite powerful : you can easily take off TV&#8217;s at 100ft, and even works thru your pocket (and pretty far if you wear GoreTex). But guess it, with power comes batteries, and the downside is it&#8217;s size, roughly the size of a cigarette pack (all the pictures below are pretty outdated&#8230;).</p>
<div id="attachment_192" class="wp-caption aligncenter" style="width: 250px"><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/telecommandof.jpg"><img class="size-full wp-image-192" title="TVBGone with it's camouflage package" src="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/telecommandof.jpg" alt="TVBGone with it's camouflage package" width="240" height="302" /></a><p class="wp-caption-text">TVBGone with it</p></div>
<p>The design is pretty simple : an AtTiny85, 6 TSAL 6100 IR diodes from Vishay (rated 1A for short pulses), 6+1 NPN transistors. Unlike what is show in the picture below, there is no more jumper (it was used to switch between programming mode and run mode). The tantalum capacitor has been scrounged, and not bought. If you know what coltan is, you know that buying tantalum stuff is rather bad.</p>
<div id="attachment_191" class="wp-caption aligncenter" style="width: 277px"><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/img_0638.jpg"><img class="size-full wp-image-191" title="Bottom view" src="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/img_0638.jpg" alt="TBGone bottom view" width="267" height="346" /></a><p class="wp-caption-text">TBGone bottom viewTVBGone with it</p></div>
<p>The thing is powered by 3xAA batteries. <strong>There is no current limiter</strong>, the only limit is provided by the batteries internal resistance so take care if you want to change supply for a LiPo or whatever, you&#8217;ll blow the LEDs for sure. In this case, add a resistor along each LED, or better, use some current regulator.</p>
<p>For now, the 6 TSAL LEDs are sucking 2.5 Amps without a current limiter.</p>
<div id="attachment_190" class="wp-caption aligncenter" style="width: 192px"><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/img_0636.jpg"><img class="size-full wp-image-190" title="Top view" src="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/img_0636.jpg" alt="TVBGone top view" width="182" height="277" /></a><p class="wp-caption-text">TVBGone top view</p></div>
<p>The AVR code has been found on the net, and is provided here almost unmodified. The original authors are in the <em>main.c</em> header file, among which, of course, Limor (aka Ladyada).</p>
<p>I&#8217;ve changed the IR codes a bit, removing some duplicates, reordered them too so the most used codes comes first (file with modified codes is <em>PERSOcodes.c</em>).</p>
<p>One of the problems is that LG TV can not yet be turned off. This is a pain since LGs are everywhere. I don&#8217;t have time to reverse engineer timings for LG or use convert Lirc codes for now. But for sure, this would be valuable work. If you do it, please drop me a note.</p>
<p>EDIT : CaitSith2 dropped a note saying he has more up to date code for TVBG which turns off LGs too (see <a title="comments" href="#comments">comments</a>). So you&#8217;d better use <a title="CaitSith2 code" href="http://caitsith2.net/projects/tvbgone/">his</a> code than mine. Thanks CaitSith2 !</p>
<p>EDIT2 : It seems that CaitSith2 is more high power : 8 TSAL6100, 4xAA&#8230; nice !</p>
<p>In the <a href="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/tvbgonetar.gz">schematics</a> (tvbgone2_cms), all the little pads near JP1 are for a very weird slide button (I was too leazy to draw an eagle lib part). So don&#8217;t panic and adjust for your switch.</p>
<p>There is another schematic included : tvbgone_mini.sch, which is a variant intended to be build as jewelry. I plan to use <a title="CR2477 batteries" href="http://export.farnell.com/panasonic/cr2477-1hfe/battery-lithium-2pin-horiz-cr2477/dp/1298248">CR2477 batteries</a> but I never built it. If you make it, please tell me how things turned.</p>
<p>The P &amp; R pins are &laquo;&nbsp;Program&nbsp;&raquo; and &laquo;&nbsp;Run&nbsp;&raquo; respectively. When done programming, just cut the wire going from the central pad to P, and make a solder bridge between the central pad and the R pad. If you need to reprogram again, remove bridge, and bridge between the central pad and P, etc&#8230;</p>
<p>Get the <a href="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/tvbgonetar.gz">eagle schematics</a>, grab the <a href="http://leucos.lstilde.org/wp/wp-content/uploads/2009/05/tvbgera.tgz">code</a>, turn off those TVs and have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://leucos.lstilde.org/wp/2009/05/high-power-tvbgone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WRT54G/GS/GL Relay Mod</title>
		<link>http://leucos.lstilde.org/wp/2008/09/wrt54ggsgl-relay-mod/</link>
		<comments>http://leucos.lstilde.org/wp/2008/09/wrt54ggsgl-relay-mod/#comments</comments>
		<pubDate>Sat, 27 Sep 2008 18:35:18 +0000</pubDate>
		<dc:creator>leucos</dc:creator>
				<category><![CDATA[electronics]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[mods]]></category>
		<category><![CDATA[wrt]]></category>

		<guid isPermaLink="false">http://leucos.lstilde.org/wp/?p=50</guid>
		<description><![CDATA[How to hack a WRT54 Linksys routeur to power cycle a remote device.]]></description>
			<content:encoded><![CDATA[<p>Sometimes, it could be handy if your router (in this case, a WRT54G) could restart the device that connects it to the internet. For instance, if your ADSL modem needs some reboot or your cable modem needs a kick, having the WRT to do this would be nice.</p>
<p>This could be especially useful if the modem+router are deployed as an access point somewhere in the wild.</p>
<p>This usage is not limitating : we&#8217;re gonna build a WRT managed relay. What you switch on/off with this relay is your problem. A modem seems a reasonable idea, but you could switch a coffee pot (in this case,  you should go with HTCPCP [<a title="RFC 2324" href="http://www.ietf.org/rfc/rfc2324.txt" target="_blank">http://www.ietf.org/rfc/rfc2324.txt</a>]), lights, etc&#8230;</p>
<p>All this is possible with little modification. The behaviour of the system here is to switch the relay for approx. 14 seconds, but this time is also easy to change. You can even use a trim pot instead to make it fully tunable.</p>
<p><strong>Schematics</strong></p>
<div id="attachment_52" class="wp-caption alignleft" style="width: 160px"><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/wrm_schem_v3.png"><img class="size-thumbnail wp-image-52" title="Schematic" src="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/wrm_schem_v3-150x150.png" alt="Relay board schematic" width="150" height="150" /></a><p class="wp-caption-text">Relay board schematic</p></div>
<p>The <a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/wrm_v3.zip">schematic</a> is rather simple. The board is connected to the internal WRT54G serial port (TX pin). This pin uses LV-TLL signals (0, +3.3V), and logic high is 0V. In other words, when nothing is send out to the serial port by the WRT, the level is low and the TX pin show 3.3V. What we want is to activate the relay when voltage on this pins drop. The trick is to feed the TX pin to the Threshold pin of a 555 timer (see those excellent 555 links in <a title="Electronics Club on 555" href="http://www.kpsec.freeuk.com/555timer.htm">Electronics Club</a> and <a title="Mecanno Electronique" href="http://www.ptitrain.com/electronique/meccano/meccano_sommaire.htm">Mecanno Electronique</a> in french). And this is what happens when we the WRT sends data to the serial port : square wave comes out of second serial port TX pin and triggers the 555. For this to work, the 555 is powered at 6V, and thus triggered when TX voltage drops below 2V (approx 1/3 of VCC). The 6V feed is very primitive and comes from WRT power (12V) sliced in half by a voltage divider. It would be wiser to use a voltage regulator (7805 or al.), but we&#8217;re going the easy way here.</p>
<p>The trigger from the 555 is fed at the base of the 2N2222 transistor which in turns feed the coil enough current to switch.</p>
<p>Primitive, as I said.</p>
<p><strong>Assembling it</strong></p>
<p>First, be aware that doing the bad things below will void your WRT warranty, your modem warranty. You also can burn things or yourself in the process, etc&#8230; So do at your own risk. This being said, that stuff has been my first electronics project so it is <em>really</em> easy. <em>&laquo;&nbsp;my first electronics project&nbsp;&raquo;</em> should also be taken as a warning.</p>
<ul>
<li>Open your WRT54G (or GS, or GL) by pulling the blue cover out</li>
</ul>
<ul>
<li>Take the WRT PCB out.</li>
</ul>
<ul>
<li>Solder a wire in the TX pin (pin 3) of the serial port</li>
</ul>
<p><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/txpin.jpg"><img class="alignright size-thumbnail wp-image-51" title="TX pin location" src="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/txpin-150x150.jpg" alt="" width="150" height="150" /></a>Soldering this port is really easy, even I did it without breaking anything or melting the router to a shapeless plastic blob. You&#8217;ll find more info and pictures on the <a title="LinkSys WRT5G/GS Dual Port Mod Page" href="http://www.rwhitby.net/wrt54gs/serial.html" target="_blank">LinkSys WRT5G/GS Dual Port Mod Page</a>. You don&#8217;t need IDC headers or high end stuff like this. Just solder in the hole. It will be ok as long as you don&#8217;t pull too much on the wire.</p>
<p>The blue front cover has holes inside. These holes can&#8217;t be seen from the outside because of the stickers. This is a good place to make a complete hole with a hot wire if you plan to put your PCB relay outside the WRT. For recent models, like the GL, the PCB can probably fit inside.</p>
<ul>
<li>Pull the TX cable through the blue cover and assemble the WRT back</li>
</ul>
<ul>
<li>Solder the wires with the DC power jacks on the board<a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/wrt_board.jpg"><img class="alignright size-thumbnail wp-image-54" title="Relay board" src="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/wrt_board-150x150.jpg" alt="" width="150" height="150" /></a></li>
</ul>
<ul>
<li>Cut power cables from modem and WRT. Be sure to cut it at the right place ! You need enough cable to plug the wall wart and enough cable to plug the modem and WRT.</li>
</ul>
<ul>
<li>Remove some insulating material from the power wires and insert them in the screw clamps. Don&#8217;t mess with polarity or which wire go where. You would burn something for <em>sure</em>.</li>
</ul>
<ul>
<li>Now we need software to get this going. The basic idea is to ping some IP address, and when consecutive failures are detected, the relay is activated and the stuff behind it reboots. You can push the shell script to the WRT running Sveasoft firmware under Administration/Diagnostocs/Run, then paster script and click &laquo;&nbsp;Save Startup&nbsp;&raquo;. You can do the same with OpenWRT and probably with other firmwares.</li>
</ul>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh&lt;/code&gt;</span><br />
<br />
<span style="color: #666666; font-style: italic;">########### Tunable Variables #############</span><br />
<span style="color: #666666; font-style: italic;"># which host to check</span><br />
<span style="color: #007800;">checkhost</span>=<span style="color: #ff0000;">&quot;212.27.48.10&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># how often to check</span><br />
<span style="color: #007800;">checkinterval</span>=<span style="color: #000000;">20</span><br />
<br />
<span style="color: #666666; font-style: italic;"># how many failures to activate relay</span><br />
<span style="color: #007800;">activateafter</span>=<span style="color: #000000;">3</span><br />
<br />
<span style="color: #666666; font-style: italic;"># where is the wrt_relay_mod</span><br />
<span style="color: #666666; font-style: italic;"># serial=/tmp/test</span><br />
<span style="color: #007800;">serial</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>tts<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span><br />
<br />
<span style="color: #666666; font-style: italic;"># how long should we rest after switching</span><br />
<span style="color: #007800;">rest</span>=<span style="color: #000000;">120</span><br />
<br />
<span style="color: #666666; font-style: italic;"># how many log/debug lines do we keep</span><br />
<span style="color: #007800;">keeplines</span>=<span style="color: #000000;">20</span><br />
<span style="color: #666666; font-style: italic;">########### End Variables #################</span><br />
<br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #007800;">pingfail</span>=0<br />
<span style="color: #007800;">logfile</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>wrm.log<br />
<span style="color: #007800;">debuglogfile</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>wrm_debug.log<br />
<span style="color: #007800;">version</span>=<span style="color: #000000;">1</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<br />
log<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$logfile</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; : &quot;</span><span style="color: #800000;">${1}</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$logfile</span><br />
<br />
<span style="color: #666666; font-style: italic;"># trim log file</span><br />
<span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-n</span> 8 <span style="color: #007800;">$logfile</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$logfile</span>.tmp<br />
<span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-n</span> <span style="color: #007800;">$keeplines</span> <span style="color: #007800;">$logfile</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$logfile</span>.tmp<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$logfile</span>.tmp <span style="color: #007800;">$logfile</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
debug<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$debuglogfile</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; : &quot;</span><span style="color: #800000;">${1}</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$debuglogfile</span><br />
<br />
<span style="color: #666666; font-style: italic;"># trim debug file</span><br />
<span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-n</span> <span style="color: #007800;">$keeplines</span> <span style="color: #007800;">$debuglogfile</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$debuglogfile</span>.tmp<br />
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$debuglogfile</span>.tmp <span style="color: #007800;">$debuglogfile</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
check_loop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
<span style="color: #666666; font-style: italic;"># we sleep $checkinterval seconds</span><br />
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #007800;">$checkinterval</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">ping</span> <span style="color: #660033;">-qn</span> <span style="color: #660033;">-c</span> 1 <span style="color: #007800;">$checkhost</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null ; <span style="color: #000000; font-weight: bold;">then</span><br />
<span style="color: #666666; font-style: italic;"># network is ok</span><br />
<span style="color: #007800;">pingfail</span>=<span style="color: #000000;">0</span><br />
debug <span style="color: #ff0000;">&quot;/-\ =&amp;gt; ping ok&quot;</span><br />
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #007800;">$checkinterval</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
<span style="color: #666666; font-style: italic;"># network seems down</span><br />
<span style="color: #007800;">pingfail</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$pingfail</span> + <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span><br />
debug <span style="color: #ff0000;">&quot;/?\ =&amp;gt; <span style="color: #007800;">$pingfail</span> ping failures&quot;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$pingfail</span> <span style="color: #660033;">-ge</span> <span style="color: #007800;">$activateafter</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
log <span style="color: #ff0000;">&quot;relay switched&quot;</span><br />
debug <span style="color: #ff0000;">&quot;/!\ =&amp;gt; switching relay...&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> ACTIVATE <span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$serial</span><br />
debug <span style="color: #ff0000;">&quot;/-\ &amp;gt; resting for <span style="color: #007800;">$rest</span> seconds&quot;</span><br />
<span style="color: #007800;">pingfail</span>=0<br />
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$rest</span> - <span style="color: #007800;">$checkinterval</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># log few information at boot</span><br />
log <span style="color: #ff0000;">&quot;######################################&quot;</span><br />
log <span style="color: #ff0000;">&quot;# wrm daemon version <span style="color: #007800;">$version</span> starting&quot;</span><br />
log <span style="color: #ff0000;">&quot;# checkhost=<span style="color: #007800;">$checkhost</span>&quot;</span><br />
log <span style="color: #ff0000;">&quot;# checkinterval=<span style="color: #007800;">$checkinterval</span>&quot;</span><br />
log <span style="color: #ff0000;">&quot;# activateafter=<span style="color: #007800;">$activateafter</span>&quot;</span><br />
log <span style="color: #ff0000;">&quot;# serial=<span style="color: #007800;">$serial</span>&quot;</span><br />
log <span style="color: #ff0000;">&quot;# rest=<span style="color: #007800;">$rest</span>&quot;</span><br />
log <span style="color: #ff0000;">&quot;######################################&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># initial rest</span><br />
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #007800;">$rest</span><br />
<br />
<span style="color: #666666; font-style: italic;"># control loop</span><br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">true</span>; <span style="color: #000000; font-weight: bold;">do</span> check_loop; <span style="color: #000000; font-weight: bold;">done</span></div></div>
<p>Tune variables at your liking. You can see how the relay is software activated : it just writes &#8216;ACTIVATE&#8217; to the device driving the second serial port. What you write is not important. &#8217;saddam&#8217; and &#8216;george&#8217; work equally well for instance. You should also restrain yourself from logging too much. The idel situation for deployment is to disable debug and logging. Space is scarce on the WRT.</p>
<p>Here is the final thing assembler, with the driver modem (a Terayon TJ720). The system works fine but is<a class="imagelink" title="Assembled setup" onclick="doPopup(9);return false;" href="http://misomosi.free.fr/wp-content/assembled.jpg"><img id="image9" title="Assembled setup" src="http://misomosi.free.fr/wp-content/assembled.thumbnail.jpg" alt="Assembled setup" align="right" /></a> quite static sensitive. So discharge yourself somewhere before touching the running circuit, or the relay might activate. Also, proper casing should be done. Putting the circuit inside the WRT is possible with latter models (WRT54GS and WRT54GL). This hasn&#8217;t been tester though, and might put some noise inside.</p>
<p><strong>Bill of materials</strong></p>
<p>Building this stuff shouldn&#8217;t take more than 2 hours and if you wish to buy parts, it will cost less than 4€ (3.0€ each by 20 at <a title="GoTronic" href="http://www.gotronic.fr.">GoTronic</a> in France).</p>
<p>Here is the list of components required :</p>
<table border="0">
<tbody>
<tr bgcolor="#aaaaff">
<th>Component</th>
<th align="center">Quantity</th>
</tr>
<tr>
<td>MINIATURE RELAY 6-12V/12V-2A</td>
<td>1</td>
</tr>
<tr>
<td>TWO WAY TERMINAL BLOCK</td>
<td>2</td>
</tr>
<tr>
<td>1K RESIST. CARBON 1/4-5%</td>
<td>2</td>
</tr>
<tr>
<td>47K RESIST. CARBON 1/4-5%</td>
<td>1</td>
</tr>
<tr>
<td>33K RESIST. CARBON 1/4-5%</td>
<td>1</td>
</tr>
<tr>
<td>TRANSISTOR NPN 50V-0.2A</td>
<td>1</td>
</tr>
<tr>
<td>CAPACITOR 10n</td>
<td>1</td>
</tr>
<tr>
<td>CAPACITOR 220u</td>
<td>1</td>
</tr>
<tr>
<td>CAPACITOR 100u</td>
<td>1</td>
</tr>
<tr>
<td>DIODE 1A 1N4007 or eq.</td>
<td>1</td>
</tr>
<tr>
<td>DIODE 1N4148 or eq.</td>
<td>1</td>
</tr>
<tr>
<td>NE555 TIMER</td>
<td>1</td>
</tr>
<tr>
<td>LED 5MM RED (not in schematics)</td>
<td>1</td>
</tr>
<tr>
<td>LEDS 5MM GREEN (not in schematics)</td>
<td>1</td>
</tr>
<tr>
<td>PROTO BOARD (approx 20 holes x 20 holes) or PCB to etch</td>
<td>1</td>
</tr>
</tbody>
</table>
<p>Besides the board and may be the 555, the rest is easily scavengeable.</p>
]]></content:encoded>
			<wfw:commentRss>http://leucos.lstilde.org/wp/2008/09/wrt54ggsgl-relay-mod/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nikon D50/D70 IR remote control</title>
		<link>http://leucos.lstilde.org/wp/2008/09/nikon-d50d70-ir-remote-control/</link>
		<comments>http://leucos.lstilde.org/wp/2008/09/nikon-d50d70-ir-remote-control/#comments</comments>
		<pubDate>Sat, 27 Sep 2008 16:45:46 +0000</pubDate>
		<dc:creator>leucos</dc:creator>
				<category><![CDATA[electronics]]></category>
		<category><![CDATA[photo/video]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[d50]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[nikon]]></category>
		<category><![CDATA[remote]]></category>

		<guid isPermaLink="false">http://leucos.lstilde.org/wp/?p=29</guid>
		<description><![CDATA[Nikon infrared remote control with some special features (interval shots, multiples shots, continuous shots, ...).]]></description>
			<content:encoded><![CDATA[<p align="left"><strong>The Project</strong></p>
<p align="left">After chasing the idea of building a remote for my D50, I found <a title="IR Remote Control" href="http://www.bigmike.it/ircontrol/">this</a> really interesting page with all you need (especially the IR timing) to get your remote up and running.</p>
<p align="left">But using a AtTiny2313 for this leaves a lot of room to play with. So I made an enhanced version with a 7-segments display and a menu system. The new firmware let&#8217;s you choose among several shooting modes.</p>
<p align="left">
<p align="left">
<p>The remote is almost identical to the BigMike&#8217;s one except :</p>
<ul>
<li>the firmware is, of course, modified</li>
<li>there is no On/Off button</li>
<li>there are two buttons for the menu (change/select)</li>
<li>there is a 7-segments display for the menu</li>
</ul>
<div id="attachment_32" class="wp-caption aligncenter" style="width: 209px"><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/d50r_0.jpg"><img class="size-medium wp-image-32" title="Remote control" src="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/d50r_0-199x300.jpg" alt="Remote control" width="199" height="300" /></a><p class="wp-caption-text">Remote control</p></div>
<p>The firmware sets the Tiny2313 in sleep mode after 5 seconds of inactivity.<br />
In tis mode, the datasheet gives at most 2µA current usage. So, since a CR2032 yields 220 mAh, and if I didn&#8217;t mess up somehere, you should be up and running for 10 years.</p>
<p><strong>Modes description</strong></p>
<p>The remote offers 9 shot modes, which of course can be changed in the firmware.</p>
<p>Whatever the mode, the <em>dp</em> dot blinks everytime a &laquo;&nbsp;take shot&nbsp;&raquo; IR frame is sent.</p>
<ul>
<li>Single shot mode (symbol : reversed lower &#8216;c&#8217;) : one button press makes a single shot</li>
</ul>
<ul>
<li>Double shot mode (symbol : two horizontal dashes ) : one button press makes two shots in a row</li>
</ul>
<ul>
<li>Triple shot mode (symbol : three horizontal dashes ) : one button press makes three shots in a row</li>
</ul>
<ul>
<li>Continuous shot (symbol : lower &#8216;c&#8217;) : one  button press starts continuous shooting as fast as possible until the &#8216;menu&#8217; button is pressed again or the battery is dead <img src='http://leucos.lstilde.org/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<ul>
<li>Continuous shot every second (symbol : number 1) : one  button press starts shooting 1 picture per second until the &#8216;menu&#8217; button is pressed again or the battery is dead</li>
</ul>
<blockquote><p>Numbers 2, 5, 0 and 6 are also continuous shoot mode with 1 picture every 2, 5 10 and 60 seconds respectively.</p></blockquote>
<div id="attachment_33" class="wp-caption aligncenter" style="width: 209px"><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/d50r_1.jpg"><img class="size-medium wp-image-33" title="Modes selection" src="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/d50r_1-199x300.jpg" alt="Modes selection" width="199" height="300" /></a><p class="wp-caption-text">Modes selection</p></div>
<p><strong>Files</strong></p>
<p>Wanna build yours ? You&#8217;ll need :</p>
<div id="attachment_35" class="wp-caption aligncenter" style="width: 310px"><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/d50r_schematics.png"><img class="size-medium wp-image-35" title="Schematic" src="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/d50r_schematics-300x212.png" alt="Circuit schematic" width="300" height="212" /></a><p class="wp-caption-text">Circuit schematic</p></div>
<div id="attachment_34" class="wp-caption aligncenter" style="width: 223px"><a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/d50r_board.png"><img class="size-medium wp-image-34" title="Board" src="http://leucos.lstilde.org/wp/wp-content/uploads/2008/09/d50r_board-213x300.png" alt="Circuit board layout" width="213" height="300" /></a><p class="wp-caption-text">Circuit board layout</p></div>
<p>The core of the code (IR timing loop) is taken straight from <a title="IR Remote Control" href="http://www.bigmike.it/ircontrol/">BigMike&#8217;s</a> ASM source.</p>
<p><strong>Issues</strong></p>
<p>There are some issues in my version. I am not sure if they are firmware/hardware/ir issues. The problem is the reliability of triggering : sometimes it just doesn&#8217;t work. This does make the remote of reduced usability for continuous shooting modes where timing is critical.</p>
<p>I wonder where this problem comes from : IR receptor low sensitivity ? inaccurate frequency generation ? AF mode induced triggering problems in some situations ?<br />
Since I have relatively few hardware here (no friend with another D50, no oscilloscope, &#8230;) I didn&#8217;t dig it up for now.</p>
<p>And oh, BTW, the usual warnings apply : this remote can brick your MCU, destroy your Nikon, set your house on fire, etc&#8230; You&#8217;ve been warned !</p>
<p><strong>Thanks</strong></p>
<p>Big thanks to <a href="http://www.bigmike.it/ircontrol/" target="_blank">Bighignoli Michele</a>, <a href="http://www.jonas-diemer.de/english/projects/nikon-ir-remote-control.html" target="_blank">Jonas Diemer</a> and <a href="http://www.natemc.com/nikontrigger.php" target="_blank">Nate</a> who pioneered the area.</p>
<p>EDIT : I finally managed to put my hands back on the firmware ! You can grab the <a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/12/nikon_remote2asm.gz">ASM source</a> or the <a href="http://leucos.lstilde.org/wp/wp-content/uploads/2008/12/nikon_remote-2hex.gz">hex</a> file. Have fun !</p>
]]></content:encoded>
			<wfw:commentRss>http://leucos.lstilde.org/wp/2008/09/nikon-d50d70-ir-remote-control/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
