<?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>Wed, 09 May 2012 07:30:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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>Using Logitech Extreme 3D Pro joystick with Arduino HID library</title>
		<link>http://www.circuitsathome.com/mcu/using-logitech-extreme-3d-pro-joystick-with-arduino-hid-library</link>
		<comments>http://www.circuitsathome.com/mcu/using-logitech-extreme-3d-pro-joystick-with-arduino-hid-library#comments</comments>
		<pubDate>Wed, 09 May 2012 07:30:33 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[fpv]]></category>
		<category><![CDATA[HID]]></category>
		<category><![CDATA[Joystick]]></category>
		<category><![CDATA[jpystick]]></category>
		<category><![CDATA[Logitech Extreme 3D pro]]></category>
		<category><![CDATA[report descriptor]]></category>
		<category><![CDATA[USB Host Shield]]></category>

		<guid isPermaLink="false">https://www.circuitsathome.com/?p=7308</guid>
		<description><![CDATA[<p class="wp-caption-text">Logitech joystick connected to Arduino</p> <p>HID report parsing explained in the previous article works pretty well with properly aligned HID reports. The analog controls are placed on a byte or word boundary and buttons occupy dedicated fields. The majority of HID devices are designed this way, however, some other devices are not that simple [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_7309" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/2012/05/logitech_title.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/05/logitech_title-288x216.jpg" alt="Logitech joystick connected to Arduino" title="Logitech joystick connected to Arduino" width="288" height="216" class="size-thumbnail wp-image-7309" /></a><p class="wp-caption-text">Logitech joystick connected to Arduino</p></div>
<p>HID report parsing <a href="/mcu/hid-joystick-code-sample">explained in the previous article</a> works pretty well with properly aligned HID reports. The analog controls are placed on a byte or word boundary and buttons occupy dedicated fields. The majority of HID devices are designed this way, however, some other devices are not that simple to interface and today I&#8217;m going to show how to handle one of those.</p>
<p>A Logitech Extreme 3D Pro joystick is one nice HID device. It is good looking, well-built, and have a twist handle, which adds third axis to a stick making this model popular among FPV fliers since you can control pitch, roll and yaw with one hand. Also, X and Y axis are 10 bits which gives good precision. There is one problem with this joystick &#8211; its input report.</p>
<p>Logitech, in its infinite wisdom, decided to pack all the high and low resolution analog controls plus 12 buttons in 6 bytes of input report. The report looks like this &#8211; 10 bits of X, 10 bits of Y, and 4 bits of hat switch. After that, things become easier &#8211; one byte of Rz AKA &#8220;twist handle&#8221;, one byte of buttons, one byte of throttle (called &#8220;slider&#8221; in the report), and finally, one partially filled byte holding the rest of the buttons. Take a look at the screenshot below &#8211; two most important controls are not byte aligned, therefore, simple straightforward parsing of the report is not possible. Also, <code>USBHID_descr</code> won&#8217;t show this report correctly.</p>
<p>To demonstrate how to deal with this report I wrote a <a href="https://github.com/felis/USB_Host_Shield_2.0/tree/master/examples/HID/le3dp">simple Arduino sketch</a>. It was made by modifying an example from the previous article. I also made it as simple as possible &#8211; as soon as any of the controls changes its value, new report is printed on the serial terminal. The sample output is shown below followed by code explanation.<br />
<span id="more-7308"></span></p>

<div class="wp_syntax"><div class="code"><pre class="basic" style="font-family:monospace;">Start
HU Init
Addr:1
NC:1
&nbsp;
Cnf:1
HU configured
&nbsp;
Buf: FCF18780000000
X: 01FC Y: 01FC Hat Switch: 08 Twist: 80 Slider: 00 Buttons A: 00 Buttons B: 00
&nbsp;
Buf: FCF18780000200
X: 01FC Y: 01FC Hat Switch: 08 Twist: 80 Slider: 02 Buttons A: 00 Buttons B: 00
&nbsp;
Buf: FCF18783000200
X: 01FC Y: 01FC Hat Switch: 08 Twist: 83 Slider: 02 Buttons A: 00 Buttons B: 00
&nbsp;
Buf: FCF18786000200
X: 01FC Y: 01FC Hat Switch: 08 Twist: 86 Slider: 02 Buttons A: 00 Buttons B: 00</pre></div></div>

<p>The first important piece of the code is the report representation. To be able to access every control the following structure has been declared &#8211; compare it with the screenshot produced by my trusty Totalphase Beagle USB protocol analyzer:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span> GamePadEventData
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">union</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//axes and hut switch</span>
    <span style="color: #993333;">uint32_t</span> axes<span style="color: #339933;">;</span>
    <span style="color: #993333;">struct</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #993333;">uint32_t</span> x <span style="color: #339933;">:</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span>
      <span style="color: #993333;">uint32_t</span> y <span style="color: #339933;">:</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span>
      <span style="color: #993333;">uint32_t</span> hat <span style="color: #339933;">:</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span>
      <span style="color: #993333;">uint32_t</span> twist <span style="color: #339933;">:</span> <span style="color: #0000dd;">8</span><span style="color: #339933;">;</span>      
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">uint8_t</span> buttons_a<span style="color: #339933;">;</span>
  <span style="color: #993333;">uint8_t</span> slider<span style="color: #339933;">;</span>
  <span style="color: #993333;">uint8_t</span> buttons_b<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p><div id="attachment_7315" class="wp-caption aligncenter" style="width: 650px"><a href="/wp/wp-content/uploads/2012/05/logitech_report.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/05/logitech_report.jpg" alt="Logitech input report" title="Logitech input report" width="640" height="480" class="size-full wp-image-7315" /></a><p class="wp-caption-text">Logitech input report</p></div><br />
The <code>Parse()</code> method works similarly to the original code &#8211; it receives the report from the device and compares it with the stored copy of the previous reading. If reports are different, <code>OnGamePadChanges()</code> is called, which simply prints the report on the terminal. It can easily be modified to do something useful like change PWM pulse width to control motor speed, servo pulse or generate analog signal.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> JoystickReportParser<span style="color: #339933;">::</span><span style="color: #202020;">Parse</span><span style="color: #009900;">&#40;</span>HID <span style="color: #339933;">*</span>hid<span style="color: #339933;">,</span> bool is_rpt_id<span style="color: #339933;">,</span> <span style="color: #993333;">uint8_t</span> len<span style="color: #339933;">,</span> <span style="color: #993333;">uint8_t</span> <span style="color: #339933;">*</span>buf<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	bool match <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Checking if there are changes in report since the method was last called</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</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>RPT_GAMEPAD_LEN<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> buf<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> oldPad<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			match <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  	<span style="color: #666666; font-style: italic;">// Calling Game Pad event handler</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>match <span style="color: #339933;">&amp;&amp;</span> joyEvents<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		joyEvents<span style="color: #339933;">-&gt;</span>OnGamePadChanged<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> GamePadEventData<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</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>RPT_GAMEPAD_LEN<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> oldPad<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> buf<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This simple technique is very helpful when dealing with awkward reports. If you need help with parsing output from your HID reports or would like to see more detailed explanation of the code, please let me know.</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/using-logitech-extreme-3d-pro-joystick-with-arduino-hid-library/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adjusting inverter control in Tektronix 7104 oscilloscope power supply</title>
		<link>http://www.circuitsathome.com/measurements/adjusting-inverter-control-in-tektronix-7104-oscilloscope-power-supply</link>
		<comments>http://www.circuitsathome.com/measurements/adjusting-inverter-control-in-tektronix-7104-oscilloscope-power-supply#comments</comments>
		<pubDate>Mon, 23 Apr 2012 23:53:45 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Measurements]]></category>
		<category><![CDATA[7104]]></category>
		<category><![CDATA[adjust inverter control]]></category>
		<category><![CDATA[oscilloscope]]></category>
		<category><![CDATA[power supply]]></category>
		<category><![CDATA[Tektronix]]></category>

		<guid isPermaLink="false">https://www.circuitsathome.com/?p=7288</guid>
		<description><![CDATA[<p class="wp-caption-text">Access to 109V test point</p> <p>In this short article I want to share a trick that I learned today while checking the power supply of my trusty Tektronix 7104 oscilloscope. Step A2 of calibration section of the manual calls for measuring/adjusting of pre-regulated 109V voltage on TP1326 test point. Typically, test point access for [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_7289" class="wp-caption alignleft" style="width: 298px"><a href="/wp/wp-content/uploads/2012/04/7104_109v_access_01.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/04/7104_109v_access_01-288x216.jpg" alt="Access to 109V test point" title="Access to 109V test point" width="288" height="216" class="size-thumbnail wp-image-7289" /></a><p class="wp-caption-text">Access to 109V test point</p></div>
<p>In this short article I want to share a trick that I learned today while checking the power supply of my trusty Tektronix 7104 oscilloscope. Step A2 of calibration section of the manual calls for measuring/adjusting of pre-regulated 109V voltage on TP1326 test point. Typically, test point access for this step requires removing power supply cover which takes time and exposes high voltages. The test setup presented on a title picture( click on it to make it bigger) shows how to access this test point leaving power supply cover in place.</p>
<p>The power supply cover is at ground potential so don&#8217;t try to reach the test point with non-insulated probe. I used Tektronix Klip Chip IC probe threaded through nearby ventilation hole to grab the test point post. The post is clearly seen through a larger hole, through which an adjustment potentiometer R1293 is usually accessed. A flashlight is handy. </p>
<p>Next picture shows the closeup of the test connection. A test probe is supported by a &#8220;Third Hand&#8221; thingy &#8211; I wanted to observe voltage fluctuations in the course of two hours to make sure it stays within limits.</p>
<p>I&#8217;m hoping this trick will be useful for somebody dealing with similar power supply.</p>
<p>Oleg.<br />
<a href="/wp/wp-content/uploads/2012/04/7104_109v_access_02.jpg"><img src="/wp/wp-content/uploads/2012/04/7104_109v_access_02.jpg" alt="" title="7104_109v_access_02" width="1024" height="768" class="aligncenter size-full wp-image-7293" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/measurements/adjusting-inverter-control-in-tektronix-7104-oscilloscope-power-supply/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing Arduino code for HID Joystick</title>
		<link>http://www.circuitsathome.com/mcu/hid-joystick-code-sample</link>
		<comments>http://www.circuitsathome.com/mcu/hid-joystick-code-sample#comments</comments>
		<pubDate>Tue, 03 Apr 2012 16:06:02 +0000</pubDate>
		<dc:creator>alex</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[HID]]></category>
		<category><![CDATA[Joystick]]></category>
		<category><![CDATA[MAX3421E]]></category>
		<category><![CDATA[USB Host Shield]]></category>

		<guid isPermaLink="false">https://www.circuitsathome.com/?p=7197</guid>
		<description><![CDATA[<p>This article focuses on how to use the existing USB code library and HID report descriptor info to implement joystick functionality.  Human readable HID report descriptor and report information can be easily obtained using USBHID_desc.pde sketch &#8211; see previous article for details. This information will help you getting field details such as size and count [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://www.circuitsathome.com/wp/wp-content/uploads/2012/03/alex_joystick.jpg"><img src="/wp/wp-content/uploads/2012/03/alex_joystick-288x216.jpg" alt="" title="alex_joystick" width="288" height="216" class="alignright size-thumbnail wp-image-7276" /></a>This article focuses on how to use the existing USB code library and HID report descriptor info to implement joystick functionality.  Human readable HID report descriptor and report information can be easily obtained using <code>USBHID_desc.pde</code> sketch &#8211; see <a href="/mcu/usb/visualizing-hid-device-reports-and-report-descriptors">previous article</a> for details. This information will help you getting field details such as size and count info. Also, if you don&#8217;t have Arduino Mega or 2560 to run <code>USBHID_desc</code>, report descriptor for your device can be obtained using one of many PC tools known as USB analyzers, or even the <a href="http://www.usb.org/developers/tools/">official usb.org device verification tool</a>. This article is written by Alex Glushchenko &#8211; a developer behind second revision of USB Host Library as well as majority of device support code.</p>
<p>As you may already know report is a data structure used by HID device to return the information about the certain device parameters such as joystick coordinates or button events, or receive new settings such as switching on/off LEDs on keyboard.   </p>
<p>Report descriptor is a data structure which describes report or reports, if there are few in number, field sequence, sizes and counts.  Each report descriptor consists of several items. Each item describes some field property. I am not going too deep into details on items, explaining only the most important ones which are absolutely necessary in writing your own report parser.  </p>
<p>The items usually describe type of field (input/output/feature), minimum, maximum field values, units, value meaning (usage) etc.<br />
<span id="more-7197"></span><br />
The joystick I&#8217;m using can be seen on title picture (click on it to make it bigger). Here is how my joystick report descriptor looks like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">Usage Page Gen Desktop Ctrls<span style="color: #009900;">&#40;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#41;</span>
Usage Game Pad
Collection Application
Collection Logical
Report Size<span style="color: #009900;">&#40;</span><span style="color:#800080;">08</span><span style="color: #009900;">&#41;</span>
Report Count<span style="color: #009900;">&#40;</span><span style="color: #208080;">05</span><span style="color: #009900;">&#41;</span>
Logical Min<span style="color: #009900;">&#40;</span><span style="color: #208080;">00</span><span style="color: #009900;">&#41;</span>
Logical Max<span style="color: #009900;">&#40;</span>FF00<span style="color: #009900;">&#41;</span>
Physical Min<span style="color: #009900;">&#40;</span><span style="color: #208080;">00</span><span style="color: #009900;">&#41;</span>
Physical Max<span style="color: #009900;">&#40;</span>FF00<span style="color: #009900;">&#41;</span>
Usage X
Usage Y
Usage Z
Usage Z
Usage Rz
Input<span style="color: #009900;">&#40;</span><span style="color: #208080;">00000010</span><span style="color: #009900;">&#41;</span>
Report Size<span style="color: #009900;">&#40;</span><span style="color: #208080;">04</span><span style="color: #009900;">&#41;</span>
Report Count<span style="color: #009900;">&#40;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#41;</span>
Logical Max<span style="color: #009900;">&#40;</span><span style="color: #208080;">07</span><span style="color: #009900;">&#41;</span>
Physical Max<span style="color: #009900;">&#40;</span>3B01<span style="color: #009900;">&#41;</span>
Unit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">14</span><span style="color: #009900;">&#41;</span>
Usage Hat Switch
Input<span style="color: #009900;">&#40;</span><span style="color: #208080;">01000010</span><span style="color: #009900;">&#41;</span>
Unit<span style="color: #009900;">&#40;</span><span style="color: #208080;">00</span><span style="color: #009900;">&#41;</span>
Report Size<span style="color: #009900;">&#40;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#41;</span>
Report Count<span style="color: #009900;">&#40;</span>0C<span style="color: #009900;">&#41;</span>
Logical Max<span style="color: #009900;">&#40;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#41;</span>
Physical Max<span style="color: #009900;">&#40;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#41;</span>
Usage Page Button<span style="color: #009900;">&#40;</span><span style="color:#800080;">09</span><span style="color: #009900;">&#41;</span>
Usage Min<span style="color: #009900;">&#40;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#41;</span>
Usage Max<span style="color: #009900;">&#40;</span>0C<span style="color: #009900;">&#41;</span>
Input<span style="color: #009900;">&#40;</span><span style="color: #208080;">00000010</span><span style="color: #009900;">&#41;</span>
Usage Page Undef<span style="color: #009900;">&#40;</span><span style="color: #208080;">00</span><span style="color: #009900;">&#41;</span>
Report Size<span style="color: #009900;">&#40;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#41;</span>
Report Count<span style="color: #009900;">&#40;</span><span style="color:#800080;">08</span><span style="color: #009900;">&#41;</span>
Logical Max<span style="color: #009900;">&#40;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#41;</span>
Physical Max<span style="color: #009900;">&#40;</span><span style="color: #208080;">01</span><span style="color: #009900;">&#41;</span>
Usage
Input<span style="color: #009900;">&#40;</span><span style="color: #208080;">00000010</span><span style="color: #009900;">&#41;</span>
End Collection
Collection Logical
Report Size<span style="color: #009900;">&#40;</span><span style="color:#800080;">08</span><span style="color: #009900;">&#41;</span>
Report Count<span style="color: #009900;">&#40;</span><span style="color: #208080;">07</span><span style="color: #009900;">&#41;</span>
Physical Max<span style="color: #009900;">&#40;</span>FF00<span style="color: #009900;">&#41;</span>
Logical Max<span style="color: #009900;">&#40;</span>FF00<span style="color: #009900;">&#41;</span>
Usage
Output<span style="color: #009900;">&#40;</span><span style="color: #208080;">00000010</span><span style="color: #009900;">&#41;</span>
End Collection
End Collection</pre></td></tr></table></div>

<p>It may look puzzling at first sight, but soon it is going to look more clear to you. HID specification makes it possible for any  host to know exactly what the certain report field means by introducing usages and usage tables. </p>
<p>Usage table specifies all possible controls and device setting IDs for a given class of devices, such as game controllers.</p>
<p>So, analyzing report descriptor dump you have to pay attention to usage table, usage, report size, report count, input and output items. </p>
<p>Now let&#8217;s see what we have in the dump. First we have five (line 6) input (line 16) fields X, Y, Z, Z, Rz for Game Pad (lines 11-15), 8-bit in size each (line 5), followed by 4-bit Hat Switch field, 12 buttons, 1-bit each, 8-bit field with unknown usage. 64 bit in total which is 8 bytes.  You don&#8217;t have to calculate Output items unless you plan to make use of output report. </p>
<p>Now let me explain some details. Each report field or group of fields with the same properties is described by a number of items. Each field explanation ends with an Input, Output or Feature item. Take another look at the dump. Game Pad fields are five in number which is specified by Report Count(05), 8 bit in size Report Size(08) and individual usages for X, Y, Z, Z and Rz. Hat Switch is one field 4-bit in size, 12 buttons are described by Usage Page Button(09) and usage range specified by Usage Min(01) and Usage Max(0C).</p>
<p>Now you know how to interpret report descriptor dump. Let&#8217;s go down to code. There is a sample sketch called <code>USBHIDJoystick.pde</code> which we are going to look at. Just make sure you have the <a href="https://github.com/felis/USB_Host_Shield_2.0" title="USB Host Shield 2.0 library" target="_blank">latest version of the USB Host library</a> downloaded. With the current version of the USB Host library you do not have to write all the code from scratch, use <code>HIDUniversal</code> class to reuse the main functionality responsible for USB interaction. You have to inherit <code>HIDReportParser</code> class to implement report parser functionality and provide its address by  <code>SetReportParser</code> method to <code>HIDUniversal</code> class instance. Files <code>hidjoystickrptparser.h</code> and <code>hidjoystickrptparser.cpp</code> contain all the interesting code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span> GamePadEventData
<span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">uint8_t</span> X<span style="color: #339933;">,</span> Y<span style="color: #339933;">,</span> Z1<span style="color: #339933;">,</span> Z2<span style="color: #339933;">,</span> Rz<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
class JoystickEvents
<span style="color: #009900;">&#123;</span>
public<span style="color: #339933;">:</span>
	virtual <span style="color: #993333;">void</span> OnGamePadChanged<span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> GamePadEventData <span style="color: #339933;">*</span>evt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	virtual <span style="color: #993333;">void</span> OnHatSwitch<span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span> hat<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	virtual <span style="color: #993333;">void</span> OnButtonUp<span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span> but_id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	virtual <span style="color: #993333;">void</span> OnButtonDn<span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span> but_id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">#define RPT_GEMEPAD_LEN		5</span>
&nbsp;
class JoystickReportParser <span style="color: #339933;">:</span> public HIDReportParser
<span style="color: #009900;">&#123;</span>
	JoystickEvents		<span style="color: #339933;">*</span>joyEvents<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #993333;">uint8_t</span>				oldPad<span style="color: #009900;">&#91;</span>RPT_GEMEPAD_LEN<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">uint8_t</span>				oldHat<span style="color: #339933;">;</span>
	<span style="color: #993333;">uint16_t</span>			oldButtons<span style="color: #339933;">;</span>
&nbsp;
public<span style="color: #339933;">:</span>
	JoystickReportParser<span style="color: #009900;">&#40;</span>JoystickEvents <span style="color: #339933;">*</span>evt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	virtual <span style="color: #993333;">void</span> Parse<span style="color: #009900;">&#40;</span>HID <span style="color: #339933;">*</span>hid<span style="color: #339933;">,</span> bool is_rpt_id<span style="color: #339933;">,</span> <span style="color: #993333;">uint8_t</span> len<span style="color: #339933;">,</span> <span style="color: #993333;">uint8_t</span> <span style="color: #339933;">*</span>buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Now consider <code>Parse()</code> method functionality. Because the event buffer allocated for the report is pretty large and the size of my joystick report is only 8 byte long, <code>Parse()</code> is called only once per each report.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> JoystickReportParser<span style="color: #339933;">::</span><span style="color: #202020;">Parse</span><span style="color: #009900;">&#40;</span>HID <span style="color: #339933;">*</span>hid<span style="color: #339933;">,</span> bool is_rpt_id<span style="color: #339933;">,</span> <span style="color: #993333;">uint8_t</span> len<span style="color: #339933;">,</span> <span style="color: #993333;">uint8_t</span> <span style="color: #339933;">*</span>buf<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	bool match <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Checking if there are changes in report since the method was last called</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</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>RPT_GEMEPAD_LEN<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> oldPad<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			match <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Calling Game Pad event handler</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>match <span style="color: #339933;">&amp;&amp;</span> joyEvents<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		joyEvents<span style="color: #339933;">-&gt;</span>OnGamePadChanged<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> GamePadEventData<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</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>RPT_GEMEPAD_LEN<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> oldPad<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> buf<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #993333;">uint8_t</span> hat <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;</span> <span style="color: #208080;">0xF</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Calling Hat Switch event handler</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>hat <span style="color: #339933;">!=</span> oldHat <span style="color: #339933;">&amp;&amp;</span> joyEvents<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		joyEvents<span style="color: #339933;">-&gt;</span>OnHatSwitch<span style="color: #009900;">&#40;</span>hat<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		oldHat <span style="color: #339933;">=</span> hat<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #993333;">uint16_t</span> buttons <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #208080;">0x0000</span> <span style="color: #339933;">|</span> buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">6</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	buttons <span style="color: #339933;">&lt;&lt;=</span> <span style="color: #0000dd;">4</span><span style="color: #339933;">;</span>
	buttons <span style="color: #339933;">|=</span> <span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;&gt;</span> <span style="color: #0000dd;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">uint16_t</span> changes <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>buttons <span style="color: #339933;">^</span> oldButtons<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Calling Button Event Handler for every button changed</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>changes<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span> i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span><span style="color: #208080;">0x0C</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #993333;">uint16_t</span> mask <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #208080;">0x0001</span> <span style="color: #339933;">&lt;&lt;</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>mask <span style="color: #339933;">&amp;</span> changes<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> joyEvents<span style="color: #009900;">&#41;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>buttons <span style="color: #339933;">&amp;</span> mask<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
					joyEvents<span style="color: #339933;">-&gt;</span>OnButtonDn<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">else</span>
					joyEvents<span style="color: #339933;">-&gt;</span>OnButtonUp<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		oldButtons <span style="color: #339933;">=</span> buttons<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The logic is the same for all report fields. First the report buffer is checked against the previously saved one for the data changes. If changes found the appropriate event handler is invoked with the current state data passed as a function argument. In case of Game Pad the current state data is passed as structure pointer. In case of the Hat Switch the current state is passed as integer value.</p>
<p>Handling buttons is a bit more complicated. Lines 30-33 are responsible for finding out which buttons have changed their states since the last <code>Parse()</code> call. Cycling through each bit of the mask we find out the current state of the changed button. If the button is pressed, <code>OnButtonDn()</code> event handler is called. If the button released, <code>OnButtonUp()</code> event handler is called.</p>
<p>If your joystick report has different structure, all you have to do is modify the Parse method to change fields offsets and sizes. Pretty simple, isn&#8217;t it?</p>
<p>The last component of the code is actual event handlers. In this example they simply output game pad, hat switch and button states to the serial console. Again, the body of each function can easily be modified to perform something more useful.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> JoystickEvents<span style="color: #339933;">::</span><span style="color: #202020;">OnGamePadChanged</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> GamePadEventData <span style="color: #339933;">*</span>evt<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;X: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	PrintHex<span style="color: #339933;">&lt;</span>uint8_t<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>evt<span style="color: #339933;">-&gt;</span>X<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>Y: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	PrintHex<span style="color: #339933;">&lt;</span>uint8_t<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>evt<span style="color: #339933;">-&gt;</span>Y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>Z: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	PrintHex<span style="color: #339933;">&lt;</span>uint8_t<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>evt<span style="color: #339933;">-&gt;</span>Z1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>Z: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	PrintHex<span style="color: #339933;">&lt;</span>uint8_t<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>evt<span style="color: #339933;">-&gt;</span>Z2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>Rz: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	PrintHex<span style="color: #339933;">&lt;</span>uint8_t<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>evt<span style="color: #339933;">-&gt;</span>Rz<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> JoystickEvents<span style="color: #339933;">::</span><span style="color: #202020;">OnHatSwitch</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span> hat<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;Hat Switch: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	PrintHex<span style="color: #339933;">&lt;</span>uint8_t<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>hat<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> JoystickEvents<span style="color: #339933;">::</span><span style="color: #202020;">OnButtonUp</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span> but_id<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;Up: &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>but_id<span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> JoystickEvents<span style="color: #339933;">::</span><span style="color: #202020;">OnButtonDn</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span> but_id<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;Dn: &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>but_id<span style="color: #339933;">,</span> DEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The full text of Arduino sketch plus parsers/callbacks is <a href="https://github.com/felis/USB_Host_Shield_2.0/tree/master/examples/HID/USBHIDJoystick">available on GitHub</a>. The code works with <a href="/products-page/arduino-shields/usb-host-shield-2-0-for-arduino">USB Host Shield 2.0</a>, it has been tested on Arduino UNO, Mega, as well as Mega 2560. Unlike <code>USBHID_desc</code> this code takes just a little more than 16K of program space. The joystick I use is a random eBay unit (note from Oleg: I have a wireless HID joystick which looks quite differently from this one, however, the report descriptor is the same. If you have similar one, try it &#8211; it may work with this code without any modifications). If you&#8217;re shopping for a joystick, make sure it has analog game pads, otherwise you will only see values 0&#215;00, 0&#215;80 and 0xff from them. Also, all HID devices are picky about power, if you see strange behaviour while running your Arduino from USB the first thing to do is switch to external supply.</p>
<p>Try this code and if you see any issues or errors, please leave a comment. Also, if you have other HID devices you&#8217;d like me to cover, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/hid-joystick-code-sample/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Visualizing HID device reports and report descriptors</title>
		<link>http://www.circuitsathome.com/mcu/usb/visualizing-hid-device-reports-and-report-descriptors</link>
		<comments>http://www.circuitsathome.com/mcu/usb/visualizing-hid-device-reports-and-report-descriptors#comments</comments>
		<pubDate>Tue, 03 Apr 2012 00:41:33 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[HID]]></category>
		<category><![CDATA[MAX3421E]]></category>
		<category><![CDATA[USB Host Shield]]></category>

		<guid isPermaLink="false">https://www.circuitsathome.com/?p=7237</guid>
		<description><![CDATA[<p> Human Interface Device class of USB devices has a unique property &#8211; a report descriptor which contains information about data that device is sending to the host as well as data that can be sent to the device. This property allows for variety of devices &#8211; keyboards, mice, joysticks, digital scales, uninterruptible power sources, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/wp/wp-content/uploads/2012/04/reportdesc_sshot.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/04/reportdesc_sshot.jpg" alt="Screenshot of USBHID_desc sketch output" title="Screenshot of USBHID_desc sketch output" width="666" height="413" class="size-full wp-image-7245" /></a><br />
<a href="http://en.wikipedia.org/wiki/USB_human_interface_device_class">Human Interface Device</a> class of USB devices has a unique property &#8211; a report descriptor which contains information about data that device is sending to the host as well as data that can be sent to the device. This property allows for variety of devices &#8211; keyboards, mice, joysticks, digital scales, uninterruptible power sources, GPS receivers, and even <a href="http://www.thinkgeek.com/geektoys/warfare/8a0f/?srp=3" title="USB missile launcher">toy missile launchers</a> to belong to a single class &#8211; HID. A vendor just needs to pick a <a href="http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf">usage table</a> which contains controls similar to vendor&#8217;s device &#8211; every OS has a generic support for HID devices so in most cases specific device driver is not necessary. The report descriptor again makes this possible &#8211; it contains definitions or report fields therefore a generic parser can process reports from any arbitrary HID device. However, this generic parser will take too much space on small microcontroller systems such as Arduino due to the amount of constants that needs to be present in the program code.</p>
<p>It shall be noted that a HID report itself is a simple structure of fixed fields and when this structure is known a very lightweight parser can easily be developed. HID development in legacy USB library has stopped at this point; I thought people will just take a look at the spec and write report parser for their device. It soon became evident that very few are actually willing to do this and in rev.2.0 of the library the HID report parsing is semi-automatic &#8211; a report descriptor has to be analyzed first using USBHID_desc utility presented in this article and then actual reports for the device can be parsed using library facilities (an article about coding report parsing <a href="/mcu/hid-joystick-code-sample">is here</a>).<br />
<span id="more-7237"></span><br />
Even though report descriptor parsing is moved to a separate utility, it is still a heavy load for Arduino. The code, which at present only contains strings for keyboards, mice and joysticks, won&#8217;t fit into 32K Arduino &#8211; a Mega or 2560 is necessary. A screenshot of descriptor report output of a typical mouse can be seen on title picture. The explanation follows.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="basic" style="font-family:monospace;">Usage Page Gen Desktop Ctrls(01)
Usage Mouse
Collection Application
Usage Pointer
Collection Physical
Usage Page Button(09)
Usage Min(01)
Usage Max(03)
Logical Min(00)
Logical Max(01)
Report Size(01)
Report Count(03)
Input(00000010)
Report Size(05)
Report Count(01)
Input(00000001)
Usage Page Gen Desktop Ctrls(01)
Usage X
Usage Y
Usage Wheel
Logical Min(81)
Logical Max(7F)
Report Size(08)
Report Count(03)
Input(00000110)
End Collection
End Collection</pre></td></tr></table></div>

<p>Mouse buttons are defined first. We can see that it is input item (line 13). They are buttons (line 6), which is also confirmed by logical min and max (line 9,10) &#8211; only two values, 0 and 1, are possible. The report size is one bit (line 11) and number of buttons is 3 (line 12).</p>
<p>The next item (line 16) is a filler for the rest of the first byte. It specifies one (line 15) 5-bit (line 14) report with no minimums or maximums.</p>
<p>The last report (line 25) specifies X-axis, Y-axis and wheel (lines 18-20). 3 reports (line 24) has been specified, one byte each (line 23).</p>
<p>That&#8217;s all we need to know about the device in order to communicate to it. For the curious, detailed explanation of these and all other fields in this report can be found in USB specifications listed on usb.org <a href="http://www.usb.org/developers/hidpage/">HID page</a>. Device Class Definition and HID Usage Tables are two most important docs.</p>
<p>USBHID_desc also can parse HID reports on the fly. In order to generate some reports I&#8217;m going to move my mouse and observe the results. Here&#8217;s what happens when I move it vertically:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="basic" style="font-family:monospace;">Buf: 00000100
 Mouse Pointer Btn1(00) Btn2(00) Btn3(00)
(00)
 X Y Wheel(00)(01)(00)</pre></td></tr></table></div>

<p>Line 1 shows the raw report, 4 bytes in length. Line 2 shows state of the buttons, none of them pressed. Line 3 shows state of the &#8220;filler&#8221; report; since it doesn&#8217;t have usage page assosciated with it, it doesn&#8217;t have a name. It never changes, either. Line 4 shows state of X,Y and wheel, the Y axis having moved 1 step. We can also find it easily in the raw report in the third byte.</p>
<p>Next output shows how the report looks like when mouse is moved diagonally. We can see that both X and Y are changed and can check that value for X-axis is output in the second byte of the report.</p>

<div class="wp_syntax"><div class="code"><pre class="basic" style="font-family:monospace;">Buf: 00FDAB00
 Mouse Pointer Btn1(00) Btn2(00) Btn3(00)
(00)
 X Y Wheel(FD)(AB)(00)</pre></div></div>

<p>The next output demonstrates reports for wheel and button presses. It can be seen that buttons are stored in 3 low bits of the first byte of the report.</p>

<div class="wp_syntax"><div class="code"><pre class="basic" style="font-family:monospace;">Buf: 00000002
 Mouse Pointer Btn1(00) Btn2(00) Btn3(00)
(00)
 X Y Wheel(00)(00)(02)
&nbsp;
Buf: 01000000
 Mouse Pointer Btn1(01) Btn2(00) Btn3(00)
(00)
 X Y Wheel(00)(00)(00)
&nbsp;
Buf: 00000000
 Mouse Pointer Btn1(00) Btn2(00) Btn3(00)
(00)
 X Y Wheel(00)(00)(00)
&nbsp;
Buf: 04000000
 Mouse Pointer Btn1(00) Btn2(00) Btn3(01)
(00)
 X Y Wheel(00)(00)(00)
&nbsp;
Buf: 00000000
 Mouse Pointer Btn1(00) Btn2(00) Btn3(00)
(00)
 X Y Wheel(00)(00)(00)
&nbsp;
Buf: 02000000
 Mouse Pointer Btn1(00) Btn2(01) Btn3(00)
(00)
 X Y Wheel(00)(00)(00)
&nbsp;
Buf: 00000000
 Mouse Pointer Btn1(00) Btn2(00) Btn3(00)
(00)
 X Y Wheel(00)(00)(00)</pre></div></div>

<p>The last output demonstrates the behaviour of USBHID_desc encountering unsupported device (digital scale). It tries to parse the report descriptor but doesn&#8217;t have enough information for human-readable representation of the report. As a result, only raw reports are output. The first report shows empty scale, the second &#8211; scale loaded with Arduino Mega/USB Host Shield combo on which USBHID_desc is running (~68g or 2.4oz).</p>

<div class="wp_syntax"><div class="code"><pre class="basic" style="font-family:monospace;">Usage Page Scale(8D)
Usage
Collection Application
Usage
Collection Logical
Report Id(01)
Report Size(08)
Report Count(01)
Logical Min(01)
Logical Max(0C)
Usage
Collection Logical
Usage Min(21)
Usage Max(2A)
Feature(00000000)
End Collection
Usage
Collection Logical
Usage Min(51)
Usage Max(5C)
Feature(00000000)
End Collection
End Collection
Usage
Collection Logical
Report Id(02)
Report Size(01)
Report Count(02)
Logical Min(00)
Logical Max(01)
Usage Min(80)
Usage Max(81)
Output(00000010)
Report Size(06)
Report Count(01)
Output(00000011)
End Collection
Usage
Collection Logical
Report Id(03)
Report Size(08)
Logical Min(01)
Usage
Collection Logical
Logical Max(08)
Usage Min(71)
Usage Max(78)
Input(00000000)
End Collection
Usage
Collection Logical
Logical Max(0C)
Usage Min(51)
Usage Max(5C)
Input(00000000)
End Collection
Logical Min(81)
Logical Max(7F)
Usage
Input(00000010)
Report Size(10)
Logical Min(00)
Logical Max(FFFF0000)
Usage
Input(00000010)
End Collection
Buf: 03040BFF0000
&nbsp;
&nbsp;
Buf: 03040BFF2100</pre></div></div>

<p>USBHID_desc is a useful program designed to help with analyzing reports and report descriptors of HID devices using Arduino Mega or Mega 2560 board and <a href="/products-page/arduino-shields/usb-host-shield-2-0-for-arduino">USB Host Shield 2.0</a>. By the end of this week I&#8217;m hoping to post an article demonstrating how to use the information &#8211; stay tuned!</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/usb/visualizing-hid-device-reports-and-report-descriptors/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simulating cable disconnect on USB Host Shield 2.0</title>
		<link>http://www.circuitsathome.com/camera-control/simulating-cable-disconnect-on-usb-host-shield-2-0</link>
		<comments>http://www.circuitsathome.com/camera-control/simulating-cable-disconnect-on-usb-host-shield-2-0#comments</comments>
		<pubDate>Thu, 29 Mar 2012 13:45:14 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Camera Control]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[digital camera control]]></category>
		<category><![CDATA[MAX3421E]]></category>
		<category><![CDATA[MOSFET]]></category>
		<category><![CDATA[USB Host Shield]]></category>
		<category><![CDATA[VBUS]]></category>

		<guid isPermaLink="false">http://www.circuitsathome.com/?p=4301</guid>
		<description><![CDATA[<p><p class="wp-caption-text">A MOSFET controlling VBUS</p> Today I want to show a simple USB Host Shield 2.0 modification which allows controlling power to USB peripheral. I learned this technique from Camille&#8217;s comment to one of digital camera USB control articles. In short, the idea was to cut VBUS connection between USB host and peripheral, simulating disconnect [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_7206" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/2012/03/vbus_mosfet.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/03/vbus_mosfet-288x216.jpg" alt="A MOSFET controlling VBUS" title="A MOSFET controlling VBUS" width="288" height="216" class="size-thumbnail wp-image-7206" /></a><p class="wp-caption-text">A MOSFET controlling VBUS</p></div><br />
Today I want to show a simple USB Host Shield 2.0 modification which allows controlling power to USB peripheral. I learned this technique from Camille&#8217;s comment to one of digital camera USB control articles. In short, the idea was to cut VBUS connection between USB host and peripheral, simulating disconnect state. P-channel MOSFET, inserted into VBUS,  worked as a switch. I designed this capability into USB Host Shield 2.0 but never needed the functionality therefore this useful feature was left undocumented. Recently I started working with very interesting Nikon P&#038;S camera which can be turned on and off with VBUS power so I finally made this modification. It is very simple.</p>
<p>Take a look at the title picture (click on it to make it larger). The modification uses existing VBUS power select pads of the shield. Out of the box, the one labeled 5V is shorted with solder bridge. First step is to remove this bridge with a solder wick so both pads are clean.</p>
<p>It can be seen that a MOSFET in SOT-23 package fits nicely on those pads (I&#8217;m using FDN306P). Drain and source pins are soldered to VBUS and 5V, respectively, and gate, which hangs in the air, is routed to an unused digital pin via an 1M resistor. When digital pin is low the MOSFET conducts. When digital pin goes high the MOSFET switches off disconnecting VBUS from the peripheral.</p>
<p>If you  are going to drive high-power peripherals, like digital cameras or phones, it is a good idea to add some capacitance to 5V. I&#8217;m using 220uF low-ESR organic polymer tantalum cap in 1210 package which fits nicely on 0.1&#8243; spaced 5V and GND pins of the shield; an ordinary leaded 100-200uF aluminum capacitor will work as well.</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/camera-control/simulating-cable-disconnect-on-usb-host-shield-2-0/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Sony PS3 Controller support added to USB Host library</title>
		<link>http://www.circuitsathome.com/mcu/sony-ps3-controller-support-added-to-usb-host-library</link>
		<comments>http://www.circuitsathome.com/mcu/sony-ps3-controller-support-added-to-usb-host-library#comments</comments>
		<pubDate>Sun, 04 Mar 2012 20:02:12 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[balancing robot]]></category>
		<category><![CDATA[dualshock 3]]></category>
		<category><![CDATA[move motion controller]]></category>
		<category><![CDATA[move navigation controller]]></category>
		<category><![CDATA[playstation]]></category>
		<category><![CDATA[PS3]]></category>
		<category><![CDATA[USB Host Shield]]></category>

		<guid isPermaLink="false">https://www.circuitsathome.com/?p=7147</guid>
		<description><![CDATA[<p><p class="wp-caption-text">A fragment of PS3 Bluetooth code</p> I&#8217;m quite pleased to announce that ever-popular Sony PS3 game controllers are now supported by current (rev.2.0) USB Host Library. Kristian Lauszus from TKJ Electronics developed a library to interface with Dualshock 3, as well as Move Navigation and Motion controllers via a Bluetooth dongle (only CSR-based ones [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_7158" class="wp-caption alignleft" style="width: 298px"><a href="/wp/wp-content/uploads/2012/03/code_288-216-03.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/03/code_288-216-03.jpg" alt="A fragment of PS3 Bluetooth code" title="A fragment of PS3 Bluetooth code" width="288" height="216" class="size-full wp-image-7158" /></a><p class="wp-caption-text">A fragment of PS3 Bluetooth code</p></div><br />
I&#8217;m quite pleased to announce that ever-popular Sony PS3 game controllers are now supported by current (rev.2.0) USB Host Library. Kristian Lauszus from <a href="http://blog.tkjelectronics.dk/" title="TKJ Electronics" target="_blank">TKJ Electronics</a> developed <a href="https://github.com/TKJElectronics/USB_Host_Shield_2.0" target="_blank"> a library</a> to interface with Dualshock 3, as well as Move Navigation and Motion controllers via a Bluetooth dongle (only CSR-based ones are supported at the moment). This library has been merged into the main code and I will start maintaining it as soon as my Dualshock 3 arrives.</p>
<p>Sony PS3 controllers are advanced versions of ordinary HID joysticks. They can be interfaced via USB or Bluetooth, the buttons can be read as analog or digital and controller contains rumble motor which can be activated remotely to indicate a hit, for example. The controller also contains a gyroscope and accelerometers so it is possible to control a robot by simply waving and/or rotating the controller.  </p>
<p>Kristian got his inspiration from <a href="/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-1">Richard Ibbotson&#8217;s articles</a>, as well as works by <a href="/mcu/rc-car-controlled-by-wii-remote-on-arduino">Tomoyuki Tanaka</a> and others (full list can be found in PS3README file). His <a href="https://github.com/TKJElectronics/USB_Host_Shield_2.0/wiki" title="TKJ Electronics Wiki" target="_blank">Wiki page</a> gives implementation details, communication protocol, differences between controllers, as well as plenty of links to other sources of PS3 controller interfacing knowledge.</p>
<p>Kristian developed this library as a part of his <a href="http://blog.tkjelectronics.dk/2012/03/the-balancing-robot/" title="Balancing robot">Balancing robot project</a>. The project is very well documented &#8211; if you are interested in robots, PID or remote control, please take a look. I also enjoyed watching this <a href="http://youtu.be/N28C_JqVhGU" title="Balancing robot presentation">video presentation</a>, give it a shot to see balancing robot in action.</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/sony-ps3-controller-support-added-to-usb-host-library/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Major ACM/Prolific bug fix posted on gitHub</title>
		<link>http://www.circuitsathome.com/mcu/major-acmprolific-bug-fix-posted-on-github</link>
		<comments>http://www.circuitsathome.com/mcu/major-acmprolific-bug-fix-posted-on-github#comments</comments>
		<pubDate>Wed, 29 Feb 2012 20:38:55 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[acm]]></category>
		<category><![CDATA[pl2303]]></category>
		<category><![CDATA[USB Host Shield]]></category>
		<category><![CDATA[usb to serial]]></category>

		<guid isPermaLink="false">https://www.circuitsathome.com/?p=7134</guid>
		<description><![CDATA[<p></p> <p>While playing with some cheap USB to RS-232 converters which use counterfeit PL2303 chips I found a bug in acm code which was sitting there from initial release. This bug was causing sluggish response from serial devices, as well as random 0x0d and 0x06 error codes. The bug is now fixed and corrected version [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/wp/wp-content/uploads/2011/10/code_288-216-01.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2011/10/code_288-216-01.jpg" alt="" title="code_288-216-01" width="288" height="216" class="alignright size-full wp-image-6737" /></a></p>
<p>While playing with some cheap USB to RS-232 converters which use counterfeit PL2303 chips I found a bug in acm code which was sitting there from initial release. This bug was causing sluggish response from serial devices, as well as random <code>0x0d</code> and <code>0x06</code> error codes. The bug is now fixed and <a href="https://github.com/felis/USB_Host_Shield_2.0">corrected version of the library</a> has been posted on GitHub a moment ago. </p>
<p>As a side effect to aforementioned bug fix some new functionality is now available. First, <code>ACM</code> and <code>PL2303</code> classes now have <code>isReady()</code> method which can be used to check if certain device has been enumerated, initialized, and ready for service. This method is now used in all sample sketches, see, for example, <a href="https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/pl2303/pl2303_tinygps/pl2303_tinygps.pde">pl2303_tinygps.pde</a>, line 98.</p>
<p>Another addition is a block of code which performs proper PL2303 initialization. It is a mix of Linux pl2303.c code and Windows Prolific driver USB protocol traces. This block was added during troubleshooting; it turned out that it doesn&#8217;t make any difference on PL2303-based devices that I have &#8211; either genuine or counterfeit. However, it is tempting to be able to simulate &#8220;proper&#8221; manufacturer-recommended behaviour in the code so I decided to keep the initialization. It is turned off by default; if desired, it can be added during compilation by defining <code>PL2303_COMPAT</code> (see <a href="https://github.com/felis/USB_Host_Shield_2.0/blob/master/cdcprolific.h">cdcprolific.h</a>, line 41 and <a href="https://github.com/felis/USB_Host_Shield_2.0/blob/master/cdcprolific.cpp">cdcprolific.cpp</a>, lines 159-179 ). The block adds ~500 bytes to the binary so don&#8217;t turn it on just in case.</p>
<p>Please check the new code with your devices and let me know if you can see any improvements or new issues.</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/major-acmprolific-bug-fix-posted-on-github/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Low cost step-up-down 120ma DC-DC converter</title>
		<link>http://www.circuitsathome.com/dc-dc/low-cost-step-up-down-120ma-dc-dc-converter</link>
		<comments>http://www.circuitsathome.com/dc-dc/low-cost-step-up-down-120ma-dc-dc-converter#comments</comments>
		<pubDate>Sun, 26 Feb 2012 01:31:18 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[DC-DC]]></category>
		<category><![CDATA[Store]]></category>
		<category><![CDATA[converter]]></category>
		<category><![CDATA[MCP1253]]></category>
		<category><![CDATA[step-down]]></category>
		<category><![CDATA[step-up]]></category>

		<guid isPermaLink="false">https://www.circuitsathome.com/?p=6981</guid>
		<description><![CDATA[<p><p class="wp-caption-text">120ma Inductorless DC-DC converter</p> Today&#8217;s electronic projects often require more than one supply voltage. 5V is often used to power MCUs, while sensors and peripheral interface controllers usually need 3.3V &#8211; if both types are used in your circuit, both voltages must be provided. Typically, one of the voltages is produced from the main [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_6983" class="wp-caption alignleft" style="width: 298px"><a href="/wp/wp-content/uploads/2012/02/ILDC_title.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/02/ILDC_title-288x216.jpg" alt="120ma Inductorless DC-DC converter" title="120ma Inductorless DC-DC converter" width="288" height="216" class="size-thumbnail wp-image-6983" /></a><p class="wp-caption-text">120ma Inductorless DC-DC converter</p></div><br />
Today&#8217;s electronic projects often require more than one supply voltage. 5V is often used to power MCUs, while sensors and peripheral interface controllers usually need 3.3V &#8211; if both types are used in your circuit, both voltages must be provided. Typically, one of the voltages is produced from the main supply (battery, wall wart, etc.) and the second voltage is then derived from the first using either linear LDO regulator if the second voltage is lower than the first or a boost converter if the second voltage is higher.</p>
<p>The boost converter I&#8217;ve designed uses Microchip MCP1253 charge pump controller. It doesn&#8217;t use an inductor and is capable of providing selectable 5V or 3.3V output voltage and up to 120ma of output current. The converter is half-inch long and weighs just 0.5g. All through-hole pads are placed on 0.1&#8243; grid making it breadboard-friendly. Thanks to inductorless desgn, the converter is inexpensive, stable, and easy to use while providing automatic switching between step-down and step-up modes, and offering extra options, such as external shutdown and supply monitoring. The following picture shows board connections (click on it to make it bigger):</p>
<div id="attachment_6993" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/2012/02/ILDC_pinout2.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/02/ILDC_pinout2-288x216.jpg" alt="ILDC_pinout" title="ILDC_pinout" width="288" height="216" class="size-thumbnail wp-image-6993" /></a><p class="wp-caption-text">ILDC_pinout</p></div>
<ul>
<li><strong>Vin, Vout, GND</strong> are the only connections necessary out of the box (they are marked on the other side of the PCB). Input voltage can be 2.0-6.0V, output voltage is set to 5V. The converter automatically switches from buck to boost, therefore it is possible, for example, to have regulated 5V output in the whole discharge range of a battery of four alkaline cells (3.6-6V), or 3.3V from a single LiPo (if you switch output voltage to 3.3V, see below). The output current is 120ma, maintained down to 2.8 Vin at 5V Vout</li>
<li><strong>3-pad Vout set jumper</strong> is set to 5V by a shorting middle pad to the right one. To switch output voltage to 3.3V remove the short using solder wick and short middle pad to the left one</li>
<li><strong>Shutdown</strong> The converter can be stopped by pulling this signal low. By default, it is hardwired to Vin, in order to use it, you need to cut a trace inside <strong>Shutdown enable jumper</strong>. The jumper can be later closed, if necessary, similarly to output voltage selector</li>
<li><strong>Power Good</strong> This signal falls low when output is out of regulation, which can indicate low battery or excessive load. In order to use this signal, a 100K 0603 resistor must be soldered on vacant pads indicated by the arrow <strong>Power Good Resistor</strong></li>
</ul>
<p><a href="/wp/wp-content/uploads/2012/02/IND_DCDC_r1.zip" title="Eagle Files">Design files</a> are available for download. Fully populated and tested boards <a href="/products-page/power-supplies/120ma-5v3-3v-step-upstep-down-converter" title="Store Link">are offered for sale</a> at the store. If there is enough interest, I can also offer blank PCBs as well as boards preconfigured for 3.3V output voltage. Please leave a comment if you&#8217;d like these options added.</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/dc-dc/low-cost-step-up-down-120ma-dc-dc-converter/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Modified USB Isolator</title>
		<link>http://www.circuitsathome.com/measurements/modified-usb-isolator</link>
		<comments>http://www.circuitsathome.com/measurements/modified-usb-isolator#comments</comments>
		<pubDate>Fri, 24 Feb 2012 17:51:27 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Measurements]]></category>
		<category><![CDATA[adum4160]]></category>
		<category><![CDATA[linear]]></category>
		<category><![CDATA[usb isolator]]></category>

		<guid isPermaLink="false">https://www.circuitsathome.com/?p=7037</guid>
		<description><![CDATA[<p class="wp-caption-text">Modified USB Isolator</p> <p>David Peters shared his modifications to my USB Isolator board. The board can be seen on a title picture (click on it to make it bigger), the design files can be downloaded and below is the list of modifications:</p> Isolated VBUS supply has been added DC/DC converter can be enabled or [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_7038" class="wp-caption alignright" style="width: 298px"><a href="/wp/wp-content/uploads/2012/02/david_usbiso.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/02/david_usbiso-288x216.jpg" alt="Modified USB Isolator" title="Modified USB Isolator" width="288" height="216" class="size-thumbnail wp-image-7038" /></a><p class="wp-caption-text">Modified USB Isolator</p></div>
<p>David Peters shared his modifications to my USB Isolator board. The board can be seen on a title picture (click on it to make it bigger), the <a href="/wp/wp-content/uploads/2012/02/dp_ui12.zip">design files can be downloaded</a> and below is the list of modifications:</p>
<ul>
<li>Isolated VBUS supply has been added</li>
<li>DC/DC converter can be enabled or disabled by jumper to choose external power supply</li>
<li>7805 linear regulator can be used instead of DC-DC converter</li>
<li>Optional additional capacitors for better filtering</li>
<li>Enumeration reset possible with jumper</li>
<li>LEDs for input and output power visualization</li>
<li>Isolation between areas is 6mm providing ~600V protection</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/measurements/modified-usb-isolator/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Arduino 1.0-compatible USB Host Library released</title>
		<link>http://www.circuitsathome.com/mcu/arduino-1-0-compatible-usb-host-library-released</link>
		<comments>http://www.circuitsathome.com/mcu/arduino-1-0-compatible-usb-host-library-released#comments</comments>
		<pubDate>Wed, 11 Jan 2012 02:58:28 +0000</pubDate>
		<dc:creator>oleg</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[USB Shield]]></category>
		<category><![CDATA[MAX3421E]]></category>
		<category><![CDATA[USB Host Shield]]></category>

		<guid isPermaLink="false">https://www.circuitsathome.com/?p=6950</guid>
		<description><![CDATA[<p> Fresh update of USB Host Library 2.0 has just been posted to GitHub. The primary purpose of this release is to maintain compatibility with Arduino releases &#8211; the USB Host Library is now compiles in 1.0 as well as pre-1.0 versions of Arduino IDE. Enjoy!</p> <p>Several important changes have been made to the code, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://www.circuitsathome.com/wp/wp-content/uploads/2012/01/code_288-216-02.jpg"><img src="https://www.circuitsathome.com/wp/wp-content/uploads/2012/01/code_288-216-02.jpg" alt="" title="" width="288" height="216" class="alignright size-full wp-image-6954" /></a><br />
<a href="https://github.com/felis/USB_Host_Shield_2.0">Fresh update of USB Host Library 2.0</a> has just been posted to GitHub. The primary purpose of this release is to maintain compatibility with Arduino releases &#8211;  the USB Host Library is now compiles in 1.0 as well as pre-1.0 versions of Arduino IDE. Enjoy!</p>
<p>Several important changes have been made to the code, some related to 1.0 compatibility and some not. The library examples were all tested and corrected, the information below is intended for developers using the library in their own projects:</p>
<ol>
	<strong>
<li>PL2302 driver.</strong> Arduino 1.0 defines PL symbol internally (thank you, Paul for finding this out!), therefore, I needed to change name of Prolific class driver. The new name is <code>PL2302</code>; I updated library examples to compile correctly, if someone uses this class in their own development, the right way to define an instance of Prolific device is now <code>PL2303 Pl(&#038;Usb, &#038;AsyncOper);</code></li>
<p>	<strong>
<li>NAK handling.</strong> A bug preventing long polls of an endpoint has been fixed. Previously, if <code>bmNakPower</code> member of <code>epInfo</code> structure was left unitialized the transfer to this endpoint would stop after receiving a single NAK. With current version, the endpoint would be polled for up to 5 seconds. This is rarely desirable, so please initialize <code>bmNakPower</code> with <code>USB_NAK_DEFAULT</code> or <code>USB_NAK_MAX_POWER</code>. If a single poll is desired, as is often the case with interrupt endpoints, specify <code>USB_NAK_NOWAIT</code> and if more than maximum number of NAKs (up to 5 seconds) is necessary, specify <code>USB_NAK_NONAK</code>.</li>
<p>	<strong>
<li>Code speed.</strong> An unnecessary delay of 20ms has been found (thank you, Alex for discovering this!) and removed from <code>USB::setAddress()</code> member function. As a result, every USB transfer is now 20ms faster. While generally a good thing, it could inadvertently affect data exchanges with slow endpoints. If after upgrading to the current version you start seeing more NAKs, that&#8217;s probably why.</li>
</ol>
<p>One nice thing about Arduino 1.0 is built-in PROGMEM support for strings. It is now possible to free about 300-400 bytes of RAM by redefining USBTRACE and USBTRACE2 macros used in debugging output (thank you, John, for the tip!). For example, <code>USBTRACE (Serial.print(F(s)))</code> will move all USBTRACE strings to PROGMEM. The code size will increase so be careful with this feature if your code size is close to the limit for your Arduino board.</p>
<p>This is the end of announcement &#8211; download the code, play with it and if you have any issues please share your findings in the comments.</p>
<p>Oleg.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.circuitsathome.com/mcu/arduino-1-0-compatible-usb-host-library-released/feed</wfw:commentRss>
		<slash:comments>106</slash:comments>
		</item>
	</channel>
</rss>

