<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Circuits@Home</title>
	
	<link>http://www.circuitsathome.com</link>
	<description>A Solder Joint</description>
	<lastBuildDate>Thu, 04 Mar 2010 23:24:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/chome" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="chome" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Next revision of USB Host Shield goes to production</title>
		<link>http://www.circuitsathome.com/mcu/arduino/next-revision-of-usb-host-shield-goes-to-production</link>
		<comments>http://www.circuitsathome.com/mcu/arduino/next-revision-of-usb-host-shield-goes-to-production#comments</comments>
		<pubDate>Mon, 01 Mar 2010 12:00:54 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[rev.1.2]]></category>
		<category><![CDATA[shield]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=2766</guid>
		<description><![CDATA[<p class="wp-caption-text">A panel of rev.1.21 shields</p>
<p>I&#8217;ve been working lately on improving manufacturability of my products. As a first result, I&#8217;m changing board revision of USB Host Shield to 1.21. The main difference between revisions 1.0 and 1.21 is  level converters and jumpers in SMT packages. Picture on the right shows the very first panel [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_2765" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/AUS_r121_panel.jpg"><img src="/wp/wp-content/uploads/AUS_r121_panel-288x216.jpg" alt="A panel of rev.1.21 shields" title="AUS_r121_panel" width="288" height="216" class="size-thumbnail wp-image-2765" /></a><p class="wp-caption-text">A panel of rev.1.21 shields</p></div>
<p>I&#8217;ve been working lately on improving manufacturability of my products. As a first result, I&#8217;m changing board revision of USB Host Shield to 1.21. The main difference between revisions 1.0 and 1.21 is  level converters and jumpers in SMT packages. Picture on the right shows the very first panel of rev.1.21 board fresh from the oven.</p>
<p>Functionally, the board is the same. However, schematic has changed a little in part where control signals go through level converters. Therefore, it is important to use the right schematic when troubleshooting or hacking the shield. <a href="/downloads">Downloads section</a> has been rearranged and documentation for both variants added and labeled. I also posted closeup pictures of new board in store listings for the shield and bare PCB. I still have several rev1.0 boards available, they should be all gone by the end of the week so when you buy a board this week, you may get an old version. If you have a preference, let me know.</p>
<p>Lastly, from now on USB Host Shields comes bundled with stackable headers, the famous 4uconn part numbers 18688 and 18689. &#8220;Bundled&#8221; here means that by default they come in a bag, un-soldered. However, if you prefer, I can solder them for you &#8211; send me an e-mail after the purchase stating that you&#8217;d like your headers soldered and indicate the direction, female or male side up.</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/arduino/next-revision-of-usb-host-shield-goes-to-production/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Repairing front panel buttons of Tektronix 7904 oscilloscope.</title>
		<link>http://www.circuitsathome.com/measurements/repairing-front-panel-buttons-of-tektronix-7904-oscilloscope</link>
		<comments>http://www.circuitsathome.com/measurements/repairing-front-panel-buttons-of-tektronix-7904-oscilloscope#comments</comments>
		<pubDate>Mon, 15 Feb 2010 13:00:50 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Measurements]]></category>
		<category><![CDATA[7904]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[front]]></category>
		<category><![CDATA[oscilloscope]]></category>
		<category><![CDATA[panel]]></category>
		<category><![CDATA[repair]]></category>
		<category><![CDATA[Tektronix]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=2705</guid>
		<description><![CDATA[<p class="wp-caption-text">Front panel interconnect board of Tektronix 7904</p>
I am a proud owner of several Tektronix 7000-series mainframes. Among them, 7904 500MHz 4-compartment oscilloscope is my bench workhorse. The screen is big enough, the bandwidth is adequate for majority of tasks I do, and absence of cooling fan makes it pleasantly quiet. In addition, the instrument [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_2704" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/7904_frontbutton_01.jpg"><img src="/wp/wp-content/uploads/7904_frontbutton_01-288x216.jpg" alt="Front panel interconnect board of Tektronix 7904" title="7904_frontbutton_01" width="288" height="216" class="size-thumbnail wp-image-2704" /></a><p class="wp-caption-text">Front panel interconnect board of Tektronix 7904</p></div><br />
I am a proud owner of several Tektronix 7000-series mainframes. Among them, 7904 500MHz 4-compartment oscilloscope is my bench workhorse. The screen is big enough, the bandwidth is adequate for majority of tasks I do, and absence of cooling fan makes it pleasantly quiet. In addition, the instrument is lightweight comparing to other 7000 mainframes and has legs mounted on the rear panel making it possible to put scope on the floor in a vertical position.</p>
<p>I became annoyed by malfunction of right buttons of both vertical and horizontal mode selectors (they failed to lock in place) and decided that my scope deserves some TLC. Besides fixing the buttons I also wanted to replace some dead illumination bulbs with LEDs. Mode switches are dual, with one switch in the pair dedicated to turning light bulb on/off. Bulbs are powered by 5V and dimming is implemented by means of two diode drops. So the 3V LED restricted to 10ma by a resistor shall work fine and even be able to dim a little. In addition, LED power is comsumption about 8% of a bulb.</p>
<p>The front panel buttons are mounted on a narrow PCB (called &#8220;A3- Front Panel Interconnect Board&#8221; in the service manual) running across the middle of the front panel. It can be easily accessed after removing side panels. There are several cables connected to the board on both sides, it is good idea to mark them before disconnecting. The title picture shows left side of the board (one close to horizontal bay &#8220;B&#8221;) with my marks on it. After pulling out cables I moved the PCB carefully towards the rear and to the side. The board bends easily and is somewhat accessible form the top of the instrument.</p>
<p>The button assembly is held in place by screws also used to mount upper plug-in guide bars in the plug-in compartment. Picture below shows location of the left ones (holding vertical mode buttons). After unscrewing four Phillips-head screws I pulled the vertical mode buttons out of the chassis, carefully guiding it around cables, structural members and dead mice.</p>
<p><span id="more-2705"></span></p>
<p><div id="attachment_2716" class="wp-caption aligncenter" style="width: 298px"><a href="/wp/wp-content/uploads/7904_frontbutton_02.jpg"><img src="/wp/wp-content/uploads/7904_frontbutton_02-288x216.jpg" alt="Screws holding vertical mode button block" title="7904_frontbutton_02" width="288" height="216" class="size-thumbnail wp-image-2716" /></a><p class="wp-caption-text">Screws holding vertical mode button block</p></div>
<p>It was discovered that the cause of button not locking was a piece of loose plastic getting in the way so after blowing some compressed air through switches and applying a drop of DeOxit the block was as good as new. Illumination bulb was produced from ordinary eBay variety 5mm white LED using Dremel tool. Pictures below show original and modified LEDs, and LED placement on the board. On a second picture, original bulb can be seen to the right of the LED.</p>
<div id="attachment_2717" class="wp-caption aligncenter" style="width: 298px"><a href="/wp/wp-content/uploads/7904_frontbutton_03.jpg"><img src="/wp/wp-content/uploads/7904_frontbutton_03-288x216.jpg" alt="LED shortened to fit" title="7904_frontbutton_03" width="288" height="216" class="size-thumbnail wp-image-2717" /></a><p class="wp-caption-text">LED shortened to fit</p></div>
<div id="attachment_2727" class="wp-caption aligncenter" style="width: 298px"><a href="/wp/wp-content/uploads/7904_frontbutton_04.jpg"><img src="/wp/wp-content/uploads/7904_frontbutton_04-288x216.jpg" alt="LED replacing light bulb in Tek 7904 vertical mode button block" title="7904_frontbutton_04" width="288" height="216" class="size-thumbnail wp-image-2727" /></a><p class="wp-caption-text">LED replacing light bulb in Tek 7904 vertical mode button block</p></div>
<p>Overal, I&#8217;m very pleased with this modification. The illumination is soft with slight bluish tint which, in my opinion, matches the aluminum faceplate better than &#8220;straw yellow&#8221; color of original bulbs. It also dims quite nicely with standard control illumination rotary switch of the instrument. I ran out of LEDs so I couldn&#8217;t replace all of the bulbs at once, but one day I will surely do this.</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/measurements/repairing-front-panel-buttons-of-tektronix-7904-oscilloscope/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>USB Cable of My Dreams</title>
		<link>http://www.circuitsathome.com/mcu/usb/usb-cable-of-my-dreams</link>
		<comments>http://www.circuitsathome.com/mcu/usb/usb-cable-of-my-dreams#comments</comments>
		<pubDate>Thu, 28 Jan 2010 17:31:45 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[USB]]></category>
		<category><![CDATA[bitscope]]></category>
		<category><![CDATA[cable]]></category>
		<category><![CDATA[isolator]]></category>
		<category><![CDATA[short]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=2603</guid>
		<description><![CDATA[<p class="wp-caption-text">USB A to B connectors back to back</p>
<p>USB isolation is good for you. Isolated DAC makes better sound, isolated oscilloscope produces cleaner trace, and making line voltage measurements with isolated instruments helps us live longer. However, USB isolation often comes with a cost of extra USB cable, which may become excessive if we take [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_2602" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/USB_Short_cable.jpg"><img src="/wp/wp-content/uploads/USB_Short_cable-288x216.jpg" alt="USB A to B connectors back to back" title="USB_Short_cable" width="288" height="216" class="size-thumbnail wp-image-2602" /></a><p class="wp-caption-text">USB A to B connectors back to back</p></div>
<p>USB isolation is good for you. Isolated DAC makes better sound, isolated oscilloscope produces cleaner trace, and making line voltage measurements with isolated instruments helps us live longer. However, USB isolation often comes with a cost of extra USB cable, which may become excessive if we take into account precious desk space taken by said cable, as well as time spent on finding and untangling it.</p>
<p>I made several attempts to build a short cable which would also be able to bear load of USB isolator. Finally, while searching for a source of PCB mounted USB male B-type connector, I found this little marvel on eBay.</p>
<p>There is not much to say about it. It is short rigid adapter with USB A-type connector on one end and B-type on the other. The following picture shows typical arrangement &#8211; USB isolator connected to my Bitscope with USB adapter holding isolator in the air.</p>
<p>Of course, this little adapter can be used for connecting many other devices. Another picture shows our beloved Arduino connected to a USB port of a laptop computer. Here the weak spot of the adapter is clearly seen &#8211; since A and B connectors are turned 180 degrees, connected device would be turned upside down. For isolator it doesn&#8217;t matter much; however, operating Arduino&#8217;s Reset button and connecting shields would be difficult.</p>
<p>Adapter is available from several sources on eBay. Prices vary from $0.90 to $2.00, often with free shipping. The search string is &#8220;USB 2.0 Male to Printer Scanner A-B Converter Adapter&#8221;. Enjoy!</p>
<p>Oleg.</p>
<table>
<tr>
<td>
<div id="attachment_2619" class="wp-caption aligncenter" style="width: 298px"><a href="/wp/wp-content/uploads/USB_Short_cable_Bscope.jpg"><img src="/wp/wp-content/uploads/USB_Short_cable_Bscope-288x216.jpg" alt="USB Isolator connected to Bitscope using short cable" title="USB_Short_cable_Bscope" width="288" height="216" class="size-thumbnail wp-image-2619" /></a><p class="wp-caption-text">USB Isolator connected to Bitscope using short cable</p></div>
</td>
<td>
<div id="attachment_2630" class="wp-caption aligncenter" style="width: 298px"><a href="/wp/wp-content/uploads/USB_Short_Cable_Arduino.jpg"><img src="/wp/wp-content/uploads/USB_Short_Cable_Arduino-288x216.jpg" alt="Using USB adapter to connect Arduino to a PC" title="USB_Short_Cable_Arduino" width="288" height="216" class="size-thumbnail wp-image-2630" /></a><p class="wp-caption-text">Using USB adapter to connect Arduino to a PC</p></div>
</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/usb/usb-cable-of-my-dreams/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 3</title>
		<link>http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-3</link>
		<comments>http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-3#comments</comments>
		<pubDate>Mon, 25 Jan 2010 19:00:10 +0000</pubDate>
		<dc:creator>I-Bot</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[MAX3421E]]></category>
		<category><![CDATA[PS3]]></category>
		<category><![CDATA[Wiimote]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=2473</guid>
		<description><![CDATA[<p class="wp-caption-text">Wiimote controller wit USB Host Shield</p>
<p>This is the third part of a series of articles written to describe development of interface between Arduino and popular game controllers using USB Host Shield. Previous parts:</p>

Part 1. Introduction
Part 2. PS3 controller interface

<p>Revision 0.4 &#8211; 13th January 2010</p>
<p>Part 3. Develop the Bluetooth USB and HCI interface used in [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_2370" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/HPIM1104web.jpg"><img src="/wp/wp-content/uploads/HPIM1104web-288x216.jpg" alt="Wiimote controller wit USB Host Shield" title="Wiimote" width="288" height="216" class="size-thumbnail wp-image-2370" /></a><p class="wp-caption-text">Wiimote controller wit USB Host Shield</p></div>
<p>This is the third part of a series of articles written to describe development of interface between Arduino and popular game controllers using USB Host Shield. Previous parts:</p>
<ul>
<li><a href="/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-1"><strong>Part 1. Introduction</strong></a></li>
<li><a href="/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-2"><strong>Part 2. PS3 controller interface</strong></a></li>
</ul>
<p><strong>Revision 0.4 &#8211; 13th January 2010</strong></p>
<p><strong>Part 3. Develop the Bluetooth USB and HCI interface used in the support of the Wiimote and PS3 game controller, and also some utilities needed to analyse and configure these devices.</strong></p>
<p><strong>1.        USB Interface</strong><br />
As before, we first look at the descriptors for the USB dongle using the <a href="http://github.com/ribbotson/USB-Host/blob/master/examples/USB_desc.pde">USB_Desc sketch</a>. The result is:</p>
<p><span id="more-2473"></span></p>
<pre>Start
Device descriptor:
Descriptor Length:    12
Descriptor type:      01
USB version:          0110
Device class:         E0
Device Subclass:      01
Device Protocol:      01
Max.packet size:      10
Vendor  ID:           0A12
Product ID:           0001
Revision ID:          0134
Mfg.string index:     00
Prod.string index:    00
Serial number index:  00
Number of conf.:      01
Configuration descriptor:
Total length:         006C
Num.intf:             02
Conf.value:           01
Conf.string:          00
Attr.:                80
Max.pwr:              32
Interface descriptor:
Intf.number:          00
Alt.:                 00
Endpoints:            03
Intf. Class:          E0
Intf. Subclass:       01
Intf. Protocol:       01
Intf.string:          00
Endpoint descriptor:
Endpoint address:     81
Attr.:                03
Max.pkt size:         0010
Polling interval:     01
Endpoint descriptor:
Endpoint address:     82
Attr.:                02
Max.pkt size:         0040
Polling interval:     00
Endpoint descriptor:
Endpoint address:     02
Attr.:                02
Max.pkt size:         0040
Polling interval:     00
Interface descriptor:
Intf.number:          01
Alt.:                 00
Endpoints:            02
Intf. Class:          E0
Intf. Subclass:       01
Intf. Protocol:       01
Intf.string:          00
Endpoint descriptor:
Endpoint address:     83
Attr.:                01
Max.pkt size:         0000
Polling interval:     01
Endpoint descriptor:
Endpoint address:     03
Attr.:                01
Max.pkt size:         0000
Polling interval:     01
Interface descriptor:
Intf.number:          01
Alt.:                 01
Endpoints:            02
Intf. Class:          E0
Intf. Subclass:       01
Intf. Protocol:       01
Intf.string:          00
Endpoint descriptor:
Endpoint address:     83
Attr.:                01
Max.pkt size:         0009
Polling interval:     01
Endpoint descriptor:
Endpoint address:     03
Attr.:                01
Max.pkt size:         0009
Polling interval:     01
Interface descriptor:
Intf.number:          01
Alt.:                 02
Endpoints:            02
Intf. Class:          E0
Intf. Subclass:       01
Intf. Protocol:       01
Intf.string:          00
Endpoint descriptor:
Endpoint address:     83
Attr.:                01
Max.pkt size:         0011
Polling interval:     01
Endpoint descriptor:
Endpoint address:     03
Attr.:                01
Max.pkt size:         0011
Polling interval:     01
</pre>
<p>The device descriptor is straight forward, but the configuration descriptor shows two interfaces and the second interface has alternate settings. The usage of the different endpoints is described here: <a href="http://www.bluetooth.com/NR/rdonlyres/24C24181-5B5D-4566-BB4F-D4C302910B9D/1766/usbncb.pdf">Bluetooth Endpoint Usage</a></p>
<p>The second interface (interface one) is used for isochronous bandwidth related to carrying voice channels and we do not use this for Bluetooth HID, so they will be ignored.</p>
<p>We have four endpoints to consider:</p>
<p>The control endpoint (endpoint 0): This is used to send control messages and HCI commands.</p>
<p>The interrupt endpoint (endpoint 0&#215;81): Where HCI events are received from the USB dongle.</p>
<p>The input endpoint (endpoint 0x 82): The bulk endpoint where ACL reports are received from the connected Bluetooth device.</p>
<p>The output endpoint (endpoint 0&#215;02): The bulk endpoint where ACL reports are sent to the connected Bluetooth device.</p>
<p>These four endpoints discovered are registered as pipes to the USB Host library.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">  <span style="color: #808080; font-style: italic;">/* Initialize data structures for endpoints of device 1*/</span>
    ep_record<span style="color: #009900;">&#91;</span> CONTROL_PIPE <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span> Usb.<span style="color: #202020;">getDevTableEntry</span><span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">0</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;">//copy endpoint 0 parameters</span>
    ep_record<span style="color: #009900;">&#91;</span> EVENT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">epAddr</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x01</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Bluetooth event endpoint</span>
    ep_record<span style="color: #009900;">&#91;</span> EVENT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">Attr</span>  <span style="color: #339933;">=</span> EP_INTERRUPT<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> EVENT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">MaxPktSize</span> <span style="color: #339933;">=</span> INT_MAXPKTSIZE<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> EVENT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">Interval</span>  <span style="color: #339933;">=</span> EP_POLL<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> EVENT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">sndToggle</span> <span style="color: #339933;">=</span> bmSNDTOG0<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> EVENT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">rcvToggle</span> <span style="color: #339933;">=</span> bmRCVTOG0<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAIN_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">epAddr</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x02</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Bluetooth data endpoint</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAIN_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">Attr</span>  <span style="color: #339933;">=</span> EP_BULK<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAIN_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">MaxPktSize</span> <span style="color: #339933;">=</span> BULK_MAXPKTSIZE<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAIN_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">Interval</span>  <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAIN_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">sndToggle</span> <span style="color: #339933;">=</span> bmSNDTOG0<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAIN_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">rcvToggle</span> <span style="color: #339933;">=</span> bmRCVTOG0<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAOUT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">epAddr</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x02</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Bluetooth data endpoint</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAOUT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">Attr</span>  <span style="color: #339933;">=</span> EP_BULK<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAOUT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">MaxPktSize</span> <span style="color: #339933;">=</span> BULK_MAXPKTSIZE<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAOUT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">Interval</span>  <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAOUT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">sndToggle</span> <span style="color: #339933;">=</span> bmSNDTOG0<span style="color: #339933;">;</span>
    ep_record<span style="color: #009900;">&#91;</span> DATAOUT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">rcvToggle</span> <span style="color: #339933;">=</span> bmRCVTOG0<span style="color: #339933;">;</span>
    Usb.<span style="color: #202020;">setDevTableEntry</span><span style="color: #009900;">&#40;</span> BT_ADDR<span style="color: #339933;">,</span> ep_record <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The VID and the PID of the Bluetooth dongle should be checked to ensure compatibility. The CSR is the only dongle currently supported, but others have been found compatible and may be added later.<br />
The device is configured and the interface 0 then set. At this stage we have communication with the Bluetooth dongle and can now start to communicate over Bluetooth.</p>
<p><strong>2.	Listen while we talk</strong><br />
We are now in a position to send HCI commands to the Bluetooth dongle over the control pipe, but first need to set up a process to read the interrupt pipe regularly. The events received on the interrupt pipe may not be directly related to the commands sent, so they must be processed as they arrive. As the USB host, we control the data transfers; we do not have to buffer large amounts of data, we only pull over the pipe what we can handle at any time.  Also in the spirit of our “reduced host” for both USB and Bluetooth, we do no have to process all of the 36 possible events in the Bluetooth specification; we process only the ones we need for each application and ignore the rest. Significant events are communicated to the higher level routines through a set of flags.<br />
We also commence reading the ACL input endpoint in case ACL events are ready there too. These are ignored until connection is made, but are read in case they block HCI events.<br />
At this stage we handle only these HCI events:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define EV_COMMAND_COMPLETE  0x0e</span>
<span style="color: #339933;">#define EV_COMMAND_STATUS    0x0f</span>
<span style="color: #339933;">#define EV_CONNECT_COMPLETE  0x03</span>
<span style="color: #339933;">#define EV_DISCONNECT_COMPLETE 0x05</span>
<span style="color: #339933;">#define EV_NUM_COMPLETE_PKT  0x13</span>
<span style="color: #339933;">#define EV_INQUIRY_COMPLETE  0x01</span>
<span style="color: #339933;">#define EV_INQUIRY_RESULT    0x02</span>
<span style="color: #339933;">#define EV_REMOTE_NAME_COMPLETE  0x07</span>
<span style="color: #339933;">#define EV_INCOMING_CONNECT  0x04</span>
<span style="color: #339933;">#define EV_ROLE_CHANGED  0x12</span></pre></div></div>

<p>And we use these flags:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* HCI event flags*/</span>
<span style="color: #339933;">#define HCI_FLAG_CMD_COMPLETE 0x01</span>
<span style="color: #339933;">#define HCI_FLAG_CMD_STATUS 0x02</span>
<span style="color: #339933;">#define HCI_FLAG_CONN_COMPLETE 0x04</span>
<span style="color: #339933;">#define HCI_FLAG_DISCONN_COMPLETE 0x08</span>
<span style="color: #339933;">#define HCI_FLAG_CONNECT_OK 0x10</span>
<span style="color: #339933;">#define HCI_FLAG_INQUIRY_COMPLETE 0x20</span>
<span style="color: #339933;">#define HCI_FLAG_REMOTE_NAME_COMPLETE 0x40</span>
<span style="color: #339933;">#define HCI_FLAG_INCOMING_REQUEST 0x80</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Macros for event flag tests</span>
<span style="color: #339933;">#define hci_cmd_complete (hci_event_flag &amp;amp; HCI_FLAG_CMD_COMPLETE)</span>
<span style="color: #339933;">#define hci_cmd_status (hci_event_flag &amp;amp; HCI_FLAG_CMD_STATUS)</span>
<span style="color: #339933;">#define hci_connect_complete (hci_event_flag &amp;amp; HCI_FLAG_CONN_COMPLETE)</span>
<span style="color: #339933;">#define hci_disconnect_complete (hci_event_flag &amp;amp; HCI_FLAG_DISCONN_COMPLETE)</span>
<span style="color: #339933;">#define hci_connect_ok (hci_event_flag &amp;amp; HCI_FLAG_CONNECT_OK)</span>
<span style="color: #339933;">#define hci_inquiry_complete (hci_event_flag &amp;amp; HCI_FLAG_INQUIRY_COMPLETE)</span>
<span style="color: #339933;">#define hci_remote_name_complete (hci_event_flag &amp;amp; HCI_FLAG_REMOTE_NAME_COMPLETE)</span>
<span style="color: #339933;">#define hci_incoming_connect_request (hci_event_flag &amp;amp; HCI_FLAG_INCOMING_REQUEST)</span></pre></div></div>

<p><strong>3.	Sending HCI Commands</strong></p>
<p>To send HCI commands such as HCI reset we send a class specific output via the control pipe</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// used in control endpoint header for HCI Commands</span>
<span style="color: #339933;">#define bmREQ_HCI_OUT  USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE</span>
<span style="color: #339933;">#define HCI_COMMAND_REQ    0  </span>
<span style="color: #993333;">void</span> hci_reset<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   hci_event_flag <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// clear all the flags</span>
   buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x03</span><span style="color: #339933;">;</span>
   buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x0c</span><span style="color: #339933;">;</span>
   buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">;</span>
   HCI_Command<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">3</span> <span style="color: #339933;">,</span> buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//perform HCI Command</span>
byte HCI_Command<span style="color: #009900;">&#40;</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> nbytes<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span> dataptr <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    hci_command_packets<span style="color: #339933;">--;</span> 
    hci_event_flag <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;=</span> ~HCI_FLAG_CMD_COMPLETE<span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span> Usb.<span style="color: #202020;">ctrlReq</span><span style="color: #009900;">&#40;</span> BT_ADDR<span style="color: #339933;">,</span> ep_record<span style="color: #009900;">&#91;</span> CONTROL_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">epAddr</span><span style="color: #339933;">,</span> bmREQ_HCI_OUT<span style="color: #339933;">,</span> HCI_COMMAND_REQ<span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span> <span style="color: #339933;">,</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> nbytes<span style="color: #339933;">,</span> dataptr <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>4.	Bluetooth HCI Utility</strong><br />
Our first sketch to access the Bluetooth dongle will be a utility to gather data from the Bluetooth dongle itself and also to make Bluetooth inquires and connections. The sketch is structured as a state machine to maintain non blocking behavior and so enable the event task to run regularly. The <a href="http://github.com/ribbotson/USB-Host/blob/master/examples/Blueutils.pde">blueutils sketch</a> is loaded into the Arduino, and a CSR bluetooth dongle connected to the USB shield. Running the sketch returns the following over the serial port:</p>
<pre>
freeMemory() reports:   1513
CSR Initialized
HCI Reset complete
ACL Data Packet Length: 672
SCO Data Packet Length: 48
Total ACL Data Packets: 4
Total SCO Data Packets: 1
HCI Version:            3
HCI Revision:           3164
LMP Version:            3
Manufacturer Id:        10
LMP Subversion:         3164
Local Name:
Local Bluetooth Address:  00158316C075
Search for devices
Search complete
Devices Found :         0
Wait for Incoming Connect Request</pre>
<p>This confirms we are talking to the dongle and gives useful information especially the bluetooth address hardcoded into the dongle.</p>
<p><strong>5.	Connecting Wiimote Game Controller</strong><br />
The connection process is different for the Wiimote and the PS3, so we will look at these in turn.</p>
<p>The wiimote has two methods of connection know as soft connect and hard connect. We look at the soft connect mode here. In soft connect mode a connection is made from the Arduino to the Wiimote, and to enable this the Bluetooth address of the wiimote must be discovered. </p>
<p>The blueutils sketch is run again, and when the message comes on the serial port of &#8220;Search for devices&#8221;, the &#8220;1&#8243; and &#8220;2&#8243; buttons on the Wiimote are pressed simultaneously. The search will take about 10 seconds and at the end return something similar to:</p>
<pre>
freeMemory() reports: 1513
CSR Initialized
HCI Reset complete
ACL Data Packet Length: 672
SCO Data Packet Length: 48
Total ACL Data Packets: 4
Total SCO Data Packets: 1
HCI Version:            3
HCI Revision:           3164
LMP Version:            3
Manufacturer Id:        10
LMP Subversion:         3164
Local Name:
Local Bluetooth Address:  00158316C075
Search for devices
Search complete
Devices Found :         1
Found BDADDR: 0022AA8A06A3  Class:  042500  Mode: 1 Offset: 69C9 

Remote Name:  0 Nintendo RVL-CNT-01
Connected to device
</pre>
<p>Here the Arduino has found the Wiimote and used the discovered Bluetooth Address to make a connection to it.</p>
<p><strong>6.	Connecting PS3 Game Controller</strong><br />
The PS3 Game Controller connection process is the other way round. The PS3 controller make the connection to the Arduino. The PS3 controller does not respond to requests for inquiry or connection.</p>
<p>To initate the connection the PS3 controller needs to know the Bluetooth Address of the Arduino. MotioninJoy can be used to set a USB dongle address into the PS3 contoller or alternatively sixpair.c under linux. These read the USB dongle bluetooth address and set this into the PS3 controller.</p>
<p>Since we know the Arduino Bluetooth address from the utility above &#8220;Local Bluetooth Address:	00158316C075&#8243; and we have ability using <a href="http://github.com/ribbotson/USB-Host/blob/master/examples/PS3LCD.pde">PS3LCD</a> or the <a href="http://github.com/ribbotson/USB-Host/tree/master/ps3/">PS3 library</a> to set the host Bluetooth Address, we can also use that method.</p>
<p>When the PS3 is programmed with the correct USB dongle Bluetooth address, the following is dsplayed when the &#8220;PS&#8221; buuton on the PS3 Game Controler is pressed at the &#8220;Wait for Incoming Connect Request&#8221; prompt.</p>
<pre>
freeMemory() reports:   1513
CSR Initialized
HCI Reset complete
ACL Data Packet Length: 672
SCO Data Packet Length: 48
Total ACL Data Packets: 4
Total SCO Data Packets: 1
HCI Version:            3
HCI Revision:           3164
LMP Version:            3
Manufacturer Id:        10
LMP Subversion:         3164
Local Name:
Local Bluetooth Address:  00158316C075
Search for devices
Search complete
Devices Found :         0
Wait for Incoming Connect Request
Connected to device</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-3/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 2</title>
		<link>http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-2</link>
		<comments>http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-2#comments</comments>
		<pubDate>Wed, 20 Jan 2010 19:00:38 +0000</pubDate>
		<dc:creator>I-Bot</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[MAX3421E]]></category>
		<category><![CDATA[PS3]]></category>
		<category><![CDATA[Wiimote]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=2385</guid>
		<description><![CDATA[<p class="wp-caption-text">Sony PS3 controller</p>
<p>This is the second part of a series of articles written to describe development of interface between Arduino and popular game controllers using USB Host Shield. Previous parts:</p>

Part 1. Introduction

<p>Revision 0.6 &#8211; 13th January 2010</p>
<p>Part 2: Develop the USB interface to the PS3 controller</p>
<p>1.       USB Reduced Hosts</p>
<p>Full USB hosts such as Windows [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_2366" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/HPIM1095web.jpg"><img src="/wp/wp-content/uploads/HPIM1095web-288x216.jpg" alt="Sony PS3 controller" title="Sony_PS3_Controller" width="288" height="216" class="size-thumbnail wp-image-2366" /></a><p class="wp-caption-text">Sony PS3 controller</p></div>
<p>This is the second part of a series of articles written to describe development of interface between Arduino and popular game controllers using USB Host Shield. Previous parts:</p>
<ul>
<li><a href="/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-1"><strong>Part 1. Introduction</strong></a></li>
</ul>
<p><strong>Revision 0.6 &#8211; 13th January 2010</strong></p>
<p><strong>Part 2: Develop the USB interface to the PS3 controller</strong></p>
<p><strong>1.       </strong><strong>USB Reduced Hosts</strong></p>
<p>Full USB hosts such as Windows and Linux based computers can manage a large variety of different USB devices and load appropriate USB drivers for each device. There is an enumeration or discovery phase where the host gathers information on the attached USB device and uses this information for the driver selection and configuration. In small embedded applications this is not possible or required to support this variety, so the application usually only supports a few devices, often only one. This means the discovery process can be much reduced since the results are already known. This will reduce the memory required for the application by hard coding the device configuration into the application.</p>
<p>Though the configuration will be hard coded, we still need to initially gather the information from the device itself and other sources.</p>
<p>The existing device drivers mentioned above for Windows and Linux are important in our development process. The Windows drivers are usually complete, but not available in source form. Linux drivers are available in source form, though not always as complete. Device manufacturers are usually very reluctant to provide information required to build a driver or embedded application. So we rely on copying Linux code or “sniffing” Windows code to give us guidance.</p>
<p><span id="more-2385"></span></p>
<p> <strong>2.       </strong><strong> PS3 Game Controller USB Interface</strong></p>
<p>The first thing is to get the device and configuration descriptors. This may be documented, but often not, so we will collect direct from the USB device itself. This may be done under Windows using a program such as USBView or using the Arduino and the host shield.</p>
<p>Using USBView: <a href="http://www.ftdichip.com/Resources/Utilities/usbview.zip">USBView Software</a></p>
<p>The PS3 controller is connected to the PC and then selected in USBView. The following descriptor information is delivered for the Sony PS3 controller when connected via USB.</p>
<pre>
Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:       0x00
bDeviceSubClass:    0x00
bDeviceProtocol:    0x00
bMaxPacketSize0:    0x40 (64)
idVendor:           0x054C (Sony Corporation)
idProduct:          0x0268
bcdDevice:          0x0100
iManufacturer:      0x01
iProduct:           0x02
iSerialNumber:      0x00
bNumConfigurations: 0x01
ConnectionStatus:   DeviceConnected
Current Config Value: 0x01
Device Bus Speed:   Full
Device Address:     0x01
Open Pipes:         2
Endpoint Descriptor:
bEndpointAddress:   0x02
Transfer Type:      Interrupt
wMaxPacketSize:     0x0040 (64)
bInterval:          0x01
Endpoint Descriptor:
bEndpointAddress:   0x81
Transfer Type:      Interrupt
wMaxPacketSize:     0x0040 (64)
bInterval:          0x01
</pre>
<p>The report shows two additional endpoints besides the control endpoint (endpoint 0). The first of these is an input endpoint (0&#215;02) and is where the host will receive reports from the PS3 game controller when anything changes. The second (0&#215;81) is an output endpoint and is where the host can send reports to the PS3 controller, though these can also be sent via special messages on the control endpoint 0.</p>
<p>Taking the same report for the Madcatz PS3 shows that it also has almost identical information. It also shows with identical idVendor and idProduct. The only difference is in the MaxPacketSize0 which is 8 for the Madcatz. This difference is managed automatically by the USB library.</p>
<p>To read the device and configuration descriptors using the Arduino, we install the USB Host Shield and download the following <a href="http://github.com/ribbotson/USB-Host/blob/master/examples/USB_desc.pde">USB_Desc sketch</a>. The sketch uses this <a href="http://github.com/ribbotson/USB-Host/tree/master/usb_host/">Modified USB Host Library</a>. The library was modified from the version from Oleg to give a longer time for the device to deliver the descriptors. However in the non blocking code we need later, we also need sometimes not to wait at all. Therefore an additional change is made to allow for waiting or not.</p>
<p>The sketch reports the following descriptors with a bit more detail:</p>
<pre>
Start
freeMemory() reports 683
Device descriptor:
Descriptor Length:    12
Descriptor type:      01
USB version:          0200
Device class:         00
Device Subclass:      00
Device Protocol:      00
Max.packet size:      40
Vendor  ID:           054C
Product ID:           0268
Revision ID:          0100
Mfg.string index:     01
Prod.string index:    02
Serial number index:  00
Number of conf.:      01
Configuration descriptor:
Total length:         0029
Num.intf:             01
Conf.value:           01
Conf.string:          00
Attr.:                80
Max.pwr:              FA
Interface descriptor:
Intf.number:          00
Alt.:                 00
Endpoints:            02
Intf. Class:          03
Intf. Subclass:       00
Intf. Protocol:       00
Intf.string:          00
Unknown descriptor:
Length:               09
Type:                 21
Contents:             110100012294000705
Endpoint descriptor:
Endpoint address:     02
Attr.:                03
Max.pkt size:         0040
Polling interval:     01
Endpoint descriptor:
Endpoint address:     81
Attr.:                03
Max.pkt size:         0040
Polling interval:     01
memoryMin() reports 336
</pre>
<p>Also here you see the reports from freeMemory and memoryMin(), which for this example were added to check the memory consumption of the USB stack. These are not usually present in the report. There is also an unknown report which is a class report for the HID device. The large difference between freeMemory and memoryMin in this example is due to a 256 byte buffer being defined for the configuration data plus there is also about 100 bytes of stack in data memory used by the USB library. The text strings were moved to program memory with a special print function, otherwise it would not fit into the available data memory of an ATMega168.</p>
<p> <br />
<strong>3.           Configuring the USB library to connect the PS3 game Controller</strong></p>
<p>Having obtained the descriptor information, this is coded into the USB configuration of the USB library. The library requires a structure for each endpoint to contain this data and this structure is then provided to the library using the Usb.setDevTableEntry() function. </p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Endpoint information structure               */</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* bToggle of endpoint 0 initialized to 0xff    */</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* during enumeration bToggle is set to 00      */</span>
&nbsp;
<span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span> <span style="color: #009900;">&#123;</span>       
&nbsp;
    byte epAddr<span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">//copy from endpoint descriptor without bit 7 if set</span>
&nbsp;
    byte Attr<span style="color: #339933;">;</span>          <span style="color: #666666; font-style: italic;">// Endpoint transfer type.</span>
&nbsp;
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> MaxPktSize<span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Maximum packet size.</span>
&nbsp;
    byte Interval<span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// Polling interval in frames.</span>
&nbsp;
    byte sndToggle<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">//last toggle value, bitmask for HCTL toggle bits</span>
&nbsp;
    byte rcvToggle<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">//last toggle value, bitmask for HCTL toggle bits</span>
&nbsp;
<span style="color: #009900;">&#125;</span> EP_RECORD<span style="color: #339933;">;</span></pre></div></div>

<p>We then also make a check to confirm that the device connected is the one which we support by checking the VID and PID in the device descriptor.If this is successful we set the configuration for the device and then we have three pipes connected to the PS3 device from the Arduino and communication is established.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">device_descriptor <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>USB_DEVICE_DESCRIPTOR <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>buf<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>
&nbsp;
    <span style="color: #009900;">&#40;</span>device_descriptor<span style="color: #339933;">-&gt;</span>idVendor <span style="color: #339933;">!=</span> PS3_VID<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span>device_descriptor<span style="color: #339933;">-&gt;</span>idProduct <span style="color: #339933;">!=</span> PS3_PID<span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Unsupported USB Device&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</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;">//stop  </span></pre></div></div>

<p> <strong>4.        Communication with the Game controller from a sketch</strong></p>
<p>Having established communication we now have to send commands and receive reports in the format the PS3 game controller requires. This format is somewhat described in the documents mentioned in the first article and emulated in the software for linux and python. This information was probably obtained from “sniffing” the interaction of the game controller to a PS3. I do have a USB sniffer from Ellisys which could connect between a PS3 and the controller, but I do not have a PS3. So I relied on published information and also “sniffed” the connection between the game controller and a PC running the Motioninjoy software.</p>
<p>Motioninjoy is probably the most complete PC application to support the PS3 controller so should offer the best information. To sniff the connection I used a PC based program called <a href="http://sourceforge.net/projects/usbsnoop/">SnoopyPro</a></p>
<p>Between the setting of the configuration and the receipt of data on the input pipe , there are two commands sent to the PS3 game controller. The first sets the game controller to send 01 type reports to the input pipe whenever any changes occur on the controller.<br />
<span style="color: #800080">SetupPacket:<br />
0000: 21 09 f4 03 00 00 04 00<br />
bmRequestType: 21<br />
DIR: Host-To-Device<br />
TYPE: Class<br />
RECIPIENT: Interface<br />
bRequest: 09<br />
TransferBuffer: 0&#215;00000004 (4) length<br />
0000: 42 0c 00 00</span></p>
<p>This can be performed using the USB library by:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define PS3_F4_REPORT_LEN 4</span>
<span style="color: #339933;">#define HID_REPORT_FEATURE 3</span>
<span style="color: #339933;">#define PS3_F4_REPORT_ID  0xF4</span>
prog_char feature_F4_report<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> PROGMEM <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #208080;">0x42</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x0c</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">/* Set the PS3 controller to send reports */</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</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>PS3_F4_REPORT_LEN<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> buf<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> pgm_read_byte_near<span style="color: #009900;">&#40;</span> feature_F4_report <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    rcode <span style="color: #339933;">=</span> Usb.<span style="color: #202020;">setReport</span><span style="color: #009900;">&#40;</span> PS3_ADDR<span style="color: #339933;">,</span> ep_record<span style="color: #009900;">&#91;</span> CONTROL_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">epAddr</span><span style="color: #339933;">,</span> PS3_F4_REPORT_LEN<span style="color: #339933;">,</span>  PS3_IF<span style="color: #339933;">,</span> HID_REPORT_FEATURE<span style="color: #339933;">,</span> PS3_F4_REPORT_ID <span style="color: #339933;">,</span> buf <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> rcode <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;">&quot;Set report error: &quot;</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> rcode<span style="color: #339933;">,</span> HEX <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</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;">//stop</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Here the report content was held in program memory.</p>
<p>The second command packet is not essential, but sets the LEDs on the game controller so that it stops flashing and goes to light LED 1 constantly. This command is developed later to control all the LED and rumble. </p>
<p><span style="color: #800080">SetupPacket:</span></p>
<p><span style="color: #800080">0000: 21 09 01 02 00 00 30 00</span></p>
<p><span style="color: #800080">bmRequestType: 21</span></p>
<p><span style="color: #800080">  DIR: Host-To-Device</span></p>
<p><span style="color: #800080">  TYPE: Class</span></p>
<p><span style="color: #800080">  RECIPIENT: Interface</span></p>
<p><span style="color: #800080">bRequest: 09 </span></p>
<p><span style="color: #800080">TransferBuffer: 0&#215;00000030 (48) length</span></p>
<p><span style="color: #800080">0000: 00 ff 00 ff 00 00 00 00 00 02 ff 27 10 00 32 ff</span></p>
<p><span style="color: #800080">0010: 27 10 00 32 ff 27 10 00 32 ff 27 10 00 32 00 00</span></p>
<p><span style="color: #800080">0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00</span></p>
<p>This can be performed using the USB library by: </p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define PS3_01_REPORT_LEN 48</span>
<span style="color: #339933;">#define HID_REPORT_OUTPUT  2</span>
<span style="color: #339933;">#define PS3_01_REPORT_ID  0x01</span>
prog_char output_01_report<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> PROGMEM <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span>
                                     <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x02</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xff</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x27</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x10</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x32</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xff</span><span style="color: #339933;">,</span>
                                     <span style="color: #208080;">0x27</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x10</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x32</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xff</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x27</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x10</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span>
                                     <span style="color: #208080;">0x32</span><span style="color: #339933;">,</span> <span style="color: #208080;">0xff</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x27</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x10</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x32</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span>
                                     <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span>
                                     <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x00</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #808080; font-style: italic;">/* Set the PS3 controller LED 1 On */</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</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>PS3_01_REPORT_LEN<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> buf<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> pgm_read_byte_near<span style="color: #009900;">&#40;</span> output_01_report <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    rcode <span style="color: #339933;">=</span> Usb.<span style="color: #202020;">setReport</span><span style="color: #009900;">&#40;</span> PS3_ADDR<span style="color: #339933;">,</span> ep_record<span style="color: #009900;">&#91;</span> CONTROL_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">epAddr</span><span style="color: #339933;">,</span> PS3_01_REPORT_LEN<span style="color: #339933;">,</span>  PS3_IF<span style="color: #339933;">,</span> HID_REPORT_OUTPUT<span style="color: #339933;">,</span> PS3_01_REPORT_ID <span style="color: #339933;">,</span> buf <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> rcode <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;">&quot;Set report error: &quot;</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> rcode<span style="color: #339933;">,</span> HEX <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</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;">//stop</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>01 type reports can now be read from the input pipe using: </p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Poll PS3 interrupt pipe and process result if any */</span>
&nbsp;
<span style="color: #993333;">void</span> PS3_poll<span style="color: #009900;">&#40;</span> <span style="color: #993333;">void</span> <span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #009900;">&#123;</span>
    byte rcode <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">//return code</span>
    <span style="color: #808080; font-style: italic;">/* poll PS3 */</span>
    rcode <span style="color: #339933;">=</span> Usb.<span style="color: #202020;">inTransfer</span><span style="color: #009900;">&#40;</span>PS3_ADDR<span style="color: #339933;">,</span> ep_record<span style="color: #009900;">&#91;</span> INPUT_PIPE <span style="color: #009900;">&#93;</span>.<span style="color: #202020;">epAddr</span><span style="color: #339933;">,</span> PS3_01_REPORT_LEN<span style="color: #339933;">,</span> buf <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> rcode <span style="color: #339933;">!=</span> <span style="color: #0000dd;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    process_report<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p> </p>
<p><strong>5.        Interpreting and using PS3 reports</strong></p>
<p>The 01 type reports are formatted as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Structure which describes the type 01 input report</span>
<span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> ReportType<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">//Report Type 01</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> Reserved1<span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// Unknown</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span>  ButtonState<span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Main buttons</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PSButtonState<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// PS button</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> Reserved2<span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// Unknown</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> LeftStickX<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// left Joystick X axis 0 - 255, 128 is mid</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> LeftStickY<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// left Joystick Y axis 0 - 255, 128 is mid</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> RightStickX<span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// right Joystick X axis 0 - 255, 128 is mid</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> RightStickY<span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// right Joystick Y axis 0 - 255, 128 is mid</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> Reserved3<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Unknown</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureUp<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// digital Pad Up button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureRight<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// digital Pad Right button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureDown<span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// digital Pad Down button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureLeft<span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// digital Pad Left button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureL2<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// digital Pad L2 button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureR2<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// digital Pad R2 button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureL1<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// digital Pad L1 button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureR1<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// digital Pad R1 button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureTriangle<span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// digital Pad Triangle button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureCircle<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// digital Pad Circle button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureCross<span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// digital Pad Cross button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> PressureSquare<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// digital Pad Square button Pressure 0 - 255</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> Reserved4<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Unknown</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> Charge<span style="color: #339933;">;</span>         <span style="color: #666666; font-style: italic;">// charging status ? 02 = charge, 03 = normal</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> Power<span style="color: #339933;">;</span>          <span style="color: #666666; font-style: italic;">// Battery status ?</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> Connection<span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// Connection Type ?</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> Reserved5<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Unknown</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> AccelerometerX<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// X axis accelerometer Big Endian 0 - 1023</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> Accelero         <span style="color: #666666; font-style: italic;">// Y axis accelerometer Big Endian 0 - 1023</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> AccelerometerZ<span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Z axis accelerometer Big Endian 0 - 1023</span>
    <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> GyrometerX<span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// Z axis Gyro Big Endian 0 - 1023</span>
&nbsp;
<span style="color: #009900;">&#125;</span> TYPE_01_REPORT<span style="color: #339933;">;</span></pre></div></div>

<p> </p>
<p>The state of the game controller buttons is contained in the ButtonState and PSButtonState variables mapped as follows: </p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define buSelect    (PS3Report-&gt;ButtonState &amp; 0x0001)</span>
<span style="color: #339933;">#define buLAnalog   (PS3Report-&gt;ButtonState &amp; 0x0002)</span>
<span style="color: #339933;">#define buRAnalog   (PS3Report-&gt;ButtonState &amp; 0x0004)</span>
<span style="color: #339933;">#define buStart     (PS3Report-&gt;ButtonState &amp; 0x0008)</span>
<span style="color: #339933;">#define buUp        (PS3Report-&gt;ButtonState &amp; 0x0010)</span>
<span style="color: #339933;">#define buRight     (PS3Report-&gt;ButtonState &amp; 0x0020)</span>
<span style="color: #339933;">#define buDown      (PS3Report-&gt;ButtonState &amp; 0x0040)</span>
<span style="color: #339933;">#define buLeft      (PS3Report-&gt;ButtonState &amp; 0x0080)</span>
<span style="color: #339933;">#define buL2        (PS3Report-&gt;ButtonState &amp; 0x0100)</span>
<span style="color: #339933;">#define buR2        (PS3Report-&gt;ButtonState &amp; 0x0200)</span>
<span style="color: #339933;">#define buL1        (PS3Report-&gt;ButtonState &amp; 0x0400)</span>
<span style="color: #339933;">#define buR1        (PS3Report-&gt;ButtonState &amp; 0x0800)</span>
<span style="color: #339933;">#define buTriangle  (PS3Report-&gt;ButtonState &amp; 0x1000)</span>
<span style="color: #339933;">#define buCircle    (PS3Report-&gt;ButtonState &amp; 0x2000)</span>
<span style="color: #339933;">#define buCross     (PS3Report-&gt;ButtonState &amp; 0x4000)</span>
<span style="color: #339933;">#define buSquare    (PS3Report-&gt;ButtonState &amp; 0x8000)</span>
<span style="color: #339933;">#define buPS        (PS3Report-&gt;PSButtonState &amp; 0x01)</span></pre></div></div>

<p>  </p>
<p>The Accelerometer and Gyro values are in Big Endian format and need byte swapping before use as an unsigned integer value.</p>
<p>The following example program shows how the values can be used from the report. The example used the LCD display connected to the USB Host Shield. The example also controls the LED and rumble motors. This example does not use the library described below. <a href="http://github.com/ribbotson/USB-Host/blob/master/examples/PS3LCD.pde">PS3 LCD sketch</a>.</p>
<p>A menu item is provided in the example to read and set the Bluetooth Device Address of the Game controller. This is used in the pairing process for the game controller when in Bluetooth mode. This setup can alternatively be done with sixpair.c under linux, or Motioninjoy under windows.</p>
<p><strong>6.        A PS3 Game Controller Library</strong></p>
<p>The PS3_USB library adds support for the Sony PS3 Game controller to the Arduino by USB cable on the USB Host Shield from Circuits@Home. It allows a sketch to gather information from the PS3 Game Controller including buttons, joysticks and accelerometers. It also allows output to the LED and rumble features of the Game controller. Additional function is provided to read and write Bluetooth addresses for pairing in Bluetooth mode.</p>
<p>The library requires the USB Host Shield to be installed and uses the libraries developed for the shield, it is not compatible with other USB ports at present. The shield and the libraries do consume memory considerable resources on the Arduino; though they can be supported on most Arduino variants even the ATMega168 based boards with 1K of RAM.</p>
<p><strong>Connections:</strong><br />
The USB Host shield is assembled and links configures depending on the Arduino variant used. The shield supports 3.3V and 5V Arduino in different configurations. The GPIO connections are not required by this library, but another library MaxLCD exists to support an optional LCD display on this interface if required. The USB Host shield uses digital pins D7 through D13 and these pins are not available to the sketch for other purposes. Power for the USB device is derived from the Arduino, so sufficient power must be provide from the USB or external power supply.<br />
The Sony PS3 Game controller is connected by USB cable to the USB A connector on the host shield. The library is tested with the Sony Controller PS3 Game controller and also the Madcatz wireless PS3 game controller which is wireless connected from the game controller to a Madcatz USB dongle. The Madcatz does not support the rumble feature.</p>
<p><strong>Methods:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A method to perform low level initialisation of the PS3 class, should be called in the setup() function to perform hardware initialisation of the USB Host Shield before calling task().</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> task<span style="color: #009900;">&#40;</span> <span style="color: #993333;">void</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method must be called regularly to manage the all events occurring on the USB port. Calls to this routine should be made in the range of once per millisecond to 20 times per second. The report data from the PS3 Game Controller will not be available if this routine is not called regularly.</em><em></em></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> getStatus<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method returns an unsigned character to show the status of the USB and PS3 connection. Bits are used as follows:<br />
bit 0: statusDeviceConnected Set when a USB device is plugged into the USB port on the Host Shield<br />
bit 1: statusUSBConfigured Set when a valid PS3 device is detected and configured<br />
bit 2: statusPS3Connected Set when the PS3 device is connected and sending reports based on changes on the controller (buttons pressed, joystick moved,..)<br />
bits 3: statusReportReceived Set when a report is received from the PS3 controller that a change has occurred on one of the parameters. This bit is cleared by the stat_report_received() method;</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">bool statConnected<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method returns the state of the statusPS3Connected bit for the attached device.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">bool statReportReceived<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method returns the state of the statusReportReceived bit for the attached device. Calling this method also clears the bit if set.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">bool buttonChanged<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method returns true if a Game Controller button has been pressed or released, since the last call to this method.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">bool buttonPressed<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> button<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method returns the state of the Game Controller button specified in the call. True if button pressed. Buttons are:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define buSelect 0</span>
<span style="color: #339933;">#define buLAnalog 1</span>
<span style="color: #339933;">#define buRAnalog 2</span>
<span style="color: #339933;">#define buStart 3</span>
<span style="color: #339933;">#define buUp 4</span>
<span style="color: #339933;">#define buRight 5</span>
<span style="color: #339933;">#define buDown 6</span>
<span style="color: #339933;">#define buLeft 7</span>
<span style="color: #339933;">#define buL2 8</span>
<span style="color: #339933;">#define buR2 9</span>
<span style="color: #339933;">#define buL1 10</span>
<span style="color: #339933;">#define buR1 11</span>
<span style="color: #339933;">#define buTriangle 12</span>
<span style="color: #339933;">#define buCircle 13</span>
<span style="color: #339933;">#define buCross 14</span>
<span style="color: #339933;">#define buSquare 15</span>
<span style="color: #339933;">#define buPS 16</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> LEDRumble<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> ledrum<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method sets the state of the LEDs and rumble motors on the Game Controller. Ledrum values are:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define psLED1 0x01</span>
<span style="color: #339933;">#define psLED2 0x02</span>
<span style="color: #339933;">#define psLED3 0x04</span>
<span style="color: #339933;">#define psLED4 0x08</span>
<span style="color: #339933;">#define psRumbleHigh 0x10</span>
<span style="color: #339933;">#define psRumbleLow 0x20</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> getMotion<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> accel<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method returns the value read from the accelerometer or Gyro in the Game Controller. Values are in range 0 to 1023 with 512 as centre. Accel values are:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define AccelerometerX 0</span>
<span style="color: #339933;">#define AccelerometerY 1</span>
<span style="color: #339933;">#define AccelerometerZ 2</span>
<span style="color: #339933;">#define GyrometerZ 3</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> getJoystick<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> joystick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method returns the value read from the joystick on the Game Controller. Values are in range 0 to 255. Joystick values are:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define leftJoystickX 0</span>
<span style="color: #339933;">#define leftJoystickY 1</span>
<span style="color: #339933;">#define rightJoystickX 2</span>
<span style="color: #339933;">#define rightJoystickY 3</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> getPressure<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> button<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method returns the value read for the button pressure on the Game Controller. Values are in range 0 to 255. Button values are:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define buUp 4</span>
<span style="color: #339933;">#define buRight 5</span>
<span style="color: #339933;">#define buDown 6</span>
<span style="color: #339933;">#define buLeft 7</span>
<span style="color: #339933;">#define buL2 8</span>
<span style="color: #339933;">#define buR2 9</span>
<span style="color: #339933;">#define buL1 10</span>
<span style="color: #339933;">#define buR1 11</span>
<span style="color: #339933;">#define buTriangle 12</span>
<span style="color: #339933;">#define buCircle 13</span>
<span style="color: #339933;">#define buCross 14</span>
<span style="color: #339933;">#define buSquare 15</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> setBDADDR<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span> bdaddr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method sets the master Bluetooth address to the PS3 Game Controller. The master Bluetooth address is the address where the Game controller will attempt to make a Bluetooth connection when pairing. Bdaddr[6] is a six unsigned char array containing the Bluetooth address with least significant byte first.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> getBDADDR<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span> bdaddr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This method gets the master Bluetooth address in the PS3 Game Controller. The master Bluetooth address is the address where the Game controller will attempt to make a Bluetooth connection when pairing. Bdaddr[6] is a six unsigned char array containing the Bluetooth address with least significant byte first.</p>
<p><strong>Memory usage:</strong><br />
The library is fairly complex and takes about 5000 bytes of program memory depending on the methods actually used. Due to the complexity and data buffers the data memory usage is about 350 bytes. Since no warning is generated at compile time of data memory usage, care should be taken to monitor and manage consumption. MemoryFree() can be used to check data memory usage. While this fits onto the AtMega168, it may be better to use a larger device if additional code/libraries are complex or if a large number of serial.print() functions are used.</p>
<p><strong>Example sketch:</strong><br />
The <a href="http://github.com/ribbotson/USB-Host/blob/master/ps3/examples/PS3servo.pde">test sketch</a> included in the download demonstrates many of the capabilities of the library.<br />
<a href="http://github.com/ribbotson/USB-Host/tree/master/ps3/">Get Arduino PS3 Library here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PS3 and Wiimote Game Controllers on the Arduino Host Shield: Part 1</title>
		<link>http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-1</link>
		<comments>http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-1#comments</comments>
		<pubDate>Thu, 14 Jan 2010 16:16:37 +0000</pubDate>
		<dc:creator>I-Bot</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[MAX3421E]]></category>
		<category><![CDATA[PS3]]></category>
		<category><![CDATA[Wiimote]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=2354</guid>
		<description><![CDATA[<p><p class="wp-caption-text">Bluetooth</p>
Revision 0.9 – 13th January 2010</p>
<p>Part 1: Introduction</p>
<p>1.       Background
These articles describe how to interface PS3 and Wiimote game controllers directly onto the Arduino using the USB Host Shield. These controllers have not previously been directly connected to an Arduino due to the USB and Bluetooth interfaces and protocols used, and their relative complexity. The [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_2363" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/HPIM1103web.jpg"><img src="/wp/wp-content/uploads/HPIM1103web-288x216.jpg" alt="Bluetooth" width="288" height="216" class="size-thumbnail wp-image-2363" /></a><p class="wp-caption-text">Bluetooth</p></div><br />
<strong>Revision 0.9 – 13th January 2010</strong></p>
<p><strong>Part 1: Introduction</strong></p>
<p><strong>1.       </strong><strong>Background</strong><br />
These articles describe how to interface PS3 and Wiimote game controllers directly onto the Arduino using the USB Host Shield. These controllers have not previously been directly connected to an Arduino due to the USB and Bluetooth interfaces and protocols used, and their relative complexity. The game controllers are a good match to the capabilities of the Arduino, and to the imagination of Arduino users, they have not only buttons and joysticks, but also motion sensing, and other goodies which deserve to be in the hands and ideas of Arduino users. Also I hope these articles provide some guidance for people to develop other USB host and Bluetooth applications for small embedded processors.<br />
Arduino already comes in versions which have USB and Bluetooth interfaces, but these are not suitable for our chosen game controllers. When used in USB mode, the PS3 controller is a USB device and needs to talk to a USB host. The normal Arduino USB interface is also a device, so not compatible. When in Bluetooth mode, both of these game controllers use the Bluetooth HID protocol and this is not compatible with the commonly used Bluetooth modules which support only the RFCOMM Serial Port Protocol. Arduino users have successfully used a PC as an intermediary between the game controllers and the Arduino, so the PC is host to both devices.</p>
<p>These articles were written by Richard who is new to the Arduino, blogs, github, libraries, etc, so please give me any help and feedback on how I might improve or correct these articles and software.</p>
<p><span id="more-2354"></span></p>
<p>This video shows the PS3 controller and the Wiimote bluetooth working on the basic Atmega168 Arduino.<br />
<a href='http://www.youtube.com/watch?v=cYcp4gfRY_A'>Introduction Youtube Video</a></p>
<p>Recently a new Arduino shield has been developed by Oleg here at Circuits@Home, which provides a USB host interface directly onto the Arduino. This shield is based on the MAX3421E USB controller IC from Maxim, which can operate in both device and host modes. Oleg has also created libraries for the basic functions of the MAX3421E and USB host operation. I have previously used the MAX3421E with success on other processors and decided to try to add support for our game controllers using this shield. There are significant challenges to this due to the complexity of the protocols and the limited flash and SRAM space on the base Atmega168 based Arduino.</p>
<p>The code developed here is licensed under the LGPL License and should be fairly easy to port to other USB host controllers. Given the recent explosion in availability of microcontrollers with integrated USB OTG or reduced host, from Atmel, Microchip and others, then I would expect quite a few derived versions.</p>
<p>You will see as the code develops the fairly high complexity of the protocols involved, and such development effort is only really justified in a case like this where no off the shelf alternative has been found. There are integrated USB host solutions from GHI Electronics and FTDI Vinculum, but these again do not support the Bluetooth HID yet. They do support many other devices and classes including mass storage, serial, and HID, they can be interfaced to Arduino and do not put such a drain on the memory and programming of the Arduino.</p>
<p><strong>2.       </strong><strong>The PS3 Controller</strong></p>
<p><img class="alignnone size-full wp-image-2366" src="/wp/wp-content/uploads/HPIM1095web.jpg" alt="Sony PS3 Controller" width="640" height="482" /><br />
I have used two PS3 different game controllers; the first is a Sony Six Axis Dual Shock 3 Wireless controller, and the second is the Madcatz Wireless six axis controller. The Sony has a USB connector and also operates in Bluetooth mode for wireless. The Madcatz comes with its own USB dongle, so uses a proprietary wireless protocol instead of Bluetooth. The PS3 controller is well documented and supported already with drivers and applications on Windows and Linux besides the PS3 itself, so there is plenty of interface information available.<br />
<img class="alignnone size-full wp-image-2365" src="/wp/wp-content/uploads/HPIM1096web.jpg" alt="Madcatz PS3 Controller" width="640" height="482" /><br />
 </p>
<p>The PS3 controller has a large number of buttons which can be read as digital values and some as analog pressure values. There are two joysticks which can be read with analog values to 8 bit resolution, and also 4 LED’s which can be remotely controlled. There are additionally a 3 axis accelerometer and a single axis gyro which give outputs based on the motion of the controller. The Sony controller additionally has two rumble motors.</p>
<p>The following sources have been used to find information and code examples for the PS3 controllers:</p>
<p><a href="http://wiki.ps2dev.org/ps3:hardware:sixaxis">PS3 Wiki General</a></p>
<p><a href="http://python-ps3.svn.sourceforge.net/viewvc/python-ps3/bootable/sixaxis/connection.c?view=markup">PS3 using Python</a></p>
<p><a href="http://www.pabr.org/sixlinux/sixlinux.en.html">PS3 under Linux</a></p>
<p><a href="http://onakasuita.org/ps3">SixAxis on Windows</a></p>
<p><a href="http://www.motioninjoy.com/">PS3 Windows Driver</a></p>
<p><strong>3.       </strong><strong>Wiimote Controller</strong></p>
<p><img class="alignnone size-full wp-image-2370" src="/wp/wp-content/uploads/HPIM1104web.jpg" alt="Wiimote" width="640" height="482" /><br />
 </p>
<p>The Wiimote has less buttons than the PS3 controller and the characteristic stick shape. Though less well endowed with buttons and joysticks than the PS3 controller it has a 3 axis accelerometer, rumble, Infra-Red Camera, speaker and LED. It also has an expansion port where additional devices including 3 axis Gyro and remote joystick can be connected.</p>
<p>The Wiimote does not have a direct USB connection and only works under Bluetooth.</p>
<p>The following sources have been used to find information and code examples for the Wiimote Controllers:</p>
<p><a href="http://en.wikipedia.org/wiki/Wiimote">Wiimote Wiki General</a></p>
<p><a href="http://homepage.mac.com/ianrickard/wiimote/wiili_wimote.html">Wiimote Information</a></p>
<p><a href="http://wiibrew.org/wiki/Wiimote">Wiimote Wiki: Detail</a></p>
<p><a href="http://libwiimote.sourceforge.net/">Wiimote using Linux</a></p>
<p><strong>4.       </strong><strong>Arduino</strong></p>
<p>I chose to use the lowest spec AtMega168 based Arduino and this forced me to be always conscious of the amount of Flash and data memory used. I made extensive use of the MemoryFree library to keep track of the usage of the 1K of RAM. I tried to limit were possible the number and size of data buffers, and to keep the number of text strings as low as possible.</p>
<p><a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213583720;start=all">Original MemoryFree</a></p>
<p>I later modified MemoryFree to allow capture and storage of minimum values. This enables the viewing of free memory at the deepest level of the function calls, where any problems occur.</p>
<p><a href="http://github.com/ribbotson/USB-Host/tree/master/Memory_Free/">Modified MemoryFree</a></p>
<p> <br />
In terms of processing power the Arduino does not seem to limit performance. Some complexity is added to the code because it is necessary to avoid blocking code. Blocking code would prevent some of the background processes running. These processes are not absolutely time critical, but must be called regularly. The time taken to write a serial string is usually OK, the time to wait for a key press would not be.</p>
<p> </p>
<p><strong>5.       </strong><strong>USB  Host Shield</strong></p>
<p>The Circuits at Home USB host shield is based on the Maxim MAX3421E USB controller IC. This IC can operate in device and host modes, though the Arduino library only supports the host mode. The USB host shield offers a number of interface options for different Arduino types using 3.3V or 5V power supplies. There is also two 8 bit GPIO ports and a library to support an LCD display on this port.</p>
<p>The <a href="/category/mcu/usb">USB Host Shield</a> is described and well documented here on the Circuits@Home website.</p>
<p>Full construction information is provided including schematic and PCB layout, or PCB and built boards are available in the on-line store.</p>
<p>The USB shield uses the following Arduino hardware resources which are then not available for other purposes:<br />
Digital Pin 7 used for MAX_RESET<br />
Digital Pin 8 used for GPX<br />
Digital Pin 9/PWM used for INT<br />
Digital Pin 10/PWM used for SS<br />
Digital Pin 11/PWM used for MOSI<br />
Digital Pin 12 used for MISO<br />
Digital Pin 13/LED used for SCLK</p>
<p>Power for the USB host shield is taken from the Arduino and also powers the USB device. Care must be taken to ensure the total supply current required is available from the Arduino and its power source.</p>
<p>The MAX3421 is documented in Datasheets, programming guide, and application notes by Maxim:</p>
<p><a href="http://www.ghielectronics.com/downloads/general/MAX3421E.pdf">MAX3421E Datasheet</a></p>
<p><a href="http://www.hdl.co.jp/ftpdata/utl-001/AN3785.pdf">MAX3421E Programming Guide</a></p>
<p><a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3639/t/do">Maxim Application Notes</a></p>
<p>Oleg at Circuits@Home has provided Arduino libraries for the MAX3421E function and the USB host function. Small modifications were necessary in these to support the game controllers, mainly in the NAK handling to ensure non blocking behaviour. The changes should not interfere with existing applications using the libraries and may be incorporated to the standard library.</p>
<p><a href="http://github.com/felis/USB_Host_Shield">USB Host Shield Library</a></p>
<p>The library is based on code from Maxim for the ARM processor, but this original code is not complete:</p>
<p><a href="http://www.maxim-ic.com/tools/evkit/index.cfm?EVKit=623">Original Maxim ARM Code</a></p>
<p>USB is a complex protocol and even though much is done automatically by the MAX3421E, some knowledge of the USB protocol is needed. As primers, these are good sources:</p>
<p><a href="http://www.beyondlogic.org/usbnutshell/usb-in-a-nutshell.pdf">USB in a Nutshell</a></p>
<p><a href="http://www.beyondlogic.org/usbnutshell/usb1.htm">USB Standards</a></p>
<p>After that the best references are the USB protocol specifications:</p>
<p><a href="http://www.usb.org/developers/docs/usb_20_052709.zip">USB Specification</a></p>
<p><a href="http://www.usb.org/developers/hidpage/">USB HID Specifications</a></p>
<p><strong>6.       </strong><strong>Bluetooth Dongles</strong></p>
<p>Bluetooth USB dongles come from many suppliers and there is no way to support them all in a simple embedded application. I have used devices which are based on the Cambridge Silicon Radio(CSR) Bluecore 4. These devices are common and low cost at less than $5 each. The dongle is used is based on the BC41B143A chip. The data sheet is here:</p>
<p><a href="http://pdf1.alldatasheet.com/datasheet-pdf/view/114802/ETC/BC41B143A-ANN-E4.html">BC41B143A Datasheet</a></p>
<p>The dongle conforms to the Bluetooth specification for an HCI interface and is available here:</p>
<p><a href="http://www.bluetooth.com/NR/rdonlyres/1F6469BA-6AE7-42B6-B5A1-65148B9DB238/840/Core_v210_EDR.zip">Bluetooth 2.0 Specification</a></p>
<p><a href="http://www.bluetooth.com/NR/rdonlyres/0BE438ED-DC1B-41D1-AAC0-1AAA956097A2/980/HID_SPEC_V10.pdf">Bluetooth HID Specification</a></p>
<p>The dongle used came packaged like this:<br />
<img class="alignnone size-medium wp-image-2359" src="/wp/wp-content/uploads/HPIM1107-637x480.jpg" alt="Bluetooth USB Dongle" width="637" height="480" /><br />
 <br />
A more general Bluetooth protocol tutorial is available from <a href="http://www.palowireless.com/infotooth/tutorial.asp">palowireless.</a></p>
<p><strong>7.       </strong><strong>My Development Process and Following Articles</strong></p>
<p>I decided to split the development and these articles into the following steps:</p>
<p><a href="/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-2"><strong>Part 2:</strong></a> Develop the USB interface to the PS3 controller. This allowed me to gain experience of the Arduino and the USB shield. It also provides a quick working wireless solution using the Madcatz game controller.</p>
<p><a href="/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-3"><strong>Part 3:</strong></a> Develop the Bluetooth USB and HCI interface used in the support of the Wiimote and PS3 game controller, and also some utilities needed to analyse and configure these devices.</p>
<p><strong>Part 4:</strong> Develop the Wiimote support over Bluetooth</p>
<p><strong>Part 5:</strong> Develop the PS3 support over Bluetooth</p>
<p> <br />
<strong>This article is provided under the </strong><a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Share Alike License</a></p>
<p><strong>Associated software code developed by the author is licensed under the </strong><a href="http://www.gnu.org/licenses/licenses.html">LGPL License</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/programming/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-1/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Trigger probe amplifier</title>
		<link>http://www.circuitsathome.com/measurements/trigger-probe-amplifier</link>
		<comments>http://www.circuitsathome.com/measurements/trigger-probe-amplifier#comments</comments>
		<pubDate>Fri, 08 Jan 2010 00:48:24 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[DC-DC]]></category>
		<category><![CDATA[Measurements]]></category>
		<category><![CDATA[amplifier]]></category>
		<category><![CDATA[inductor]]></category>
		<category><![CDATA[probe]]></category>
		<category><![CDATA[schematic]]></category>
		<category><![CDATA[SMPS]]></category>
		<category><![CDATA[trigger]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1621</guid>
		<description><![CDATA[<p class="wp-caption-text">Magnetic probe amplifier connected</p>
Recently, I was researching low-noise DC-DC converters and while reading Linear Technology Application Note 70 found this clever and useful circuit, designed by Jim Williams.  The idea is to sense current in power inductor of the converter with another inductor, placed within short distance from the first one. The sensing [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_2131" class="wp-caption alignright" style="width: 226px"><a href="/wp/wp-content/uploads/mag_probe_amp_connected.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/mag_probe_amp_connected-288x216.jpg" alt="Magnetic probe amplifier connected" title="mag_probe_amp_connected" width="216" height="288" class="size-thumbnail wp-image-2131" /></a><p class="wp-caption-text">Magnetic probe amplifier connected</p></div><br />
Recently, I was researching low-noise DC-DC converters and while reading Linear Technology<a href="http://www.linear.com/pc/downloadDocument.do?navId=H0,C1,C1003,C1040,C1130,P1535,D4159"> Application Note 70</a> found this clever and useful circuit, designed by Jim Williams.  The idea is to sense current in power inductor of the converter with another inductor, placed within short distance from the first one. The sensing inductor is connected to a circuit which amplifies and conditions the signal and generates nice clean square wave pulses which can be used to trigger oscilloscope sweep. The probe is isolated from the circuit preventing measurement corruption. As a bonus, analog output of probe amplifier allows observing current waveform through power inductor. </p>
<p>As is often the case with application notes, circuit description and build details are somewhat brief; I&#8217;m posting my notes hoping that the information will be helpful for other builders. Also, since <a href="http://www.batchpcb.com">BatchPCB</a> doubled my order, I have extra PCBs; if anyone wants to build this circuit on a professionally made PCB with just couple green wires, <a href="mailto:mazurov@circuitsathome.com">e-mail me</a> &#8211; the PCB can be yours for the price of postage.</p>
<p><span id="more-1621"></span></p>
<p>To get detailed information about the circuit operation please read the application note. Circuit description starts at page 37. </p>
<p>Some parts used in the original circuit are hard to impossible to find.  J.W. Miller #100267 inductor specified in the application note is no longer available. I tried several different 1mH inductors &#8211; they all worked.  My favorite one is Xicon 434-1120-103K, available through Mouser. The axial construction makes it easy to solder to a cable and it can also be conveniently placed inside a piece of copper pipe to make probe more directional.</p>
<p>CA3096 transistor array was discontinued long time ago. I substituted it with Fairchild FMB3904 and FMB3906. While not a matched pairs, they perform well. Philips makes pin-compatible matched variant of those parts, I&#8217;m planning to try it in next revision of the board to see if it makes any difference.</p>
<p>I also made some minor changes to the schematic, mostly to clarify things. <a href="/chome_downloads/Mag_probe_amp_r01.zip">Project files</a> are available from downloads section. This is a preliminary version &#8211; I&#8217;m planning to re-route the board to make it easier to fit on oscilloscope&#8217;s external trigger connector. As you can see on a title picture, analog out (lower left BNC connector, the shiny one) is unusable unless external trigger input connector is placed in the corner of oscilloscope&#8217;s front panel, like on this Tektronix 475A.</p>
<p>Also on a title page you can see probe compensation box. Luckily for me I had one from old times &#8211; the new ones, available from several parts distributors are ridiculously expensive. Buying old probe from eBay and cannibalizing it for its comp box would be much more economical. Don&#8217;t expect using the cable attached to the comp box though since it&#8217;s not a regular coax and won&#8217;t work. Another good source for small metal boxes with BNC connectors is used RF measurement equipment section on eBay.</p>
<p>Last piece of the setup &#8211; power to the amplifier, can be provided in many ways.  The easiest is to utilize 5V provided by Tektronix oscilloscope probe power connector.  Wall warts work well too.</p>
<p>Using the probe is simple. First, connect analog output to 50ohm oscilloscope input with attenuator set to 0.5V/div and digital output to oscilloscope external trigger input. Place probe inductor in the vicinity of the power inductor and observe current waveform. Adjust spacing to get good peak-to-peak amplitude without clipping. Check your digital output &#8211; you should see 5V p-p square-wave signal in phase with input signal crossing the midpoint. You now can use the digital output to trigger the &#8217;scope while observing output noise of the converter ( which, if your converter is good is too weak and fuzzy to give a good trigger ). </p>
<p><div id="attachment_2132" class="wp-caption alignleft" style="width: 298px"><a href="/wp/wp-content/uploads/mprobe_far.jpg"><img src="/wp/wp-content/uploads/mprobe_far-288x216.jpg" alt="Probe Placement" title="Probe Placement" width="288" height="216" class="size-thumbnail wp-image-2132" /></a><p class="wp-caption-text">Probe Placement</p></div>
<p>The probe is quite sensitive. Picture to the left shows typical placement. Little test fixture clamped in the Irvin clamp holds a DC-DC converter. The probe is placed on the right &#8211; it&#8217;s blue 1mH inductor held in alligator clip. The power inductor is on the left side of the converter&#8217;s board. The distance is about 1.5cm and circuit performs very well; in fact, this is the closest distance when probe signal passes first stage without clipping. It has to be noted also that the power inductor is of pot core variety and therefore radiates very weak field.</p>
<p>Of course, the probe amplifier can be used to condition not only inductor output but any other signal which won&#8217;t overload the input stage. Upper frequency limit is approximately 120MHz. I highly recommend building this circuit and playing with it &#8211; it is a useful aid to many common types of oscilloscope measurements.</p>
<p>Oleg. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/measurements/trigger-probe-amplifier/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hook up PS3 controller to USB Host shield</title>
		<link>http://www.circuitsathome.com/mcu/programming/hook-up-ps3-controller-to-usb-host-shield</link>
		<comments>http://www.circuitsathome.com/mcu/programming/hook-up-ps3-controller-to-usb-host-shield#comments</comments>
		<pubDate>Thu, 03 Dec 2009 00:38:22 +0000</pubDate>
		<dc:creator>I-Bot</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[embedded]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[MAX3421E]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=2037</guid>
		<description><![CDATA[<p class="wp-caption-text">PS3 controller connected to Arduino USB Host Shield</p>
<p>Another HID example has been added to Github repository of USB Host Shield for Arduino (which you can purchase in my store) . Richard Ibbotson sent me this nice piece of code along with some pictures. He also posted a  short description of his sketch in [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_2040" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/PS3_AUSB_01_RI.jpg"><img src="/wp/wp-content/uploads/PS3_AUSB_01_RI-288x216.jpg" alt="PS3 controller connected to Arduino USB Host Shield" title="PS3_AUSB_01_RI" width="288" height="216" class="size-thumbnail wp-image-2040" /></a><p class="wp-caption-text">PS3 controller connected to Arduino USB Host Shield</p></div>
<p>Another <a href="http://github.com/felis/USB_Host_Shield/blob/master/examples/PS3LCD.pde">HID example</a> has been added to Github repository of <a href="/category/mcu/arduino/usb-shield">USB Host Shield for Arduino</a> (which you can <a href="/products-page/arduino-shields/usb-host-shield-for-arduino/">purchase</a> in my store) . Richard Ibbotson sent me this nice piece of code along with some pictures. He also posted a <a href="/mcu/programming/usb-host-shield-in-the-store/comment-page-1#comment-3570"> short description</a> of his sketch in comments section:</p>
<blockquote><p>
I wrote a sketch for the interface of the PS3 controller over USB. I have two controllers, one Sony and one Madcatz wireless with a USB dongle. Both of these work fine to the USB host shield. I only made one minor change to the library to increase the NAK count. The sketch tests all the function, buttons, joysticks, accelerometer/gyro, leds and rumble. This is not yet under bluetooth just USB. I can set the host bluetooth adddress on the controller though which is needed for bluetooth pairing.</p>
<p>Did not make much attempt to reduce code or data size, so only have about 4K of program space and 240 bytes of data space left, but sketch is pretty long. The actual PS3 part is very small and could be made to a small library.</p>
<p>Next is to move to the bluetooth part, from what I have found on the direct USB, I am pretty confident this will fit even on the 168.
</p></blockquote>
<p>PS3 controller support opens some very interesting possibilities. Not only can it be used as a normal &#8220;joystick plus buttons&#8221; type of control, but you can also utilize it&#8217;s accelerometer/gyro. With wireless variant of the controller all kinds of very powerful radio control are possible. Who is going to be the first to make a mechanical dog, which follows you around and brings back the controller when you throw it away?</p>
<p>If you want to try the sketch, make sure you have <a href="http://github.com/felis/USB_Host_Shield">the latest library code</a> as well &#8211; there are some small but important changes made recently in NAK handling.</p>
<table>
<tr>
<td>
<div id="attachment_2041" class="wp-caption alignleft" style="width: 298px"><a href="/wp/wp-content/uploads/PS3_AUSB_02_RI.jpg"><img src="/wp/wp-content/uploads/PS3_AUSB_02_RI-288x216.jpg" alt="MadCatz wireless controller to USB Host Shield" title="PS3_AUSB_02_RI" width="288" height="216" class="size-thumbnail wp-image-2041" /></a><p class="wp-caption-text">MadCatz wireless controller to USB Host Shield</p></div>
</td>
</tr>
<tr>
<td>
<div id="attachment_2042" class="wp-caption alignleft" style="width: 298px"><a href="/wp/wp-content/uploads/PS3_AUSB_03_RI.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/PS3_AUSB_03_RI-288x216.jpg" alt="Wireless mini keyboard connected to USB Host Shield" title="PS3_AUSB_03_RI" width="288" height="216" class="size-thumbnail wp-image-2042" /></a><p class="wp-caption-text">Wireless mini keyboard connected to USB Host Shield</p></div>
</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/programming/hook-up-ps3-controller-to-usb-host-shield/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>USB Host breakout at work</title>
		<link>http://www.circuitsathome.com/mcu/programming/usb-host-breakout-at-work</link>
		<comments>http://www.circuitsathome.com/mcu/programming/usb-host-breakout-at-work#comments</comments>
		<pubDate>Sat, 28 Nov 2009 07:17:03 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[MCU]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[embedded]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[MAX3421E]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=2002</guid>
		<description><![CDATA[<p></p>
<p>Here is an interesting project which uses MAX3421E breakout board to connect XBox360 wireless controller to old Nintendo Entertainment System. Francois Gervais used Cortex-M3 as an interface between Nintendo and a game controller. There are two other videos showing the details of the setup &#8211; check them out as well.</p>
<p></p>
<p></p>
<p></p>
]]></description>
			<content:encoded><![CDATA[<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/TzW0JAx2lFM&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/TzW0JAx2lFM&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object></p>
<p>Here is an interesting project which uses <a href="/products-page/breakout-boards/max3421e-breakout-board-populated/">MAX3421E breakout board</a> to connect XBox360 wireless controller to old Nintendo Entertainment System. Francois Gervais used Cortex-M3 as an interface between Nintendo and a game controller. There are two other videos showing the details of the setup &#8211; check them out as well.</p>
<p><span id="more-2002"></span></p>
<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/yMIsyEuRqJ0&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/yMIsyEuRqJ0&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object></p>
<p><object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/lZoLYMpZuOc&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/lZoLYMpZuOc&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/programming/usb-host-breakout-at-work/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USB Isolator Most Frequently Asked Question</title>
		<link>http://www.circuitsathome.com/mcu/usb/usb-isolator-most-frequently-asked-question</link>
		<comments>http://www.circuitsathome.com/mcu/usb/usb-isolator-most-frequently-asked-question#comments</comments>
		<pubDate>Tue, 27 Oct 2009 00:38:25 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Measurements]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[adum4160]]></category>
		<category><![CDATA[isolator]]></category>
		<category><![CDATA[schematic]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1444</guid>
		<description><![CDATA[<p class="wp-caption-text">ADuM4160 PIN pin grounding</p>
Q. I am getting &#8220;USB device not recognized&#8221; error message &#8211; what do I do? Also, since the isolator is soldered into my circuit, &#8220;reconnect peripheral&#8221; suggestion seems too difficult to follow.
<p>I decided to write this article after receiving several e-mails from people who bought my isolator. While setups described in [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_1995" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/ADuM_grounding.jpg"><img src="/wp/wp-content/uploads/ADuM_grounding-288x216.jpg" alt="ADuM4160 PIN pin grounding" title="ADuM_grounding" width="288" height="216" class="size-thumbnail wp-image-1995" /></a><p class="wp-caption-text">ADuM4160 PIN pin grounding</p></div>
<h4>Q. I am getting &#8220;USB device not recognized&#8221; error message &#8211; what do I do? Also, since the isolator is soldered into my circuit, &#8220;reconnect peripheral&#8221; suggestion seems too difficult to follow.</h4>
<p>I decided to write this article after receiving several e-mails from people who bought my isolator. While setups described in those e-mails were different, the problem was the same &#8211; a PC refusing to recognize the device connected through the isolator. Here I will try to explain what is happening and also share my ideas how to troubleshoot and possibly fix the problem.</p>
<p>When nothing is connected to USB port, the bus is held at ground level with pull down resistors on the host side. USB device, when connected, pulls one of bus lines up, often times also with a resistor connected to Vbus and data line. Host sees it, sends bus reset and tries to query the device. If device is answering, host keeps querying the device and eventually enumerates it. When device is enumerated, application takes over.</p>
<p>If device is not answering (like for example, when self-powered device is turned off), host will give up and post &#8220;Device not recognized&#8221; message. To get attention from the host, we need to generate bus event, i.e., disconnect the peripheral and connect it back again.</p>
<p><span id="more-1444"></span></p>
<p>If we are dealing with typical copper-wire-connected USB host and peripheral, which end of USB cable gets disconnected and reconnected would not matter. However, when host and peripheral are talking through ADuM4160, this is not always the case. I tested about 50 different USB devices and found out that while breaking the connection on the peripheral side works every time, host side disconnect does or does not help depending on device.</p>
<p>It is possible to simulate device disconnect without breaking actual connection by pulling PIN pin of ADuM4160 to ground. Normally it is held at 5V by R8 pull up resistor.  This resistor is located next to peripheral side USB connector and marked 1M above it. Left side of it, the one right below the &#8220;1M&#8221; mark is connected to PIN pin (12). The closest ground point is right pad of bypass capacitor, which sits above R8. An experimenter with good eyesight and steady hand can easily connect those two points with tweezers. However, if said experimenter is not feeling comfortable operating tweezers inside powered circuit, a safer arrangement is shown on the title picture.</p>
<p>Disconnecting peripheral, either directly or by driving PIN pin, with power applied to the isolator and host side connected, will most likely solve device detection problem. If you still having issues with the circuit, please let me know, I will try to help.</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/usb/usb-isolator-most-frequently-asked-question/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 0.665 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-03-04 16:24:34 -->
