<?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>Carl&#039;s Blog</title>
	<atom:link href="http://blog.carlellis.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.carlellis.co.uk</link>
	<description>Researcher. Mountaineer.</description>
	<lastBuildDate>Sun, 19 Feb 2012 16:20:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Big displays and tabletops &#8211; the wrong approach?</title>
		<link>http://blog.carlellis.co.uk/2012/02/big-displays/</link>
		<comments>http://blog.carlellis.co.uk/2012/02/big-displays/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 16:20:51 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[Academia]]></category>
		<category><![CDATA[billboards]]></category>
		<category><![CDATA[conjecture]]></category>
		<category><![CDATA[digital signage]]></category>
		<category><![CDATA[public displays]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[vision]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=293</guid>
		<description><![CDATA[The current model Current research trends are in favour of large public displays, hidden projectors, and table top displays &#8211; Microsoft&#8217;s Surface being a prominent example along with the many research projects involving public displays. A lot of these projects have options for multiple users operating the systems, in fact some are made only for [...]]]></description>
			<content:encoded><![CDATA[<h2>The current model</h2>
<p>Current research trends are in favour of large public displays, hidden projectors, and table top displays &#8211; Microsoft&#8217;s Surface being a prominent example along with the many research projects involving public displays.</p>
<p>A lot of these projects have options for multiple users operating the systems, in fact some are made only for collaboration in the workplace (Highwire&#8217;s <a href="http://highwire-dtc.com/coffeetable/" target="_blank">CoffeeTable</a>, and Intel&#8217;s <a href="http://www.youtube.com/watch?gl=GB&amp;v=GR2c2S3oGyI" target="_blank">What Do You Bring To the Table?</a>). However, when systems are in a public setting, the use becomes more of a public service than a means for collaboration and when the users are acting independently great efforts are made to determine identity and facilitate independent interaction and data presentation. <em></em></p>
<p><em>The classic example of this is where you walk up to a public display in a university and the display shows your time-table.</em></p>
<p>In the above scenario, what happens when a display is surrounded by more than one person &#8211; say 5 people. Does it show 5 individual timetables? If 50 people approach the display does it show 50 timetables? That is impractical, so what is a fair way to display a crowds worth of information to a waiting crowd? It could be shown one at a time, but then who gets to see theirs first, and more importantly how does one recognise your own timetable if you can&#8217;t remember it in the first place? Does your name have to appear with the time-table? Will public users be comfortable with this scenario? What authentication methods are used for systems such as these, do users need to opt in, will these questions have the same answers for different displays?</p>
<p>If we ignore other issues except authentication, how does the display know who you are to display the relevant information? Read a unique ID from your phone, a smart card, or some other wireless unique device? How does this deal with phones being sold, or smart cards being lost? What happens if someone of a criminal nature got hold of young student&#8217;s ID card and started stalking the student? Is there a line of how public information must be before it appears on a public display? Even if the display is not in a completely public setting, say it is behind the security check point in a company, who decides the amount of information which is displayed on a screen? The user, or the programmer in charge of the presentation software? If authentication is required before information is shown on a display, does this not ruin the workflow of the display &#8211; and would this not also stop frantic late users from approaching the system?</p>
<p>With privacy being a current issue within society, do not public displays get relegated to becoming glorified billboards with the only personal information they will be allowed to show will be that which could be found on the public page of a person? Will the only use of these systems be for when one has lost their phone, and the display is currently free?</p>
<p>Currently I believe the only use of these systems will be gained from location-based advertising &#8211; where content is changed based on the demographic of people around it and the time of day.</p>
<h2>A different model</h2>
<p>If we are looking into the future (a trait which many scientists are likely to do) there is another model which is what I believe public interacting displays should be tending towards.</p>
<p>By dissecting the mission of a public display it can be seen that it encompasses two functions.</p>
<ol>
<li>Being a dedicated geographical point for a certain type of information or request,</li>
<li>Having a method to display feedback to the user.</li>
</ol>
<p>If we look to the future and imagine a hypothetical piece of hardware exists, we can remove point 2 from the list of needed functions &#8211; and remove a lot of privacy issues.</p>
<p>We have this technology &#8211; albeit in a crude way &#8211; at the moment. A personal screen. Currently, this tend to be a smart phone/device of some sort. These tend to have authentication when they are switched on, via a pass code. They even support banking systems which &#8211; one would hope &#8211; worry about the security of the device in question.</p>
<p>The limitations of these devices are their size and resolution. A personal screen of 4 inches isn&#8217;t brilliant, so let us create a hypothetical product to facilitate this model. Imagine a pair of glasses which could project upon its lenses virtual displays at any arbitrary projection and geometry to simulate real life displays. They could even be simulated on static points in the real world, needing a user to be close to it for it to be used &#8211; as in real life. The simulated displays would be displaying what ever the public display wanted to &#8211; by virtue of its number 1 function: <em>being a dedicated geographical point for a certain type of information or request</em>.</p>
<p>Let&#8217;s go back to the 50 people in front of a timetable billboard. With their own personal screen they would be seeing just their timetable, in an almost completely private setting &#8211; while still being surrounded by 49 other people. In fact, if wireless communication density is sufficiently high, it could replace conventional screens on desks, on phones, all together. With regards to public billboards though, advertisers would be able to get what they have always wanted &#8211; a message directly to who they want it to go to.</p>
<p>This is of course all conjecture, but I think it should be where the domain should be heading.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2012/02/big-displays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Golf</title>
		<link>http://blog.carlellis.co.uk/2012/02/code-golf/</link>
		<comments>http://blog.carlellis.co.uk/2012/02/code-golf/#comments</comments>
		<pubDate>Thu, 09 Feb 2012 23:35:43 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[CSLU]]></category>
		<category><![CDATA[code golf]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=280</guid>
		<description><![CDATA[CSLU did code golf today. I did 1 and a half tasks, which were: Output the first 100 prime numbers Output e to 100 decimal places Prime numbers I&#8217;m quite proud of this, I managed to do this in 55 characters initially but then after some collaboration with the rest of the club shrunk it [...]]]></description>
			<content:encoded><![CDATA[<p>CSLU did code golf today. I did 1 and a half tasks, which were:</p>
<ol>
<li>Output the first 100 prime numbers</li>
<li>Output e to 100 decimal places</li>
</ol>
<h2>Prime numbers</h2>
<p>I&#8217;m quite proud of this, I managed to do this in 55 characters initially but then after some collaboration with the rest of the club shrunk it down to 49 characters</p>
<pre>2.upto(541){|a|i=2;i+=1 while a%i&gt;0;p a if i==a}</pre>
<h2></h2>
<h2>e</h2>
<p>I never got his fully working as I ended up getting caught up in list comprehensions. Ended up with:</p>
<pre>1 + sum [1 / (product [m | m &lt;- [1..n] ]) | n &lt;- [1..300] ]</pre>
<p>&nbsp;</p>
<p>Which is the same as <img src='http://s0.wp.com/latex.php?latex=e+%3D+%5Csum_%7Bn%3D0%7D%5E%7B%5Cinfty+%7D+%5Cfrac%7B1%7D%7Bn%21%7D&#038;bg=fff&#038;fg=1c1c1c&#038;s=0' alt='e = &#92;sum_{n=0}^{&#92;infty } &#92;frac{1}{n!}' title='e = &#92;sum_{n=0}^{&#92;infty } &#92;frac{1}{n!}' class='latex' /> and shows how pretty Haskell is.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2012/02/code-golf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby gem &#8211; json_serialisable</title>
		<link>http://blog.carlellis.co.uk/2012/02/ruby-gem-json_serialisable/</link>
		<comments>http://blog.carlellis.co.uk/2012/02/ruby-gem-json_serialisable/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 12:35:42 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[metaprogramming]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=269</guid>
		<description><![CDATA[I was working on a ruby project and stumbed upon my first valid application of metaprogramming. I was creating json serialisation methods and realised they were all practically identical. So I looked at how attr_accessor worked and then wrote my own class method called attr_serialisable. This method generated serialisation methods automatically. Example Given a class [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a ruby project and stumbed upon my first valid application of metaprogramming. I was creating json serialisation methods and realised they were all practically identical. So I looked at how <code>attr_accessor</code> worked and then wrote my own class method called <code>attr_serialisable</code>. This method generated serialisation methods automatically.</p>
<h2>Example</h2>
<p>Given a class <code>A</code></p>
<pre>class A
  attr_accessor :a, :b, :c
  attr_serialisable :a, :b, :c

  def initialize(a, b, c)
    @a, @b, @c = a, b, c
  end
end</pre>
<p>&nbsp;</p>
<p><code>attr_serialisable</code> would generate the following methods:<br />
<code></code></p>
<pre>  def to_json(*a)
    {
      "json_class"  =&gt;  self.class.name,
      "a"           =&gt;  @a,
      "b"           =&gt;  @b,
      "c"           =&gt;  @c
    }.to_json(*a)
  end

  def json_create(o)
    new(*o["a"], *o["b"], *o["c"])
  end</pre>
<p>&nbsp;</p>
<p>Which will allow the class to easily be used by the &#8216;json&#8217; library.</p>
<h2>Links</h2>
<p><a href="http://rubygems.org/gems/json_serialisable/">Rubygems page</a><br />
<a href="https://github.com/carl-ellis/json_serialisable">Source code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2012/02/ruby-gem-json_serialisable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino Gas Sensor &#8211; Part 2</title>
		<link>http://blog.carlellis.co.uk/2012/01/arduino-gas-sensor-part-2/</link>
		<comments>http://blog.carlellis.co.uk/2012/01/arduino-gas-sensor-part-2/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 15:17:40 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[Academia]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[gas meter]]></category>
		<category><![CDATA[phd]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=260</guid>
		<description><![CDATA[Previously So I left the last article with the following: Well apart from the hardware I need, so issues need to be addressed which may or may not require extra hardware – as I’ve just thought of them. DateTime equivalent object for when I register a pulse Work out how long these will last on [...]]]></description>
			<content:encoded><![CDATA[<h2>Previously</h2>
<p>So I left the last article with the following:</p>
<blockquote><p>Well apart from the hardware I need, so issues need to be addressed which may or may not require extra hardware – as I’ve just thought of them.</p>
<ul>
<li>DateTime equivalent object for when I register a pulse</li>
<li>Work out how long these will last on battery</li>
<li>Can I set an interrupt to go off when a digital value hits a threshold? Or does this require analogue input? If I can it would massively save on battery as no polling! But, it may require fiddly per-house calibration, which the brute force method ignores</li>
<li>Laser/3d Printed box and some form of mounting which will let me attach to anything. Probably going to be velcro</li>
</ul>
</blockquote>
<p>So I&#8217;ll go through what has been done since then via this criterea.</p>
<h2>Hardware Changes</h2>
<p>The DateTime object style thing was achieved through an RTC module (<a href="http://www.sparkfun.com/products/99">http://www.sparkfun.com/products/99</a>) which communicated to the &#8216;duino using the I2C bus and takes 5V. A microSD card shield was also added to the hardware for saving events into a simple text file (<a href="http://www.sparkfun.com/products/9802">http://www.sparkfun.com/products/9802</a>).</p>
<p>Rather than use my hastily build photosensor, I used a load of <a href="http://www.rfxcom.com/sensors.htm">RFXcom sensors</a> as they are well built and have a housing designed for sticking to the meter (Which is by far the biggest engineering challenge of this project). A board layout for interfacing with the sensor units was created and the gEDA/gSchem schematic file can be found on the <a href="https://github.com/carl-ellis/Arduino-Gas-Sensor">git hub project page</a>.</p>
<h2>Software Changes</h2>
<p>Well, apart from the stuff which interfaces with the RTC module and the microSD card, not much has changed code wise. The way the RFXcom modules work was backwards to my prototype, so I measured the time it takes to discharge a capacitor rather than charge. An LED on a meter normally flashes for .1s, so the timout is set to 0.05s.</p>
<h2>Battery Life</h2>
<p>Using a multimeter showed the whole sensor drew 92mA. It isn&#8217;t ideal, but with a 6 AA battery pack which packs ~3000mAH which lasts a bout a day ( <img src='http://blog.carlellis.co.uk/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  ) However,  that was with a ridiculously high powered infrared LED on the RFXcom board. Using just the photosensor (rather than the reflective) the power output was 42mA and that was with the SD card always powered. There is a lot of scope for battery life improvement on this project.</p>
<h2>Source</h2>
<p>The source can be found on my github page at <a href="https://github.com/carl-ellis/Arduino-Gas-Sensor">https://github.com/carl-ellis/Arduino-Gas-Sensor</a> .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2012/01/arduino-gas-sensor-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Having trouble updating WordPress if your server is running vsftp?</title>
		<link>http://blog.carlellis.co.uk/2012/01/having-trouble-updating-wordpress-if-your-server-is-running-vsftp/</link>
		<comments>http://blog.carlellis.co.uk/2012/01/having-trouble-updating-wordpress-if-your-server-is-running-vsftp/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 21:25:50 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[vsftpd]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=256</guid>
		<description><![CDATA[The latest update to vsftp has, in their own words: - Add stronger checks for the configuration error of running with a writeable root directory inside a chroot(). This may bite people who carelessly turned on chroot_local_user but such is life. This kind of makes it useless for a virtual user setup. A work around [...]]]></description>
			<content:encoded><![CDATA[<p>The latest update to vsftp has, in their own words:</p>
<blockquote><p>- Add stronger checks for the configuration error of running with a writeable<br />
root directory inside a chroot(). This may bite people who carelessly turned<br />
on chroot_local_user but such is life.</p></blockquote>
<p>This kind of makes it useless for a virtual user setup. A work around has been published at <a href="https://bbs.archlinux.org/viewtopic.php?pid=1038842#p1038842">https://bbs.archlinux.org/viewtopic.php?pid=1038842#p1038842</a> .</p>
<p>Essentially, if you set chroot_local_user=NO in /etc/vsftpd.conf it will solve the problem, but then you have the security issues of not having a chroot&#8217;d guest.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2012/01/having-trouble-updating-wordpress-if-your-server-is-running-vsftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fountain code challenge</title>
		<link>http://blog.carlellis.co.uk/2012/01/fountain-code-challenge/</link>
		<comments>http://blog.carlellis.co.uk/2012/01/fountain-code-challenge/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 21:21:22 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[CSLU]]></category>
		<category><![CDATA[cslu]]></category>
		<category><![CDATA[fountain]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=247</guid>
		<description><![CDATA[For the second term of the 2011/2012 academic year I&#8217;ve made a small challenge for members of CSLU. Details are found on the PDF. Good luck. P.S a bit of background reading can be found here. PDF: CSLU Lent Challenge]]></description>
			<content:encoded><![CDATA[<p>For the second term of the 2011/2012 academic year I&#8217;ve made a small challenge for members of CSLU.</p>
<p>Details are found on the PDF.</p>
<p>Good luck.</p>
<p>P.S a bit of background reading can be found <a href="http://blog.notdot.net/2012/01/Damn-Cool-Algorithms-Fountain-Codes">here</a>.</p>
<p><a href="http://blog.carlellis.co.uk/wp-content/uploads/2012/01/challenge.pdf">PDF: CSLU Lent Challenge</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2012/01/fountain-code-challenge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino Gas Meter Sensor &#8211; Part 1</title>
		<link>http://blog.carlellis.co.uk/2011/12/arduino-gas-meter-sensor-part-1/</link>
		<comments>http://blog.carlellis.co.uk/2011/12/arduino-gas-meter-sensor-part-1/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 17:37:50 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[Academia]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[ldr]]></category>
		<category><![CDATA[light]]></category>
		<category><![CDATA[sensor]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=236</guid>
		<description><![CDATA[Motivation My newly ordered Arduino Uno came in the post today so I got to start building with it! An upcoming sensing deployment needs a way of sensing gas usage, so I&#8217;m building a basic sensor to measure it. Luckily, most gas meters have an LED pulse which goes off every so often and we [...]]]></description>
			<content:encoded><![CDATA[<h2>Motivation</h2>
<p>My newly ordered Arduino Uno came in the post today so I got to start building with it!</p>
<p>An upcoming sensing deployment needs a way of sensing gas usage, so I&#8217;m building a basic sensor to measure it. Luckily, most gas meters have an LED pulse which goes off every so often and we can measure that. The one in my house informs me the light will pulse every 10 dm^3 of gas, so every time the second number from the right on the meter ticks the light will pulse. Failing this, the 0 on the right most dial is very reflective, and an LED can be used to reflect light from it.</p>
<p>As the extra bits I need to finish the sensor hasn&#8217;t come yet, namely the SD card shield and a battery pack, I can&#8217;t lock the sensor in my gas cupboard and give it a test, so for the time being I&#8217;m turning off my computer screens and lights, then flashing a red head torch at it to simulate a pulse.</p>
<h2>Code</h2>
<p>After a bit of internet trawling, I found an ace site laying down how to do the wiring for a digital light sensor (<a href="http://www.ladyada.net/learn/sensors/cds.html#bonus_reading_photocells_without_analog_pins" target="_blank">http://www.ladyada.net/learn/sensors/cds.html#bonus_reading_photocells_without_analog_pins</a>). From that, I added in a method which took a rolling average of the last 5 measurements and outputted if the measured light was brighter than 110% of the average (not exactly statistical, but I intend for these to be locked in a dark box&#8230;).</p>
<p>Here&#8217;s what I have so far:</p>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><span style="color: #7e7e7e;">/* Based on: Photocell simple testing sketch. </span>
<span style="color: #7e7e7e;">Connect one end of photocell to power, the other end to pin 2.</span>
<span style="color: #7e7e7e;">Then connect one end of a 0.1uF capacitor from pin 2 to ground </span>
<span style="color: #7e7e7e;">For more information see www.ladyada.net/learn/sensors/cds.html */</span>

<span style="color: #7e7e7e;">// Number of measurements for averaging</span>
const <span style="color: #cc6600;">int</span> AVERAGE_LENGTH = 5;

<span style="color: #cc6600;">int</span> photocellPin = 2;     <span style="color: #7e7e7e;">// the LDR and cap are connected to pin2</span>
<span style="color: #cc6600;">int</span> photocellReading;     <span style="color: #7e7e7e;">// the digital reading</span>
<span style="color: #cc6600;">int</span> ledPin = 13;    <span style="color: #7e7e7e;">// you can just use the 'built in' LED</span>

<span style="color: #7e7e7e;">// for the circular buffer</span>
<span style="color: #cc6600;">int</span> lastReadings[AVERAGE_LENGTH];
<span style="color: #cc6600;">int</span> average = 0;
<span style="color: #cc6600;">int</span> counter = 0;

<span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><strong>setup</strong></span>(<span style="color: #cc6600;">void</span>) {
  <span style="color: #7e7e7e;">// We'll send debugging information via the Serial monitor</span>
  <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">begin</span>(9600);

  <span style="color: #7e7e7e;">// Initialise the array </span>
  <span style="color: #cc6600;">for</span>(<span style="color: #cc6600;">int</span> i=0;i&lt;AVERAGE_LENGTH;i++) {
    lastReadings[i] = 0;
  }   
}

<span style="color: #cc6600;">void</span> <span style="color: #cc6600;"><strong>loop</strong></span>(<span style="color: #cc6600;">void</span>) {
  <span style="color: #7e7e7e;">// read the resistor using the RCtime technique</span>
  photocellReading = RCtime(photocellPin);

  <span style="color: #7e7e7e;">// Calculate rolling average</span>
  ++counter %= AVERAGE_LENGTH;
  lastReadings[counter] = photocellReading;
  calcStats();
  <span style="color: #cc6600;">int</span> bound = average - (average/10);

  <span style="color: #7e7e7e;">// Glorious debug</span>
  <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">"Av = "</span>);
  <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">print</span>(average);
  <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">" = ["</span>);
  <span style="color: #cc6600;">for</span>(<span style="color: #cc6600;">int</span> i=0; i&lt;AVERAGE_LENGTH;i++) {
    <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">print</span>(lastReadings[i]);
    <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">","</span>);
  }
  <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">"] "</span>);
  <span style="color: #cc6600;">if</span> (photocellReading &lt; bound) {
    <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">print</span>(<span style="color: #006699;">" . RCtime reading = "</span>);
    <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">println</span>(photocellReading);     <span style="color: #7e7e7e;">// the raw analog reading</span>
  } <span style="color: #cc6600;">else</span> {
    <span style="color: #cc6600;"><strong>Serial</strong></span>.<span style="color: #cc6600;">println</span>();
  }

  <span style="color: #cc6600;">delay</span>(100);
}

<span style="color: #7e7e7e;">// Calculates the new mean based on the last 20 measurements </span>
<span style="color: #cc6600;">int</span> calcStats() {

  <span style="color: #7e7e7e;">// average</span>
  average = 0;
  <span style="color: #cc6600;">for</span>(<span style="color: #cc6600;">int</span> i=0;i&lt;AVERAGE_LENGTH;i++) {
    average += lastReadings[i];
  }
  average /= AVERAGE_LENGTH;
}

<span style="color: #7e7e7e;">// Uses a digital pin to measure a resistor (like an FSR or photocell!)</span>
<span style="color: #7e7e7e;">// We do this by having the resistor feed current into a capacitor and</span>
<span style="color: #7e7e7e;">// counting how long it takes to get to Vcc/2 (for most arduinos, thats 2.5V)</span>
<span style="color: #cc6600;">int</span> RCtime(<span style="color: #cc6600;">int</span> RCpin) {
  <span style="color: #cc6600;">int</span> reading = 0;  <span style="color: #7e7e7e;">// start with 0</span>

  <span style="color: #7e7e7e;">// set the pin to an output and pull to LOW (ground)</span>
  <span style="color: #cc6600;">pinMode</span>(RCpin, <span style="color: #006699;">OUTPUT</span>);
  <span style="color: #cc6600;">digitalWrite</span>(RCpin, <span style="color: #006699;">LOW</span>);

  <span style="color: #7e7e7e;">// Now set the pin to an input and...</span>
  <span style="color: #cc6600;">pinMode</span>(RCpin, <span style="color: #006699;">INPUT</span>);
  <span style="color: #cc6600;">while</span> (<span style="color: #cc6600;">digitalRead</span>(RCpin) == <span style="color: #006699;">LOW</span>) { <span style="color: #7e7e7e;">// count how long it takes to rise up to HIGH</span>
    reading++;      <span style="color: #7e7e7e;">// increment to keep track of time </span>

    <span style="color: #cc6600;">if</span> (reading == 30000) {
      <span style="color: #7e7e7e;">// if we got this far, the resistance is so high</span>
      <span style="color: #7e7e7e;">// its likely that nothing is connected! </span>
      <span style="color: #cc6600;">break</span>;           <span style="color: #7e7e7e;">// leave the loop</span>
    }
  }
  <span style="color: #7e7e7e;">// OK either we maxed out at 30000 or hopefully got a reading, return the count</span>

  <span style="color: #cc6600;">return</span> reading;
}</pre>
<h2>Next Steps</h2>
<p>Well apart from the hardware I need, so issues need to be addressed which may or may not require extra hardware &#8211; as I&#8217;ve just thought of them.</p>
<ul>
<li>DateTime equivalent object for when I register a pulse</li>
<li>Work out how long these will last on battery</li>
<li>Can I set an interrupt to go off when a digital value hits a threshold? Or does this require analogue input? If I can it would massively save on battery as no polling! But, it may require fiddly per-house calibration, which the brute force method ignores</li>
<li>Laser/3d Printed box and some form of mounting which will let me attach to anything. Probably going to be velcro.</li>
</ul>

<a href='http://blog.carlellis.co.uk/2011/12/arduino-gas-meter-sensor-part-1/duino/' title='duino'><img width="150" height="112" src="http://blog.carlellis.co.uk/wp-content/uploads/2011/12/duino.jpg" class="attachment-thumbnail" alt="duino" title="duino" /></a>
<a href='http://blog.carlellis.co.uk/2011/12/arduino-gas-meter-sensor-part-1/meter/' title='meter'><img width="150" height="112" src="http://blog.carlellis.co.uk/wp-content/uploads/2011/12/meter.jpg" class="attachment-thumbnail" alt="meter" title="meter" /></a>
<a href='http://blog.carlellis.co.uk/2011/12/arduino-gas-meter-sensor-part-1/serial-out/' title='Serial out'><img width="150" height="145" src="http://blog.carlellis.co.uk/wp-content/uploads/2011/12/Serial-out.png" class="attachment-thumbnail" alt="Serial out" title="Serial out" /></a>

<p>Here&#8217;s a video of it working:<br />
<iframe src="http://www.youtube.com/embed/F8zYlIB4oG8" frameborder="0" width="420" height="315"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2011/12/arduino-gas-meter-sensor-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSXGraph</title>
		<link>http://blog.carlellis.co.uk/2011/12/graph-test/</link>
		<comments>http://blog.carlellis.co.uk/2011/12/graph-test/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 18:30:00 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jsxgraph]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=154</guid>
		<description><![CDATA[I found this cool graphing JS library which has a wordpress plugin! It&#8217;s called JSXGraph and is rather nifty!. Here is an example graphs showing Facebook users over time. Here&#8217;s the code: &#60;jsxgraph width="600" height="200" box="box"&#62; var brd = JXG.JSXGraph.initBoard('box', {boundingbox: [-50, 900, 3000, -150], keepaspectratio:true, axis:true, grid:0, showNavigation:false}); brd.suspendUpdate(); //Points for graph var p [...]]]></description>
			<content:encoded><![CDATA[<p>I found this cool graphing JS library which has a wordpress plugin! It&#8217;s called <a href="http://jsxgraph.uni-bayreuth.de/wp/">JSXGraph</a> and is rather nifty!. Here is an example graphs showing Facebook users over time.</p>
<pre><div id='box' class='jxgbox' style='width:600px; height:200px;'></div><script type='text/javascript'>
var brd = JXG.JSXGraph.initBoard('box',
            {boundingbox: [-50, 900, 3000, -150],
             keepaspectratio:true,
             axis:true,
             grid:0,
             showNavigation:false});

brd.suspendUpdate();

//Points for graph
var p = [];
  p[0] = brd.create('point', [0,0], {style:6,name:""});
  p[1] = brd.create('point', [1665,100], {style:6,name:"100"});
  p[2] = brd.create('point', [1890,200], {style:6,name:"200"});
  p[3] = brd.create('point', [2050,300], {style:6,name:"300"});
  p[4] = brd.create('point', [2193,400], {style:6,name:"400"});
  p[5] = brd.create('point', [2359,500], {style:6,name:"500"});
  p[6] = brd.create('point', [2527,600], {style:6,name:"600"});
  p[7] = brd.create('point', [2672,700], {style:6,name:"700"});
  p[8] = brd.create('point', [2787,800], {style:6,name:"800"});

//Line
var graph = brd.create('curve',
              brd.neville(p),
              {strokeColor:'red',
               strokeWidth:5,
               strokeOpacity:0.5});

//Labels
xtxt = brd.create('text',[1400,-110, 'Days Online'], {fontSize:12});
ytxt = brd.create('text',[10,850, 'Millions of users'], {fontSize:12});

brd.unsuspendUpdate();
</script></pre>
<p>Here&#8217;s the code:</p>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
&lt;jsxgraph width="600" height="200" box="box"&gt;
var brd = JXG.JSXGraph.initBoard('box',
            {boundingbox: [-50, 900, 3000, -150],
             keepaspectratio:true,
             axis:true,
             grid:0,
             showNavigation:false});

brd.suspendUpdate();

//Points for graph
var p = [];
  p[0] = brd.create('point', [0,0], {style:6,name:""});
  p[1] = brd.create('point', [1665,100], {style:6,name:"100"});
  p[2] = brd.create('point', [1890,200], {style:6,name:"200"});
  p[3] = brd.create('point', [2050,300], {style:6,name:"300"});
  p[4] = brd.create('point', [2193,400], {style:6,name:"400"});
  p[5] = brd.create('point', [2359,500], {style:6,name:"500"});
  p[6] = brd.create('point', [2527,600], {style:6,name:"600"});
  p[7] = brd.create('point', [2672,700], {style:6,name:"700"});
  p[8] = brd.create('point', [2787,800], {style:6,name:"800"});

//Line
var graph = brd.create('curve',
              brd.neville(p),
              {strokeColor:'red',
               strokeWidth:5,
               strokeOpacity:0.5});

//Labels
xtxt = brd.create('text',[1400,-110, 'Days Online'], {fontSize:12});
ytxt = brd.create('text',[10,850, 'Millions of users'], {fontSize:12});

brd.unsuspendUpdate();
&lt;/jsxgraph&gt;
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2011/12/graph-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming languages course</title>
		<link>http://blog.carlellis.co.uk/2011/12/programming-languages-course/</link>
		<comments>http://blog.carlellis.co.uk/2011/12/programming-languages-course/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 18:12:39 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[CSLU]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[cslu]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[talk]]></category>
		<category><![CDATA[tryruby]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=136</guid>
		<description><![CDATA[So I ran a talk on learning programming languages last week. It was the second time I had done that particular talk, and in this case the hardware setup went smoothly &#8211; as it was done by Stephen Wattam the CSLU VP. We had a pretty good turn out, mostly of year year undergraduate students [...]]]></description>
			<content:encoded><![CDATA[<p>So I ran a talk on learning programming languages last week. It was the second time I had done that particular talk, and in this case the hardware setup went smoothly &#8211; as it was done by <a href="http://stephenwattam.co.uk/" target="_blank">Stephen Wattam</a> the CSLU VP.</p>
<p>We had a pretty good turn out, mostly of year year undergraduate students who so far had only played with a little C. I took pictures of everyone hard at work doing their task &#8230; well, ok. They were mostly on <a href="http://tryruby.org/" target="_blank">tryruby.org</a> which was even <strong>better</strong>.</p>
<p>It showed that they had an interest in a new language which is fairly good at prototyping and will allow them to try out their ideas fast. I may have semi pushed them on to it in my talk, so I&#8217;m glad they were listening. No one tried learning Haskell though, but then I&#8217;ll drop in on everyone next term and see how they are doing. The slides and some info for my talk can be found  at the <a href="http://www.cslu.co.uk/2011/01/08/week-8-languages-talk/" target="_blank">CSLU site</a>.</p>
<p style="text-align: left;">On a side note &#8230; My Instagram tshirt came! I&#8217;m not sure if I&#8217;ll ever wear it outside as it&#8217;s a bit long, but still!</p>

<a href='http://blog.carlellis.co.uk/2011/12/programming-languages-course/img_1347/' title='lang1'><img width="150" height="112" src="http://blog.carlellis.co.uk/wp-content/uploads/2011/12/IMG_1347.jpg" class="attachment-thumbnail" alt="lang1" title="lang1" /></a>
<a href='http://blog.carlellis.co.uk/2011/12/programming-languages-course/img_1346/' title='lang2'><img width="150" height="112" src="http://blog.carlellis.co.uk/wp-content/uploads/2011/12/IMG_1346.jpg" class="attachment-thumbnail" alt="lang2" title="lang2" /></a>
<a href='http://blog.carlellis.co.uk/2011/12/programming-languages-course/img_1344/' title='lang3'><img width="150" height="112" src="http://blog.carlellis.co.uk/wp-content/uploads/2011/12/IMG_1344.jpg" class="attachment-thumbnail" alt="lang3" title="lang3" /></a>
<a href='http://blog.carlellis.co.uk/2011/12/programming-languages-course/img_1348/' title='instatshirt'><img width="150" height="112" src="http://blog.carlellis.co.uk/wp-content/uploads/2011/12/IMG_1348.jpg" class="attachment-thumbnail" alt="instatshirt" title="instatshirt" /></a>

]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2011/12/programming-languages-course/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rain &#8211; Agent-based water</title>
		<link>http://blog.carlellis.co.uk/2011/08/rain-agent-based-water/</link>
		<comments>http://blog.carlellis.co.uk/2011/08/rain-agent-based-water/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 22:22:03 +0000</pubDate>
		<dc:creator>carl</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[agent]]></category>
		<category><![CDATA[gosu]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[texplay]]></category>

		<guid isPermaLink="false">http://blog.carlellis.co.uk/?p=124</guid>
		<description><![CDATA[Well I&#8217;ve been wanting to do this for a while now, and on Sunday with a freshly installed (and therefore speedy) net book under my belt, I thought I&#8217;d have a crack at it. Last year (maybe even 2 years now) ago, I made a weak plasmoid generator with the intention of using it for [...]]]></description>
			<content:encoded><![CDATA[<p>Well I&#8217;ve been wanting to do this for a while now, and on Sunday with a freshly installed (and therefore speedy) net book under my belt, I thought I&#8217;d have a crack at it.</p>
<p>Last year (maybe even 2 years now) ago, I made a <a href="https://github.com/carl-ellis/Weak-Plasmoid-Generator" target="_blank">weak plasmoid generator </a>with the intention of using it for terrain generation. I&#8217;ve always wanted to use that library for some agent based programming, and a simple (rule wise) example of it would be water. You put some water agents on the map they move as low as they can go, then evaporate. This kind of does that, and definitely suffers from &#8220;proof of concept&#8221; syndrome. Water moves, but to do anything fancy will require redoing, which I&#8217;ll probably end up doing on my next free Sunday.</p>
<p>So,  using a library called <a href="https://github.com/jlnr/gosu/">Gosu</a> to handle the drawing and the event loop, and a library called <a href="https://github.com/banister/texplay">TexPlay</a> which allowed me to modify pixels, I got a render up and running which displayed a map of tiles (1 pixel tile <img src='http://blog.carlellis.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ), and the colour was defined with a lambda that was passed to all of them.</p>
<p>As I&#8217;m learning Haskell at the moment, I thought I&#8217;d give some lambdas a go, and it made it really easy actually.</p>
<p>There are two types of agents in this program,  Rain and Sources.</p>
<ul>
<li>Rain just flows to a low point.</li>
<li>Sources make Rains.</li>
</ul>
<p>Rains become sources if they hit a low point, which basically has the effect of stacking the Rains that have pooled there so they can make lakes. As Rains are destroyed when they stop, and Sources can only produce a finite amount of Rains based on how many are there when it is made, the system sort of stays constant. Initial sources are given enough Rains to cover the whole map 1 deep.</p>
<p>That is awkward to explain.</p>
<p>Most of the issues with this program was making the renderer fast enough to work on a net book, and as I&#8217;m not a graphics man, I made many rooky mistakes.</p>
<p>This is fairly mesmirizing to watch, and I&#8217;ll definitely improve it further, by:</p>
<ul>
<li>Making the map colouring sample from colour-&gt;height table</li>
<li>Have water level as a tile attribute to make things cleaner</li>
<li>Fix evaporation</li>
<li>Make it so that tiles which have a constant flow of agents over them are distinguished from one-off &#8220;rain&#8221; paths</li>
<li>Fix Rain</li>
</ul>
<p>It&#8217;s a project, feel free to fork from git hub here at <a href="https://github.com/carl-ellis/Rain" target="_blank">https://github.com/carl-ellis/Rain</a></p>
<p>&nbsp;</p>
<p>Old school screen capture.</p>
<p>Video here:  <a href="http://www.youtube.com/watch?v=BIqRy3wtdBk">Rain &#8211; agent-based</a></p>
<p>&nbsp;</p>
<p><iframe src="http://www.youtube.com/embed/BIqRy3wtdBk" frameborder="0" width="425" height="349"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.carlellis.co.uk/2011/08/rain-agent-based-water/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

