<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>alexwhittemore.com</title>
	<atom:link href="http://www.alexwhittemore.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alexwhittemore.com</link>
	<description>//Blog</description>
	<lastBuildDate>Tue, 29 Nov 2011 17:33:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Eagle Parts Library Now on Github</title>
		<link>http://www.alexwhittemore.com/eagle-parts-library-now-on-github/</link>
		<comments>http://www.alexwhittemore.com/eagle-parts-library-now-on-github/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 17:33:44 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[eagle]]></category>
		<category><![CDATA[eagle library]]></category>
		<category><![CDATA[eagle parts]]></category>
		<category><![CDATA[eda]]></category>
		<category><![CDATA[schematic]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=552</guid>
		<description><![CDATA[I finally got around to putting my personal Eagle parts library on Github. There's not much else to it, find it here. The most noteworthy thing in there is the SOT223-5 footprint, which I couldn't find anywhere online or in the default libraries. Enjoy! Complete listing below.This is certainly subject to (rapid) change, see the [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_553" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-29-at-12.25.57-PM.png"><img class="size-medium wp-image-553" title="Screen Shot 2011-11-29 at 12.25.57 PM" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-29-at-12.25.57-PM-300x232.png" alt="" width="300" height="232" /></a><p class="wp-caption-text">Eagle parts!</p></div>
<p>I finally got around to putting my personal Eagle parts library on Github. There's not much else to it, find it <a href="https://github.com/alexwhittemore/alexwhittemore-eagle">here</a>. The most noteworthy thing in there is the SOT223-5 footprint, which I couldn't find anywhere online or in the default libraries. Enjoy! Complete listing below.<span id="more-552"></span>This is certainly subject to (rapid) change, see the commit messages on github, but for now the library includes:</p>
<ul>
<li>Analog Devices AD7685</li>
<li>ADC121C021</li>
<li>TI INA125 (the default libs already have it, but for some reason that wasn't good enough, don't remember why)</li>
<li>Linear Technology LTC1063</li>
<li>Maxim MAX7414</li>
<li>Maxim MAX31855</li>
<li>ON Semi MC74VHC1GT126</li>
<li>TI REF3333</li>
<li>Burr-Brown REG103</li>
<li>SN754410</li>
<li>Omega PCB-Mount Thermocouple Receptacle</li>
<li>Bournes 25-turn trim pot</li>
<li>Amphenol USB3.0A Receptacle</li>
<li>Amphenol USB3.0B Receptacle</li>
</ul>
<p>The packages are all standard from the default libraries except:</p>
<ul>
<li>Sot223-5</li>
</ul>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5518377310821477";
google_ad_slot = "4999204559";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/eagle-parts-library-now-on-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USB IR Toy V3 Mouser Shopping Cart</title>
		<link>http://www.alexwhittemore.com/usb-ir-toy-v3-mouser-shopping-cart/</link>
		<comments>http://www.alexwhittemore.com/usb-ir-toy-v3-mouser-shopping-cart/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 05:44:51 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[bom]]></category>
		<category><![CDATA[dangerous prototypes]]></category>
		<category><![CDATA[irtoy]]></category>
		<category><![CDATA[mouser]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=543</guid>
		<description><![CDATA[I got the USB IR Toy v3 as a free PCB from Dangerous Prototypes a few weeks back, but until recently I haven't had much time to track down all the parts for it. Given that this is a v3 and not a v2, there isn't a simple shopping cart of parts at Mouser kicking [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_546" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/FileUSB-IRtoy-v3-pcb.jpeg"><img class="size-medium wp-image-546" title="USB-IRtoy-v3-pcb" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/FileUSB-IRtoy-v3-pcb-300x191.jpg" alt="" width="300" height="191" /></a><p class="wp-caption-text">USB IR Toy v3</p></div>
<p>I got the <a href="http://dangerousprototypes.com/docs/Vanesse:_USB_IR_Toy_v3" target="_blank">USB IR Toy v3</a> as a free PCB from Dangerous Prototypes a few weeks back, but until recently I haven't had much time to track down all the parts for it. Given that this is a v3 and not a v2, there isn't a simple shopping cart of parts at Mouser kicking around. So, I decided to make one! <span id="more-543"></span>Here is <a title="Mouser Project BOM" href="https://www.mouser.com/ProjectManager/ProjectDetail.aspx?AccessID=109e5044dc" target="_blank">the link</a> to the project on Mouser. I have some notes from assembling it, though, that someone with more knowledge of the project should hopefully be able to respond to.</p>
<p>1. I didn't specify an inductor for L1, my plan is to simply short the pads together. My logic is that I have no idea where to find an 0805 footprint inductor, and the bypass caps on all the ICs should be plenty. Yes? No?<br />
2. I decided to use one of the already-required 1µF ceramic caps for the regulator, rather than a polarized cap as none was specified. The bigger footprint suggests a tantalum was intended, but the datasheet for the regulator makes no specification as to WHAT kind of bypass cap should be used, only that it should be &gt;=1µF. And the 0805 cap used elsewhere in the project will physically fit those pads.<br />
3. VUSB of the PIC is shorted to 3v3 = VDD, is that right? It seems to me like it's not, but then maybe it's a typo in the schematic symbol for the IC.<br />
4. PIC18F24J50, is that right? The specified part number doesn't exist, and looks like it's an incorrectly formed version of this part (same part, with some digits/characters transposed).<br />
5. I used the existing Infrared demodulator, TSOP38238 rather than TSOP34838, which is not in at mouser and won't be for another two or three weeks. Is there a special reason why the latter was specified?<br />
6. On the board I have (same as in the picture on the <a href="http://dangerousprototypes.com/docs/Vanesse:_USB_IR_Toy_v3" target="_blank">project page</a>), there is no reset switch placed. I don't know if the switch is obsoleted by software or some such, but if it's not, it'll have to be jerry-rigged anyway, so there's no sense in buying a part that we can't solder.<br />
7. I used the BC81840MTF as T1, rated in the parts listing as 800mA+ when the project calls for 1A+, is that a problem? It seems to me like 1A for an LED is insane, but then that's what the BOM on the project page calls for. Is there a problem here?</p>
<p>Assuming these points all check out, the project cart should be good to go! HOWEVER! An astute reader will note that the quantities are all higher than required. I like to order extras of EVERYTHING, especially the little parts, since I ALWAYS seem to lose parts to the carpet (last project, it was a $15 MSOP-10 ADC. Thank goodness the project budget paid for one or two extra). This is obviously more critical with the small, cheap parts (0805 resistors and caps) than it is with the big parts (PICs, LEDs). You could probably shave a fair few dollars off the project cost by making these quantities closer to what's actually required. And in fact, when I order, I probably will. Something to consider.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5518377310821477";
google_ad_slot = "4999204559";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/usb-ir-toy-v3-mouser-shopping-cart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bulbdial Mod Revisit</title>
		<link>http://www.alexwhittemore.com/bulbdial-mod-revisit/</link>
		<comments>http://www.alexwhittemore.com/bulbdial-mod-revisit/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 02:04:04 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[bulbdial]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[mod]]></category>
		<category><![CDATA[touch]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=532</guid>
		<description><![CDATA[I've been getting great use out of my modded Evil Mad Scientist Laboratories Bulbdial clock (you might remember, I modded it with a touch sensitive strip to turn the display on and off), but it's been having some problems lately. Because I couldn't solder to the aluminum tape I previously used, the contacts taped in [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_533" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/IMG_0865.jpg"><img class="size-medium wp-image-533 " title="BulbdialRevisit" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/IMG_0865-300x224.jpg" alt="" width="300" height="224" /></a><p class="wp-caption-text">The new copper tape in place</p></div>
<p>I've been getting great use out of my modded Evil Mad Scientist Laboratories Bulbdial clock (you <a href="http://www.alexwhittemore.com/?p=447">might remember</a>, I modded it with a touch sensitive strip to turn the display on and off), but it's been having some problems lately. Because I couldn't solder to the aluminum tape I previously used, the contacts taped in place were getting loose, causing the clock to flicker on and off. The loose contacts also made functionality very sporadic. The solution was to swap the aluminum strips out with the <a href="http://www.sparkfun.com/products/10561">copper foil</a> I bought a while back from Sparkfun for a whopping $3. <span id="more-532"></span></p>
<p>While I was working, I decided to revisit the mod. Here is the module I had previously made:</p>
<div id="attachment_535" class="wp-caption alignnone" style="width: 234px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/IMG_08621.jpg"><img class="size-medium wp-image-535" title="IMG_0862" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/IMG_08621-224x300.jpg" alt="" width="224" height="300" /></a><p class="wp-caption-text">Top view of circuitry</p></div>
<p>And from the bottom:</p>
<div id="attachment_536" class="wp-caption alignnone" style="width: 234px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/IMG_0863.jpg"><img class="size-medium wp-image-536" title="IMG_0863" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/IMG_0863-224x300.jpg" alt="" width="224" height="300" /></a><p class="wp-caption-text">Bottom view of circuitry</p></div>
<p>And finally, everything put together:</p>
<div id="attachment_537" class="wp-caption alignnone" style="width: 234px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/IMG_0864.jpg"><img class="size-medium wp-image-537" title="IMG_0864" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/IMG_0864-224x300.jpg" alt="" width="224" height="300" /></a><p class="wp-caption-text">Assembled</p></div>
<p>I also decided to actually add the schematic into the original, just for clarity. Before:</p>
<div id="attachment_538" class="wp-caption alignnone" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-27-at-8.40.30-PM.png"><img class="size-medium wp-image-538" title="Screen Shot 2011-11-27 at 8.40.30 PM" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-27-at-8.40.30-PM-300x210.png" alt="" width="300" height="210" /></a><p class="wp-caption-text">Original switch schematic</p></div>
<p>And the modded version, as it stands now:</p>
<div id="attachment_539" class="wp-caption alignnone" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-27-at-8.38.48-PM.png"><img class="size-medium wp-image-539" title="Screen Shot 2011-11-27 at 8.38.48 PM" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-27-at-8.38.48-PM-300x212.png" alt="" width="300" height="212" /></a><p class="wp-caption-text">Schematic with mod</p></div>
<p>However, I'm curious as to what would happen if I scrapped the center pin on the header I added to the switch, which is jumpered to VDD elsewhere on the board. I could instead connect the touch strips to the pin of the µC itself, in effect creating a diode-connected transistor. The main problem I can see is that this would only allow for the transistor to pull the input pin (which must be internally pulled up) to GND+Vf of the transistor's base-emitter diode. <del>I haven't checked what the 'low' voltage of the pin is now with the current design</del>, but I'd bet that the input is unstable at 'low' = .7V. Still, it'd be cool to eliminate the one part and the one extra assembly step. (Update: I did check what the current 'low' voltage is, around 0.07-0.08V, quite stably 'low' indeed).</p>
<p>Perhaps some more experimentation next time. But in the mean time, the problem has been fixed.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5518377310821477";
google_ad_slot = "4999204559";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/bulbdial-mod-revisit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open Source IDE and Toolchain for the STM32F4 Discovery on Mac OSX Lion</title>
		<link>http://www.alexwhittemore.com/open-source-ide-and-toolchain-for-the-stm32f4-discovery-on-mac-osx-lion/</link>
		<comments>http://www.alexwhittemore.com/open-source-ide-and-toolchain-for-the-stm32f4-discovery-on-mac-osx-lion/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 04:23:38 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Microcontrollers]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=492</guid>
		<description><![CDATA[ST Micro in the last few weeks was the first to market with the brand new ARM Cortex-M4 32-bit microcontroller core. The really interesting new feature is the 'F' in the name - this is the first low-cost, low-ish-power light duty microcontroller to include a built in, single cycle per instruction 32-bit floating point unit. [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_528" class="wp-caption alignleft" style="width: 200px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/stm32f4_discovery.jpeg"><img class="size-medium wp-image-528 " title="stm32f4_discovery" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/stm32f4_discovery-190x300.jpg" alt="" width="190" height="300" /></a><p class="wp-caption-text">STM32F4-Discovery</p></div>
<p>ST Micro in the last few weeks was the first to market with the brand new ARM Cortex-M4 32-bit microcontroller core. The really interesting new feature is the 'F' in the name - this is the first low-cost, low-ish-power light duty microcontroller to include a built in, single cycle per instruction 32-bit floating point unit. In typical ST fashion, the development board is awesome - it's got a built in ST-LINK/V2 programmer and in-circuit debugger on the top half. The bottom half contains the M4 and a host of fun peripherals to play with, including a 3-axis MEMS accelerometer, an audio DAC with class D output driver, a bunch of LEDs, and all GPIOs broken out to .1" headers.<span id="more-492"></span></p>
<p>But alas, the software stinks. In fact, it doesn't come with software. There are 4 proprietary (and EXPENSIVE) toolchains supported, Altium TASKING, Atollic TrueStudio, IAR Embedded Workbench for ARM, and Keil MDK-ARMT. Of those, only Atollic and IAR have free versions, where IAR is 32 KB limited (the M4 has 1MB flash), and where Atollic is neither time nor size limited, but doesn't support C++. For some that will be fine, but I'm certain I'll find that annoying.</p>
<p>So what do we do?! Luckily, the single most developed compiler out there is open source, GCC! We're going to use a commercially-developed open source compiler, Mentor Graphics' <a href="http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/lite-edition">Sourcery CodeBench Lite edition</a>. We'll pair that with the open source IDE Eclipse (standard for most open source and commercial development toolchains alike), and then weave in ST's tools like ST-LINK/V2 to fill in the gaps. I'm going to mash up a few different existing tutorials to do this, starting with this <a href="https://sites.google.com/site/stm32discovery/open-source-development-with-the-stm32-discovery/setting-up-eclipse-for-stm32-discovery-development">excellent tutorial</a> for setting up this same toolchain, but for the original STM32VL Discovery and on Windows.</p>
<p>Prerequesites: you'll need Apple's developer tools (<a href="http://developer.apple.com/technologies/tools/">Xcode</a>), a package manager for *nix programs (instructions given are for <a href="http://mxcl.github.com/homebrew/">homebrew</a>, you could probably use <a href="http://www.macports.org/">macports</a> if you really want), and <a href="http://git-scm.com/">git</a>.</p>
<p>Here's what we'll be using:</p>
<p>Indigo R Eclipse IDE for C/C++ Developers (Mac Cocoa 64-bit)<br />
<a href="http://www.eclipse.org/downloads/packages/release/indigo/r">http://www.eclipse.org/downloads/packages/release/indigo/r</a></p>
<p>STM32F4 DSP and standard peripherals library<br />
STM32F4 Discovery board firmware package<br />
<a href="http://www.st.com/internet/mcu/product/252149.jsp#SOFTWARE_AND_DEVELOPMENT_TOOLS">http://www.st.com/internet/mcu/product/252149.jsp#SOFTWARE_AND_DEVELOPMENT_TOOLS</a>Start downloading these now, they can take a long time.</p>
<p>&nbsp;</p>
<p>Sourcery G++ Lite 2011.03-42 for ARM EABI Source TAR - jsnyder package<br />
<a href="https://github.com/jsnyder/arm-eabi-toolchain">https://github.com/jsnyder/arm-eabi-toolchain</a></p>
<p>1. Download and install Eclipse. From <a href="http://www.eclipse.org/downloads/packages/release/indigo/r">here</a>, download the Mac Cocoa 64-bit version of Eclipse for C/C++ developers. Extract the .tar.gz, and copy the 'eclipse' folder to /Applications, as you would with any other Mac app. Launch Eclipse.app from that folder. When prompted for a workspace directory, add 'stm32f4-discovery-projects' to the path just before '/workspace', as below:</p>
<div id="attachment_497" class="wp-caption alignnone" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-17-at-11.28.54-AM.png"><img class="size-medium wp-image-497 " title="Eclipse Path" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-17-at-11.28.54-AM-300x218.png" alt="Set your workspace path" width="300" height="218" /></a><p class="wp-caption-text">Set your path</p></div>
<p>2. Install Sourcery G++ lite. We're going to use the arm-eabi-toolchain builder from James Snyder. Launch Terminal from /Applications/Terminal or spotlight and enter the following commands, preferably one at a time. Note that the compile commands (CC=clang make... and make cross-gdb take a LONG time, go grab coffee).<br />
<code><br />
cd<br />
git clone https://github.com/jsnyder/arm-eabi-toolchain.git<br />
cd arm-eabi-toolchain<br />
brew install mpfr gmp libmpc texinfo<br />
mkdir -p $HOME/arm-cs-tools/bin<br />
export PATH=$HOME/arm-cs-tools/bin:$PATH<br />
CC=clang make cross-binutils cross-gcc cross-g++ cross-newlib<br />
make cross-gdb<br />
export PATH=$HOME/arm-cs-tools/bin:$PATH<br />
make clean<br />
</code></p>
<p>3. Configure Eclipse. Launch Eclipse that you started earlier. In the menu, go to 'Help&gt;Install New Software...' then click on the 'Available Software Sties' link. Search for 'cdt' and select the one checkbox that pops up. Hit OK.</p>
<div id="attachment_506" class="wp-caption alignnone" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-4.38.18-PM.png"><img class="size-medium wp-image-506 " title="Available Software Sites" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-4.38.18-PM-300x189.png" alt="" width="300" height="189" /></a><p class="wp-caption-text">Search for &#39;cdt&#39;</p></div>
<p>In the 'Available Software' window, select the last entry in the 'Work with:' dropdown. Expand 'CDT Optional Features' and select 'GCC Cross Compiler Support'. Click 'Next' until the wizard successfully installs and/or updates everything (in my case, all the software was already installed, so it just updated). Restart Eclipse when prompted.</p>
<div id="attachment_508" class="wp-caption alignnone" style="width: 296px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-4.46.16-PM.png"><img class="size-medium wp-image-508 " title="Available Software (better shot)" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-4.46.16-PM-286x300.png" alt="" width="286" height="300" /></a><p class="wp-caption-text">Select Cross Compiler Support</p></div>
<p>4. Create a custom template. In Eclipse, go to 'File&gt;New C++ Project'. Name the project 'Template', and for 'project type', select 'Cross-Compile Project' under 'Executable'. Click 'Next', NOT FINISH.</p>
<div id="attachment_516" class="wp-caption alignnone" style="width: 290px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-6.52.38-PM.png"><img class="size-medium wp-image-516" title="C++ Project" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-6.52.38-PM-280x300.png" alt="" width="280" height="300" /></a><p class="wp-caption-text">Template project settings</p></div>
<p>On the next screen, set the tool command prefix to 'arm-none-eabi-' and the tool command path to '~/arm-cs-tools/bin'</p>
<div id="attachment_518" class="wp-caption alignnone" style="width: 291px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-7.21.03-PM.png"><img class="size-medium wp-image-518" title="Cross Compile Command" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-7.21.03-PM-281x300.png" alt="" width="281" height="300" /></a><p class="wp-caption-text">Enter these values for tool prefix and path.</p></div>
<p>Click 'Next' then 'Finish'. Click on the 'Go to workbench' icon. In the project explorer, right click 'Template' and click 'Properties'. In the 'Project Properties' window, select 'C/C++ Build&gt;Settings'. Under 'Cross GCC Assembler&gt;General' add <code>-mthumb -mcpu=cortex-m4</code>to 'Assembler Flags'.</p>
<div id="attachment_522" class="wp-caption alignnone" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-8.12.15-PM.png"><img class="size-medium wp-image-522" title="Cross GCC Assembler General" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-8.12.15-PM-300x218.png" alt="" width="300" height="218" /></a><p class="wp-caption-text">Add -mthumb -mcpu=cortex-m4 to assembler flags.</p></div>
<p>In the 'Miscellaneous' sections of both 'Cross GCC Compiler' and 'Cross G++ Compiler' set the 'Other flags' to <code>-c -mthumb -mcpu=cortex-m4</code>. Finally, go to 'Cross G++ Linker&gt;Miscellanoues' and set the 'Linker flags' to <code>-T "${ProjDirPath}\startup_src\stm32_flash.ld" -mthumb -mcpu=cortex-m4 -Wl,-Map=linker.map -Wl,-cref -Wl,--gc-sections</code>. Click OK.</p>
<p>In the Project Explorer, right click 'Template' and select 'New&gt;Folder' to create 'src' and 'startup-src'</p>
<div id="attachment_523" class="wp-caption alignnone" style="width: 290px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-9.28.23-PM.png"><img class="size-full wp-image-523" title="Project Explorer" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-9.28.23-PM.png" alt="" width="280" height="192" /></a><p class="wp-caption-text">Create these folders</p></div>
<p>5. Extract the earlier downloaded stm32f4_dsp_stdperiph_lib.zip inside the ~/Documents/stm32f4-discovery-projects/ directory.</p>
<div id="attachment_524" class="wp-caption alignnone" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-10.16.40-PM.png"><img class="size-medium wp-image-524" title="Directory Structure" src="http://www.alexwhittemore.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-19-at-10.16.40-PM-300x93.png" alt="" width="300" height="93" /></a><p class="wp-caption-text">Make sure your project directory looks like this</p></div>
<p>Copy the file <code>~/Documents/stm32f4-discovery-projects/STM32F4xx_DSP_StdPeriph_Lib_V1.0.0/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/TrueSTUDIO/startup_stm32f4xx.s</code> to the startup_src directory you created in Eclipse above, then <strong>change the extension from .s to .S, capitalized.</strong> Note that you must drag/drop or copy/paste directly <strong>into the Eclipse interface</strong> or the file won't show up in Eclipse.</p>
<p>This is as far as I've gotten. I'm currently hung up on how to replace '<strong>stm32_flash.ld</strong>' since the M4 isn't nearly the same flash layout as the value line board used in that tutorial and I can't seem to find a proper linker script. If you know where to go from here, PLEASE comment!</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5518377310821477";
google_ad_slot = "4999204559";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/open-source-ide-and-toolchain-for-the-stm32f4-discovery-on-mac-osx-lion/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How USB Charging in iProducts Works</title>
		<link>http://www.alexwhittemore.com/how-usb-charging-in-iproducts-works/</link>
		<comments>http://www.alexwhittemore.com/how-usb-charging-in-iproducts-works/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 02:32:30 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[iPhone Technical Articles]]></category>
		<category><![CDATA[Technical Articles]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=482</guid>
		<description><![CDATA[This may seem tirade-ish, and if so I'm sorry. This was spurred by the story posted here at TUAW. Basically, there's a little USB pass through dongle that you can buy to eliminate your iPad "not charging" woes. TUAW kind of misses the boat on bothering to explain or understand it, so here's how it [...]]]></description>
			<content:encoded><![CDATA[<p>This may seem tirade-ish, and if so I'm sorry. This was spurred by the story posted <a href="http://www.tuaw.com/2010/08/17/power-your-ipad-from-underpowered-usb-ports/">here at TUAW</a>. Basically, there's a little USB pass through dongle that you can buy to eliminate your iPad "not charging" woes. TUAW kind of misses the boat on bothering to explain or understand it, so here's how it works, in comment-on-the-article form (so read the article first):<span id="more-482"></span></p>
<div id="_mcePaste">It's got nothing to do with size of the dongle or weight of the iPad or the price of tea in china. Either the "NASA Scientist" mentioned is misquoted or is confused about the function of the device (i.e. thinks it's a battery backup like a juicepack), both equally likely.</div>
<div id="_mcePaste">The USB spec (old as sin, every computer made since 2000 or before knows this part) says that a device can have 100mA, period. These days, that's nothing. Things will charge from it, but slow as syrup. And they won't say they're charging. It also says, 'if you want more, ask.' That is, use the USB data lines to request a greater current. If the USB host says "ok," you can draw a maximum of 500mA. Again, every computer since time supports this half amp.</div>
<div>But that's still not all that much when you consider an iPad, with its huge battery capacity. So if the iPad gets here, it tells you "sorry, not charging [fast]" (I added the 'fast' part, that's what it means). If it can negotiate for an amp or more, as can be provided by lots of modern computers, and all modern macs, perfect. Charging at 1A/5V is 5W which theoretically means around a 5 hour full charge. Awesome. Given how batteries charge, it's probably more like 3/2 that time, but whatever. And if it can negotiate 1.5A, even better still.</div>
<div id="_mcePaste"><strong>But what if it's not plugged into a DATA port, but just a dumb provider of 5V, like a wall socket?</strong></div>
<p>Technically, in order to obey the USB spec, if it didn't negotiate for &gt; 100mA, it can't have &gt;100mA If it tries to draw more than 100mA and it's attached to a USB port with a power supply line that legitimately can't provide it, the result is a drop in voltage on the line, and bad things happen. Maybe it's connected to a 5V supply that can handle 40930485 amps, it doesn't matter. It's just not allowed.</p>
<p>Of course, most things can supply at least 500mA, and to be sure, lots do regardless of negotiation. If I plug a dumb little USB fan or whatever else into my computer, it may use more than 100mA. Technically it's not within the USB spec in this case, but whatever. So basically, you're safe drawing up to 500mA from a USB port without asking, although you probably won't get USB certification.</p>
<p>But of course, with a dumb charger, if you want to be within spec, you can't just *go* and draw what you like. There has to be some other methodology. iDevices for a long time have employed resistors on the data(+) and data(-) lines of the USB port to handle this. LadyAda tore apart <a href="http://www.ladyada.net/make/mintyboost/icharge.html">a few chargers</a> to figure this out, and she found something like this: if you want the iDevice to take 500mA, hold data+ at ~2.8v and data- at ~2.0v . <strong>edit: sorry, I didn't read the LadyAda page well enough, 2.8/2.0 is 1A, and 2.0/2.0 is 500mA. </strong>If you want it to charge at 1A, do something similar but with different values.</p>
<p>Finally, there's the more recent USB Charging spec. The pertinant part here is that on modern devices, you're within the letter of the USB spec if you short data+ and data- together as a message to the device, "you can draw any current you like, from 500mA to 1.5A."</p>
<p><strong>And something like that is going on here.</strong> It could be one of two different things. It's definitely safe to say that on the male USB plug, only V+ and GND are attached. That way there's no data negotiation at all. On the female side, it's possible that resistors are in place as in the paragraph above to tell the iDevice "I'm a dumb charger, draw 500mA." Although I lean away from that conclusion, since I BET that in such a case, the iDevice would still warn about too little current to charge. The other option is that, as per the Charging spec, the lines are shorted together. That'd technically tell the device "draw whatever," but I THINK that iDevices only draw 500mA in this case, which like I said is generally safe. And it could be that the iPad draws an amp, and the dongle just hopes that most users' computers will be able to handle it.</p>
<p>The bottom line is this:</p>
<p><strong>The dongle is not magic! </strong>It doesn't make power out of nowhere. It doesn't matter that it's small and light, or that the iPad is big and not. The takeaway here is that the dongle skirts the letter of USB law to say "computer, give me all you've got, whether you like it or not" and to tell the iPad "here's all the power you desire!" Maybe it works across the board, maybe not, but I'll definitely tell you I won't buy one. I'm 100% positive that if I stick that thing in my late 2008 MBP (with its 500mA max of usb current, yes, I tested the hard way), I'm DEFINITELY getting an overcurrent USB warning. And if I don't, the thing's not helping anyway.</p>
<p><strong>EDIT: </strong>I forgot to mention, but it's worth doing so, you can't simply tell the device "you have an amp" if you don't, in fact, have an amp to back it up. It won't just fall back to 500mA, that's not how Ohm's Law (v=ir) works. If the device tries to draw an amp, one of two things NECESSARILY happens. Either the computer CAN support the draw, but doesn't SAY so (in which case, there's certainly good reason it doesn't say so, and good reason you shouldn't be drawing an amp), or the computer CAN'T support the draw, and the USB bus fires an overcurrent warning and the power rail is shut down. And no charging at all takes place. In no case is it a good plan.</p>
<p><strong>UPDATE: </strong>For shiggles, I did some quick testing with my USB breakout cable. As per LadyAda's findings, my iPhone 4 with a nearly-full battery draws around 575mA from it's in-package wall charger, stock configuration. Stock configuration has data+ at 2.8 and data- at 2.0, which is what you'd expect from a charger UL rated for 1A supply. Similarly, when I disconnect the charger's data lines entirely, and instead show the phone 2.0v/2.0v, I measure a draw of around 510mA. Again, that's what I'd expect. I'd also expect to see that, charging full swing, it draws more connected to 2.8/2.0, but I'll have to wait until I have a low battery to test.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/how-usb-charging-in-iproducts-works/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Custom Breadboard</title>
		<link>http://www.alexwhittemore.com/custom-breadboard/</link>
		<comments>http://www.alexwhittemore.com/custom-breadboard/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 19:02:10 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[breadboard]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=462</guid>
		<description><![CDATA[A few people asked about this. I've seen breadboards with binding posts before, but usually they're nothing special, just some banana plugs near the board that you can screw a jumper wire into. I wanted something a little more full featured, so I whipped this up. It's 3 interlocking cheap $5 breadboards, linked together, that [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_469" class="wp-caption alignleft" style="width: 234px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0054-e1281808225735.jpg"><img class="size-medium wp-image-469" title="front view" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0054-e1281808225735-224x300.jpg" alt="front view" width="224" height="300" /></a><p class="wp-caption-text">My custom board</p></div>
<p>A few people asked about this. I've seen breadboards with binding posts before, but usually they're nothing special, just some banana plugs near the board that you can screw a jumper wire into. I wanted something a little more full featured, so I whipped this up.<span id="more-462"></span></p>
<div id="attachment_472" class="wp-caption alignright" style="width: 234px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0055.jpg"><img class="size-medium wp-image-472 " title="back view" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0055-e1281809029759-224x300.jpg" alt="back view" width="224" height="300" /></a><p class="wp-caption-text">View from the back, you can kind of see the power distribution block wiring.</p></div>
<p>It's 3 interlocking cheap $5 breadboards, linked together, that have had the sticky backing peeled off and that have been stuck to a clipboard. There are 8 banana terminals/binding posts mounted on the clip which are hardwired to the power rails of each individual board by a configureable jumper block. The advantage is that it keeps power management easy and clean, and any spare power rails can be used as easy interconnects to a meter(s) so that you don't have to have extra leads coming in. Basically, any off-board connections that can be made by banana plug can be moved away from the prototyping area, which means things stay more organized and there's less opportunity for heavy wires to yank out of the design by accident.</p>
<p>Also, mounting everything on a big clipboard means there's leftover room, in which I added (fake) laminated white paper as a whiteboard area. This way, notes can be made and labels added to clearly indicate current configuration.</p>
<p>Here's a quick video walkthrough:<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=14142437&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=14142437&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/14142437">Custom Breadboard</a> from <a href="http://vimeo.com/user2362024">Alex Whittemore</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/custom-breadboard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Touch Brightness Bulbdial</title>
		<link>http://www.alexwhittemore.com/touch-brightness-bulbdial/</link>
		<comments>http://www.alexwhittemore.com/touch-brightness-bulbdial/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 22:56:24 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[bulbdial]]></category>
		<category><![CDATA[capacitive]]></category>
		<category><![CDATA[resistive]]></category>
		<category><![CDATA[touch sensor]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=447</guid>
		<description><![CDATA[UPDATE: People keep asking about the breadboard setup. Fair enough. I'll throw together a quick overview when I get home today. UPDATE: here it is: http://www.alexwhittemore.com/?p=462 The Bulbdial clock from Evil Mad Scientist is probably the coolest clock idea I've ever seen. Even cooler are my parents, who got the kit for my birthday.  The [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_448" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0039.jpg"><img class="size-medium wp-image-448" title="The Bulbdial Clock" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0039-300x224.jpg" alt="Bulbdial clock with breadboard and multimeter" width="300" height="224" /></a><p class="wp-caption-text">Let&#39;s make it touch sensitive!</p></div>
<p>UPDATE: People keep asking about the breadboard setup. Fair enough. I'll throw together a quick overview when I get home today.<br />
UPDATE: here it is: <a href="http://www.alexwhittemore.com/?p=462">http://www.alexwhittemore.com/?p=462</a></p>
<p>The <a href="http://www.evilmadscientist.com/article.php/bulbdialkit">Bulbdial clock</a> from Evil Mad Scientist is probably the coolest clock idea I've ever seen. Even cooler are my parents, who got the kit for my birthday.  The basic idea is that three rings of LEDs cast shadows onto a clock face to form H/M/S hands, somewhat like a sundial, with the hands slowly animating around. A lot of thought clearly went into making this kit, and it's very nicely done, but there's a major drawback: I want to use it on my bed side table, where I usually keep a clock, but it's too bright for me to fall asleep! Of course, that's been thought of too: in the normal view mode, the three buttons at the bottom of the clock are brightness up, down, and "mute," which turns off the LEDs entirely. But they're hard to get to buried underneath the frame of the clock, and it makes muting the display cumbersome in the dark. Let's fix that!</p>
<p><span id="more-447"></span></p>
<p>My general solution to the problem at hand is pretty simple: I want some kind of strip running across the top edge of the front plate of the case that, when touched, toggles the display on or off. My first thought jumped to a capacitive sensor: I know that I can find one or two parts on <a href="http://www.sparkfun.com/">http://www.sparkfun.com/</a> to handle the heavy lifting, and I know they're pretty reliable. Problems with this plan sprang up pretty quickly, though. First, the two parts available on sparkfun are pretty expensive. One SMD bare part is ~$12, and a different broken-out part is $24. Both are a bit more than I want to spend on this project. Second, looking at the schematic from the bottom of the first link above, there are no spare GPIO pins left on the ATMega on the clock! That's sort of a deal breaker; I could use the hardware serial tx/rx lines, but then I lose the built-in serial functionality which I might want, and I want to be as unobtrusive as possible. Also, comments on those two parts mention that they can be difficult to set up with Arduino anyway, and I'm not especially good at programming micros, so even if there were GPIO pins left to use for software serial, that'd probably be a headache.</p>
<p>So sensor type option two is a resistive setup, which is not only substantially easier, it can even be made with all passive components bolted on to the existing design, as I'll do first (although the drawbacks will become apparent quickly). So resistive sensor, method one:</p>
<div id="attachment_451" class="wp-caption alignleft" style="width: 300px"><a href="http://www.delphiglass.com/copper-foil-supplies/copper-foil/1-4-copper-foil-1-0-mil?source=froogle"><img class="size-full wp-image-451 " title="copper foil tape" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/126681.jpg" alt="copper foil tape" width="290" height="290" /></a><p class="wp-caption-text">You use this to fasten pieces of stained glass into a pane by soldering.</p></div>
<p>In both cases, there need to be two conductive strips running along the top case edge in question to sense a finger's resistance. Ideally I'd have used the kind of copper foil tape used in stained glass, like <a href="http://www.delphiglass.com/copper-foil-supplies/copper-foil/1-4-copper-foil-1-0-mil?source=froogle">this stuff.</a> It's cheap, conductive, sticky-backed, and it'll hold solder to fasten leads to: it's INTENDED to fasten pieces of glass together by soldering. But I haven't done stained glass in years, and I don't happen to have any lying around. And I didn't feel like waiting a day (I did this on a weekend) then driving 20 minutes to a supply store and back just to get a $5 roll of copper foil. Instead, I dropped by the hardware store and went with option two:</p>
<div id="attachment_452" class="wp-caption alignright" style="width: 160px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0042.jpg"><img class="size-thumbnail wp-image-452" title="Ace metal repair tape" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0042-e1281635302995-150x150.jpg" alt="ace metal repair tape" width="150" height="150" /></a><p class="wp-caption-text">Option two.</p></div>
<p>This is the stuff you repair muffler leaks and such with. It's conductive, which, for my purposes, is pretty much the only hard requirement. It doesn't hold solder at ALL, so fastening wires to it was a pain, but oh well. Maybe some day that I have time I'll go get some copper foil, but not right now. I carefully cut two strips of it each about 3mm thick and 35cm long. That itself was a pain, but conveniently, at 5ft you have plenty to practice on. Once I cut those strips, I carefully laid them on the front and back edges of the top case edge such that there was a 1-2mm gap between them. They folded over the edges by a ways, but as uneven as they are, they still look fine.</p>
<div id="attachment_453" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0051.jpg"><img class="size-medium wp-image-453 " title="conductive strips" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0051-300x224.jpg" alt="conductive strips" width="300" height="224" /></a><p class="wp-caption-text">Conductive strips running along the top edge of the case</p></div>
<p>I don't have a great picture of the connections on the other side, but you can probably imagine. I peeled two wires off the side of some ribbon I had laying around and stripped the ends. I just electrical-taped those to the strips on one side near the bottom such that each wire contacts one side. Then I stripped the other ends, which are now our "sensor terminals." The only other parts to worry about are headers soldered to the main clock board and a little detachable board soldered to the sensor which plugs into them.</p>
<p>And that does it for the "sensor" part - with no finger present, the wires have an open circuit between them, and when a finger is present, there's some resistance, the value of which depends on an annoying number of variables.</p>
<p>Now, I had to pick a method to READ this sensor, so here's what I did FIRST.</p>
<p>I looked first at the schematic surrounding the relevant switch, it's simple enough.</p>
<div id="attachment_450" class="wp-caption alignright" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-12-at-1.33.41-PM.png"><img class="size-medium wp-image-450 " title="schematic" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-12-at-1.33.41-PM-300x172.png" alt="schematic" width="300" height="172" /></a><p class="wp-caption-text">We&#39;re looking at that bottom switch, Z.</p></div>
<p>The three switches are all connected between GPIO pins in "read" mode and ground. That is, internally there's a pull-up resistor to VDD and the micro is reading the voltage below it. I can use that. The way the digital "read" mode works is that, if the voltage at the pin is above some threshold, the microcontroller reads a "1" and if it's below the threshold, it reads a "0". In this case, since the switch is NO (normally open), a "1" corresponds to "not pressed," meaning I need to momentarily "close" the switch, shorting the pin to ground to "press" it and get a "0."</p>
<p>I used this threshold behavior to my advantage to reduce the part count to a single resistor. I selected a resistor to put in parallel with the switch such that the voltage at the microcontroller pin was just ove the threshold around 2.7v. In my case, that was somewhere between 35kΩ and 45kΩ. Then, the touch sensor is wired in parallel to that. When it's touched, the resistance across it serves to decrease the resistance of the 35k-45k resistor, since the two are in parallel. Assuming you tuned the 35-45k resistor right (I used a 100k pot for testing), the resulting resistance drop will decrease the voltage at the pin until it's just below the threshold to register a "0" and a button press.</p>
<div id="attachment_454" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0053.jpg"><img class="size-medium wp-image-454 " title="finished method one" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0053-300x224.jpg" alt="finished method one" width="300" height="224" /></a><p class="wp-caption-text">The finished product of method one</p></div>
<p>In practice this works, but it's what you'd generously refer to as ghetto hackery. It doesn't work all that well, and it's a bad design for many reasons: First, the resistance presented by your hand on the sense strips is HIGHLY variable. I eventually settled on this method because, at the time that I was in my basement testing, it was a pretty hot and humid day out and my hands were a bit clammy. The salt on them from sweating on and off at an elevated rate all day combined with the moisture meant that the resistance at the sense strips was abnormally low, resulting in fairly accurate microcontroller response. I found over the course of the next few days that normal dry and clean hands had far too much resistance, even over such a short distance, to get a good response. I had to either press hard, or use my full hand (more surface area). The only reliable way to get a good press was to lick my finger before pressing: the saliva is much more conductive. That's alright, but it doesn't effectively solve the original problem, which is easily and quickly shutting the light off at night. Having to lick my finger is just about as cumbersome as picking up the clock, and much grosser.</p>
<div id="attachment_455" class="wp-caption alignright" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-12-at-5.25.25-PM.png"><img class="size-medium wp-image-455" title="original schematic" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-12-at-5.25.25-PM-300x178.png" alt="original schematic" width="300" height="178" /></a><p class="wp-caption-text">Method one schematic: V1 is the ~2.7v value with no finger present</p></div>
<p>Besides not functioning either well or predictably, another problem with the design is that you have a constant current flowing through both the fixed resister and the internal pull-up. By V=IR, with V= ~2.7v and R = ~39k, you get I = ~.000069A, or<br />
~69µA constantly flowing from the internal supply to ground. Now, that's not all that much, and it's not as if I'm going to burn a resistor (even the little tiny one in the micro), but that's still just wasting power. That much current could provide enough juice for 69 MSP430 microcontrollers in standby. In addition, holding the micro's sense pin around the threshold voltage is probably just bad practice. The Arduino software seems to handle this nicely, but the micro is probably reading horrible noise on that pin from its internal comparator. All in all, it's just bad.</p>
<p>So I decided to scrap the passive plan and try method two. I could have done something like get another microcontroller (I have a few MSP430 value line parts <a href="http://www.alexwhittemore.com/?p=382">lying around now</a>) and make essentially an ohm meter, using a GPIO pin to output 1 or 0 to the Arduino's input (switch) pin. But that'd be unnecessarily complex. What I really wish is that I could somehow amplify the resistance of my finger. Wait, did somebody say "amplify"? Transistor time!</p>
<div id="attachment_456" class="wp-caption alignleft" style="width: 210px"><a href="http://en.wikipedia.org/wiki/2N2222"><img class="size-full wp-image-456 " title="2N2222A_and_schema" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/200px-2N2222A_and_schema.jpg" alt="2n2222 and schematic" width="200" height="189" /></a><p class="wp-caption-text">Everybody&#39;s friend, the quad-2</p></div>
<p>Idea two is to not exactly to amplify the RESISTANCE of my finger, but at least to amplify the CURRENT that flows through it. Touching the sense strips means a small current flows through my finger as per V=IR. If I pipe that current into the base of a standard NPN transistor, I can amplify it. And I can make the amplified current flow between the internal IC pull-up resistor and ground. BINGO! This has the advantage, thanks to the huge current gain (β=200 for the spare 2n2222 I had), even with a really big resistance  on the sense strips (dry hands), that tiny current results in a relatively large current from collector to emitter of the transistor. A relatively high I flowing through a resistor of relatively high R (that is, the internal pull-up) is a relatively high voltage drop. If this current is high ENOUGH (.151mA, according to I = V/R = 5/33k), then the transistor is effectively a dead short to ground, which is exactly what the Arduino wants to register a "0" on that pin. And if it's not .151mA, the voltage at the pin will probably at LEAST go below the threshold by an amount greater than in method 1.</p>
<div id="attachment_457" class="wp-caption alignright" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0044.jpg"><img class="size-medium wp-image-457" title="new finished product" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0044-300x224.jpg" alt="new finished product" width="300" height="224" /></a><p class="wp-caption-text">Now it looks like this. I also added headers for the sensor such that it&#39;s totally modular. You know, in case I decide to change my mind again.</p></div>
<p>So the part count is now up to a single transistor instead of a single resistor, and it's already much more reliable. The only thing is that it's usually pretty bad to put the full VDD directly onto a BJT's (Bipolar Junction Transistor's) base, because then you can get nasty side effects and it's not good for the transistor. The finger will always be a great enough base resistance, but in the case that the sensor is shorted with some kind of metal, I added a real base resistor of 1kΩ in series with the sensor. It won't decrease the small current substantially, and we have plenty of headroom. You can't really see it in the image to the right, but the board is now about the same size and includes female headers to plug into the clock, as well as headers to plug into the sensor. I didn't do that originally, but now I can take the board out totally. I also had to add VDD to the mix, since there are now active components. That's the little red jumper that goes from the wall plug jack to the center pin on my header which was previously unused.</p>
<div id="attachment_459" class="wp-caption alignleft" style="width: 234px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0050.jpg"><img class="size-medium wp-image-459" title="schematics" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/IMG_0050-e1281651530627-224x300.jpg" alt="schematics before and after" width="224" height="300" /></a><p class="wp-caption-text">The new schematic on bottom and the old one on top.</p></div>
<p>So there you have it. A simple little one-or-two part mod to make darkening my clock easier, and a whole boatload of ideas about how to implement a resistive touch sensor. Here's a video, for fun (it was made with design one, but you probably won't notice a difference since my hands were sweaty at the time and it worked fine <img src='http://www.alexwhittemore.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=14102230&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=14102230&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/14102230">Bulbdial touch mod</a> from <a href="http://vimeo.com/user2362024">Alex Whittemore</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5518377310821477";
google_ad_slot = "4999204559";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/touch-brightness-bulbdial/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How to make iPhone headsets suck less</title>
		<link>http://www.alexwhittemore.com/iphone-headsets-suck/</link>
		<comments>http://www.alexwhittemore.com/iphone-headsets-suck/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 12:54:39 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[earbuds]]></category>
		<category><![CDATA[headphones]]></category>
		<category><![CDATA[soldering]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=374</guid>
		<description><![CDATA[Say what you will, but iPhones are pretty awesome, and so are the headsets that come with them. At least up until you put them in your ears. The inline controls are awesome, but the speakers are uncomfortable, lacking in low end punch, and do nothing for sound isolation. Other, much better headphones exist, but for under [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_377" class="wp-caption alignleft" style="width: 234px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/07/IMG_0002-e1280633549220.jpg"><img class="size-medium wp-image-377" title="Crappy Buds" src="http://www.alexwhittemore.com/wp-content/uploads/2010/07/IMG_0002-e1280633549220-224x300.jpg" alt="Crappy Buds" width="224" height="300" /></a><p class="wp-caption-text">Crappy Buds</p></div>
<p>Say what you will, but iPhones are pretty awesome, and so are the headsets that come with them. At least up until you put them in your ears. The inline controls are awesome, but the speakers are uncomfortable, lacking in low end punch, and do nothing for sound isolation. Other, much better headphones exist, but for under a gajillion dollars, none come with the same kind of inline controls. Here's how to have the best of both worlds.<span id="more-374"></span></p>
<p>The solution is pretty simple:</p>
<p>1. Find an iPhone headset and a set of earbuds that don't suck.<br />
2. Cut the earbuds off of each cord.<br />
3. Splice the good buds onto the good (iPhone) cord.</p>
<p>Of course, it's a little harder than that (but not much, don't worry). Here's what I did.  I won't tell you how to find good earbuds: it's your call what you like. I selected a pair of Sennheiser CX150s. I bought them cheap (€20) in Germany, so I had them when I bought my iPhone, and they are solid quality - much much better than the iPhone headset, anyway. A good candidate for surgery.  The next step is to make your cuts. This is tricky: you don't want to cut the iPhone headset too close to the microphone, because if you mess up and have to move back on the wire, you'll quickly run out of space. But then if you cut too close to the buds, you'll have to do the same on your donor headphones in order to keep roughly the same length from finished earbud to mic. My strategy was to cut ~1.5" from the iPhone buds, and around 2.5" to 3" from the Sennheisers. At best, you only increase the length by 1" on both sides, and at worst, you have as much space to mess up.  Once you've cut, you need to strip and tin. The outer insulation is a pain. Sometimes you can cut it with wire strippers without damaging the conductors (Sennheisers), sometimes it just squishes and stretches when you pull it (iPhone set). If the latter happens, try working the insulation gently with flush cutters. I can't say much more besides "be careful" since it depends on what headphones you're using how finicky the insulation is. Tinning is a different story. With a lower-temp iron, I find that burning the acrylic insulation off of the conductors is necessary. But sometimes this leaves soot that makes tinning the conductors a pain. If you can manage it, save trouble by using a really high temp iron and melt the insulation off with a blob of solder on your tip. This will tin them at the same time.  IMPORTANT: <strong>PUT HEATSHRINK ON</strong>! I can't count on both hands and feet how many times I've neatly soldered up a project only to remember that I never put heatshrink tubing on.Do it now. Tip: if you can, slide two pieces on for the outermost layer. Shrink one, then slide over the other and shrink that. It doesn't insulate any better, but it adds structure to what will otherwise be a somewhat fragile joint.  Solder up the connections. The trickiest thing here is to know which is which. The iPhone headset follows the scheme red: right+ green: left+ copper color: common ground red/green twist: mic/controls (right side only). The donor headset should share a similar wiring. In general, its safe to say that, if you see the same color on both sides, that's ground.  Shrink the tubing. I use my pencil torch from a judicious distance. It's way too hot up close, but it  heats a nice plume of air and from a good 6", it'll shrink tubing right up.  And there you have it. But if you're bored, and want to kill 17 minutes, I have a video for you too. I promise future guides won't be so long. I just don't want to edit the video down anymore since I've spent enough time on it.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=13879185&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=13879185&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/13879185">Headphone Build</a> from <a href="http://vimeo.com/user2362024">Alex Whittemore</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Epilog: After using the headphones for a few minutes, I noticed that the audio image felt like it was pulling a hard right in my head: normally stereo sound feels centered in the middle of your head, but these headphones felt like they were centered on my right ear. The problem is that one of the channels has the incorrect polarity, that is the audio is inverted. Even though it's only off by a few microseconds, this has the effect of offsetting balance drastically. The solution is to simply reverse the polarity of one channel, it doesn't matter which. I reversed the left channel since it's got far more wiggle room to mess up than the right, in this case.</p>
<p>This also gave me the opportunity to do somthing I didn't previously: For added strength, slide TWO pieces of heatshrink on the headphone line before soldering. Shrink one over the joint, then slide the other over and shrink that too. The outer piece serves to tighten the inner piece on the wire (it previously didn't hold the insulation well, and any tension in the headphones was supported by the solder joint) as well as to prevent flex in the joint.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/iphone-headsets-suck/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Backgrounder vs. Build and Run</title>
		<link>http://www.alexwhittemore.com/backgrounder-build-run/</link>
		<comments>http://www.alexwhittemore.com/backgrounder-build-run/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 05:46:48 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[iPhone Technical Articles]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[backgrounder]]></category>
		<category><![CDATA[build and run]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=412</guid>
		<description><![CDATA[Here's a quick note on how Backgrounder, from the wonderful http://twitter.com/ashikase interacts with Xcode's Build and Run functionality. First, Backgrounder: The MobileSubstrate extension manages background persistance for apps both supporting iOS4's native switching as well as apps that require additional assistance. One of the options in Backgrounder is to "enable at launch," which means exactly [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_413" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-07-at-1.26.30-AM-copy.png"><img class="size-medium wp-image-413" title="Console" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-07-at-1.26.30-AM-copy-300x212.png" alt="Console showing error" width="300" height="212" /></a><p class="wp-caption-text">This is what happens when you Build and Go with Backgrounder running.</p></div>
<p>Here's a quick note on how Backgrounder, from the wonderful <a href="http://twitter.com/ashikase">http://twitter.com/ashikase</a> interacts with Xcode's Build and Run functionality.<span id="more-412"></span></p>
<p>First, Backgrounder: The MobileSubstrate extension manages background persistance for apps both supporting iOS4's native switching as well as apps that require additional assistance. One of the options in Backgrounder is to "enable at launch," which means exactly what you'd think: apps get backgrounding enabled as soon as they're launched, and one must explicitly disable the function if desired. That's the setup I have: If it's got Native functionality built in, let it background, and tell it so when it launches.</p>
<p>But now we need to discuss how that happens. Backgrounder is implemented in-app as a .dylib extension. That extension constitutes code loaded into the app at runtime, in this case code which handles persistence after minimize. In order for that code to activate, something needs to tell it it should, and Backgrounder handles that message by sending a SIGUSR1 signal to the running app process whenever backgrounding is to be enabled. Keep in mind that could be by an activator gesture or some such. In my case, the problem is that the SIGUSR1 signal gets sent to the app as soon as it loads, and GDB catches it. Maybe you caught on, and maybe you're a dolt like me and it took you some hand holding, but you can get over this hump by simply clicking "continue" in the top right of the console window. This will dismiss the SIGUSR1 and the app will continue to execute as normal.</p>
<p>Your other option, if you're getting annoyed by always clicking continue, is to add an override for your app to disable Backgrounder. That will prevent SIGUSR1 from ever being sent and hiccuping your debugging. Though it's probably only worth the annoyance if you're recompiling constantly. And in addition, you'll have to re-override the project any time the name changes.</p>
<p>At any rate, hopefully that clears up any problems you might run into with this.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-5518377310821477";
google_ad_slot = "4999204559";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/backgrounder-build-run/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Developing for a Jailbroken iPhone A to Z (iOS 4.0.1)</title>
		<link>http://www.alexwhittemore.com/developing-jailbroken-iphone-ios-401/</link>
		<comments>http://www.alexwhittemore.com/developing-jailbroken-iphone-ios-401/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 00:30:55 +0000</pubDate>
		<dc:creator>Alex Whittemore</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[iPhone Technical Articles]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[jailbreak development]]></category>
		<category><![CDATA[jailbroken]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://www.alexwhittemore.com/?p=398</guid>
		<description><![CDATA[Vital Stats: iOS 4.0.1 Xcode 3.2.3 Mac OSX 10.6.4 Snow Leopard iPhones 3G, 3GS, 4 (I finally have the whole lineup!) PROBLEM: I still can't get iPhone 4 working. If you have one, please try it and help me out! UPDATE: Found the cause of the problem to be certain status bar libraries installed alongside [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_403" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-04-at-8.27.40-PM.png"><img class="size-medium wp-image-403" title="Screen shot 2010-08-04 at 8.27.40 PM" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-04-at-8.27.40-PM-300x213.png" alt="" width="300" height="213" /></a><p class="wp-caption-text">Jailbreak Development for iOS4!</p></div>
<p>Vital Stats:<br />
iOS 4.0.1<br />
Xcode 3.2.3<br />
Mac OSX 10.6.4 Snow Leopard<br />
iPhones 3G, 3GS, 4 (I finally have the whole lineup!)</p>
<p>PROBLEM: I still can't get iPhone 4 working. If you have one, please try it and help me out! UPDATE: Found the cause of the problem to be certain status bar libraries installed alongside other apps. I'm not sure why they cause the problem, but see full notes at the bottom of the post.</p>
<p><strong>The Goal</strong>: As usual, we want to be able to click "build and go" in Xcode and get the app we're working on to load to the phone and start up. Also, we want to be able to debug from within Xcode itself. After all, Xcode is cool, and terminal+makefiles+gcc+gdb is lame.<span id="more-398"></span></p>
<p><strong>Abstract</strong>: The plan remains unchanged from the 3.x method. In fact, you commenters practically wrote this one for me. This time we're going to tell Xcode that it doesn't <em>need </em>to codesign for iPhoneOS targets, then we're going to tell it <em>don't</em>codesign for iPhoneOS targets, then we're going to tell it, <em>well, actually, codesign but do it using our script, not your built in method.</em></p>
<p><strong>The Process: </strong>With Xcode closed and your device unplugged from the computer,</p>
<ol>
<li> <em>If you've done this step before for previous guides, you may ignore it. </em>You'll need a code signing identity in order to sign code to run on the device. Normally, this would be issued by Apple, but later on we'll break the signature check so you can make a "Self-Signing Identity" using this <a href="http://developer.apple.com/mac/library/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW1">guide</a> from apple (<a href="http://developer.apple.com.nyud.net/mac/library/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW1">coral</a>). Note that you should name the identity “iPhone Developer” EXACTLY to avoid having to change a bunch of the steps below.</li>
<li>On your jailbroken iPhone, install the app AppSync. Add the source <strong>http://cydia.hackulo.us</strong> to cydia. You'll get a warning about pirating software: this patch, by virtue of breaking Apple's DRM so that we can install our own app, also enables us to install cracked App Store apps. Don't do that. It's immoral, fails to support legitimate developers who should be rewarded for their effort, and perhaps above all, pirating $2 cell phone apps is just ultra lame. But since our purposes are not nefarious, dismiss the warning. From this repo, install the package AppSync for OS 4.0, and for good measure, <strong>reboot the device.</strong></li>
<li>Make some Plist adjustments, starting with SDKSettings.plist:
<pre class="syntax bash">cd /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk
sudo cp SDKSettings.plist SDKSettings.plist.orig
sudo vi SDKSettings.plist</pre>
<p>Find</p>
<pre class="syntax bash">&lt;key&gt;CODE_SIGNING_REQUIRED&lt;/key&gt;
&lt;string&gt;YES&lt;/string&gt;</pre>
<p>and change YES to NO<br />
then find</p>
<pre class="syntax bash">&lt;key&gt;ENTITLEMENTS_REQUIRED&lt;/key&gt;
&lt;string&gt;YES&lt;/string&gt;</pre>
<p>and change YES to NO again. HINT: in vi, you can type the '/' key in order to "Cmd-F"</li>
<li>Now, move on to the platform Info.plist
<pre class="syntax bash">cd /Developer/Platforms/iPhoneOS.platform/
sudo cp Info.plist Info.plist.orig
sudo vi Info.plist</pre>
<p>Two times, the following appears:</p>
<pre class="syntax bash">&lt;key&gt;CODE_SIGN_CONTEXT_CLASS&lt;/key&gt;
&lt;string&gt;XCiPhoneOSCodeSignContext&lt;/string&gt;</pre>
<p>Find each occurrence and replace the block</p>
<pre class="syntax bash">&lt;string&gt;XCiPhoneOSCodeSignContext&lt;/string&gt;</pre>
<p>with</p>
<pre class="syntax bash">&lt;string&gt;XCCodeSignContext&lt;/string&gt;</pre>
</li>
<li>And now the real bad boy, some binary patching of Xcode:
<pre class="syntax bash">cd ~/Desktop
vi script</pre>
<p>hit the "i" key and copy/paste:</p>
<pre class="syntax bash">#!/bin/bash
cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/
dd if=iPhoneOS\ Build\ System\ Support of=working bs=500 count=255
printf &quot;\xc3\x26\x00\x00&quot; &gt;&gt; working
/bin/mv -n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original
/bin/mv working iPhoneOS\ Build\ System\ Support
chmod a+x iPhoneOS\ Build\ System\ Support</pre>
<p>type the keys, in order: <esc> ":" "x" "enter"</p>
<pre class="syntax bash">chmod 777 script
./script</pre>
<p>If it works right, you should see something like</p>
<pre class="syntax bash">$ ./script
223+1 records in
223+1 records out
111648 bytes transferred in 0.002678 secs (41692099 bytes/sec)</pre>
</li>
<p>At this point, you're done telling Xcode it doesn't <em>need</em> to codesign. Now, we tell it <em>don't</em> codesign:</p>
<li>With a new project open and ready to go (presumably you want to debug this one, though once you change these settings once, they'll persist from project to project) open Project&gt;Edit Project Settings (from the menu). Click on the "Build" tab.<br />
Find "Code Signing Identity" and its child "Any iPhoneOS Device" in the list, and set both to the entry "don't code sign"</p>
<div id="attachment_357" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/01/Screen-shot-2010-01-11-at-1.05.42-AM.png"><img class="size-medium wp-image-357" style="padding: 0px; margin: 0px; border: 0px none initial;" title="Screen shot 2010-01-11 at 1.05.42 AM" src="http://www.alexwhittemore.com/wp-content/uploads/2010/01/Screen-shot-2010-01-11-at-1.05.42-AM-300x80.png" alt="Screen shot 2010-01-11 at 1.05.42 AM" width="300" height="80" /></a><p class="wp-caption-text">Should look like this</p></div>
<p>Now you've told Xcode "don't codesign."</li>
<p><br/><br />
<br/><br />
<br/></p>
<li>Almost done: time to tell Xcode "<em>well, actually you should codesign."</em>
<pre class="syntax bash">mkdir /Developer/iphoneentitlements401
cd /Developer/iphoneentitlements401
curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt
mv gen_entitlements.txt gen_entitlements.py
chmod 777 gen_entitlements.py</pre>
</li>
<li>
<div id="attachment_404" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-04-at-5.28.58-PM.png"><img class="size-medium wp-image-404" title="Screen shot 2010-08-04 at 5.28.58 PM" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-04-at-5.28.58-PM-300x114.png" alt="" width="300" height="114" /></a><p class="wp-caption-text">Just hit cancel.</p></div>
<p>And finally, to link the device and computer. Plug your iPhone in and open Xcode. Open Window&gt;Organizer. Select the device from the list on the left hand side, and click "Use for development." You'll be prompted for a provisioning website login, click cancel. It's there to make legitimate provisioning easier, but doesn't make illegitimate not-provisioning more difficult.</li>
</ol>
<p>Now you're good to go! But there's just one last thing. You have to <strong>do this last part for every new project you make.</strong> Go to the menu Project &gt; New Build Phase &gt; New Run Script Build Phase. In the window, copy/paste this:</p>
<pre class="syntax bash">export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
if [ &quot;${PLATFORM_NAME}&quot; == &quot;iphoneos&quot; ]; then
/Developer/iphoneentitlements401/gen_entitlements.py &quot;my.company.${PROJECT_NAME}&quot; &quot;${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent&quot;;
codesign -f -s &quot;iPhone Developer&quot; --entitlements &quot;${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent&quot; &quot;${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/&quot;
fi</pre>
<p>That will call the script you just downloaded in step 5 to sign our app with a fake signature. This is important only for debugging. If you do build and go otherwise, the app will load to the phone, but the app will fail to launch and you'll get:<br />
<code><br />
Error from debugger: The program being debugged is not being run<br />
</code><br />
That should do it. Take all those steps and you should be home free for JBDev without paying $99.</p>
<p>CREDITS: Once again, credit for this process goes to various posters in <a href="http://www.iphonedevsdk.com/forum/iphone-sdk-tools-utilities/20983-sdk-3-0-xcode-3-1-3-build-go-jailbroken-device-4.html">this forum thread at iphonedevsdk.com</a>. All of these steps are there somewhere, it just took a while to re piece them together in the right combination.</p>
<p><strong>iPhone 4 Issue (UPDATE see below): </strong>So the method above has been tested working for my 3G and my 3GS. I don't have my 2G right with me, but I expect it's no different from the previous method, given that it can't run iOS4.</p>
<p>The problem that I run into is this:<br />
<code><br />
[Session started at 2010-08-04 20:35:02 -0400.]<br />
//GDB stuff<br />
Program loaded.<br />
target remote-mobile /tmp/.XcodeGDBRemote-93925-69<br />
Switching to remote-macosx protocol<br />
mem 0x1000 0x3fffffff cache<br />
mem 0x40000000 0xffffffff none<br />
mem 0x00000000 0x0fff none<br />
run<br />
Running…<br />
[Switching to thread 11523]<br />
[Switching to thread 11523]<br />
continue<br />
warning: Unable to read symbols for "/Library/MobileSubstrate/MobileSubstrate.dylib" (file not found).<br />
// A bunch of other lib load warnings like this here...<br />
warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0.1/Symbols/usr/lib/libcrypto.0.9.8.dylib" (file not found).</code></p>
<p><code>Debugger stopped.<br />
Program exited with status value:45.<br />
</code><br />
The killer is that the app installs, launches, crashes, and then launches fine manually. But I also can't connect GDB to the running process after the fact either, GDB claims the process isn't running. I have no idea what's going on. Anyone?</p>
<div id="attachment_409" class="wp-caption alignleft" style="width: 310px"><a href="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-04-at-8.39.19-PM.png"><img class="size-medium wp-image-409" title="Screen shot 2010-08-04 at 8.39.19 PM" src="http://www.alexwhittemore.com/wp-content/uploads/2010/08/Screen-shot-2010-08-04-at-8.39.19-PM-300x222.png" alt="" width="300" height="222" /></a><p class="wp-caption-text">What gives?!</p></div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-5518377310821477";
google_ad_slot = "4999204559";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>UPDATE (8/3/10): Totally by chance I happened to read this <a href="http://www.tuaw.com/2010/08/06/five-freaking-awesome-facetime-hacks-and-a-few-handy-tips/">article on TUAW today about FaceTime</a>. I didn't pay much attention until about half way down something caught my eye:</p>
<blockquote><p>...rather significant My3G bug -- when installed, you cannot use your iPhone for native software development....</p></blockquote>
<p>I had initially thought that maybe third party software was to blame but I meticulously disabled each MobileSubstrate extension I had one at a time and ruled them all out. Turns out that wasn't good enough. The (since fixed) My3G bug was exactly the source of this issue, but I had actually uninstalled My3G and the problem persisted. The issue, it turns out, is with the status bar library Intelliborn uses in their products, IntelliStatusBarIcons. BUT, it doesn't stop there. By individually uninstalling apps, I've found that Backgrounder (and NOT libstatusbar) also cause a dealbreaking bug. Instead of the program exiting with status:45, the new error is "Program received signal: "SIGUSR1". at which point the application hangs. Conveniently, the workaround is easy, if annoying: For your particular project title, add an Override in Backgrounder. Hopefully this IS a bug in Backgrounder and not a byproduct of its function. But at least now you can debug again!</p>
<p>So partly I'm dumb and partly this is just a bummer. Full story in <a href="http://www.alexwhittemore.com/?p=412">this post</a>, but the general idea is that gdb catches a SIGUSR1 from Backgrounder and you have to 'continue' through it. And obviously, disabling Backgrounder for your app prevents the signal from getting sent.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexwhittemore.com/developing-jailbroken-iphone-ios-401/feed/</wfw:commentRss>
		<slash:comments>440</slash:comments>
		</item>
	</channel>
</rss>

