<?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>MyDarkMaterials.co.uk &#187; Mac</title>
	<atom:link href="http://www.mydarkmaterials.co.uk/tag/mac/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mydarkmaterials.co.uk</link>
	<description></description>
	<lastBuildDate>Sat, 01 May 2010 12:49:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Window 7 Beta: Boot Camp &amp; VMware Fusion</title>
		<link>http://www.mydarkmaterials.co.uk/2009/01/window-7-beta-boot-camp-vmware-fusion/</link>
		<comments>http://www.mydarkmaterials.co.uk/2009/01/window-7-beta-boot-camp-vmware-fusion/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 21:14:11 +0000</pubDate>
		<dc:creator>Tinlad</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.mydarkmaterials.co.uk/?p=63</guid>
		<description><![CDATA[After reading various articles about Windows 7, curiosity got the better of me and I downloaded the beta from Microsoft. Since I have (nearly) sold my little gaming PC in anticipation of replacing it and my MacBook Pro with an iMac &#8230; <a href="http://www.mydarkmaterials.co.uk/2009/01/window-7-beta-boot-camp-vmware-fusion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After reading various articles about Windows 7, curiosity got the better of me and I <a title="Windows 7 Beta Download" href="http://www.microsoft.com/windows/windows-7/beta-download.aspx">downloaded the beta</a> from Microsoft. Since I have (nearly) sold my little gaming PC in anticipation of replacing it and my MacBook Pro with an iMac that can handle all my computing duties, I was also hoping that Windows 7 would be a good base for Steam and the associated games.</p>
<p>I followed the instructions I found on <a href="http://www.simplehelp.net/2009/01/15/using-boot-camp-to-install-windows-7-on-your-mac-the-complete-walkthrough/">Simple Help.net</a>, although there&#8217;s not much difference in installing Windows 7 than XP or Vista. Basically:</p>
<ol>
<li>Use Boot Camp Assistant to partition your drive (make sure you have a back-up first!).</li>
<li>When that&#8217;s done, insert the Windows 7 beta DVD and click &#8216;Start Installation&#8217;.</li>
<li>Format and install Windows to the drive that has &#8216;BOOTCAMP&#8217; next to it.</li>
<li>Let the installer do its thing.</li>
<li>When you&#8217;re at the Windows desktop, use Windows Update to get graphics drivers, etc. Sound probably won&#8217;t be working at this point.</li>
<li>Insert your Leopard installation DVD and install the drivers from there. Done.</li>
</ol>
<p>Assuming that all went well, you now have your Mac dual-booting with Windows 7. Hurrah.</p>
<p>I use VMware Fusion on my Mac to run various other operating systems, and it has a rather nifty feature whereby it can boot the operating system installed on your Boot Camp partition as a virtual machine. Very handy indeed, and I wanted to make use of this with Windows 7 so I could let Steam download game content without having to spend hours away from OS X.</p>
<p>Firing up Fusion, it detected the Boot Camp partition and without any setting up I could boot straight into Windows. Neat. On the first boot it detected and installed drivers for various (virtual) hardware devices and requested a restart. After that, I installed VMware Tools, which requires another restart. Finally, I have a working system. Or do I? No, because it hasn&#8217;t installed any drivers for the ethernet controller and as such has no network connectivity.</p>
<p>Googling yielded some results suggesting a similar problem can exist in Vista under VMware (not necessarily Fusion). The solution is to install the AMD PCnet drivers in the virtual machine; they can be found here: <a href="http://www.amd.com/us-en/ConnectivitySolutions/ProductInformation/0,,50_2330_6629_2452%5E2454%5E2486,00.html">AMD PCnet Windows Drivers</a>. Download the latest version (4.5.1) and transfer to the Windows 7 virtual machine (you can drag-and-drop the folder from OS X into the virtual machine if you have VMware Tools installed). Find the errant Ethernet Controller in Device Manger, right-click and select &#8216;Update Driver Software&#8217;. Point the driver wizard at the folder containing the AMD drivers and bingo. It should be recognised as an &#8216;AMD PCNET Family Ethernet Adapter (PCI)&#8217;, and we should now have Internets!</p>
<div id="attachment_66" class="wp-caption aligncenter" style="width: 400px"><img class="size-full wp-image-66 " title="Windows 7 Device Manager" src="http://www.mydarkmaterials.co.uk/wp-content/uploads/2009/01/win7devicemanager.gif" alt="Install the driver via the Device Manager" width="390" height="199" /><p class="wp-caption-text">Install the driver via the Device Manager</p></div>
<p>Performance inside the virtual machine isn&#8217;t great on my machine (2.0GHz Core Duo, 2GB RAM, of which I&#8217;ve given Windows 7 1GB), but it&#8217;s adequate for what I want it for. It certainly seems happier than Vista did when I tried it in a virtual machine, and it takes up far less space &#8211; 7.8GB with Boot Camp utilities, VMware Tools, Firefox and Steam (no games yet) installed. If I recall correctly, Vista was pushing 14GB on a fresh install alone.</p>
<div id="attachment_67" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.mydarkmaterials.co.uk/wp-content/uploads/2009/01/win7fusion.jpg"><img class="size-medium wp-image-67" title="Windows 7 beta in VMware Fusion" src="http://www.mydarkmaterials.co.uk/wp-content/uploads/2009/01/win7fusion-300x262.jpg" alt="Success." width="300" height="262" /></a><p class="wp-caption-text">Success.</p></div>
<p>I&#8217;ve yet to really give it a proper test run, but so far it seems like a nice improvement on Vista, which despite improving hugely since launch is still quite capable of making me want to tear all my body hair out. The interface looks smart, and the graphical effects are much more dignified. As much as I&#8217;m a Mac fan now, I really want Windows 7 to be a good OS. I doubt it&#8217;ll tempt me back to the fold, but without competition and choices life would be dull.</p>
<p>Plus, at the end of the day, I still need something to run Team Fortress 2 on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mydarkmaterials.co.uk/2009/01/window-7-beta-boot-camp-vmware-fusion/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Interfacing PHP with the Arduino (with a splash OS X)</title>
		<link>http://www.mydarkmaterials.co.uk/2008/11/interfacing-php-with-the-arduino/</link>
		<comments>http://www.mydarkmaterials.co.uk/2008/11/interfacing-php-with-the-arduino/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 18:29:25 +0000</pubDate>
		<dc:creator>Tinlad</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mydarkmaterials.co.uk/?p=16</guid>
		<description><![CDATA[A while ago I bought an Arduino Diecimila, which is an open-source electronics prototyping platform. It&#8217;s a very easy to use programmable micro-controller with a bevy of digital and analogue inputs and outputs. It is programmed via USB using the &#8230; <a href="http://www.mydarkmaterials.co.uk/2008/11/interfacing-php-with-the-arduino/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A while ago I bought an <a href="http://www.arduino.cc/">Arduino</a> Diecimila, which is an open-source electronics prototyping platform. It&#8217;s a very easy to use programmable micro-controller with a bevy of digital and analogue inputs and outputs. It is programmed via USB using the cross-platform Arduino software. The language is C-like with plenty of documentation available online. The Arduino appears to the OS as a serial device which makes two-way communication very easy indeed.</p>
<p>Whilst I really haven&#8217;t got a clue what I might use it for, I thought it would be cool if I could create a simple web-based system to control hardware attached to the Arduino. My server-side language of choice is PHP, so I looked for a way to allow it to send and receive data from a serial port. I didn&#8217;t have to look very far before I found the <a href="http://www.phpclasses.org/browse/package/3679.html">PHP Serial class</a>, which looked just the ticket. Unfortunately whilst it caters for Windows and Linux, it doesn&#8217;t work under OS X. Fortunately it was just a matter of adding a few more <em>else if</em>&#8216;s to allow for the slight differences in the way <em>stty</em> works in OS X.</p>
<p>I thought it would all be plain sailing from here, but this was not the case. The Diecimila resets whenever a serial connection is opened, so it can be ready to receive a new program. However this can be a problem; suppose I open a serial connection to the Arduino and tell it to light up an LED at 50% brightness. Then later I decide I want it at 100% brightness, so I open up a serial connection again, at which point the Arduino resets and the LED goes out. Not very desirable, and positively useless if the Arduino has been collecting data that you wanted to retrieve.</p>
<p>After some Googling it became apparent that I wasn&#8217;t the only one with this issue. Most suggestions were to either remove a <em>tiny</em> SMT capacitor from the board to permanently disable the auto-reset function, or to suppress the behaviour by disabling DTR (in Windows) or HUPCL (in *nix). That sounded better, so I tried it out. The commands required were:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">nhup <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">999</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>cu.usbserial-A7004WqM <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #c20cb9; font-weight: bold;">stty</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>cu.usbserial-A7004WqM <span style="color: #660033;">-hupcl</span></pre></div></div>

<p>Now, I&#8217;m no command-line/serial expert, so I only have the slightest understanding about what goes on when those two commands are run. What I do know is that it solves the problem <em>so long as the sleep process is still running</em>. It&#8217;s hardly an ideal solution (in my opinion). I suspect this might be a problem unique to OS X, as it seemed to work much better when I tried it in Debian.
</p>
<p>Then! I found a <a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213719666/28#28" >forum post</a> lurking at the bottom of a thread on the Arduino Forum. It suggests putting a 110 ohm resistor between the 5V and Reset pins, or a 47 ohm between the 3.3V and Reset pins. I had a 47 ohm resistor handy so I whacking it in there and lo! No more automatic resets. Brilliant. The post does go on to say that using the reset button with the 47 ohm resistor is place may be risky, so I&#8217;ll have to try and remember to remove it if I ever need to press it.</p>
<p>So now the PHP to Arduino link is useable. Here&#8217;s an example of some PHP code to send a character to the Arduino:</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #666666; font-style: italic;">//Include the PHP Serial class</span>
    <span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;php_serial.class.php&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//Define the serial port to use (in Windows something like 'COM1')</span>
    <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SERIALPORT'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/dev/cu.usbserial-A7004WqM'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//The character to send</span>
    <span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$serial</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> phpSerial<span style="color: #339933;">;</span> 
    <span style="color: #000088;">$serial</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">deviceSet</span><span style="color: #009900;">&#40;</span>SERIALPORT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$serial</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">deviceOpen</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
    <span style="color: #000088;">$serial</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sendMessage</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>&#8230; and an example of the Arduino code to interpret this and do something:</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
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> incomingByte <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> <span style="color: #666666; font-style: italic;">//Start serial connection, 9600 baud</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>
    <span style="color: #b1b100;">if</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> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        incomingByte <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>incomingByte <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            analogWrite<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">128</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Pin 9 to 50% if 0 received</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>incomingByte <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            analogWrite<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Pin 9 to 100% if 1 received</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This works brilliantly. With only slightly more complex code (thanks to <a href="http://principialabs.com/arduino-python-4-axis-servo-control/">a post on Principia Labs</a> for a great explanation on effective serial commands), and a bit of AJAXy goodness, I have something like this:</p>
<p>
    <object width="400" height="225" data="http://vimeo.com/moogaloop.swf?clip_id=2387120&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=2387120&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /></object>
</p>
<p>Now all I have to do if think of a use for it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mydarkmaterials.co.uk/2008/11/interfacing-php-with-the-arduino/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
<enclosure url="http://www.mydarkmaterials.co.uk/video/arduino/Arduino.mp4" length="5199166" type="audio/mp4" />
<enclosure url="http://www.mydarkmaterials.co.uk/video/arduino/Arduino.ogv" length="3916486" type="video/ogg" />
		</item>
	</channel>
</rss>
