<?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>Tony Blews &#187; Programming Bits</title>
	<atom:link href="http://www.tonyblews.co.uk/category/computers/programming-bits/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tonyblews.co.uk</link>
	<description>Jack of all, master of none</description>
	<lastBuildDate>Thu, 02 Sep 2010 02:02:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Genesis of the Arduino Dalek</title>
		<link>http://www.tonyblews.co.uk/2010/07/genesis-of-the-arduino-dalek/</link>
		<comments>http://www.tonyblews.co.uk/2010/07/genesis-of-the-arduino-dalek/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 01:36:15 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Dalek]]></category>
		<category><![CDATA[Make Stuff]]></category>
		<category><![CDATA[Programming Bits]]></category>
		<category><![CDATA[Robots]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Toys]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[dalek]]></category>

		<guid isPermaLink="false">http://www.tonyblews.co.uk/?p=850</guid>
		<description><![CDATA[As previously mentioned here, I was recently given a broken toy Dalek, which I promptly took apart (in the name of Science). Here it is before surgery commenced&#8230; Having stripped the thing down, I found inside two perfectly good electric motors, and when you find two working motors inside a toy there is only one [...]]]></description>
			<content:encoded><![CDATA[<p>As previously mentioned <a href="http://www.tonyblews.co.uk/2010/05/dalek-autopsy/">here</a>, I was recently given a broken toy Dalek, which I promptly took apart (in the name of Science).</p>
<p>Here it is before surgery commenced&#8230;</p>
<p><a href="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/dalek-1.jpg"><img class="aligncenter size-full wp-image-852" title="dalek-1" src="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/dalek-1.jpg" alt="" width="400" height="300" /></a></p>
<p>Having stripped the thing down, I found inside two perfectly good electric motors, and when you find two working motors inside a toy there is only one thing to do: Work out how to use a computer to control them!</p>
<p>So, figuring out that the easiest way of doing this was with an <a href="http://arduino.cc/">Arduino</a>, I <a href="http://www.amazon.co.uk/gp/product/B003CR56MU?ie=UTF8&amp;tag=ukwatransit-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=B003CR56MU">bought one</a>.</p>
<p>I won&#8217;t bleat on about how good the Arduino is, or how easy it is to use. There are hundreds of sites that do that.</p>
<p>Instead, here is a list of things wot i dun to get a PC controlling the Dalek.</p>
<p>To start with, I think we&#8217;ll have a bit of circuit design. Below is a simple circuit that takes 2 inputs from the Arduino and runs a motor either forwards or backwards. One input decides the direction of the motor, the other whether it is on or off.</p>
<p><a href="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/relay-circuit.jpg"><img class="aligncenter size-full wp-image-856" title="relay-circuit" src="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/relay-circuit.jpg" alt="" width="250" height="270" /></a></p>
<p>All very nice and abstract, but to be of any use it&#8217;ll need to be built. The quickest and easiest way is on Veroboard. So here is the design for that:</p>
<p><a href="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/relay-vero.jpg"><img class="aligncenter size-full wp-image-858" title="relay-vero" src="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/relay-vero.jpg" alt="" width="250" height="236" /></a></p>
<p>The relays do the switching, and the diodes are there to protect the Arduino from back-emf currents when the relays toggle. Two of these circuits will be used, one for each motor. I built them on separate strips of board to make things easier for myself. This is what they look like when all connected up and dumped onto the Dalek chassis:</p>
<p><a href="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/dalek-wired1.jpg"><img class="aligncenter size-full wp-image-860" title="dalek-wired1" src="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/dalek-wired1.jpg" alt="" width="400" height="300" /></a></p>
<p>The small board in the top left of the picture is just a plug I bodged up to make connecting the thing easier.</p>
<p>The parts used are 4x 1A5VDC DPDT relays, 4x 1N4004 diodes, a 10&#215;39 strip of Veroboard and some wires.</p>
<p>After all that soldering and burning my fingers, the next step is to write some code to make the thing move.</p>
<p>Each motor can be controlled to go backwards, forwards or stop. This gives nine possible movements, as this table shows:</p>
<p><a href="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/dalek-matrix.jpg"><img class="aligncenter size-full wp-image-865" title="dalek-matrix" src="http://www.tonyblews.co.uk/wordpress/wp-content/uploads/2010/07/dalek-matrix.jpg" alt="" width="200" height="170" /></a></p>
<p>And now its time to test this whole think by writing a program that takes keyboard commands (the letters in red, above) and sending signals to the circuitry to control the motors. Heres it is:</p>
<pre>// Project: Dalek control system
// Version 0.1 - Written before my Arduino even arrived
// Tony Blews tony@tonyblews.co.uk

int MotorDirectionR = 10;
int MotorDirectionL = 11;
int MotorPowerR     = 12;
int MotorPowerL     = 13;

void setup()
{
 pinMode(MotorDirectionR, OUTPUT);
 pinMode(MotorDirectionL, OUTPUT);
 pinMode(MotorPowerR, OUTPUT);
 pinMode(MotorPowerL, OUTPUT);

 Serial.begin(9600);
 Serial.println("Serial control Dalek system starting...");

}

// modes for the motor control
// convention here is modeXX - where X is F for forward, S for stationary and B for backwards
// first X is the left motor, second X is the right one
// for direction control, the LOW if forward and HIGH is backward
// for power control, LOW is off and HIGH is on

// all stop
void modeSS()
{
 digitalWrite(MotorDirectionR, LOW);
 digitalWrite(MotorDirectionL, LOW);
 digitalWrite(MotorPowerR,LOW);
 digitalWrite(MotorPowerL,LOW);
}

// move straight ahead
void modeFF()
{
 digitalWrite(MotorDirectionR, LOW);
 digitalWrite(MotorDirectionL, LOW);
 digitalWrite(MotorPowerR,HIGH);
 digitalWrite(MotorPowerL,HIGH);
}

// move straight backwards
void modeBB()
{
 digitalWrite(MotorDirectionR, HIGH);
 digitalWrite(MotorDirectionL, HIGH);
 digitalWrite(MotorPowerR,HIGH);
 digitalWrite(MotorPowerL,HIGH);
}

// spin left
void modeBF()
{
 digitalWrite(MotorDirectionR, LOW);
 digitalWrite(MotorDirectionL, HIGH);
 digitalWrite(MotorPowerR,HIGH);
 digitalWrite(MotorPowerL,HIGH);
}

//spin right
void modeFB()
{
 digitalWrite(MotorDirectionR, HIGH);
 digitalWrite(MotorDirectionL, LOW);
 digitalWrite(MotorPowerR,HIGH);
 digitalWrite(MotorPowerL,HIGH);
}

// move forward left
void modeSF()
{
 digitalWrite(MotorDirectionR, LOW);
 digitalWrite(MotorDirectionL, LOW);
 digitalWrite(MotorPowerR,HIGH);
 digitalWrite(MotorPowerL,LOW);
}

// move forward right
void modeFS()
{
 digitalWrite(MotorDirectionR, LOW);
 digitalWrite(MotorDirectionL, LOW);
 digitalWrite(MotorPowerR,LOW);
 digitalWrite(MotorPowerL,HIGH);
}

// move backward left
void modeSB()
{
 digitalWrite(MotorDirectionR, HIGH);
 digitalWrite(MotorDirectionL, LOW);
 digitalWrite(MotorPowerR,HIGH);
 digitalWrite(MotorPowerL,LOW);
}

// move backward right
void modeBS()
{
 digitalWrite(MotorDirectionR, LOW);
 digitalWrite(MotorDirectionL, HIGH);
 digitalWrite(MotorPowerR,LOW);
 digitalWrite(MotorPowerL,HIGH);
}

//main program loop
void loop()
{
 if (Serial.available() &gt;0)
 {
 char inByte = Serial.read();
 // this version uses the QWEASDZXC "square" on the keyboard
 // as my laptop doesn't have a numeric keypad
 switch (inByte)
 {
 case 'q':
 modeSF();
 break;
 case 'w':
 modeFF();
 break;
 case 'e':
 modeFS();
 break;
 case 'a':
 modeBF();
 break;
 case 's':
 modeSS();
 break;
 case 'd':
 modeFB();
 break;
 case 'z':
 modeBS();
 break;
 case 'x':
 modeBB();
 break;
 case 'c':
 modeSB();
 break;
 default:
 modeSS();
 break;
 }
 }
}
</pre>
<p>And with that done, I suppose all that is left to do is show a video of the bottom bit of the dalek trundling around under computer control&#8230;</p>
<p>&#8230; which have to wait until the next post.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.tonyblews.co.uk/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.tonyblews.co.uk/2010/07/genesis-of-the-arduino-dalek/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UK Waterways Site Ranking</title>
		<link>http://www.tonyblews.co.uk/2009/01/uk-waterways-site-ranking/</link>
		<comments>http://www.tonyblews.co.uk/2009/01/uk-waterways-site-ranking/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 04:11:09 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Canals]]></category>
		<category><![CDATA[Programming Bits]]></category>

		<guid isPermaLink="false">http://www.tonyblews.co.uk/?p=294</guid>
		<description><![CDATA[Ah while ago, a Mr. Andrew Denny of Granny Buttons bemoaned the lack of a UK specific site ranking chart for canal and waterways related blogs. So, I made one which tracks hits via a little image button thing like this&#8230; &#8230; then formats the results into a nice table. Furthermore, it is located at [...]]]></description>
			<content:encoded><![CDATA[<p>Ah while ago, a Mr. Andrew Denny of <a href="http://www.grannybuttons.com/">Granny Buttons</a> bemoaned the lack of a UK specific site ranking chart for canal and waterways related blogs.</p>
<p style="text-align: center;">So, I made one which tracks hits via a little image button thing like this&#8230;<br />
<a href="http://www.coobeastie.co.uk/ranking/index.php?id=2"><img class="aligncenter" src="http://www.coobeastie.co.uk/ranking/button.php?id=2&amp;log=no" alt="" width="110" height="30" /></a>&#8230; then formats the results into a nice table.</p>
<p>Furthermore, it is located at <a href="http://www.coobeastie.co.uk/ranking/">http://www.coobeastie.co.uk/ranking/</a></p>
<p>Right then&#8230;. next project?</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.tonyblews.co.uk/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.tonyblews.co.uk/2009/01/uk-waterways-site-ranking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Psycho Fireman</title>
		<link>http://www.tonyblews.co.uk/2008/08/psycho-fireman/</link>
		<comments>http://www.tonyblews.co.uk/2008/08/psycho-fireman/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 01:49:32 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Programming Bits]]></category>
		<category><![CDATA[b3ta]]></category>
		<category><![CDATA[firemen]]></category>
		<category><![CDATA[rob manuel]]></category>

		<guid isPermaLink="false">http://tonyblews.co.uk/wordpress/?p=210</guid>
		<description><![CDATA[I couple of weeks ago I did some coding for Rob Manuel of b3ta fame, specifically the code to parse a wiki page and present the resulting data in a format usuable to a Flash application. Rob has used this to load in the levels to his &#8220;Psycho Fireman&#8221; game, a variation (blatant rip-off) of [...]]]></description>
			<content:encoded><![CDATA[<p>I couple of weeks ago I did some coding for <a href="http://www.robmanuel.com/">Rob        Manuel</a> of <a href="http://www.b3ta.com/">b3ta</a> fame, specifically        the code to parse a wiki page and present the resulting data in a format        usuable to a Flash application.</p>
<p>Rob has used this to load in the levels to his &#8220;<a href="http://www.b3ta.com/links/Wiki_puzzle_game">Psycho        Fireman</a>&#8221; game, a variation (blatant rip-off) of Sokoban.</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="333" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.robmanuel.com/psychofireman/psychofireman.swf" /><embed type="application/x-shockwave-flash" width="400" height="333" src="http://www.robmanuel.com/psychofireman/psychofireman.swf"></embed></object></p>
<p>Sadly, he suffered a terminal hard-drive crash shortly afterwards, so the game was never finished.<br />
All the game progress was documented <a href="http://www.e4.com/joystick/diary.html">here</a>.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.tonyblews.co.uk/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.tonyblews.co.uk/2008/08/psycho-fireman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stafford Forum Image Host</title>
		<link>http://www.tonyblews.co.uk/2007/08/stafford-forum-image-host/</link>
		<comments>http://www.tonyblews.co.uk/2007/08/stafford-forum-image-host/#comments</comments>
		<pubDate>Wed, 01 Aug 2007 08:03:10 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Programming Bits]]></category>
		<category><![CDATA[Stafford]]></category>

		<guid isPermaLink="false">http://www.tonyblews.co.uk/?p=296</guid>
		<description><![CDATA[Just a little note to announce that the image host and upload for Stafford Forum is finished. It lives at http://www.coobeastie.co.uk/staffordforumfiles/]]></description>
			<content:encoded><![CDATA[<p>Just a little note to announce that the image host and upload for <a href="http://www.staffordforum.com/">Stafford Forum</a> is finished.</p>
<p>It lives at <a href="http://www.coobeastie.co.uk/staffordforumfiles/">http://www.coobeastie.co.uk/staffordforumfiles/</a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.tonyblews.co.uk/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.tonyblews.co.uk/2007/08/stafford-forum-image-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
