<?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>Håkon Nessjøen &#187; hobby</title>
	<atom:link href="http://lunatic.no/category/hobby/feed/" rel="self" type="application/rss+xml" />
	<link>http://lunatic.no</link>
	<description>Just another life hacker</description>
	<lastBuildDate>Tue, 29 Jun 2010 17:50:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Programming in Akelos</title>
		<link>http://lunatic.no/2010/01/programming-in-akelos/</link>
		<comments>http://lunatic.no/2010/01/programming-in-akelos/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 16:31:41 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[hobby]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://lunatic.no/?p=81</guid>
		<description><![CDATA[For some while I have been using the Akelos library for MVC development within PHP. The reason I like this library over other well-known libraries like Zend Framework, CakePHP etc, is that this library is very much coded with &#8220;Convension over configuration&#8221; which means that you don&#8217;t have to over-configure everything. And it&#8217;s easy to [...]]]></description>
			<content:encoded><![CDATA[<p>For some while I have been using the <a href="http://akelos.org/" target="_blank">Akelos</a> library for <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" target="_blank">MVC</a> development within PHP. The reason I like this library over other well-known libraries like <a href="http://framework.zend.com/" target="_blank">Zend Framework</a>, <a href="http://cakephp.org/" target="_blank">CakePHP</a> etc, is that this library is very much coded with &#8220;Convension over configuration&#8221; which means that you don&#8217;t have to over-configure everything. And it&#8217;s easy to learn new people how to use it.<span id="more-81"></span></p>
<p>For example, when you create a database, you fill inn the fields you like, in a &#8216;installer&#8217;. Each time you need to add fields, you add new up() revisions in the installer, so versioning systems like SVN or git can see that &#8220;in revision x, a new fields was added to the sql table&#8221;. This means that the versioning system can keep track of the database as well as the files.</p>
<p>Something I also love about Akelos is the ease of translation. In the Views you can write so called &#8220;sintags&#8221;. Which is basically the template language in Akelos. To write out the contents of a variable, you write {variable name} if you write text that needs translating, you write _{translate this text}. Thats variables and simple translations. Then you have functions, like a form:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= form_tag <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'myid'</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span>= text_field <span style="color:#996600;">'blog'</span>, <span style="color:#996600;">'name'</span>, <span style="color:#ff3333; font-weight:bold;">:class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'myclass'</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
&lt;/form&gt;</pre></div></div>

<p>Now I wanted to be able to translate inside function tags, so I made a little <a href="http://trac.akelos.org/ticket/229#comment:2" target="_blank">adjustment</a> to the Akelos source which made it possible to do:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> <span style="color:#006600; font-weight:bold;">&lt;%</span>= link_to _<span style="color:#996600;">'translated text'</span>, <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'about'</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
    or
 <span style="color:#006600; font-weight:bold;">&lt;%</span>= something <span style="color:#996600;">'name'</span>, <span style="color:#ff3333; font-weight:bold;">:vals</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#996600;">'plain text'</span>, _<span style="color:#996600;">'translated text'</span>, _<span style="color:#996600;">'translated text with %variable'</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>Here you also see that translated text also can contain variables from the view scope, which is pretty nifty in regards to dynamic translating. This &#8220;adjustment&#8221; was added to trunk in October 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2010/01/programming-in-akelos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Perl based Icecast clone</title>
		<link>http://lunatic.no/2010/01/simple-perl-based-icecast-clone/</link>
		<comments>http://lunatic.no/2010/01/simple-perl-based-icecast-clone/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 00:23:08 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[hobby]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://lunatic.no/?p=69</guid>
		<description><![CDATA[This is acctually a mini project I did a while ago, but I thought I could write a small post about it here, and give out the source code.
The reason I did this, was because I used icecast, and had 5 streams up with a lot of users, but sometimes you would get sound from [...]]]></description>
			<content:encoded><![CDATA[<p>This is acctually a mini project I did a while ago, but I thought I could write a small post about it here, and give out the source code.</p>
<p>The reason I did this, was because I used icecast, and had 5 streams up with a lot of users, but sometimes you would get sound from other streams on the same server, or old sound in the middle of the stream. I tried googling after other people with the same problems as me. But found nothing. So I thought; it&#8217;s quite simple software, how hard can it be to make a stable myself?</p>
<p>So first I made a proof-of-concept perl script to receive data, and send out to several listeners. Worked great at first try. Only a minior problems. If I paused the stream on one client, the whole server started waiting for that one listener, before sending any more data to all the other listeners. (more about this later) The other problem was that I didn&#8217;t have any in-stream &#8220;title&#8221; support.</p>
<p>The reason the stream stopped when one of the clients stopped listening for data (and blocked further data), is that I was sending data with a blocking socket. Now I tried googling about how to _send_ nonblocking, but coulnd&#8217;t find anything. So I made my own little workaround. (someone please give me a better solution)</p>
<p>Instead of:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">syswrite</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>I wrote a new send subroutine using IO::Select to check if the client is ready for data:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #000066;">send</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$self</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sock</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$self</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'sock'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$select</span> <span style="color: #339933;">=</span> IO<span style="color: #339933;">::</span><span style="color: #006600;">Select</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$select</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$sock</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$select</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">can_write</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">return</span> <span style="color: #0000ff;">$sock</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">syswrite</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This finally did the work for me. The &#8220;send()&#8221; subroutine now returns how many bytes it sent to the client, and if it couldn&#8217;t send any, then it returns zero of course.</p>
<p>Then over to the problem of sending title updates inside the stream. I googled this and found a nice informative page about <a href="http://www.smackfu.com/stuff/programming/shoutcast.html" target="_blank">Shoutcast MetaData</a>.  To bring it into a short explanation; if the client supports shoutcast metadata, it sends the following request header &#8220;<code>Icy-MetaData:1</code>&#8221; to inform the server that it knows about metadata. Then the server, my script, sends &#8220;icy-metaint: 123&#8243; back in the response header, where &#8220;123&#8243; is the amount of mp3 bytes before a metadata string should arrive. After exactly 123 (or whatever the server decides) bytes, the server sends a byte containing information about how long the metadata block is, and then the metadata right after. The &#8220;length byte&#8221; must be multiplied by 16 to get the real length of the metadata string. So the largest metadata string possible would be 4096 bytes long. Just after the metadata, the mp3 data continues as usual. Usually you won&#8217;t send the title data each time the metaint-counter goes around. You&#8217;re probably good by sending zero length metadata (just sending a &#8216;\0&#8242; byte as metadata-length) all the time, until the title actually changes.</p>
<p>So at this time I rewrote the script, and mode it more module based, and added support for several streams, and yaml configuration file for access control, and some status pages, using <a href="http://template-toolkit.org/" target="_blank">TemplateToolkit</a>.</p>
<p>So anyways, the script is still in early beta stage, but it should work fluently. It did however seem that the title-data got out of sync after about a day of listening to a stream, until you reconnected. Can&#8217;t seem to understand how it would get out of sync, unless a malformed tcp packet would arrive. So either I was testing it with a really crappy internet connection that time, or there is a bug berried deep in the simple code. You are free to have fun with the script, and tell me whats wrong. I also think it&#8217;s still full of debug printing. But I have already warned you, this is still in the proof of concept &#8220;whack-some-shit-together&#8221; stage. I&#8217;ts just one of those projects that ends up collecting dust.</p>
<p>If you fire the script up, and go to http://127.0.0.1:8001/ it should give you a list of the current connected streams. Also http://127.0.0.1:8001/xml should give you xml output of current streams. I&#8217;ve been using oddcast to send icecast stream to it.</p>
<p>Here&#8217;s the full script: <a href="http://lunatic.no/wp-content/uploads/2010/01/perlcast.tar.gz">perlcast.tar</a></p>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2010/01/simple-perl-based-icecast-clone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Big timecode display</title>
		<link>http://lunatic.no/2009/10/big-timecode-display-2/</link>
		<comments>http://lunatic.no/2009/10/big-timecode-display-2/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 23:18:49 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[electronics]]></category>
		<category><![CDATA[hobby]]></category>
		<category><![CDATA[jackd]]></category>
		<category><![CDATA[pic]]></category>
		<category><![CDATA[timecode]]></category>

		<guid isPermaLink="false">urn:myopera-lunatic-blog-4383464</guid>
		<description><![CDATA[So, in the last blog entry I told you about the perl DMX backend that we are doing for the party project of ours.We have concluded that we will have a bitchin&#8217; intro show. And it will be timecode controlled. Every little audio / DMX / Video effect will be timed to the millisecond.To do [...]]]></description>
			<content:encoded><![CDATA[<p>So, in the last blog entry I told you about the perl DMX backend that we are doing for the party project of ours.<br/><br/>We have concluded that we will have a bitchin&#8217; intro show. And it will be timecode controlled. Every little audio / DMX / Video effect will be timed to the millisecond.<br/><br/>To do this, we have (for now) concluded that we will use Ardour as the audio platform, and use jackd as the timecode server.<br/><br/>The nice part about this, is that it&#8217;s very easy to code a jack client that fetches the timecode in realtime, and then transmit it via UDP to our external timecode display. And thats where this blog post comes in place; we are creating a cool 8 digit 7-segment display to display our timecode.<br/><br/><span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/bilde%284%29.jpg' /></span><br/>William got 8 of these modules from Kay, who agian bought them for almost nothing at eBay. :D (in Norway they cost about $25 each at the time of writing)<br/><br/>Anyways. As you see in the picture, william has glued the 8 digits together, wich we will put inside a box, and wire up with some pic18f4520 and some ENC28J60 for ethernet connectivity. Yes, the module will be stand-alone, only connected to ethernet, and display the current timestamp/timecode in Ardour/our DMX system.<br/><br/>Do we _really_ need it? no. Is it really cool? yes.<br/><br/>So, so far we have finally gotten the box for the device. It&#8217;s acctually a image frame, with an exceptionally deep frame on the backside to contain the whole shebang.<br/><br/>Here are some more &#8220;under construction&#8221; photos:<br/><span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/28092009056.jpg' /></span> <span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/28092009053.jpg' /></span><br/><br/>In the first photo you can (almost) see the PIC18F4520 on a vero board, with a connected prototype board with the ENC28J60 chip, which works perfectly and successfully outputs data to the (soon to be connected) displays when it receives timecode UDP data on port 1337 ;P<br/><br/>This project has not been the easiest, even though the concept is simple. I&#8217;m not the greatest engineer in regards to analog electronics. The problem is that the 7segment displays needs 7.2v, and uses common anode. This means that I cannot use the displays directly from the PIC processor. So i went on using a ULN2803A to drive the display. This solves the &#8220;common anode&#8221; problem. Now on to solving the 7.2v problem. I have as I said, not very much to say in the analog electronics world. So I went on, and found the first PNP transistor I could find. Kay was kind enough to donate them to us.<br/><br/>He had a bunch of 2N3906 transistors, wich seemed to be &#8220;workable&#8221;. So i set them up on a breadboard and after some fidling with resistors and pulling up the signal, to let the PIC pull it down, to enable the flow trough collector and emitter. This seemed to work great, so I soldered the whole shebang together.<br/><br/>Everything works great now, except that the display &#8220;fluctuates&#8221;. Seems like either the 5v regulator is too weak (it gets pretty hot, but I can&#8217;t check it, because my multimeter doesn&#8217;t want to measure current), or the transistors are a bit too sensitive. Sometimes, when there is traffic on the network the display fluctuates when the ethernet-leds light up. So something is not at it&#8217;s fully potential yet. But I&#8217;ll measure a bit when I get a working multimeter.<br/><br/>So here are the latest images(only thing missing is the 4 dots at the bottom):<br/><span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/bilde%286%29.jpg' /></span> <span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/bilde%287%29.jpg' /></span></p>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2009/10/big-timecode-display-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DMX system in perl</title>
		<link>http://lunatic.no/2009/08/dmx-system-in-perl-2/</link>
		<comments>http://lunatic.no/2009/08/dmx-system-in-perl-2/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 13:25:57 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[dmx]]></category>
		<category><![CDATA[hobby]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">urn:myopera-lunatic-blog-4226181</guid>
		<description><![CDATA[William and me are starting to prepare for the next Exploit party, and this year we have decided to control all the lightning and video equiptment by perl.
We started for two days ago. William has a ENTTEC USB Pro which is fine for interfacing. In Linux, it is recognized as a standard COM port, and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://williamviker.net/" target="_blank">William</a> and me are starting to prepare for the next Exploit party, and this year we have decided to control all the lightning and video equiptment by perl.</p>
<p>We started for two days ago. William has a <a href="http://www.enttec.com/index.php?main_menu=Products&amp;prod=70304&amp;show=description" target="_blank">ENTTEC USB Pro</a> which is fine for interfacing. In Linux, it is recognized as a standard COM port, and the API consists of sending characters to the virtual COM port.</p>
<p>So as an example of how easy it is to send DMX with this device from perl, I&#8217;ll give an example below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #000000; font-weight: bold;">use</span> Device<span style="color: #339933;">::</span><span style="color: #006600;">SerialPort</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Time<span style="color: #339933;">::</span><span style="color: #006600;">HiRes</span> <span style="color: #009966; font-style: italic;">qw/usleep/</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$PORT</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'/dev/ttyUSB0'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ob</span> <span style="color: #339933;">=</span> Device<span style="color: #339933;">::</span><span style="color: #006600;">SerialPort</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>new<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$PORT</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Can't Open $PORT: $!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$packet</span> <span style="color: #339933;">=</span> <span style="color: #000066;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">128</span><span style="color: #009900;">&#41;</span> x <span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$length</span> <span style="color: #339933;">=</span> <span style="color: #000066;">length</span> <span style="color: #0000ff;">$packet</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$write</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ob</span><span style="color: #339933;">-</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span>write<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>7E<span style="color: #000099; font-weight: bold;">\x</span>06&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000066;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$length</span> <span style="color: #0000ff;">&amp;amp</span><span style="color: #339933;">;</span> 0xFF<span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000066;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$length</span> <span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #0000ff;">&amp;amp</span><span style="color: #339933;">;</span> 0xFF<span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">$packet</span> <span style="color: #339933;">.</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>E7&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Wrote $write bytes to DMX controller<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This little script will send 30 channels of value 128 to the DMX controller, which will keep repeating this information, until it gets new information.</p>
<p>To clarify, the first byte 0&#215;7E is the start byte for the enttec api. The next byte 0&#215;06 is the function we are using, which is DMX OUT. Then there is two bytes of length information, describing how many channels we are going to send. And then the package is sent. It&#8217;s important to remember to send a 0&#215;00 byte as the first channel, since this is the start byte of the actual DMX data. (also called the SC in the DMX standard specification)</p>
<p>We needed a central area to save our current channel data, and william found a nice perl module called Cache::FastMmap which uses mmap to save data. This way we can have several scripts using the same memory buffer, where we will putt the current DMX channel data. The first byte in the shared memory holds the current &#8216;version number&#8217; of the data. Each time any data is changed, the first byte&#8217;s value is increased. This way each &#8220;reader&#8221; can check if there are new data asyncronically.</p>
<p>So after some initial successful testing, I created a module called Exploit::Scene. This is the module that all scripts that need direct DMX control will use. The external methods are pretty simple. You have get(), set(), to get and set a single channel value, isNew() and resetNew() to check if the DMX channel data has changed since last time you checked. commit() to save new channel data you have edited, and getDMXpacket() to get full 513 bytes of channel data. (or less, if you have set a smaller universe_size)</p>
<p>Now we could start to create some small test scripts. So William made a script that tests a single RGB LED fixture. And I created a console application to show/edit the DMX data. Of course these scripts are just for testing, and will not be used in the finished &#8216;product&#8217;, since everything will be centralized in a web interface to combine effects, etc.</p>
<p><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/dmx_test.png" alt="" /></span></p>
<p>Here you can se the console application i wrote with the Curses perl module. The green cursor on the left is moved with your up and down keys, to select a channel. If you use the left or right keys, you increase or decrease the channel value. If you press space, you toggle the channel to full 0xff or null 0&#215;00 values. Page Up and Page Down will show you next &#8216;page&#8217; of channels, up to 512. The color on the bars is reflecting the channel value, first 1/3 is red, next is yellow, and last is green. The console is live, so if any other processes is changing DMX data, it will immediately show the new data while you are editing. So it&#8217;s both a monitor and editor. Which will be nice to have when the full system is done. So we can monitor the dmx channels live without the actual fixtures.</p>
<p>We have created two backend scripts. backend-dmx and backend-udp. These connect to the mmap with the Exploit::Scene module as explained, and use the getDMXpacket() function to get the data to send to either the DMX controller, or udp. By UDP I mean that we are sending all the DMX data to a local multicast address. 239.255.0.$universe. This way, any computer on the network can connect to this stream, and get out the data it needs. So we can have several computers on the network triggering on DMX data. For this we have the Exploit::UDPScene module, which behaves similar to the MMAP version, but used multicast to get it&#8217;s data.</p>
<p>More info will come when we are further along with the project.</p>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2009/08/dmx-system-in-perl-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>13 Input USB Temperature Sensor for PC</title>
		<link>http://lunatic.no/2009/08/13-input-usb-temperature-sensor-for-pc-2/</link>
		<comments>http://lunatic.no/2009/08/13-input-usb-temperature-sensor-for-pc-2/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 22:42:00 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[electronics]]></category>
		<category><![CDATA[hobby]]></category>
		<category><![CDATA[pic microcontroller]]></category>

		<guid isPermaLink="false">urn:myopera-lunatic-blog-4221683</guid>
		<description><![CDATA[I love doing statistics of everything, because data is power. So we thought we would put a temperature sensor in every server-rack in this server housing facility, and I checked the prices of some standard components. First I thought of the DS1820, which is fine, but two drawbacks. It&#8217;s somewhat expensive, and takes a full [...]]]></description>
			<content:encoded><![CDATA[<p>I love doing statistics of everything, because data is power. So we thought we would put a temperature sensor in every server-rack in this server housing facility, and I checked the prices of some standard components. First I thought of the DS1820, which is fine, but two drawbacks. It&#8217;s somewhat expensive, and takes a full second to read value from. So if you wire a lot of sensors serially, you&#8217;ll need to wait one second for each sensor on the same line.<br/><br/>Then I found these cute analog temperature sensors, called MCP9700A. And they cost only €0.37 each. Or if you buy larger quantites, you&#8217;ll get even lower prices. So I thought.. the PIC18F4520 has 13 analog ports. Why not create a small pcb with a pic18f4520, and some connectors, and wire it to the computer via RS232.<br/><br/>The problem then, is that i&#8217;d have to buy max232 chip, and then I&#8217;d need a RS232->USB cable, and thats pretty expensive. But then I found the life-saver chip FT232R. This awesomeness in a chip enclosure is a RS232(or any serial data in TTL levels)-to-USB &#8216;converter&#8217;. It has drivers for windows *, Mac, Linux. And you can even modify the eeprom inside it, to make it use a different VID and PID or just change the device description of it. And it also have two GP pins, which you can connect to LEDs to show when it sends or receives data. The BEST part about this already awesome chip, is it&#8217;s price. Here in Norway a RS232->USB cable costs from €42 an up. But this device, practically the same (except for missing RS232 level converter), costs only €2.87. And thats with all the leetnes of being able to change the device description and all, included.<br/><br/>So I wired it all up in Eagle, and it came out to be like this.<br/>Schematics:<br/><span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/Schematics.png' /></span><br/>Board:<br/><span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/Tempsensor%20MK%20I.png' /></span> <span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/Tempsensor%20MK%20I%20-%20bottom.png' /></span><br/><br/>So here I have a PIC18F4520 processor, 20Mhz XTAL for it (because I had some laying around), FT232R chip, 100K Resistor pack, and a few LEDs. All in all, about €20 worth of components.<br/><br/>So, now that I had designed the board, how to get it made, and cheap? Well, I found this site called [link]www.batchpcb.com[/link]. Which is fabulous. They collect PCB boards for a bunch of people who need cheap prototype boards, and send everything together to China, where they produce the boards, and return them in about 12 days. They often set up your board several times, in case some of them should be bad. (bleedout on the copper). And the best part. If more than one of your boards are ok, they even send you the extras, with no extra charge. So I received two pcs of the PCB I ordered, and couldn&#8217;t be happier :)<br/><br/>Here&#8217;s the result, (image quality courtesy of iPhone 3G)<br/><span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/bilde%282%29.jpg' /></span> <span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/IMG_0266.JPG' /></span><br/><br/>Then we add all the components. And bobs your uncle: (image quality courtesy of iPhone 3G)<br/><span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/IMG_0275.JPG' /></span> <span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/bilde.jpg' /></span><br/><br/>And it even works! ;)<br/><br/>The software I have uploaded to the PIC18F4520 sends all the temperature info, and the 8 general purpose inputs to the computer via a virtual com port on the computer, 20 times a second.</p>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2009/08/13-input-usb-temperature-sensor-for-pc-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SIM300CZ library for Eagle</title>
		<link>http://lunatic.no/2009/07/sim300cz-library-for-eagle-2/</link>
		<comments>http://lunatic.no/2009/07/sim300cz-library-for-eagle-2/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 00:32:41 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[SIM300]]></category>
		<category><![CDATA[hobby]]></category>

		<guid isPermaLink="false">urn:myopera-lunatic-blog-3988704</guid>
		<description><![CDATA[I am playing around with this nifty GPRS module called SIM300, which is just plain awesome. :cool:I am still using the test board that you can buy from the manufacturer, but are soon getting ready to use my own PCB board. But to do that, I need to draw the PCB board first. And I [...]]]></description>
			<content:encoded><![CDATA[<p>I am playing around with this nifty GPRS module called SIM300, which is just plain awesome. :cool:<br/><br/>I am still using the test board that you can buy from the manufacturer, but are soon getting ready to use my own PCB board. But to do that, I need to draw the PCB board first. And I like to use Eagle, since the trial version has everything I need.<br/><br/>Only thing left is to have symbols for schematics and package for PCB. This is what I have been working on today.<br/><br/>So this is the resulting symbol:<br/><span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/SIM300CZ%20symbol.png' /></span><br/><br/>And this is the package:<br/><span class='imgcenter'><img alt='' src='http://files.myopera.com/lunatic/blog/SIM300CZ%20package.png' /></span><br/><br/>Now, I made the package, using the measurements in the SIM300C documentation, but I haven&#8217;t tried it yet. So I really don&#8217;t know if I have been dead on, on all the measurements in the package. But time will show, as I will try to print it out and compare, and eventually etch a pcb with it :)<br/><br/>If anyone wants to try the library, its here:<br/><a class="attach" href="http://files.myopera.com/lunatic/blog/SIM300.lbr" target="_blank">SIM300.lbr</a><br/><br/>The library contains both SIM300Z and SIM300CZ. The SIM300Z package (molex package) was created by  Vamsi Kodati, but the symbol and the SIM300CZ and the pin-connecting is all me :happy:</p>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2009/07/sim300cz-library-for-eagle-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kerneldriver for LCD display (Tyan M1000 display for GT14 barebone)</title>
		<link>http://lunatic.no/2009/02/kerneldriver-for-lcd-display-tyan-m1000-display-for-gt14-barebone-2/</link>
		<comments>http://lunatic.no/2009/02/kerneldriver-for-lcd-display-tyan-m1000-display-for-gt14-barebone-2/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 10:37:16 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[16x2]]></category>
		<category><![CDATA[hobby]]></category>
		<category><![CDATA[kernel module development]]></category>
		<category><![CDATA[lcd]]></category>

		<guid isPermaLink="false">urn:myopera-lunatic-blog-2975210</guid>
		<description><![CDATA[So we bought this 1U Tyan GT14 Barebone with a LCD display and buttons in front of it. It was chosen mainly because of it&#8217;s anonymity and the LCD display.
So I set to download LCD drivers for linux. First I couldn&#8217;t find them at all.. The page at tyan.com is extremely slow, and even with [...]]]></description>
			<content:encoded><![CDATA[<p>So we bought this 1U Tyan GT14 Barebone with a LCD display and buttons in front of it. It was chosen mainly because of it&#8217;s anonymity and the LCD display.</p>
<p>So I set to download LCD drivers for linux. First I couldn&#8217;t find them at all.. The page at tyan.com is extremely slow, and even with google cache, it was not possible to find the driver. After a while, I tried connecting to <a href="ftp://ftp.tyan.com/" target="_blank">their FTP server</a>, where I were more lucky. Here I found a C example of how to write text to the display. Only problem was, it was linked to a binary library which was compiled with a different libc version. Shit out of luck I thought, no. I searched the FTP a bit more, and suddenly I found a lcdproc module by the Tyan staff. And it included all the source!</p>
<p>Yippee! But I don&#8217;t like the way LCDproc prevents me from doing what I want. I want to be able to control it directly, but from several sources. So I went to create a kernel module for Linux. Partly also because I wanted to play a bit with kernel development again :P</p>
<p>So attached you can find the source code for the new M1000 tyanlcd driver for 2.6 kernels.<br />
<a class="attach" href="http://files.myopera.com/lunatic/blog/tyanlcd-0.1.tar.gz" target="_blank">tyanlcd-0.1.tar.gz</a></p>
<p>It actually took me a while longer to do. Not because of very big problems. But because as I started to google about on how to access the serial port from kernel-space, I quickly found out that it is not very easy. There is a lot of serial drivers, and even though this device will only be on tyan mainboards, so it sould be safe, I wanted to be sure it worked on any serial port that linux has support for. I tried looking at serio, but found ot that this was the wrong way to go. And then read Alan Cox mentioning somwhere that the best approach to use the serial port would be to <a href="http://lkml.indiana.edu/hypermail/linux/kernel/0307.2/2223.html" target="_blank">create a new line discipline</a>. But I could not find a good description of this, or even how to use it when done.</p>
<p>So I ended up using the not so loved filp_open() to open /dev/ttyS1 where the LCD device always resides in a tyan barebone. This way I had acces to the device using file-&gt;f_op-&gt;write() and someone used file-&gt;f_op-&gt;ioctl, but I found out that this was not exported in the file object I received. So I went on investigating the insides of the kernel myself, and finally found a way to reach it&#8217;s ioctl function. The tty object resides inside file-&gt;private_data, and inside the tty object you have a driver struct, with a ops struct which have the ioctl function. So by doing:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">  tty<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> tty_struct<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>f<span style="color: #339933;">-&gt;</span>private_data<span style="color: #339933;">;</span>
  tty<span style="color: #339933;">-&gt;</span>driver<span style="color: #339933;">-&gt;</span>ops<span style="color: #339933;">-&gt;</span>ioctl<span style="color: #009900;">&#40;</span>tty<span style="color: #339933;">,</span> f<span style="color: #339933;">,</span> TCSETS<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;</span>settings<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>I was finally able to set the correct baud rate, number of bits, stop bits, etc. As soon as this was done, it was piece of cake writing text to the LCD display using the original lcdproc driver code as a template for the instructions to the device.</p>
<p>After this proof of concept worked, I added the posibility to both read and write to the display using the /proc filesystem. The driver creates a file called /proc/tyanlcd where you can send text which wil be sent directly to the display. The first 16 characters is the first line, and the next 16 characters is the last line. (the display is 16&#215;2 characters).</p>
<p>Reading the proc file gives you both lines on a single line. Seperate them by 16 characters and you have the current two lines displayed on the display.</p>
<p>Next task will be to make support for the buttons.</p>
<p>Small videoclip of the date showing in the display: <a class="attach" href="http://files.myopera.com/lunatic/blog/mov02074.avi" target="_blank">mov02074.avi</a><br />
Which shows the realtime output of the following proof of concept bash script:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><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>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;    <span style="color: #007800;">$(date +%H:%M:%S)</span>      &quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>tyanlcd
  <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2009/02/kerneldriver-for-lcd-display-tyan-m1000-display-for-gt14-barebone-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LEDDisplay games</title>
		<link>http://lunatic.no/2006/12/leddisplay-games-2/</link>
		<comments>http://lunatic.no/2006/12/leddisplay-games-2/#comments</comments>
		<pubDate>Sat, 02 Dec 2006 23:55:18 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[games]]></category>
		<category><![CDATA[hobby]]></category>
		<category><![CDATA[led display]]></category>

		<guid isPermaLink="false">urn:myopera-lunatic-blog-599260</guid>
		<description><![CDATA[
So.. We can&#8217;t have a &#8220;screen&#8221; without pong or snake, can we?


When I completed the LED Displays abillity to be controlled from the computer via RS232, I wrote a nifty little module in Perl, which I called: Acme::LEDDisplay.
With this module I am able to use the display just as a.. well&#8230; display :)
But &#8217;till today, [...]]]></description>
			<content:encoded><![CDATA[<div>
<div id="excerpt">So.. We can&#8217;t have a &#8220;screen&#8221; without pong or snake, can we?</div>
</div>
<div>
When I completed the LED Displays abillity to be controlled from the computer via RS232, I wrote a nifty little module in Perl, which I called: Acme::LEDDisplay.</p>
<p>With this module I am able to use the display just as a.. well&#8230; display :)<br />
But &#8217;till today, I haven&#8217;t made anything really cool. Just some small things like live Network-graph and live IRC log ;p</p>
<p>But today I wrote two games for it, and I&#8217;m pretty pleased about the result :)</p>
<p>The new scripts for today are Snake/Nibbles, Pong, and a little meaningless bouncy-script.</p>
<p><strong>Nibbles</strong><br />
<img src="http://files.myopera.com/lunatic/blog/ATT00299.jpg" alt="" /><br />
Source:<br />
<a href="http://files.myopera.com/lunatic/blog/nibbles.pl" target="_blank">nibbles.pl</a><br />
Video:<br />
<a href="http://files.myopera.com/lunatic/blog/MOV00332.avi" target="_blank">MOV00332.avi</a></p>
<p><strong>Pong</strong><br />
<img src="http://files.myopera.com/lunatic/blog/ATT00293.jpg" alt="" /><br />
Source:<br />
<a href="http://files.myopera.com/lunatic/blog/pong.pl" target="_blank">pong.pl</a><br />
Video:<br />
<a href="http://files.myopera.com/lunatic/blog/MOV00334.avi" target="_blank">MOV00334.avi</a></p>
<p><strong>Meaningless script</strong><br />
Also made this little ball-bouncing script, which pong is built upon. It uses pretty much the same &#8220;ball&#8221; module. You can start it with as many balls you want. And it bounces them randomly about.</div>
<div>
Source:<br />
<a href="http://files.myopera.com/lunatic/blog/bballs.pl" target="_blank">bballs.pl</a><br />
Video:<br />
<a href="http://files.myopera.com/lunatic/blog/MOV00331.avi" target="_blank">MOV00331.avi</a></div>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2006/12/leddisplay-games-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LEDDisplay / BlinkenLed</title>
		<link>http://lunatic.no/2006/11/leddisplay-blinkenled-2/</link>
		<comments>http://lunatic.no/2006/11/leddisplay-blinkenled-2/#comments</comments>
		<pubDate>Sun, 26 Nov 2006 05:21:29 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[blikenlights]]></category>
		<category><![CDATA[blinkenled]]></category>
		<category><![CDATA[hobby]]></category>
		<category><![CDATA[led display]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">urn:myopera-lunatic-blog-584572</guid>
		<description><![CDATA[My newest project; LED Display.

Youtube video of it
The idea came from germany, where the group &#8220;CCC&#8221; or Chaos Computer Club, created a matrix of lights in the &#8220;Haus des Lehrers&#8221; building at Alexanderplatz in Berlin. They installed computer controlled lights in 144 windows spanned over 8 floors (18 windows per floor). This was done first [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-size: medium;">My newest project; LED Display.</span><br />
<a href="http://www.youtube.com/watch?v=GHMd2JFMvOw" target="_blank"><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/ATT00293.jpg" alt="" /></span></a><br />
<a href="http://www.youtube.com/watch?v=GHMd2JFMvOw" target="_blank">Youtube video of it</a></p>
<p>The idea came from germany, where the group &#8220;CCC&#8221; or Chaos Computer Club, created a matrix of lights in the &#8220;Haus des Lehrers&#8221; building at Alexanderplatz in Berlin. They installed computer controlled lights in 144 windows spanned over 8 floors (18 windows per floor). This was done first in 2001. You can look at their webpage at <a href="http://blinkenlights.de/" target="_blank">BlinkenLights.de</a>.</p>
<p>If you search for Blinkenlights on video.google.com or youtube you will find a really interesting documentary about the Blinkenlights project. I saw this video a few years ago, but when I saw it again now recently, I ignited on all my sparks. I had to make my own small scale version.</p>
<p>So I surfed the web, and I found, amongst others, <a href="http://www.jalcds.de/blinkenleds/" target="_blank">BlinkenLEDs</a>. These guys had done almost exactly what I wanted to do. I saw that they were using a 4094 Bit-shift register. I myself would have used a 74xxx series chip, but since they had done it perfectly with this chip, and since it looked like it worked perfectly even without resistors for each LED, I incorporated the 4094 chip in my plans.</p>
<p>My plan differs from theirs in two ways. I wanted mine to be able to run without a computer connected. For this I planned using the PIC16F628. Someone might wonder why I wouldn&#8217;t use the cheaper &#8220;less cmos&#8221; version PIC16F84. But the answer is also the answer to the other way my project differs. I wanted to use the serial port, instead of the LPT(read: printer) port. And the PIC16F628 has hardware USART capability, which makes RS232 connection simple.</p>
<p>The part-list for mye circuit is as follows:</p>
<pre>  1     PIC16F628
  1     18-PIN socket (for the PIC)
  1     MAX232
  1     95128 SPI controlled EEPROM (128KB memory)
  1     20MHz Crystal for the PIC
  1     33uF electrolyte capacitor (noise reduction for PIC)
  2     22pF capacitors for 20Mhz crystal
  2     Veroboards (prototyping boards)
  3M    Flat cable
  4     1uF electrolyte capacitors (for the MAX232)
  18    4094 Bit shift registers
  144   Red 3mm Leds (I've got 4000 spare :P)
  misc  Wires</pre>
<p>The circuit was planned live inside my head ;) I have regretted this a bit as the project evolved, but all in all, I&#8217;m pretty happy/proud about the result.</p>
<p><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/image1.jpg" alt="" /></span></p>
<p>Here you can see a picture of the controller-card when I had completed the wiring of 3 bit-shift registers, the PIC16F628 and the MAX232. I were planning on having two rows of bitshift registers filling the whole left side of the board, spacing just enough to have 8 wires up to the LED board from each register.</p>
<p><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/image2.jpg" alt="" /></span></p>
<p>Here you see how I wired the first 4 bit-shift registers. I found out later, that I wanted the first register to be on the next row. Even though here you can see that I have connected the first register on this &#8220;second row&#8221; to the PIC16F628 processor. If you are really  observant, you can tell that I have changed my mind a few times on the wiring of the bottommost row ;P<br />
It also prooved later that I should have thought it over just one more time. Because here lies the root of all evil! I wired up all the STROBE pins to +5v, and wired together all the OUTPUT ENABLE pins, to one of the ports of the PIC processor. This was not what I meant to do. Because of this, my display will flicker a bit each time it updates the screen. But since it is a 20MHz processor, it&#8217;s hardly noticable.</p>
<p><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/image3.jpg" alt="" /></span></p>
<p>This is a picture of all the 18 Bit-shift registers wired up.</p>
<p><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/image4.jpg" alt="" /></span></p>
<p>This is all the registers wired up. You can see I have moved the control-cable from the processor to the leftmost registers. I tested the circuit with a program on the processor that lit one row by one, and all of them worked at the first try! :D</p>
<p><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/image5.jpg" alt="" /></span></p>
<p>It was then over to the LED card. Here I have drilled out 144 holes. Pretty boring work I can tell you&#8230;. You see that I have wired the ground from the 9 first LEDs.</p>
<p><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/image6.jpg" alt="" /></span></p>
<p>This is how it looks when all 144 LEDs are connected. This took very long time, especially afther the first few rows. Since my friend had to leave, and so I was two hands short. But I got it done at the end. I wish this board was pre-tinned like the controller-vero board, since this made it even harder to solder the LEDS with only my own two hands.</p>
<p><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/image7.jpg" alt="" /></span></p>
<p>Then I started wiring up the leds to the shift registers. I am glad that I saw how terrible the wiring looked at the projects at BlinkenLEDS. So that I bought flat cable for my project. I&#8217;m pretty satisfied with how I wired up the leds to the flat cable. Even though it took quite a long time. After each new row, I powered up the circuit to check if there were any &#8220;dead pixels&#8221;. There were a few (read: totally 4-5), mostly since the board wasn&#8217;t pre-tinned, and I don&#8217;t have flux other than what the tin provided. But since I was in lack of hands, the flux evaporated before I got to actually solder the leds to the board.</p>
<p><span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/image8.jpg" alt="" /></span></p>
<p>Here you see the board running a program that alternates between all the leds. The display works! It was time for celebration with a &#8220;blm&#8221; movie from the BlinkenLights project. So I wrote a parser in perl that converted a .blm file to .c code for my PIC16F628.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ttl</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@arr</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@outarr</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$out</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">m/^@(\d+)$/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #0000ff;">$ttl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">m/^[01]{18}$/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">push</span> <span style="color: #0000ff;">@arr</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">scalar</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@arr</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot; PORTB &amp;= ~SHOW; // Hide display<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$pos</span> <span style="color: #009900;">&#40;</span>0<span style="color: #339933;">..</span>17<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ari</span> <span style="color: #009900;">&#40;</span>0<span style="color: #339933;">..</span>7<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">push</span> <span style="color: #0000ff;">@outarr</span><span style="color: #339933;">,</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$ari</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$pos</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot; sendbyte(0b&quot;</span><span style="color: #339933;">.</span><span style="color: #000066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">@outarr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;);<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #0000ff;">@outarr</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #0000ff;">@arr</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot; PORTB |= SHOW; // Show display<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot; delay_ms($ttl);<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The result was a moving version of this:<br />
<span class="imgcenter"><img src="http://files.myopera.com/lunatic/blog/image9.jpg" alt="" /></span><br />
Source of the BLM file, and moving GIF of the animation can be found <a href="http://www.blinkenlights.de/gallery/speedit.en.html" target="_blank">here</a>.</p>
<p>I have now coded the RS232 support and I first modified the above code to send the animation directly to the display. And then I coded myself a perl module to control the display live. I called it &#8220;Acme::LEDDisplay&#8221; and using some quick hacks. I have support for pset (pixel set), pget (pixel get), line, circle and text.</p>
<p>With this I can create live output from just about everything. The sky is the limit :D</p>
<p>Here is a video sample of &#8220;<a href="http://www.blinkenlights.de/gallery/spin.en.html" target="_blank">spin.blm</a>&#8221; on my display: <a class="attach" href="http://files.myopera.com/lunatic/blog/MOV00315.avi" target="_blank">MOV00315.avi</a></p>
<p>The project is almost done. I have made it possible to send blm movies directly from the PC, and control the display in simple perlcode. But the &#8220;offline-playing&#8221; part is not done. I had a few problems getting the SPI&lt;-&gt;EEPROM communication to work, so I have ordered some more EEPROMs to check if the one I have is broken. I really hope that, because it would be fun to be able to upload a few &#8220;movies&#8221;, and let it run for itself on batterypower. Maybe show off a few christmas greetings for example ;)</p>
<p>I also might wire it to my recently bougt Bluetooth module, so I can control it without any wires whatsoever :)</p>
<p>If you want more info about how I wired things up, sourcecode, etc. Give me a reply!</p>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2006/11/leddisplay-blinkenled-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My blog</title>
		<link>http://lunatic.no/2006/09/my-blog-2/</link>
		<comments>http://lunatic.no/2006/09/my-blog-2/#comments</comments>
		<pubDate>Mon, 25 Sep 2006 10:31:04 +0000</pubDate>
		<dc:creator>Håkon Nessjøen</dc:creator>
				<category><![CDATA[first post]]></category>
		<category><![CDATA[hobby]]></category>

		<guid isPermaLink="false">urn:myopera-lunatic-blog-483785</guid>
		<description><![CDATA[Well.. Two things have been decided today;

To start a new blog  
To keep it english (read: engrish)

So here it is. I will try to post my hobbyprojects here and stuff, maybe someone might appreciate it. :coffee:
]]></description>
			<content:encoded><![CDATA[<p>Well.. Two things have been decided today;<br/>
<ul class="bullets">
<li>To start a new blog<br/>  </li>
<li>To keep it english (read: engrish)<br/></li>
</ul>
<p><br/>So here it is. I will try to post my hobbyprojects here and stuff, maybe someone might appreciate it. :coffee:</p>
]]></content:encoded>
			<wfw:commentRss>http://lunatic.no/2006/09/my-blog-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
