<?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>AngryViking</title>
	<atom:link href="http://www.blog2.angryviking.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.blog2.angryviking.com</link>
	<description>The Mad in Science</description>
	<lastBuildDate>Wed, 11 Nov 2009 21:12:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Steam Clock code</title>
		<link>http://www.blog2.angryviking.com/?p=58</link>
		<comments>http://www.blog2.angryviking.com/?p=58#comments</comments>
		<pubDate>Wed, 11 Nov 2009 21:12:02 +0000</pubDate>
		<dc:creator>Audin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blog2.angryviking.com/?p=58</guid>
		<description><![CDATA[As promised, here is the steam clock source code. It uses two non-standard Arduino libraries: Stepper &#8211; with half-stepping DateTime &#8211; a software clock The code is pretty straightforward. move() does most of the stepper work. hour() and minute() do the minimal calculation needed to point at the right places on the dial. minute() is [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, here is the steam clock source code.</p>
<p>It uses two non-standard Arduino libraries:</p>
<ol>
<li><a href="http://code.google.com/p/arduino/issues/detail?id=139">Stepper</a> &#8211; with half-stepping</li>
<li><a href="http://www.arduino.cc/playground/Code/DateTime">DateTime</a> &#8211; a software clock</li>
</ol>
<p>The code is pretty straightforward.  move() does most of the stepper work.  hour() and minute() do the minimal calculation needed to point at the right places on the dial.  minute() is used for seconds as well.  wiggle() bounces the needle around the current point.  Its fun to look at and makes a nice noise.</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
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;DateTime.h&gt;</span>
<span style="color: #339933;">#include &lt;Stepper.h&gt;</span>
&nbsp;
<span style="color: #339933;">#define TIME_MSG_LEN  11   // time sync to PC is HEADER and unix time_t as ten ascii digits</span>
<span style="color: #339933;">#define TIME_HEADER  't'   // Header tag for serial time sync message</span>
<span style="color: #339933;">#define TZ 8               // How many hours off of GMT are you?</span>
&nbsp;
Stepper s<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">200</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">,</span><span style="color: #0000dd;">5</span><span style="color: #339933;">,</span><span style="color: #0000dd;">6</span><span style="color: #339933;">,</span><span style="color: #0000dd;">7</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Stepper is on pins 4, 5, 6, 7.  Using the enhanced Stepper library with half-stepping.</span>
&nbsp;
<span style="color: #993333;">int</span> p <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Steam Clock 0.8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  DateTime.<span style="color: #202020;">sync</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">10000000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Needs to come from RTC.</span>
&nbsp;
  pinMode<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> INPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// home sensor</span>
  pinMode<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">3</span><span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// home ir led</span>
&nbsp;
  find_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  allminutes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  allhours<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  bouncehome<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> find_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  digitalWrite<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">3</span><span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// turn on LED</span>
  digitalWrite<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// turn on pull-up for sensor</span>
&nbsp;
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">900</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    s.<span style="color: #202020;">step</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>digitalRead<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Home!!!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        p <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
       <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   digitalWrite<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">3</span><span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// turn off LED</span>
   digitalWrite<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// turn off pull-up.</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> allminutes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> t<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>t<span style="color: #339933;">&lt;=</span><span style="color: #0000dd;">60</span><span style="color: #339933;">;</span>t<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    minute<span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>t <span style="color: #339933;">%</span> <span style="color: #0000dd;">10</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      wiggle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> 
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> allhours<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> t<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>t<span style="color: #339933;">&lt;=</span><span style="color: #0000dd;">24</span><span style="color: #339933;">;</span>t<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     hour<span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> bouncehome<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   minute<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   wiggle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> move<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> to<span style="color: #339933;">,</span><span style="color: #993333;">int</span> speed<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  s.<span style="color: #202020;">setSpeed</span><span style="color: #009900;">&#40;</span>speed<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>to <span style="color: #339933;">!=</span> p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">int</span> steps <span style="color: #339933;">=</span> to <span style="color: #339933;">-</span> p<span style="color: #339933;">;</span>
    s.<span style="color: #202020;">step</span><span style="color: #009900;">&#40;</span>steps<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    p <span style="color: #339933;">+=</span> steps<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> wiggle<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  s.<span style="color: #202020;">setSpeed</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">-=</span> <span style="color: #0000dd;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     s.<span style="color: #202020;">step</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     s.<span style="color: #202020;">step</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     s.<span style="color: #202020;">step</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     s.<span style="color: #202020;">step</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>  
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> hour<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> h<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//  move((int)(h * 2.125), 200);  // this shoulnd't be a float...</span>
  move<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>h <span style="color: #339933;">*</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// oh, 2 seems to work better anyway. yay!</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> minute<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> m<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  move<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">400</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>m <span style="color: #339933;">*</span> <span style="color: #0000dd;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> getPCtime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// if time available from serial port, sync the DateTime library</span>
  <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>Serial.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span>  TIME_MSG_LEN <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>  <span style="color: #666666; font-style: italic;">// time message</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> Serial.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> TIME_HEADER <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
      time_t pctime <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> TIME_MSG_LEN <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>   
        <span style="color: #993333;">char</span> c<span style="color: #339933;">=</span> Serial.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>          
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> c <span style="color: #339933;">&gt;=</span> <span style="color: #ff0000;">'0'</span> <span style="color: #339933;">&amp;&amp;</span> c <span style="color: #339933;">&lt;=</span> <span style="color: #ff0000;">'9'</span><span style="color: #009900;">&#41;</span>   
          pctime <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">10</span> <span style="color: #339933;">*</span> pctime<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">-</span> <span style="color: #ff0000;">'0'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// convert digits to a number            </span>
      <span style="color: #009900;">&#125;</span>   
      DateTime.<span style="color: #202020;">sync</span><span style="color: #009900;">&#40;</span>pctime <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>TZ <span style="color: #339933;">*</span> <span style="color: #0000dd;">60</span> <span style="color: #339933;">*</span> <span style="color: #0000dd;">60</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Sync DateTime clock to the time received on the serial port</span>
    <span style="color: #009900;">&#125;</span>  
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> debugOutput<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'t'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">now</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Hour</span><span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">':'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Minute</span><span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">':'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Second</span><span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Day</span><span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Month</span><span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Year</span><span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  getPCtime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  debugOutput<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  DateTime.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  hour<span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Hour</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  wiggle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">2000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  DateTime.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  minute<span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Minute</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  wiggle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">2000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  DateTime.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  minute<span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Second</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  DateTime.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Second</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">50</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     move<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">400</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>DateTime.<span style="color: #202020;">Second</span> <span style="color: #339933;">+</span> <span style="color: #0000dd;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #0000dd;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</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>
     move<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">400</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #0000dd;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.blog2.angryviking.com/?feed=rss2&amp;p=58</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Steam Clock</title>
		<link>http://www.blog2.angryviking.com/?p=49</link>
		<comments>http://www.blog2.angryviking.com/?p=49#comments</comments>
		<pubDate>Tue, 10 Nov 2009 21:59:47 +0000</pubDate>
		<dc:creator>Audin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blog2.angryviking.com/?p=49</guid>
		<description><![CDATA[I picked up an old pressure gauge from my local reclaimed building hardware co-op (RE-store!).  I&#8217;ve had it for several months with the idea to replace the guts with a stepper motor to allow microcontroller control of the needle.  In the end it has turned into a clock! This is the &#8216;core&#8217; of the meter.  It originally [...]]]></description>
			<content:encoded><![CDATA[<div class="flickr-photos"><object width="480" height="640" data="http://www.flickr.com/apps/video/stewart.swf?v=71377&photo_id=4090937079&photo_secret=4dfcd82ae4" type="application/x-shockwave-flash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="flickr_show_info_box=false"></param> <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=71377&photo_id=4090937079&photo_secret=4dfcd82ae4"></param> <param name="bgcolor" value="#000000"></param> <param name="allowFullScreen" value="true"></param> <embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=71377&photo_id=4090937079&photo_secret=4dfcd82ae4" bgcolor="#000000" allowfullscreen="true" flashvars="flickr_show_info_box=false" width="480" height="640"></embed></object></div>
<p>I picked up an old pressure gauge from my local reclaimed building hardware co-op (RE-store!).  I&#8217;ve had it for several months with the idea to replace the guts with a stepper motor to allow microcontroller control of the needle.  In the end it has turned into a clock!</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Steam Clock brass core" href="http://www.flickr.com/photos/audin/4088839350/"><img class="alignnone" src="http://farm3.static.flickr.com/2538/4088839350_f8275a32be.jpg" alt="Steam Clock brass core" width="500" height="375" /></a></p>
<p>This is the &#8216;core&#8217; of the meter.  It originally had a pressure tube meter movement thing hanging off it.  I remove that part and drilled out the copper body to more easily handle power wires.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Stepper motor mount." href="http://www.flickr.com/photos/audin/4088081049/"><img class="alignnone" src="http://farm3.static.flickr.com/2791/4088081049_5fc7eec2c3.jpg" alt="Stepper motor mount." width="500" height="375" /></a></p>
<p>Where the meter movement itself went now needed to go a stepper motor.  This aluminum plate holds the motor.  The plate is made of aluminum salvaged from a CommutaCar charger case.  The standoffs are from the voice coil assembly of an old hard drive.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Stepper motor clearance!" href="http://www.flickr.com/photos/audin/4088083863/"><img class="alignnone" src="http://farm3.static.flickr.com/2622/4088083863_fccec22867.jpg" alt="Stepper motor clearance!" width="500" height="375" /></a></p>
<p>This is the stepper motor itself.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Stepper and 'home' sensor." href="http://www.flickr.com/photos/audin/4088843022/"><img class="alignnone" src="http://farm3.static.flickr.com/2792/4088843022_d2c20361e2.jpg" alt="Stepper and 'home' sensor." width="500" height="375" /></a></p>
<p>This is the stepper motor mounted and the &#8216;home&#8217; sensor added.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Movement!" href="http://www.flickr.com/photos/audin/4088088193/"><img class="alignnone" src="http://farm3.static.flickr.com/2615/4088088193_f1540f4d09.jpg" alt="Movement!" width="500" height="375" /></a></p>
<p>This then is the whole working clock.</p>
<p>Clock components:</p>
<ol>
<li>Meter movement itself.  (lower left)</li>
<li>Arduino.  (upper right)</li>
<li>Darlington motor driver. (middle)</li>
<li>Home sensor.  (under clock face)</li>
<li>Power supply.  (on the left)</li>
<li>Real time clock.  (not pictured)</li>
</ol>
<p>Many of the parts were &#8216;rescued&#8217; from old hardware.  The stepper motor is from an old HP DLT tape drive (each of these drives have 3 steppers in them!  Plus a bunch of bearings and a brushless motor).  The Home sensor is an IR beam-break (what are those called anyway?) detector.  Both its LED and detector are directly connected to the AVR.  They are turned on for calibration and then turned back off.  The Darlington driver chip was in my junk box.  It just provides more current handling than the AVR can do on its own.  The real time clock and power supply will be new parts.</p>
<p>When complete the guts will all fit behind the clock face.  The arduino will be replaced with a &#8216;naked&#8217; ATMEGA168 (probably, or a mega8 if the code will fit).  The power supply will be swapped out for another regulator since the one on the breadboard doesn&#8217;t work very well (it has an overly sensitive PTC thingy that likes to shut it down for no reason).  I don&#8217;t have the real time clock yet, but it will be a self-contained clock chip with a backup battery.  Probably a DS1307.</p>
<p>The arduino code uses two libraries: Stepper, to run the motor, and DateTime, which is used to keep the time.  When the RTC is added it will be used to &#8216;seed&#8217; the DateTime with the real time every once in a while (hourly?).  I&#8217;m guessing the clock will keep better time than the arduino, thus the desire to resync every once in a while.</p>
<p>The next post will include code!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog2.angryviking.com/?feed=rss2&amp;p=49</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Lacking in Performoodles.</title>
		<link>http://www.blog2.angryviking.com/?p=45</link>
		<comments>http://www.blog2.angryviking.com/?p=45#comments</comments>
		<pubDate>Mon, 13 Apr 2009 20:54:35 +0000</pubDate>
		<dc:creator>Audin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blog2.angryviking.com/?p=45</guid>
		<description><![CDATA[So as some of you know I work at a company that deals with satellite data services on aircraft.  These services are both slow and expensive.  So trying to use them is actually an act of trying to avoid using them&#8230;if that makes any sense.  Also, to complicate things, the company I work for is [...]]]></description>
			<content:encoded><![CDATA[<p>So as some of you know I work at a company that deals with satellite data services on aircraft.  These services are both slow and expensive.  So trying to use them is actually an act of trying to avoid using them&#8230;if that makes any sense.  Also, to complicate things, the company I work for is related to, and gets proceeds from, the amount of bandwidth used.  So we both want to use as much bandwidth as possible, but also to use a little as possible.  ugh.</p>
<p>One of our soon-to-be products is an inflight internet service.  This provides a mostly transparent connection for the passenger&#8217;s laptop or the IFE screen in the seat.</p>
<p>The connection we are using for this service provides 492kbps maximum.  On the surface, that doesn&#8217;t seem too bad.  It&#8217;s 4 ISDN lines.  Or half a 1MB DSL/Cable modem.  And it&#8217;s like 8 56k modems!</p>
<p>But.</p>
<p>The latency is killer.  The satellites are in Geosynchronous orbit.  Thats 22,000 miles away.  And 22,000 miles back.  And then, the data lands at one of three ground stations, none of which are in very good locations, so there is a several thousand mile trip over fiber back to my companies data center.  Ugh.</p>
<p>That all adds up to between 0.9 and 3 (usually about 1.5) seconds of latency for a round trip.  Ugh^2.</p>
<p>So that means that any time you ask the ground for something, there is at least 2 seconds before you are going to START getting a response.  The ground won&#8217;t even know you asked the question for almost a second!</p>
<p>Of course, it&#8217;s actually worse than that.</p>
<p>What if you ask the question over TCP?  TCP takes 1.5 round trips to even being transferring data.  Ugh.</p>
<p>Then, of course, TCP is very bad at making efficient use of long latency links (known as &#8216;long fat pipes&#8217;).  TCP generally starts a new connection slowly, so as to not immediately fill it up and risk packet loss.  This is called Slow Start, and is a form of Congestion Avoidance.  It works by waiting for the first several packets to be ACKed by the receiving side before speeding up the transmit rate.  Once the expected ACKs stop coming, the sending side knows what the link capacity is and will slow down a little to fit.  This works very well for short pipes with low latency.  However, since we have such a long latency, and packet loss is actually rather rare, this is an extremely inefficient way to go about things.  If the response data set is small, the connection will in fact never make it out of the Slow Start phase.  This is because by the time the ACKs which would allow the sender to start sending faster get there all the data is already in the pipe.  What could have been a very short 400kbps burst turns into a 1 second long 10kbps dribble.</p>
<p>Then we have DNS.  Before a TCP connection can even be established, you have to do a DNS lookup to turn &#8216;www.google.com&#8217; into &#8217;74.125.53.104&#8242;.  DNS lookups take about 3 seconds.  Thank god they are cached.  But still.  Ugh.</p>
<p>So here are some load times for web sites over this satellite link.</p>
<p>These times were collected using a perl script I wrote for the purpose.  I was unable to find any preexisting tools worth a damn.  The tool emulates a sort of worse-case situation: no cache, full page load from scratch.  However, the script will make use of keep-alives if the server supports them.  And it can make use of a proxy server to avoid the DNS delay.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Fun page load times over satellite!" href="http://www.flickr.com/photos/audin/3439237044/"><img class="aligncenter" src="http://farm4.static.flickr.com/3572/3439237044_62a1e28e71.jpg" alt="Fun page load times over satellite!" width="500" height="244" /></a></p>
<p>For comparison here is a bunch of web sites loaded by the same script over 786k ADSL.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Some web page load times over ADSL" href="http://www.flickr.com/photos/audin/3438435975/"><img class="aligncenter" src="http://farm4.static.flickr.com/3661/3438435975_b5d0b6ee1d.jpg" alt="Some web page load times over ADSL" width="500" height="354" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog2.angryviking.com/?feed=rss2&amp;p=45</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Plumbing</title>
		<link>http://www.blog2.angryviking.com/?p=41</link>
		<comments>http://www.blog2.angryviking.com/?p=41#comments</comments>
		<pubDate>Mon, 06 Apr 2009 00:14:30 +0000</pubDate>
		<dc:creator>Audin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.blog2.angryviking.com/?p=41</guid>
		<description><![CDATA[Somewhere along the line this last winter the pipe leading to my back yard faucet burst.  I woke up at 2am or so and fumbled around in the dark trying to figure out where the running water noise was coming from and how to turn it off.   Afterwards i went back to bed. This morning [...]]]></description>
			<content:encoded><![CDATA[<p>Somewhere along the line this last winter the pipe leading to my back yard faucet burst.  I woke up at 2am or so and fumbled around in the dark trying to figure out where the running water noise was coming from and how to turn it off.   Afterwards i went back to bed.</p>
<p>This morning I woke up again and decided to fix the pipe so that I could put new water in my hot tub.</p>
<p>This is the pipe, next to the pipe i cut to replace it:</p>
<p style="text-align: center;"><a class="tt-flickr tt-flickr-Medium" title="Bursty!" href="http://www.flickr.com/photos/audin/3416481624/"><img class="aligncenter" src="http://farm4.static.flickr.com/3310/3416481624_78ed657e07.jpg" alt="Bursty!" width="300" height="225" /></a></p>
<p style="text-align: left;">Unfortunately, after soldering this new pipe in place, it became apparent that the valve nearby was also damaged.  Upon disassembly the inner workings pretty much fell apart, as the ice had broken them all up.  So after lots more poking around and some splashing and a trip to the pumbing store, I once again had a working faucet!  yay!</p>
<p style="text-align: left;">After that little adventure, I commenced the long slow tub draining exercise.</p>
<p style="text-align: left;"><a class="tt-flickr tt-flickr-Small" title="Draining Hot Tub." href="http://www.flickr.com/photos/audin/3416481638/"><img class="aligncenter" src="http://farm4.static.flickr.com/3345/3416481638_a524fc220c_m.jpg" alt="Draining Hot Tub." width="240" height="180" /></a></p>
<p style="text-align: left;">This part is still ongoing, as it (and the one leading to the street) is a very small hose trying to drain a very large hot tub.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog2.angryviking.com/?feed=rss2&amp;p=41</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trivet Light</title>
		<link>http://www.blog2.angryviking.com/?p=24</link>
		<comments>http://www.blog2.angryviking.com/?p=24#comments</comments>
		<pubDate>Mon, 30 Mar 2009 20:26:11 +0000</pubDate>
		<dc:creator>Audin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[LED]]></category>

		<guid isPermaLink="false">http://www.blog2.angryviking.com/?p=24</guid>
		<description><![CDATA[One of my favorite places to visit often is the Ballard ReStore.  It is a reclaimed building supply place.  A non-profit.  And they also do a good job of passing on some of the odder things found when pulling down old buildings.  They will at times have old meters or photography or lab equipment in [...]]]></description>
			<content:encoded><![CDATA[<p>One of my favorite places to visit often is the Ballard ReStore.  It is a reclaimed building supply place.  A non-profit.  And they also do a good job of passing on some of the odder things found when pulling down old buildings.  They will at times have old meters or photography or lab equipment in addition to the windows and doors and cabinets and other more normal stuff.</p>
<p>Anyway, one of the sort of interesting things they had when i was walking through a while back was plastic bathroom tile.  These are 4&#8243; square slightly translucent swirled plastic tiles.  I wondered if LEDs would look interesting shining through them.  So I bought 4 of them.  This is another nice thing about this place, the boxes are generally all open.</p>
<p><a class="tt-flickr tt-flickr-Small" title="IMG_2565.JPG" href="http://www.flickr.com/photos/audin/3245768296/"><img class="alignright" src="http://farm4.static.flickr.com/3260/3245768296_c431465b7f_m.jpg" alt="IMG_2565.JPG" width="240" height="180" /></a></p>
<p>So I took two of these tiles and framed them with some random wood i scrounged from my back yard and made a sort of trivet out of them as you can see on the right.</p>
<p>Then I took some tricolor LED modules I had and an ATTiny85 and some FETs and added some internal lighting.</p>
<p>This was my first time playing with an ATTiny, and my first time actually &#8216;producing&#8217;&#8211;as opposed to breadboarding&#8211;an AVR based device.  I used an annoying prototyping method I had seen mentioned on the web.  I will never try that again.  Ick.  Anyway, here is the board</p>
<p><a class="tt-flickr tt-flickr-Thumbnail" title="Trivetlight all soldered up." href="http://www.flickr.com/photos/audin/3265444920/"><img class="alignnone" src="http://farm2.static.flickr.com/1193/3265444920_537b59ce74_t.jpg" alt="Trivetlight all soldered up." width="100" height="75" /></a> And here is the back of the board <a class="tt-flickr tt-flickr-Thumbnail" title="Solder side." href="http://www.flickr.com/photos/audin/3264645373/"><img class="alignnone" src="http://farm2.static.flickr.com/1424/3264645373_32fd15b6da_t.jpg" alt="Solder side." width="100" height="75" /></a> showing the insane prototyping method involving enameled magnet wire.</p>
<p>It works.  I would like to add some batteries and an inductive power pickup to it so the power cord could be hidden under the table.  Also the plastic tiles are somewhat too opaque, so something clearer would be better.</p>
<p style="text-align: center;">
]]></content:encoded>
			<wfw:commentRss>http://www.blog2.angryviking.com/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sigrun Radio 1500</title>
		<link>http://www.blog2.angryviking.com/?p=23</link>
		<comments>http://www.blog2.angryviking.com/?p=23#comments</comments>
		<pubDate>Mon, 30 Mar 2009 02:03:54 +0000</pubDate>
		<dc:creator>Audin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[radio]]></category>
		<category><![CDATA[tubes]]></category>

		<guid isPermaLink="false">http://blog.angryviking.com/?p=23</guid>
		<description><![CDATA[This is Sigrun Radio 1500.  A micropower High Fidelity AM brodcast I sometimes turn on to send music to my tube radio (which you can see at left).  Some day I will build a proper antenna for it and set it up to broadcast around the clock.  But at the moment the signal dies halfway [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter" title="Sigrun Radio 1500" src="http://farm4.static.flickr.com/3305/3301861708_ff26de5684_d.jpg" alt="" width="375" height="500" /></p>
<p>This is Sigrun Radio 1500.  A micropower High Fidelity AM brodcast I sometimes turn on to send music to my tube radio (which you can see at left).  Some day I will build a proper antenna for it and set it up to broadcast around the clock.  But at the moment the signal dies halfway down my driveway, so there isn&#8217;t much point.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog2.angryviking.com/?feed=rss2&amp;p=23</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Big Pool Lamp</title>
		<link>http://www.blog2.angryviking.com/?p=19</link>
		<comments>http://www.blog2.angryviking.com/?p=19#comments</comments>
		<pubDate>Mon, 30 Mar 2009 01:54:15 +0000</pubDate>
		<dc:creator>Audin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.angryviking.com/?p=19</guid>
		<description><![CDATA[So this was at the ReStore today.  It is 12V at 300Watts.  What should I do with it?]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a class="tt-flickr tt-flickr-Medium" title="IMG_2607.JPG" href="http://www.flickr.com/photos/audin/3405313564/"><img class="aligncenter" src="http://farm4.static.flickr.com/3636/3405313564_af079fab3d.jpg" alt="IMG_2607.JPG" width="500" height="375" /></a></p>
<p>So this was at the ReStore today.  It is 12V at 300Watts.  What should I do with it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog2.angryviking.com/?feed=rss2&amp;p=19</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AVR Synthesizer</title>
		<link>http://www.blog2.angryviking.com/?p=18</link>
		<comments>http://www.blog2.angryviking.com/?p=18#comments</comments>
		<pubDate>Mon, 30 Mar 2009 01:31:06 +0000</pubDate>
		<dc:creator>Audin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[AVR]]></category>

		<guid isPermaLink="false">http://blog.angryviking.com/?p=5</guid>
		<description><![CDATA[So there are a couple AVR based synthesizers out there already.  But they are all either written in (ew) ASM or want to talk to SID chips (don&#8217;t own one) or are otherwise not interesting. So a couple months ago I got one of the AVR Pocket Piano shields from Critter and Guitari.  This is [...]]]></description>
			<content:encoded><![CDATA[<p>So there are a couple AVR based synthesizers out there already.  But they are all either written in (ew) ASM or want to talk to SID chips (don&#8217;t own one) or are otherwise not interesting.</p>
<p><a class="tt-flickr tt-flickr-Thumbnail" title="IMG_2605.JPG" href="http://www.flickr.com/photos/audin/3405312618/"><img class="alignright" src="http://farm4.static.flickr.com/3664/3405312618_be4b21ce78_t.jpg" alt="IMG_2605.JPG" width="100" height="75" /></a> So a couple months ago I got one of the AVR Pocket Piano shields from <a href="http://www.critterandguitari.com/home/store/arduino-piano.php">Critter and Guitari</a>.  This is an entertaining little <a href="http://www.arduino.cc/">Arduino</a> shield with 25 buttons, three sampled pots, a volume control, an LED, and a microchip 12-bit DAC.  There are a few firmwares around to help the thing make some interesting (or not) sounds.   However they are all quite limited.  And interest in the thing seems to have deteriorated.  I took the (to me) most interesting firmware, a monophonic 1 operator DDS FM synthesizer and promoted it to three voices.  However, only having three pots was cramping my &#8216;creativity&#8217;, so I needed to find something else.</p>
<p><a class="tt-flickr tt-flickr-Thumbnail" title="IMG_2602.JPG" href="http://www.flickr.com/photos/audin/3404500039/"><img class="alignnone" src="http://farm4.static.flickr.com/3658/3404500039_aaffa38cf8_t.jpg" alt="IMG_2602.JPG" width="100" height="75" /></a> <a class="tt-flickr tt-flickr-Thumbnail" title="IMG_2603.JPG" href="http://www.flickr.com/photos/audin/3405311706/"><img class="alignnone" src="http://farm4.static.flickr.com/3632/3405311706_2689a9f2a9_t.jpg" alt="IMG_2603.JPG" width="100" height="75" /></a> Then a couple weeks ago I saw mention of the newish KORG nanoKONTROLER series.  These are very small usb-midi controllers.  There are three: a keyboard, a controller, and a drum pad.  I went into Guitar Center to look at the keyboard and ended up walking out $120 poorer with both it and the controller.  The included software from KORG sucked but was good for one evening&#8217;s entertainment.  Then getting the linux synths like <a href="http://bristol.sourceforge.net/">bristol</a> kept me entertained for a few evenings more.</p>
<p>But then I was bored again.</p>
<p>So what to do?</p>
<p>If A is fun, and B is fun, then A+B must be superfun!  So I ended up with this pile of USB cables, some perl, and some more changes to the FM AVR code.  And ended up with this thing:</p>
<p><a class="tt-flickr tt-flickr-Small" title="IMG_2600.JPG" href="http://www.flickr.com/photos/audin/3404498771/"><img class="aligncenter" src="http://farm4.static.flickr.com/3661/3404498771_5f7ff76f19_m.jpg" alt="IMG_2600.JPG" width="240" height="180" /></a></p>
<p>Due to the extra controls, I was able to add a second FM operator and an LFO.  So you have three &#8216;true&#8217; sounds to play with, plus the LFO.</p>
<p>Like so:</p>
<ol>
<li>&#8216;carrier&#8217; frequency.  This is the key you hit and the setting of Slider 1.  Slider one is the pitch of the whole keyboard.</li>
<li>FM Modulator One. This is controlled by Slider and Knob 2 on the controller.  The slider is the amount of modulation, the knob is the frequency relative to the note being played.</li>
<li>FM Modulator Two.  Same as above.</li>
<li>PLUS the LFO goes just into the audible range if you bump it up that high.  It is controlled by Slider and Knob 9.</li>
</ol>
<p>Whew.</p>
<p>To make this simpler I went back to the original monophonic FM code.  At some point I will probably try to add back a second or third voice.  Though given the extra processing required for the second operator and the LFO, i&#8217;m not sure there is time available.</p>
<p>The AVR speaks a very limited dialect of MIDI.  I use a small perl program to shuffle midi data from the ALSA midi inputs (the AVR can&#8217;t talk straight to the USB midi devices, of course) to the AVR and also print out its console.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog2.angryviking.com/?feed=rss2&amp;p=18</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Prost!</title>
		<link>http://www.blog2.angryviking.com/?p=5</link>
		<comments>http://www.blog2.angryviking.com/?p=5#comments</comments>
		<pubDate>Mon, 30 Mar 2009 00:40:58 +0000</pubDate>
		<dc:creator>Audin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.angryviking.com/?p=3</guid>
		<description><![CDATA[Yes indeed, yet another blog which will never be updated ever again.]]></description>
			<content:encoded><![CDATA[<p>Yes indeed, yet another blog which will never be updated ever again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog2.angryviking.com/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
