tag:blogger.com,1999:blog-34249453574598434592024-03-20T08:00:47.869+01:00Same Limmat TwiceUnknownnoreply@blogger.comBlogger19125tag:blogger.com,1999:blog-3424945357459843459.post-27192705188830539732016-12-13T07:54:00.001+01:002016-12-13T07:54:04.682+01:00Seasonal BlinkenlightsRecently, my wife complained about being bored by all the monochrome Christmas displays in the neighborhood. "Can't we have something gaudy?" she asked.<br />
<br />
Being cheap and lazy, I remembered that I had an <a href="https://www.sparkfun.com/products/11272" target="_blank">addressable 1m LED strip</a> that I bought several years ago and never really tried for anything interesting. After a night's hacking, I came up with a few different animations:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/MOVpuFyykqs/0.jpg" frameborder="0" height="399" src="https://www.youtube.com/embed/MOVpuFyykqs?feature=player_embedded" width="480"></iframe></div>
<br />
High art, it is not, but I picked up some new ideas, especially about <a href="http://www.alanzucconi.com/2015/09/30/colour-sorting/" target="_blank">how to sort colors.</a><br />
<br />
I also learned that these strips have highly variable builds. Not only were the colors of the wires completely different from their documentation (but easy to figure out from the physical layout), but even the colors of the LEDs were hooked up in a different order than the WS2801 data sheet would have implied.<br />
<br />
The code is fairly trivial, but given the reaction of my wife and sons, I think I got a pretty good return on those 450 lines of code.<br />
<br />
<br />
<script src="https://gist.github.com/microtherion/32faaa4d07997bfa3e49e4d9b4903ed6.js"></script>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-55773386768326919292016-06-25T19:19:00.001+02:002016-06-25T19:20:36.057+02:00Light & Ladder — Simple Testbed for MicrocontrollersRecently I was bringing up an Arduino-like core for the <a href="http://www.atmel.com/devices/ATTINY841.aspx" target="_blank">ATtiny841</a>, and wanted to test all the functionality. Testing <span style="font-family: "courier new" , "courier" , monospace;">digitalOut</span> and <span style="font-family: "courier new" , "courier" , monospace;">analogOut</span> was simple, though doing so for lots of pins required a bit of setup. <span style="font-family: "courier new" , "courier" , monospace;">digitalIn</span> was also simple, but <span style="font-family: "courier new" , "courier" , monospace;">analogIn</span> required slightly more work. As a small exercise, I decided to combine all of the required parts onto a single board. Using integrated resistor networks helped save a lot of parts.<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://raw.githubusercontent.com/microtherion/LightAndLadder/master/LightLadder_Schematic.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="436" src="https://raw.githubusercontent.com/microtherion/LightAndLadder/master/LightLadder_Schematic.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0gwHP23SFEevrIfEaO7bAwgdbfLvAHxQqikQ-1fDVVqHF_CPJAhp9vI_IFq1uB68DbUPfsKnnb7Qo9eSgQwSL5chohh5isV9emUkxVV_3Qq0PCwmKXa3o6yxnegErQqtTr6dqwmnKRRc/s1600/IMG_5626.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0gwHP23SFEevrIfEaO7bAwgdbfLvAHxQqikQ-1fDVVqHF_CPJAhp9vI_IFq1uB68DbUPfsKnnb7Qo9eSgQwSL5chohh5isV9emUkxVV_3Qq0PCwmKXa3o6yxnegErQqtTr6dqwmnKRRc/s400/IMG_5626.jpg" width="295" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
The top part is very conventional, but the bottom might be a bit more interesting. Effectively, it serves as a primitive analog computer to generate a wide selection of fractions of the voltage applied to "+" and "-". As noted on the board, connecting one or more pins from the "+" side to one or more pins from the "-" side generates a voltage V*P/(P+M) where "P" is the sum of the labels of pins connected on the "+" side and "M" the sum on the "-" side. If "+" is 5V, you can obtain e.g.:</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<ul>
<li style="text-align: left;">1V as 1/5 of 5V, by connecting "1" on the "+" side and "4" on the "-" side.</li>
<li style="text-align: left;">1.25V as 1/4, by connecting "1" on the "+" side, and 3 (as "1" and "2") on the "-" side.</li>
<li style="text-align: left;">1.5V as 3/10, by connecting "1" and "2" on the "+" side, and "1", "2", and "4" on the "-" side.</li>
</ul>
<div style="text-align: left;">
Source code available on <a href="https://github.com/microtherion/LightAndLadder" target="_blank">Github</a>, boards on <a href="https://oshpark.com/shared_projects/oy5yst8f" target="_blank">OSH Park</a>.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-27488507644760508712016-05-08T03:11:00.000+02:002016-05-08T03:11:20.253+02:00Announcing Octarine<h2>
Announcing Octarine — Electronic Component / Data Sheet Manager</h2>
<div>
Having acquired a sizable collection of parts by now, I often find myself wasting time browsing for data sheets over and over again, instead of having them ready when I need them. I decided to remedy the situation by writing an app, <a href="https://github.com/microtherion/Octarine" target="_blank">Octarine</a>, to manage my components. Building on the REST API offered by <a href="http://octopart.com/" target="_blank">octopart.com</a>, I tried to minimize the amount of information stored locally, and fetch everything else on the fly.</div>
<div>
<br /></div>
<div>
<a href="https://github.com/microtherion/Octarine/releases/tag/v1.5" target="_blank">Octarine 1.5</a> is now available on github, running on OS X 10.10 (Yosemite) or later.</div>
<div>
<br />
As usual with my hobby projects, this was an opportunity to try a few technologies I don't use much in my day job:<br />
<br />
<ul>
<li>Swift.</li>
<li>NSURLRequest</li>
<li>PDFKit</li>
<li>NSSharingService</li>
</ul>
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://raw.githubusercontent.com/microtherion/Octarine/v1.5/Documentation/Screenshots/Search.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="385" src="https://raw.githubusercontent.com/microtherion/Octarine/v1.5/Documentation/Screenshots/Search.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Component search in the Octopart database (right). Saved components (left)</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://raw.githubusercontent.com/microtherion/Octarine/v1.5/Documentation/Screenshots/Datasheet.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="386" src="https://raw.githubusercontent.com/microtherion/Octarine/v1.5/Documentation/Screenshots/Datasheet.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Data sheet viewer</td></tr>
</tbody></table>
<div>
<br /></div>
Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-3424945357459843459.post-51835781111513526032015-08-16T01:06:00.001+02:002015-08-16T01:06:59.415+02:00Introducing AutoISP - In-Circuit Reprogramming Made SimpleThis week, I was honored to see my <a href="http://shop.boxtec.ch/autoisp-master-board-p-42464.html">AutoISP</a> family of boards being put into actual commercial production by <a href="http://boxtec.ch/">Boxtec</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_x-s0LlTGYrbS9r5UXcqu2Sui9VhdM0BDLeEqliyiqSenPLYNWdB_ysyW9wTWzsmjTTCdRNRmsb97WSXUYupbfRLwabScWXx0TmUMixle8QMQ_Vh96bUasfGE2sr9IQVMVR4oX3VZDGE/s1600/AutoISP_iba.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="391" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_x-s0LlTGYrbS9r5UXcqu2Sui9VhdM0BDLeEqliyiqSenPLYNWdB_ysyW9wTWzsmjTTCdRNRmsb97WSXUYupbfRLwabScWXx0TmUMixle8QMQ_Vh96bUasfGE2sr9IQVMVR4oX3VZDGE/s400/AutoISP_iba.png" width="400" /></a></div>
<br />
AutoISP is designed to help those among us ATtiny programmers who don't write perfect software on the first iteration. Previously, our alternatives were:<br />
<br />
<ul>
<li>Pull the microcontroller from the board, plug it into a programmer, reprogram it, pull it from the programmer, and plug it back into the board.</li>
<li>Make the programming pins accessible on the board (e.g. with <a href="http://shop.boxtec.ch/hook-with-pigtail-p-40798.html">IC hooks</a> or by adding an ICSP header to the board). This may limit the use to which those pins can be put otherwise (and sparing 4 data pins on an ATtiny85 for programming is rarely an attractive proposition).</li>
</ul>
<div>
AutoISP solves this problem by placing the microcontroller itself on a <i>slave board</i> which is plugged into a socket on the circuit to be developed. The AutoISP <i>master board</i> then employs an <a href="http://shop.boxtec.ch/stmav340ttr-highspeed-video-switch-p-42396.html">STMAV340TTR</a> 4PDT "video switch" to switch between two states:</div>
<div>
<ul>
<li>If the RESET pin on its ICSP header is HIGH (or not connected), all pins on the microcontroller are connected to the development circuit, as if the microcontroller were plugged into the circuit directly.</li>
<li>If the RESET pin goes LOW, the MOSI, MISO, RESET, and SCK pins on the microcontroller get disconnected from the development circuit and connected to the ICSP header on the master board instead, which allows the microcontroller to be reprogrammed.</li>
</ul>
<div>
This makes it possible to use AutoISP transparently with most ISP programmers (e.g. the ArduinoISP sketch or <a href="http://microtherion.github.io/ScratchMonkey/index.html">ScratchMonkey</a>), as long as those programmers leave VCC turned on while not programming. With the exception of the RESET pin, all other pins of the microcontroller are available for unrestricted use.</div>
</div>
<div>
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8UmSwT_94oCjceWuSdo7KC3A6iOwvlEOej-DS9RwEC6L5v4ST8E4y9zlh48fapkA-L50BaufG5uIlwVcybzfAK6tZHFk3xnRIJQpN6VI7wyCYr07kgttR3lvaMvbUUP7m4dZ6DDqpIhk/s1600/AutoISP_iba.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8UmSwT_94oCjceWuSdo7KC3A6iOwvlEOej-DS9RwEC6L5v4ST8E4y9zlh48fapkA-L50BaufG5uIlwVcybzfAK6tZHFk3xnRIJQpN6VI7wyCYr07kgttR3lvaMvbUUP7m4dZ6DDqpIhk/s320/AutoISP_iba.png" width="313" /></a></div>
<span id="goog_992803686"></span><span id="goog_992803687"></span><br /></div>
<div>
All electronic are placed on the master board, while the slave boards merely have sockets and pin headers. At the moment, slave boards are available for the ATtinyX5 (25/45/85), ATtinyX4 (24/44/84) and ATmegaX8 (88,168,328) series, although the approach is applicable to any ATtiny or ATmega processor.<br />
<br /></div>
<div>
Detailed circuits are available on <a href="https://github.com/microtherion/AutoISP">Github</a> and in the <a href="http://shop.boxtec.ch/pub/boxtec/AutoISP-manual-v1_2.pdf">AutoISP manual</a>.</div>
<br />
<br />Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3424945357459843459.post-84903852515610845562015-04-20T03:30:00.001+02:002015-09-04T17:52:43.198+02:00Introducing ChipHeadBangThere are a number of widely used methods to connect microcontroller projects to USB, all of which are not entirely satisfactory:<br />
<span id="goog_475325981"></span><span id="goog_475325982"></span><a href="https://www.blogger.com/"></a><br />
<ul>
<li>The commonly used FTDI chips are somewhat expensive, and their manufacturer has made some unpopular decisions with their driver support (although technically, the FTDI drivers work quite well).</li>
<li>Atmel also offers microcontrollers with built in USB, but those also tend to be a bit expensive.</li>
<li>Software USB stacks use a considerable proportion of the microcontroller's processing power, and as not always as reliable as hardware solutions.</li>
</ul>
<div>
When I therefore heard about a very cheap (40 cents a piece) USB to serial converter IC, the WinChipHead CH340G, I was eager to try it, and bought a few (I bought mine on AliExpress, but they are now also available at <a href="http://shop.boxtec.ch/usb-uart-bridge-ch340-p-42354.html">Boxtec</a>). A prototype I built on a breadboard worked reasonably well, so I decided to try my hand at a custom PCB design:<a href="https://www.blogger.com/"></a></div>
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHepjnEklFSFNn3ZaSMk48aYLUNkZCVu-KeiM156B2KQAV5NI2jCyrKEzrnU73CFajfBP9y_T45fhOEGELqttMiZhcOosyfqllN_3a038jEk6hby_EuiexusxU_DCwscJT7NtD6Qs7Dac/s1600/IMG_3991.jpeg" imageanchor="1"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHepjnEklFSFNn3ZaSMk48aYLUNkZCVu-KeiM156B2KQAV5NI2jCyrKEzrnU73CFajfBP9y_T45fhOEGELqttMiZhcOosyfqllN_3a038jEk6hby_EuiexusxU_DCwscJT7NtD6Qs7Dac/s400/IMG_3991.jpeg" /></a><br />
<br />
To a large part, this follows a reference design from the <a href="http://www.seeedstudio.com/wiki/images/7/7c/CH340DS1_EN.PDF">vendor datasheet</a>, using an Eagle part made by <a href="http://fobit.blogspot.ch/2014/11/ch340g-in-eagle.html">blogger [Ian]</a>. I added a few customizations:<br />
<br />
<ul>
<li>Boxtec's Christoph Schneeberger successfully convinced me to include a fuse. Though one might suspect a nefarious plot to sell more fuses, he'd probably make a bigger profit selling replacement parts for melted down unprotected boards (not to speak of potentially frying the USB port of a laptop).</li>
<li>I added LEDs on the RX and TX lines. Since serial lines are high when quiescent, I made them active low.</li>
<li>I put an ICSP header on the board so it could easily also be used as a bitbang programmer.</li>
</ul>
<div>
In many ways, the resulting design was a bit more complex than what I had done before: It's my first design involving an USB connector, and it uses more SMD parts (12) than any of my previous designs. I was therefore quite pleased when I managed to assemble my first copy of it with relatively little drama, and the functionality worked as designed (As usual, my application of solder paste for the CH340 was somewhat uneven, so I had to fix some shorts and one flaky pin connection). The serial connection seems to work even at high rates, and the bitbang programming works at the stately pace of about 1.2KB per minute.<br />
<br />
I should mention that the CH340 has its drawbacks: Documentation is hard to find, especially if you don't speak Chinese. Driver support is iffy: My understanding is that the Linux and BSD drivers are OK, but the Windows and Mac drivers are not properly signed, and the Mac drivers will actually cause kernel panics on the latest versions of OS X. I was quite satisfied with quality of the <a href="https://www.mac-usb-serial.com/">commercial third party OS X driver</a> I ended up buying, and the price is very reasonable, but if building a cheap solution was the objective in the first place, even that reasonable price does of course spoil the economics (if not the hedonics) of the exercise.<br />
<br />
<b>UPDATE</b>: Thanks to the <a href="http://blog.codebender.cc/2015/06/12/new-stuff-updated-mac-drivers/">codebender</a> team, there is now a working free Mac driver for CH340 again, even a properly signed one.</div>
<div>
<br /></div>
<div>
Design files available on Github: <a href="https://github.com/microtherion/ChipHeadBang">https://github.com/microtherion/ChipHeadBang</a></div>
Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-3424945357459843459.post-1128464578381843712015-04-05T01:00:00.000+02:002015-04-05T01:02:52.617+02:00Introducing Quarantatre<div class="separator" style="clear: both; text-align: left;">
I might as well retitle my blog "The Art of the Blink Sketch", but this one has a bit of a twist:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/PENpCGwo3ns/0.jpg" frameborder="0" height="399" src="http://www.youtube.com/embed/PENpCGwo3ns?feature=player_embedded" width="480"></iframe></div>
<br />
The Quarantatre is a breakout board for the <a href="http://www.atmel.com/devices/ATTINY43U.aspx">ATtiny43U</a> microcontroller (basically just an implementation of the reference design shown in the <a href="http://www.atmel.com/Images/doc8206.pdf">AVR188 application note</a>, though I did not follow the component layout recommendations all that closely).<br />
<br />
In addition to the typical features found in other ATtiny models, the ATtiny43U has a built in boost converter allowing it to not only run off a single AA or AAA battery, but even to <b>generate </b>a regulated 3V voltage. While this only allows for a small current draw (apparently the limit is around 30mA), this could potentially be interesting for some applications.<br />
<br />
The boost converter needs a few external components to work, and some of them, especially the Schottky diode, are not really available in breadboard friendly variants, so to truly test the boost converter, I had to make this custom PCB (available for ordering at <a href="https://oshpark.com/shared_projects/7uvGe7Xo">OSH Park</a>, design files on <a href="https://github.com/microtherion/Quarantatre">Github</a>).<br />
<br />
As usual, I've made an Arduino-style core available on Github at <a href="https://github.com/microtherion/arduino-tiny1634-43u">https://github.com/microtherion/arduino-tiny1634-43u</a> (migrating from Google Code, which is shutting down). The standard Arduino tool chain probably won't support it; as always, I recommend <a href="http://samelimmat.blogspot.com/2013/07/using-arduino-ide-with-crosspack.html">CrossPack-AVR</a> for OS X.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-73767879989533731652014-11-28T01:55:00.000+01:002014-11-28T01:55:45.641+01:00A Sophisticated Heat Beam Which We Called a "Laser."<div class="separator" style="clear: both; text-align: left;">
Having recently acquired a stylish collection of potentiometers and knobs from <a href="http://stores.ebay.com/tayda2009/" target="_blank">Tayda2009</a>, I wanted to mount them in a mechanically solid way. An excellent opportunity to learn how to use the Epilog laser cutter at <a href="http://zurich.fablab.ch/" target="_blank">FabLab Zürich</a>. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I started with a box design built at <a href="http://www.makercase.com/" target="_blank">MakerCase</a>, rearranged the pieces to fit an A4 sheet of poplar plywood, and added the other features (cutouts for the potentiometer shafts and wires, outline for the breadboard, etc) to the top surface.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After struggling unsuccessfully with Inkscape (which was not overly fond of the 0.01mm thickness of lines signaling to the laser cutter to cut instead of rasterizing, and created PDFs that omitted all circles with that thickness), I spent a well invested dollar on <a href="https://itunes.apple.com/us/app/eazydraw/id412624365?mt=12" target="_blank">EazyDraw 3</a> (there appears to be a separate app for every version from 3 to 7, with prices neatly staggered, which I didn't know when I bought the oldest one, but it was perfectly suitable for my purposes) and redid the SVG, creating a PDF that opened just fine.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx-hFDxTFp8jxjNbRteXRk1E1wBOYlnF64YL6wCTxDLr_rOuoF5An0eEG9VVjp8zjV31kyaD1ByyDmiqEGsXbUIdTb6c491EwPSHW4KW_62JRK9_0ZVlcCTkYgPXfx_McFOp0e9wjjYRs/s1600/KnobBox.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx-hFDxTFp8jxjNbRteXRk1E1wBOYlnF64YL6wCTxDLr_rOuoF5An0eEG9VVjp8zjV31kyaD1ByyDmiqEGsXbUIdTb6c491EwPSHW4KW_62JRK9_0ZVlcCTkYgPXfx_McFOp0e9wjjYRs/s1600/KnobBox.png" height="400" width="273" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
15 minutes' or so worth of cutting and rasterizing got me this: </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://scontent-a-fra.xx.fbcdn.net/hphotos-xfa1/t31.0-8/10644169_10152833546464284_460300691519141834_o.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="475" src="https://scontent-a-fra.xx.fbcdn.net/hphotos-xfa1/t31.0-8/10644169_10152833546464284_460300691519141834_o.jpg" width="640" /></a></div>
<br />
The design has a number of flaws (a.k.a teaching moments for next time):<br />
<br />
<ul>
<li>I left off the bottom surface, because it would have been useless, but I forgot to adjust side surfaces to remove the fingers for the bottom. Oh well, I'll pretend these were meant for ventilation.</li>
<li>The box is considerably deeper than it needs to be. 2cm would have been ample, I made it twice as deep.</li>
<li>The potentiometers I bought have a little pin at the edge, which I had not noticed. In order to be able to mount them flush, I had to cut small notches for those pins, which luckily was no problem with the plywood.</li>
<li>The hole for the wires are a bit close to the potentiometer shaft hole, as the pins of the potentiometer are fairly long. On the other hand, there's no reason why the pins of the potentiometer have to point in any particular direction (the knob will mount in any orientation), so I might just cut the pin notches so the potentiometers are facing at a 45 degree angle to the wire hole next time.</li>
</ul>
Overall, though, I'm pleased with the result, shown here demonstrating three simple audio circuits (On the left, a VCO and a Metronome, using the two timers of a 556. On the right, a non-functional attempt to build an OpAmp based circuit driving a piezo element).Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-54684480466099587972014-08-01T00:22:00.001+02:002014-08-01T00:23:59.400+02:00<h2>
Lötet, freie Schweizer, lötet!</h2>
<div>
The recent introduction of <a href="http://shop.boxtec.ch/wire-red-chasing-p-42066.html" target="_blank">chasing electroluminescent (EL) wire</a> inspired me to give this a try in a seasonal installation:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/iYDJWqwMWHs?feature=player_embedded' frameborder='0'></iframe></div>
<div>
<br /></div>
<div>
admittedly, the sound on the video is not recorded off the installation—I overdubbed the same MP3 file the installation plays on top of the video, so the fairly soft rendition of the audio through the <a href="http://shop.boxtec.ch/speaker-pcb-mount-p-40858.html" target="_blank">simple speaker</a> I used did not detract from the majesty of the visuals and the occasion.</div>
<div>
<br /></div>
<div>
I noticed that so far I had never written up an EL wire project, mainly because the software generally has all the sophistication of an LED blink sketch, the hardware is 95% off the shelf (I'd rather not tinker too much with the high voltage AC current involved in an EL wire project), and my craftsmanship with the wire shaping is undistinguished. Nevertheless, I thought it was time to show how a project like this can be done.</div>
<h3>
<br /></h3>
<h3>
Bill of Materials</h3>
<div>
<ul>
<li>EL Wire — I mostly use Sparkfun's brand of EL Wire, bought mostly through <a href="http://www.boxtec.ch/" target="_blank">Boxtec</a>. Make sure whatever wire you buy has the right plugs. I bought some of my EL wire from <a href="http://www.seeedstudio.com/" target="_blank">Seeedstudio</a>, and spent some rather instructive time and effort refitting it with the plugs I needed (some <a href="http://shop.boxtec.ch/copper-tape-5mm-15m-p-41317.html" target="_blank">adhesive copper tape</a> and a bit of <a href="http://shop.boxtec.ch/heat-shrink-kit-p-41225.html" target="_blank">heat shrink tube</a> ended up working quite nicely). The wire I use is 2.3mm thick (the thinner, the more tightly the wire can be bent).</li>
<li><a href="http://shop.boxtec.ch/wire-chasing-adapter-cable-p-42067.html" target="_blank">Adapter cable for the chasing EL wire</a></li>
<li>An EL Sequencer — my <a href="http://shop.boxtec.ch/sequencer-p-41658.html" target="_blank">Sparkfun EL Sequencer</a> still works, despite the <a href="https://db.tt/ttcEqrgj" target="_blank">nasty accident</a> it suffered when I first powered it up.</li>
<li>An <a href="http://shop.boxtec.ch/inverter-12v-p-41656.html" target="_blank">EL Inverter</a> to generate the high voltage high frequency power to drive the EL wire.</li>
<li><a href="http://shop.boxtec.ch/electrical-tape-black-p-41360.html" target="_blank">Electrical tape</a> to mask off the sections of EL wire that I don't want to be seen.</li>
<li>Garden mesh to mount the wire. I bought a roll of 3x3.5mm garden mesh and cut it to size as needed.</li>
<li>An <a href="http://shop.boxtec.ch/arduino-uno-p-40155.html" target="_blank">Arduino Uno</a> with a <a href="http://shop.boxtec.ch/mp3-player-shield-p-40699.html" target="_blank">MP3 Player Shield</a> to play the music.</li>
<li>A <a href="http://shop.boxtec.ch/speaker-pcb-mount-p-40858.html" target="_blank">speaker</a> for the audio output. With some <a href="http://cdn2.boxtec.ch/pub/sparkfun/vs10XXan_output.pdf" target="_blank">additional circuitry</a>, the MP3 shield is also capable of sending a fairly reasonable quality output signal to an external amplifier (e.g. your stereo system).</li>
</ul>
<h3>
<br /></h3>
<h3>
Arranging the EL Wire</h3>
</div>
<div>
There are numerous ways of getting EL wire to keep whatever shape you want to form it. The technique I'm using (which I may have invented; I don't recall having seen it anywhere else) is to use a tight garden mesh with holes a bit bigger than the diameter of the EL wire, and weave the wire through it:</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtCVqMrSr5xB56FtuweF66E5GtQj_qSM-VlGiXYhZR6VAke6x4O3SY3FUyo5Ov144XlUwYzVL1RKSE7NaRLKZojDr_XK1crs4G6oH1RrDe_oPgPzzJOkSvWffw-x1591AGcTpudL-9LAM/s1600/IMG_2142.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtCVqMrSr5xB56FtuweF66E5GtQj_qSM-VlGiXYhZR6VAke6x4O3SY3FUyo5Ov144XlUwYzVL1RKSE7NaRLKZojDr_XK1crs4G6oH1RrDe_oPgPzzJOkSvWffw-x1591AGcTpudL-9LAM/s1600/IMG_2142.JPG" height="300" width="400" /></a></div>
<br /></div>
<div>
<span id="goog_1754077597"></span><span id="goog_1754077598"></span>it turns out that it does not matter whether the EL wire runs on the front or the back side of the mesh: it is bright enough that it will be equally visible on both sides. EL wire can bend quite a bit, but if abused too much, it will eventually break, so my wiring tends not to be all that tight.<br />
<br />
The EL wire I buy generally comes with a plastic cap at the end, and the mesh is tight enough that I need to remove the cap or cut off the end of the wire. I've generally not had problems with this practice, but in the new chasing EL wire, doing this seems to have created some sort of shortcut between the individual strands of wire, so I had to separate them a bit and put some electric tape around the end to fix the problem.<br />
<h3>
<br /></h3>
<h3>
Code for EL Wire</h3>
</div>
<div>
Basically a glorified blink sketch, as I said. Rather than synchronize line by line, or note by note, I just synchronize with the start of the song, which happens to be recorded at a fairly steady 60bpm (except for a ritardando at the end which I'm ignoring). For the chasing wire, I'm using an adapter cable using 3 channels; I do the chasing with 2 channels on, 1 off at a time, although the other way around also works, of course.</div>
<div>
<br /></div>
<script src="https://gist.github.com/microtherion/98abd173d14043720c37.js"></script>
<br />
<h3>
<br /></h3>
<h3>
Playing the MP3 File</h3>
<div>
For playing the MP3 file, I used Bill Porter's very convenient <a href="http://www.billporter.info/2012/01/28/sparkfun-mp3-shield-arduino-library/" target="_blank">MP3 shield library</a>, so the actual code to play the file was trivial: </div>
<div>
<br /></div>
<script src="https://gist.github.com/microtherion/194b92549496616eb649.js"></script>
<br />
<div>
<br /></div>
<div>
The synchronization is simply done by connecting the TX pin of the Arduino to the RX pin of the EL sequencer, and then sending some data when ready. It certainly could have been made more precise, but for my purposes, I thought it close enough.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-8872959336416775872014-04-01T04:17:00.002+02:002015-04-05T01:01:01.221+02:00Introducing Muggeseggluino<div class="separator" style="clear: both; text-align: left;">
One of the ideas that fascinate me in my electronics projects is minimalism in form factors. Having started out on an Arduino Uno, I started building ATtiny84 (14 pin DIP) based projects after a while, then ATtiny85 (8 pin DIP) based projects.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
That's where things remained for a while, but eventually, I could not resist the temptation of tinkering with the most minimalist of the ATtiny series: The ATtiny4/5/9/10, coming in a 6 pin SOT-23 package. Despite the modest specs of the series (The ATtiny10, as the luxury high end model, features 32 bytes of RAM and 1K of flash), there is decent compiler support (don't expect to run an Arduino core, of course), but programming the MCUs is a bit tricky. Pulling out the MCU from the circuit and reinserting it for every programming cycle would require rather massive amounts of soldering, and putting it onto a breakout board sort of defeats the purpose of having such a small form factor in the first place.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I decided to try a different approach: </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8dBt2ZMW4Yn1YdhGhhGYZ6Xi3WYJe7eStrRbj2K5iOt7BuSiLYOhaUjc2QZUTGLyas-h2uZ4vHT9b75ddic0Mnskzs0I_NBk1jpVdODMFFp5P88gZhvQPFkNtKXaVPRLKt8J5XRSOS5Q/s3200/IMG_3304.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8dBt2ZMW4Yn1YdhGhhGYZ6Xi3WYJe7eStrRbj2K5iOt7BuSiLYOhaUjc2QZUTGLyas-h2uZ4vHT9b75ddic0Mnskzs0I_NBk1jpVdODMFFp5P88gZhvQPFkNtKXaVPRLKt8J5XRSOS5Q/s3200/IMG_3304.jpg" height="300" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Every pin of the MCU (Except for GND) is broken out to a pin in the right row of headers. The left row is connected to the rightmost row in the prototype area. That way, the two rows of headers can be connected to operate the circuit, and separated when reprogramming the MCU. After the software is final, the headers can be removed and the two rows of pins bridged (The astute reader will notice that the space savings over a DIP breakout board, if any, are minimal, but I still like the design).</div>
<br />
The name of the board, "Muggleseggluino", derives from the Alemannic word for <a href="http://en.wikipedia.org/wiki/Muggeseggele" target="_blank">a small but distinctive amount</a>. It seemed an appropriate name for situations where just a tiny bit of microcontroller was needed as an ingredient.<br />
<br />
<div>
Right now, I'm still playing with software options. The easiest solution out of the box is Wayne Holder's <a href="https://sites.google.com/site/wayneholder/attiny10-c-ide-and-improved-device-programmer" target="_blank">ATtiny10 IDE</a>. The high voltage circuit is only needed when using pin 3 as an I/O pin, otherwise, SHDN can be used on the RESET pin directly. If you already have a 12V power supply, the <a href="http://microtherion.github.io/ScratchMonkey/HighVoltage.html" target="_blank">single transistor circuit used by ScratchMonkey</a> should also work.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-63899647260170752622014-01-28T12:55:00.001+01:002014-03-03T01:01:22.421+01:00Digispark & CoA <a href="http://boxtec.ch/" target="_blank">Boxtec</a> discussion recently brought up the fact that the last year has seen a good number of ATtiny85 based boards with USB connectors:<br />
<ul>
<li>The <a href="http://shop.boxtec.ch/digispark-usb-dev-board-p-41259.html" target="_blank">Digispark</a>, which started the trend.</li>
<li>The <a href="http://shop.boxtec.ch/adafruit-trinket-mini-microcontroller-logic-p-41838.html" target="_blank">Adafruit Trinket</a></li>
<li>The <a href="http://shop.boxtec.ch/arduino-olimexino-kit-p-41718.html" target="_blank">Olmexino-85</a></li>
<li>The <a href="http://shop.boxtec.ch/iteaduino-tiny-p-41730.html" target="_blank">Iteaduino Tiny</a></li>
</ul>
<div>
While of these, I own only Digisparks (having been one of their Kickstarter backers), the others seem close enough in design for me to offer a few thoughts about the idea.</div>
<h2>
Hardware</h2>
<div>
Electrically, all four boards seem to be based on the Digispark design: An ATtiny85 MCU, an USB connector directly connected to the MCU. Within that basic design, the boards have quite a bit of variety in the mechanical aspects:</div>
<div>
<ul>
<li>The Digispark </li>
<ul>
<li>Features a male USB connector that is simply designed into the PCB. While this is an eye catching and original design, in practice it caused me no end of mechanical problems. Even with perfect mechanical tolerances (which at least the early Digispark boards did not have), having the board sit right next to the USB plug was rarely convenient, so I ended up using a f-m USB extension cable, pretty much negating the point of having a male connector in the first place. </li>
<li>Has a voltage regulator on board and can be externally powered.</li>
<li>Has an unique and elegant, squarish form factor that Digistump is trying to build an ecosystem around.</li>
</ul>
<li>The Adafruit trinket</li>
<ul>
<li>Features a standard female USB mini connector, which in practice probably will work out much better than the male connector.</li>
<li>Voltage regulator, can be externally powered.</li>
<li>Available in 3.3V and 5V variants.</li>
<li>Reset button on board.</li>
<li>Board looks like a tiny Arduino Micro, pins brought out DIP style. Mounting holes might be quite useful.</li>
</ul>
<li>The Olmexino</li>
<ul>
<li>Female USB mini connector. <b>[Update: Now (wisely) changed to a full size USB connector]</b></li>
<li>No voltage regulator, though it looks like it might be possible to power externally with appropriate voltage. Hardware reset button.</li>
<li>Board comes as a DIY kit, which for the most part seems like a fun idea. The only board of the four featuring the through-hole variant of the ATtiny85, and even a socket for it. My one concern is the SMD USB connector, which is not my idea of fun to solder, especially since mechanical reliability is a major concern for this part. <b>[Update: It seems that Olmexino came to the same conclusion. Rev B of this board features a through hole, full size USB connector — unfortunately, nobody seems to make through hole USB mini connectors].</b></li>
<li>Pins brought out SIP style.</li>
</ul>
<li>The Iteaduino Tiny</li>
<ul>
<li>Appears to have a female USB micro connector, which I'm not terribly fond of. In my experience, mini connectors are much more convenient for frequent plugging/unplugging.</li>
<li>No voltage regulator, no reset button.</li>
<li>Instead of bringing out all pins, this design seems to have a male ISP header. I'm not at all convinced this is a good idea. The whole idea of this family of boards is to be able to do programming through USB. Furthermore, it's impossible to fall back to High Voltage Serial Programming on this board because some of the pins are only brought out through USB.</li>
<li>To add to the hardware design issues, Iteaduino <a href="http://digistump.com/board/index.php/topic,1250.msg5544.html" target="_blank">apparently did not disable the RESET functionality of the MCU</a>, so of the 4 I/O pins brought out by the header, only 3 can be used safely.</li>
</ul>
</ul>
</div>
<div>
All four of the boards share the concerns of the original Digispark design: Of the 6 I/O pins available on an ATtiny85, only 3 (PB0, PB2, PB5) are truly unencumbered: PB3/4 are connected to USB (which in practice rarely seems to be a problem, but would make me a bit nervous when the board is plugged in), and PB1 has an LED attached, which is a problem in some applications (early Digispark designs had the LED on PB0, which made I2C unusable, but this has long been fixed).</div>
<h2>
Software</h2>
<div>
All of the boards use about 2K (the Adafruit Trinket a bit more) of the flash memory for a boot loader allowing the boards to be programmed through USB. If you're used to modern Arduinos, getting used to these boards might have a bit of a learning curve, as reprogramming them is somewhat timing sensitive. None of the boards works with the Arduino IDE out of the box—the Adafruit Trinket requires some manual configuration or a custom Arduino IDE downloadable from their site, while the others use the Digispark customized Arduino IDE.</div>
<div>
<br /></div>
<div>
In addition to regular ATtiny85 activities, all of the boards have some capability to work as an USB device (e.g. a keyboard or a mouse). Generally, the software USB libraries work as advertised, but it tends to be somewhat more fragile than using a true USB capable MCU.</div>
<h2>
Pricing</h2>
<div>
One of the attractive features of the Digispark was its low price, and the clone boards are priced even more aggressively. </div>
<h2>
Final Thoughts</h2>
<div>
The Digispark was a rather original design when it first came out. From the neat form factor, to the minimalist USB connector, to the software USB and boot loader support, it featured several novel ideas, and demonstrated they could be done. As for whether they <b>should</b> be done, the situation might be less clear:</div>
<div>
<ul>
<li>In hindsight, I don't think the male USB connector was a good idea.</li>
<li>The small form factor is really convenient for space constrained projects.</li>
<li>The boot loader certainly adds convenience for beginners. If you're comfortable working with external programmers, I'm not convinced the extra convenience of a boot loader is all that useful.</li>
<li>Though the software USB support might be a bit finicky to use, it's undoubtedly a benefit for some applications.</li>
</ul>
In summary, I think these boards are at their most useful when you want USB capabilities in a project, and space and/or money are an important concern. In some projects, having a voltage regulator on board might be convenient as well. For many other projects, it seems to me that a plain ATtiny85 (possibly of the through hole variety) and an external programmer are far more flexible and not all that much harder to use.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-66814433308533299112013-08-23T03:26:00.000+02:002015-04-05T00:03:07.201+02:00ATtiny1634: My ATtiny is bigger (smaller) than yoursThe <a href="http://www.atmel.com/devices/ATtiny1634.aspx" target="_blank">ATtiny1634</a> microcontroller has an interesting combination of features:<br />
<br />
<ul>
<li>16K of flash memory, the most of any ATtinys (And matching the ATmega168 used in older Arduinos).</li>
<li>Up to 18 digital I/O pins (close to the 20 you’d get on an Arduino).</li>
<li>Two hardware UARTS (optionally usable as SPI ports), vs. 1 each on an ATmega328 / Arduino.</li>
<li>12 analog inputs (vs 6 on an ATmega328).</li>
<li>4 PWM outputs (vs 6 on an ATmega328).</li>
</ul>
As opposed to the commonly used ATtiny85 / ATtiny84, the ATtiny1634 is only available in SMD packages. The SOIC package is a bit smaller than an ATtiny84 PDIP package, but if you want a truly small package, the ATtiny1634 is also available as a <a href="http://en.wikipedia.org/wiki/WLCSP" target="_blank">WLCSP</a> package, squeezing its 20 pins into a 2mm*2.38mm ball grid pac (this could get <i>slightly</i> finicky to handle).<br />
<div>
<br /></div>
<div>
I’ve <a href="https://github.com/microtherion/arduino-tiny1634-43u" target="_blank">modified</a> the arduino-tiny core to add support for the ATtiny1634 <b>(Edit: Moved from Google code to Github in 2015)</b>. Additionally, you also need an upgraded avr-gcc toolchain. On the Mac, I recommend AVR-Crosspack, which can also be <a href="http://samelimmat.blogspot.com/2013/07/using-arduino-ide-with-crosspack.html" target="_blank">retrofitted into the Arduino IDE.</a> <a href="http://www.blogger.com/"></a></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-38586441841994106522013-07-29T04:08:00.001+02:002013-08-01T04:50:49.817+02:00Domo Arigato, XBotMicroFrom the last <a href="http://forum.boxtec.ch/index.php/topic,2268.0.html" target="_blank">Boxtec Freaky Friday</a>, I brought home a purchase I was particularly eager to unwrap: The <a href="http://shop.boxtec.ch/xbotmicro-mini-robot-platform-p-41424.html" target="_blank">XBotMicro</a>, a small, Swiss-made robotics platform.<br />
<h2>
First Impressions</h2>
<div>
The XBotMicro comes fully assembled, with a set of jumper wires, a handful of plastic standoffs and screws, and a manual in passable, though not always entirely idiomatic, English.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm6.staticflickr.com/5441/9389765434_b5f46d4e10_c.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="http://farm6.staticflickr.com/5441/9389765434_b5f46d4e10_c.jpg" width="640" /></a></div>
<div>
<br /></div>
<div>
The hardware appears to make a really excellent beginner’s platform:</div>
<div>
<ul>
<li>Motors and motor drivers built in, just require two microcontroller pins each side to drive.</li>
<li>Front equipped with solid mechanical bumper sensors.</li>
<li>LEDs for motors (green/red for forward/backward indicator) and bumpers.</li>
<li>Built-in LiPo battery, reportedly good for 2 hours’ driving. Very simple charging circuit—if the + pin sees a 5V voltage, the battery gets charged, otherwise, the battery voltage gets applied to the + pin to drive the installed microcontroller.</li>
<li>Easily accessible power switch—one would think this is a complete no-brainer, but some robotics platforms, e.g. the <a href="https://www.sparkfun.com/products/11012" target="_blank">SparkFun ProtoSnap Minibot Kit</a>, require removing the battery to stop the motors. </li>
<li>Separate motor switch: This is a really clever feature allowing a dry run of the programming by observing the LEDs, without powering the motors.</li>
</ul>
The battery comes pre-charged, and the manual contains a sketch to make the XBotMicro drive forward without needing a controller (although the included jumper wires are too short to implement this sketch).</div>
<h2>
Adding a Microcontroller</h2>
<div>
Naturally, for any nontrivial task, one would want to install a microcontroller. At first glance, I thought that pretty much any Arduino board would do—the XBotMicro certainly looks mechanically compatible with them. However, the devil is in the details: When operating in battery mode, the microcontroller has the LiPo battery, typically about 3.7V, available.</div>
<div>
<br /></div>
<div>
The manufacturer of the XBotMicro makes the <a href="http://shop.boxtec.ch/diduino-board-p-41267.html" target="_blank">Diduino</a>, a rather neat Arduino clone with a built in breadboard. While the Diduino works with 5V, it does not have a built-in voltage regulator, which makes it unsuited to input voltages greater than 6V, but gives it much more flexibility toward LOW input voltages, so the Diduino would work well with the XBotMicro. There are also a variety of 3.3V based Arduino boards, most of which should also work.</div>
<div>
<br /></div>
<div>
<strong>
Update: It’s been pointed out to me that 5V Arduino boards should also work, as long as the input voltage is applied to the 5V pin, not the VIN pin, thus bypassing the voltage regulator.</strong></div>
<div>
<br /></div>
<div>
However, none of the Arduino boards I currently own are 3.3V based, so I had to think of another alternative. I ended up putting a self <a href="http://shop.boxtec.ch/mini-breadboard-45x35cm-blue-p-40198.html" target="_blank">mini breadboard</a> on the XBotMicro and installing an ATtiny84 on it. Since I already hard the <a href="https://code.google.com/p/arduino-tiny/" target="_blank">Arduino-Tiny</a> core installed, it was quite simple to adapt the demo code to the ATtiny84 and program it using <a href="http://samelimmat.blogspot.ch/2013/06/announcing-scratchmonkey-10.html" target="_blank">ScratchMonkey</a>. The breadboard has enough room to even implement a dual-ATtiny84 controller solution if I were to need more processing power.</div>
<h2>
A Minimalist Controller</h2>
<div>
Once I had this running, I could not leave well enough alone: Why waste the 12 I/O pins of an ATtiny84 on running the XBotMicro if I could save several cents and use an ATtiny85 instead? The ATtiny85 has just the 6 I/O pins needed to drive the XBotMicro (4 outputs for the motors, 2 inputs for the bumpers), provided the RESET pin gets disabled. This requires programming the ATtiny85 using the High Voltage Serial Protocol, but <a href="http://samelimmat.blogspot.ch/2013/06/announcing-scratchmonkey-10.html" target="_blank">ScratchMonkey</a> handles this just fine, and indeed, the ATtiny85 is perfectly capable of driving the XBotMicro:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm8.staticflickr.com/7286/9386982267_c294c869a4_c.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="http://farm8.staticflickr.com/7286/9386982267_c294c869a4_c.jpg" width="640" /></a></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/NrpzA2VldFg?feature=player_embedded' frameborder='0'></iframe></div>
<h2>
</h2>
<h2>
Room for Improvement</h2>
<div>
It would be quite unreasonable to expect a brand new product like the XBotMicro to already be perfect in every way, so here’s a few minor suggestions for improvement:</div>
<div>
<ul>
<li>The language of the manual is not always 100% clear, and there are some typos.</li>
<li>I was a bit confused about the A0/A1/A2 pins, initially thinking they were alternate pins for the bumper sensors. The schematics in the documentation are not very clear on that point either.</li>
<li>The included jumper wires are very short; perfectly sized if an Arduino board is installed on top, but not very flexible for other pinouts.</li>
<li>The demo code is written in French and is structured a bit awkwardly. I’ve taken the liberty of merging it into a single file and translating it into English.</li>
</ul>
<h2>
Demo Code</h2>
</div>
<div>
Here’s my version of the demo code, with pinouts for ATtiny84 and ATtiny85 added (in fact, the code is less than 2K, so you could save a few more cents and run this on an ATtiny25, but I didn’t have any at hand).</div>
<div>
<br /></div>
<script src="https://gist.github.com/microtherion/6101436.js"></script>
<br />
<div>
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-74528631366314421962013-07-05T06:42:00.002+02:002013-07-29T02:54:43.662+02:00Using the Arduino IDE with CrossPackAs I’ve started exploring some of the more exotic members of the ATtiny family, I have increasingly been clashing with the fairly old AVR toolchain included in the Arduino IDE. I understand that there is little upside for the Arduino project in upgrading their tools: The current versions support the ATmegas on which official Arduinos are based just fine.<br />
<br />
There are, of course, a lot of people simply using <span style="font-family: Courier New, Courier, monospace;">avr-gcc</span> and <span style="font-family: Courier New, Courier, monospace;">avrdude </span><span style="font-family: inherit;">with makefiles and generic text editors, but personally, the Arduino IDE suits me just fine for most of my projects.</span><br />
<br />
After a few months of replacing bits and pieces of the toolchain, I’ve arrived at a more principled approach, based on <a href="http://www.obdev.at/products/crosspack/index.html" target="_blank">CrossPack</a>, a well maintained distribution of up to date versions of the AVR tools for OS X, including patches for the latest processors. After installing CrossPack from the web site, the following script will replace the toolchain in the Arduino IDE with a link to the CrossPack toolchain:<br />
<br />
<script src="https://gist.github.com/microtherion/5931619.js"></script>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-71146708118844707712013-06-24T03:35:00.000+02:002013-07-29T02:54:43.660+02:00Announcing ScratchMonkey 1.0Among the sketches bundled with the Arduino IDE is <span style="font-family: Courier New, Courier, monospace;">ArduinoISP</span><span style="font-family: inherit;">, which only becomes relevant once you buy your </span><i style="font-family: inherit;">second</i><span style="font-family: inherit;"> Arduino or other AVR processor. ArduinoISP turns an Arduino into a programmer, communicating with avrdude on a PC through the STK500 protocol, and </span>with a<span style="font-family: inherit;"> target AVR processor through an SPI based protocol (known as In-System Programming a.k.a ISP).</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Earlier this year, I decided to expand on this idea, and ended up writing </span><a href="http://microtherion.github.io/ScratchMonkey/index.html" style="font-family: inherit;" target="_blank">ScratchMonkey</a><span style="font-family: inherit;">, a more </span>versatile<span style="font-family: inherit;"> programmer sketch emulating the STK500v2 protocol.</span><br />
<h2>
A Better ISP Programmer</h2>
<div>
ArduinoISP is perfectly well suited for programming other Arduinos, or many AVR processors with factory fuse settings. However, the version bundled with the Arduino IDE has some limitations (some of which are addressed in forks of the standard version, to be fair):</div>
<div>
<ul>
<li>Communication speed with the computer is limited to 19200 baud for protocol compatibility reasons. ScratchMonkey is emulating a newer protocol and thus runs at 115000 baud.</li>
<li>The protocol used limits flash programming to 16 bit addresses, which prevents programming the ATmega2560 used in Arduino Mega 2560s. ScratchMonkey supports the address extensions needed for larger flash memories.</li>
<li>If the fuse settings of the target processor specify an external clock source, it is necessary to supply one i.e. by installing a crystal on the bread board (this is not a problem when reprogramming Arduinos, as the board already contains a clock source). ScratchMonkey provides a clock source by generating a PWM wave on one of the timer output pins.</li>
<li>If the fuse settings specify a very slow internal clock source (e.g. the 128kHz internal source available on some processors), or a slow external source is installed on an AVR board (e.g. a 32.768kHz watch crystal), hardware SPI is too fast to communicate with the target. ScratchMonkey automatically falls back to software emulated SPI, which can be made arbitrarily slow if necessary.</li>
</ul>
</div>
<h2>
High Voltage Programming</h2>
With some fuse settings, ISP ceases to be capable of reprogramming an AVR processor: The <span style="font-family: Helvetica; font-size: 9pt;">RSTDISBL </span><span style="font-family: inherit;">fuse turns the RESET pin into a regular input/output pin (an attractive proposition, e.g., on the 8 pin ATtiny85), and the </span><span style="font-family: Helvetica; font-size: 9pt;">SPIEN </span><span style="font-family: inherit;">fuse can disable the use of the SPI protocol. For such cases, AVR offers a bigger hammer allowing to reprogram the processor anyway: High voltage programming. </span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"><tbody>
<tr><td style="text-align: center;"><a href="http://upload.wikimedia.org/wikipedia/commons/e/e5/Tesla_colorado_adjusted.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="248" src="http://upload.wikimedia.org/wikipedia/commons/e/e5/Tesla_colorado_adjusted.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">High Voltage Programming (Artist’s Impression)</td></tr>
</tbody></table>
While the term may evoke images of Tesla or Frankenstein, the reality is considerably more prosaic, involving the application of a mere 12V signal to the RESET pin of the target processor.<br />
<br />
Along with this signal, one of two programming protocols needs to be used: AVR processors with fewer than 20 pins use High Voltage Serial Programming (HVSP), a protocol using 4 signals, while processors with 20 pins or more use one of the High Voltage Parallel Programming (HVPP) protocols, of which there are two 15 signal variants for 20 pin processors, and a 17 signal variant for processors with more than 20 pins.<br />
<br />
For some reason, most of the open source projects discussing high voltage programming limit themselves to reprogramming the fuses into a state where ISP can be used again. ScratchMonkey, on the other hand, supports full programming functionality for both HVSP and HVPP.<br />
<br />
<h2>
Supported Systems</h2>
<div>
Both an Arduino Uno and an Arduino Micro were tested as the programmer. Other Arduinos mostly should work as well, but have not been tested. I tested a wide variety of AVR processors as targets:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.flickr.com/photos/70181241@N00/8732723782/" style="margin-left: auto; margin-right: auto;" title="Untitled by neeracher, on Flickr"><img alt="Untitled" height="427" src="http://farm8.staticflickr.com/7286/8732723782_3e51cbaa45_z.jpg" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Top row: ATtiny1634, ATtiny84, ATtiny85<br />Bottom row: ATtiny4313, ATtiny861, ATmega328, ATmega1284<br />Not shown: ATmega32u4, ATmega2560 </td></tr>
</tbody></table>
<h2>
Availability</h2>
</div>
<div>
ScratchMonkey is available on <a href="https://github.com/microtherion/ScratchMonkey" target="_blank">GitHub</a>. An extensive (arguably <b>excessive</b>) manual is <a href="http://microtherion.github.io/ScratchMonkey/index.html" target="_blank">also available there.</a></div>
<div>
<br /></div>
Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-3424945357459843459.post-87779156129863528842013-05-02T23:01:00.000+02:002013-05-02T23:01:22.586+02:00Open Bench Logic Sniffer with OS XWhile trying to debug a High Voltage Parallel Programming experiment and trying to get an idea of the state of the 15 or so signals involved, I decided I had outgrown the ability of my <a href="http://shop.boxtec.ch/pirate-p-40748.html" target="_blank">Bus Pirate</a> (which works quite nicely as a logic analyzer, but is limited to 5 channels, 4096 samples at 1MHz, and very simple triggers).<br />
<div>
<br /></div>
<div>
I decided on an <a href="http://shop.boxtec.ch/open-logic-sniffer-p-40747.html" target="_blank">Open Bench Logic Sniffer</a>, made by the same people as the Bus Pirate, and working with the same logic analyzer clients. Logic Sniffer allows sampling rates up to 200MHz, and 24K samples with 8 channels, 12K samples with 16 channels, or 6K samples with 32 channels, and much more sophisticated triggers. As my OS X client, I used <a href="http://www.lxtreme.nl/ols/" target="_blank">Logic Sniffer Java client</a>, which by now has pretty much supplanted the original SUMP client for which the Logic Sniffer was designed.</div>
<div>
<br /></div>
<div>
Initial experiments were not entirely satisfactory. It seemed that 8 channel mode mostly worked, but 16 channel mode tended to work only at the 200MHz sample rate, which was too fast for my purpose and only gave me brief snippets of the transactions I wanted to examine (at least, thanks to the advanced triggers, picking those snippets was feasible).</div>
<div>
<br /></div>
<div>
I decided to look for a firmware update, and at this point, the seamy underbelly of the Logic Sniffer ecosystem came into plain view:</div>
<div>
<br /></div>
<div>
<ul>
<li>There is a confusing tangle of web pages purporting to have Logic Sniffer documentation, pointing to obsolete versions of each other, with some of the links just broken.</li>
<li>The pertinent information on the web forum discussing Logic Sniffer is distributed across several threads, and it’s not always evident which information is authoritative.</li>
<li>Some key tools for upgrading are Windows specific, making life for OS X users a bit harder.</li>
<li>The Logic Sniffer authors were not always entirely aware of what the actual manufacturers did with the devices (My brand new Logic Sniffer from Seeed Studio shipped with firmware that was more than 2 years out of date!).</li>
</ul>
As a result, my upgrade took a rather circuitous route, and at one point had me believe I had bricked my logic sniffer (turns out I had just uploaded firmware into the wrong flash memory region). For future generations, here’s what I now believe are best practices:</div>
<div>
<br /></div>
<div>
<ul>
<li>The most useful starting page for Logic Sniffer is at <a href="http://dangerousprototypes.com/docs/Open_Bench_Logic_Sniffer" target="_blank">Dangerous Prototypes</a> (while the Gadget Factory page linked is so outdated that even the “updated” link it contains leads to a mostly broken page).</li>
<li>The discussion forum is part of the <a href="http://dangerousprototypes.com/forum/viewforum.php?f=23" target="_blank">Dangerous Prototypes Forum</a>.</li>
<li>The latest firmware, however, is still hosted at <a href="http://www.gadgetfactory.net/logicsniffer/index.php?n=LogicSniffer.Download" target="_blank">Gadget Factory</a> (Don’t be discouraged by the “Mac OS X coming soon” links—see below).</li>
</ul>
To actually upgrade the firmware from an OS X machine (most other platforms are quite a bit simpler), I got the following procedure to work:</div>
<div>
<br /></div>
<div>
<ul>
<li>Get the ols-fwloader source from github and compile it (you’ll need to install autoconf through <a href="http://finkproject.org/" target="_blank">Fink</a> or <a href="http://www.macports.org/" target="_blank">MacPorts</a>). Most likely, you won’t need to install the resulting tool, but if you do, pick a suitable <code>--prefix</code>:
<script src="https://gist.github.com/microtherion/5505122.js"></script>
</li>
<li>Get the <a href="http://dangerousprototypes.com/forum/download/file.php?id=8080" target="_blank">Diolan dummy kext</a> from the <a href="http://dangerousprototypes.com/forum/viewtopic.php?f=23&t=1654&p=41840&hilit=kext#p41736" target="_blank">discussion forums</a> and install it.
<script src="https://gist.github.com/microtherion/5505225.js"></script>
You may see some scary looking warnings, but everything’s perfectly safe.</li>
<li>Get the “Linux Expert” package from the Gadget Factory download page (latest release right now is <a href="http://github.com/downloads/GadgetFactory/OpenBench-Logic-Sniffer/ols-0308-expert.tgz" target="_blank">3.08</a>). Change into the <code>OLS_Upgrader</code> directory.</li>
<li>Put your logic sniffer into “ROM update mode” by holding the “update” button on the board and then pressing the “reset” button while the “update” button is held. If successful, both green LEDs (ACT and PWR) above the USB connector should be lit.</li>
<li>Determine the serial port of your Logic Sniffer, which will be of the form <code>/dev/tty.usb*</code>. Use that port in the code below.</li>
<li>Upgrade the FPGA bitstream, and then the Logic Sniffer firmware:
<script src="https://gist.github.com/microtherion/5505351.js"></script>
</li>
<li>Now unplug and re-plug the logic sniffer. Everything should be working.</li>
</ul>
</div>
<div>
With the latest firmware, everything seems to work great. The hardware is capable of much more than the software currently supports, but even so, it’s a fairly nice instrument:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsumctX50qUnre0yhk9GbQW0f1_J4jCpgofeis8WNfZgq_QzQC6yvYhkKvGRv7ubJEU08Jq4EfI2en7j1lotYxLTmlQMKeCUWIpc1VpSAqjgDqH7m1ZUk_BELdELSweIH7xMxEbX_ulNM/s1600/skitch.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsumctX50qUnre0yhk9GbQW0f1_J4jCpgofeis8WNfZgq_QzQC6yvYhkKvGRv7ubJEU08Jq4EfI2en7j1lotYxLTmlQMKeCUWIpc1VpSAqjgDqH7m1ZUk_BELdELSweIH7xMxEbX_ulNM/s320/skitch.png" width="320" /></a></div>
<br /></div>
Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-3424945357459843459.post-16673755994976916612013-04-04T04:15:00.002+02:002013-05-08T12:47:20.345+02:00Review: Arduino MicroBoxtec kindly offered an <a href="http://shop.boxtec.ch/arduino-micro-p-41308.html" target="_blank">Arduino Micro</a> for review, and I was grateful for the opportunity to add one to my collection.<br />
<h2>
Physical Design</h2>
<div class="separator">
<a href="http://farm9.staticflickr.com/8120/8616868612_e4932ea522.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="320" src="http://farm9.staticflickr.com/8120/8616868612_e4932ea522.jpg" width="264" /></a></div>
<div>
Although I had seen the dimensions of the Micro on the data sheet, the first view of it was still impressive: The entire Arduino board comes in the size of a DIP-34 package (if such a thing existed). In fact, it is smaller than some AVR <b>microcontrollers </b>(like the ATmega1284 shown here).<br />
<br />
<div 40="" center="" class="separator”>
<a href=" d537a037f0.jpg="" farm9.staticflickr.com="" http:="" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;">
<div style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;">
<img border="0" height="150" src="http://farm9.staticflickr.com/8242/8616869424_d537a037f0.jpg" width="200" /></div>
</div>
</div>
<div style="clear: both;">
<br />
Among the more difficult consequences of the tiny size of the Micro is that the pin labels can be fairly hard to read for aging eyes like mine, and since they are <b>between</b> the pins, it’s easy to forget which pin they apply to. Several of the first experiments I built had at least one connection made to the wrong pin, though I expect I’ll get used to the labels after a while.<br />
<br />
The top of the board also features the USB Micro B connector. While USB Micro connectors are not uncommon, USB Mini is still a bit more prevalent among Arduinos, and the only Micro cable I had around happened to be Micro A. It pays to check in advance and order either the regular <a href="http://shop.boxtec.ch/micro-cable-orange-p-40926.html">USB Micro</a> cable or the <a href="http://shop.boxtec.ch/sparkfun-cerberus-cable-180cm-p-41159.html">Sparkfun Cerberus</a>
cable along with the Arduino Micro — otherwise, your friendly neighborhood retailer will be happy to charge you the price of an Arduino Micro for a connector cable!<br />
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8111/8615765323_5cc91ba2b3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://farm9.staticflickr.com/8111/8615765323_5cc91ba2b3.jpg" width="400" /></a></div>
<br />
A look at the bottom of the Micro shows that the board has components on both sides; the 34 pins are implemented as fairy sturdy male header pins that work great on breadboards. From the dimensions, I had expected that the Micro would also fit into a DIP-40 socket (e.g. so it could be easily inserted and removed from larger projects), but it appears that the pins are a bit too thick to make this possible without employing excessive force.<br />
<h2>
High Level Features</h2>
</div>
<div>
From the point of view of the Arduino API (digitalRead, digitalWrite, analogRead, analogWrite), the Arduino Micro is straightforward to use and powerful.<br />
<br /></div>
<h3>
Digital I/O</h3>
<div>
At first glance, one might think that an Arduino Micro offers exactly as many digital pins as an Arduino Uno. However, the reality is quite a bit better than that:</div>
<div>
<ul>
<li>The standard serial port of the Micro runs over USB. A hardware port is available on pins 0 (TX) and 1 (RX), but it is possible to use these pins for other purposes while still maintaining a full serial connection to a computer.</li>
<li>SPI is run through a separate set of pins (MOSI/MO, MISO/MI, SS, and SCK), which are available as digital pins if not used for SPI.</li>
</ul>
So while an Arduino Uno has a maximum of 20 pins available, and only 18 if the serial port is used, an Arduino Micro has 24 pins available. This is, in fact, better even than the Arduino Leonardo, which is largely pin compatible with the Micro, because the Leonardo only makes the SPI pins available through the ICSP header, and does not make the SS pin available at all.</div>
<div>
A few extra pins may not seem like much, but as I’m currently working on a problem requiring 19 pins (see below), having 20 pins readily available was just perfect.</div>
<h3>
</h3>
<h3>
Analog Input</h3>
<div>
The Arduino Micro has a generous 12 analog inputs (6 of which are on “analog” pins, and 6 on “digital” pins).</div>
<h3>
</h3>
<h3>
“Analog” Output</h3>
<div>
There seems to be a bit of confusion surrounding the number of PWM outputs an Arduino Micro has. While the text on boxtec’s site correctly gives the number as 7, the accompanying diagram has 8 pins labelled as “PWM”. Two of those, 4 and 12, are not usable as Arduino analog pins, and pin 3, which is usable, is not labelled “PWM”. So, for the record, the usable PWM pins are 3, 5, 6, 9, 10, 11, and 13.</div>
<div>
<br /></div>
<h2>
Low Level Features</h2>
<div>
If you like to dig a bit deeper into the mysteries of AVR programming, here are some lower level considerations.</div>
<h3>
</h3>
<h3>
Pin Layout</h3>
<div>
While digitalRead/digitalWrite are very useful abstractions, it sometimes is helpful to access the underlying port registers directly. In particular, it is sometimes possible to change or read up to 8 pins simultaneously. The precondition for this is, of course, that those pins are part of the same port, and it often helps if the physical sequence of the pins is the same as their bit order in the port.<br />
<br />
The <a href="http://www.pighixxx.com/wp-content/uploads/edd/2013/02/ARDUINO_V2.png" target="_blank">standard Arduino layout</a> is pretty good at this, with the 20 pins arranged as one 8 bit sequence and two 6 bit sequences. Unfortunately, the <a href="http://www.pighixxx.com/pgdev/Temp/microb.png" target="_blank">Arduino Micro layout</a> (and the Leonardo layout, on which it is based), is a different story altogether: The 24 pins of the ATmega32u4 are spread across 5 8-bit ports, and due to layout considerations, the Arduino boards rearrange pins and pick the occasional bit in the middle for LEDs. As a result, the longest contiguous sequences available are two 4-bit sequences.<br />
<br />
<h3>
Pin Interrupts</h3>
</div>
<div>
Another difference between the ATmega328 and the ATmega32u4 is that the former has a pin change interrupt available for any input pin, while in the latter (and thus the Micro), only 8 of the pins have pin change interrupts, 4 of which are assigned to the SPI interface. In practice, this should rarely be a limitation, but if you expect to be able to get a pin change interrupt on every conceivable I/O pin, that’s not going to work on a Micro.</div>
<div>
<br /></div>
<h3>
Timers</h3>
<div>
On a happier note, the ATmega32u4 has a very impressive collection of timers:</div>
<div>
<ul>
<li>Timer 0 (8 bit) and 1 (16 bit) appear to have fairly similar features across the entire ATmega line.</li>
<li>Timer 3 is virtually identical to Timer 1.</li>
<li>Timer 2 (8 bit on ATmega328) does not exist on the ATmega32u4.</li>
</ul>
But it is Timer 4, a 10 bit timer, that is particularly intriguing. It features no fewer than 6 PWM outputs, arranged in 3 pairs: For each PWM output, its complement can also be made available on another pin. A <i>dead time generator</i> can be set to slightly offset the two signals to introduce times when both signals are 0 (or 1), which appears to be useful for some power switching applications. A <i>fault protection input</i> can turn off the PWM outputs quickly. And finally, the timer can be clocked at an internal PLL frequency of up to 64MHz.</div>
<div>
<br /></div>
<h2>
Using the Arduino Micro</h2>
<h3>
Uploading Sketches</h3>
<div>
The Arduino IDE ships with support for the Arduino Micro in the “Board” menu. The upload procedure is a bit different from the Arduino UNO, and in practice, I’ve often found it necessary to manually press the reset button on the board in order for an upload to succeed. </div>
<div>
<br /></div>
<h3>
USB Support</h3>
<div>
One of the attractions of the Micro is obviously its hardware USB support. The Arduino software supports emulation of a Serial port, a Keyboard, and a Mouse. All three of these seem to work very reliably, and performance can be downright scary: It’s easy to send so much text to the Keyboard emulation that your computer keeps typing for several minutes after you’ve unplugged the Micro.</div>
<div>
<br /></div>
<div>
As a proof of concept, I built myself a simple mouse, using a SparkFun <a href="https://www.sparkfun.com/products/11187" target="_blank">5-Way Tactile Switch Breakout</a> board.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8262/8615761245_f72bbf19b8.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="192" src="http://farm9.staticflickr.com/8262/8615761245_f72bbf19b8.jpg" width="320" /></a></div>
<div>
<br /></div>
<div>
Nevertheless, I found that the Arduino libraries make rather conservative use of the USB hardware capabilities available. For instance, I would find it very useful to open a second USB serial port, and the hardware seems to be capable of doing it, but the libraries don’t support it. There also is no built-in support for other USB protocols, e.g. MIDI over USB. One of my future projects will be exploring third party projects like <a href="http://www.fourwalledcubicle.com/LUFA.php" target="_blank">LUFA</a>, which are supposed to be considerably more powerful. </div>
<div>
<br /></div>
<h3>
High Voltage Parallel Programming</h3>
<div>
One of my current obsessions (and the origin of my infamous 19 pin problem) is the implementation of the various programming protocols available for AVR processors. I’m in the final testing stages of a new programming sketch named <a href="http://microtherion.github.com/ScratchMonkey/" target="_blank">ScratchMonkey</a>, and was eager to play with the Arduino Micro as an alternative to the Uno for a programmer.</div>
<div>
<br /></div>
<div>
I’m pleased to report that the Micro performed perfectly in this role. The extra pins allowed me to use a simpler breadboard setup (with the Uno, I had to use an auxiliary shift register for the control signals), and after a few minutes of cabling, I was able to successfully reprogram an ATtiny4313:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8110/8616865906_b3fdbf15a6_z.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="384" src="http://farm9.staticflickr.com/8110/8616865906_b3fdbf15a6_z.jpg" width="640" /></a></div>
<div>
<br /></div>
<div>
Shown here, left to right: A Maxim MAX662ACPA+ charge pump IC to generate the 12V high voltage signal from the 5V input; the ATtiny4313 target MCU, an ATtiny85 left on the board from a previous experiment, and the Arduino Micro.</div>
<div>
<br /></div>
<h2>
Summary</h2>
<div>
An Arduino Micro probably should not be the first Arduino to give to a beginner: The small labeling, the finicky upload procedure, and the limited compatibility with Arduino shields are all drawbacks to a certain extent. However, the Micro excels with its breadboard friendliness, its USB capabilities, and a pin count and feature set exceeding most regular size Arduino boards. I highly recommend it as a second Arduino board for owners of a standard Arduino, or as a board for users with previous microcontroller experience.</div>
</div>
Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-3424945357459843459.post-70030361830247186402013-02-18T18:34:00.001+01:002013-07-29T02:54:43.658+02:00Overqualified FlashlightI had an old plastic flashlight with partially corroded innards, and no incandescent bulbs for it, so I decided to turn it into a fancy RGB LED spectacle, controlled by an <a href="http://shop.boxtec.ch/20mhz-attiny85-p-40608.html" target="_blank">ATtiny85</a>.<br />
<h2>
Power Supply</h2>
<div>
The <a href="http://shop.boxtec.ch/pub/seeed/8mmLED.pdf" target="_blank">RGB LED</a> I had needed forward voltages of 3V and more, so keeping the original 2x1.5V C cell power supply was not really viable (apart from the corrosion problem), so I decided to use a 9V battery. However, 9V was outside the operating range of the ATtiny85, so I used a <a href="http://shop.boxtec.ch/lm317l-voltage-regulator-p-40515.html" target="_blank">LM317</a> voltage regulator to adjust the voltage to 3.8V (comfortably within the range of the ATtiny85, close to 3.3V for experiments, and suitable for resistors I had available).</div>
<h2>
Prototyping & Programming</h2>
<div>
Breadboarding the circuit was trivial, with my new <a href="http://shop.boxtec.ch/pirate-p-40748.html" target="_blank">Bus Pirate</a> serving ably as a SPI programmer. </div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8389/8486528544_6d0182e5cc.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="314" src="http://farm9.staticflickr.com/8389/8486528544_6d0182e5cc.jpg" width="320" /></a></div>
<br /></div>
<div>
Adding the Bus Pirate as a Programmer to the Arduino IDE is simple: In your Arduino projects folder (<span style="font-family: Courier New, Courier, monospace;">~/Documents/Arduino</span> on a Mac), add a file <span style="font-family: Courier New, Courier, monospace;">hardware/buspirate/programmers.txt</span>:</div>
<blockquote>
<script src="https://gist.github.com/microtherion/4979113.js"></script>
</blockquote>
this will work OK, but quite slowly, as the version of avrdude shipping with current Arduino IDEs includes a suboptimal protocol for talking to the Buspirate. If you download the latest version of avrdude from its <a href="https://savannah.nongnu.org/svn/?group=avrdude" target="_blank">subversion repository</a>, recompile, and copy <span style="font-family: Courier New, Courier, monospace;">avrdude</span> and <span style="font-family: Courier New, Courier, monospace;">avrdude.conf</span> to their corresponding paths in the Arduino IDE, it’s possible to obtain much higher programming speeds<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: inherit;">(You could also re-flash the Bus Pirate firmware to set it up for the stk500 protocol, but I would not recommend that).</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">While in earlier ATtiny85 experiments, I used the <a href="http://hlt.media.mit.edu/?p=1695" target="_blank">attiny</a> Arduino cores, I switched to the <a href="http://code.google.com/p/arduino-tiny/" target="_blank">Arduino-tiny</a> cores this time, because attiny only supported 2 PWM pins on the ATtiny85, while Arduino-tiny supports 3.</span><br />
<span style="font-family: inherit;"><br /></span>
The code itself is straightforward, except that since the LED is common anode, it is activated by a LOW output, and by the “inactive” part in the PWM cycle.<br />
<script src="https://gist.github.com/microtherion/4979149.js"></script>
<br />
<h2>
Layout</h2>
<div>
I had a <a href="https://www.sparkfun.com/products/8885" target="_blank">SparkFun hex shaped protoboard</a> that fit the flashlight very well. Fitting all the components onto the board was rather challenging, especially since the position of the LED in the middle of the board was not really negotiable. My original plan was to put the LED on one side and the rest of the components on the other, although this added some additional complications for the wiring.</div>
<h2>
Assembly</h2>
<div>
Despite the cramped layout, I thought I had done a pretty good job placing the components. Unfortunately, I had forgotten to include the current limiting resistors for the LED, so the LM317 failed within a few seconds. Luckily, I had a <a href="http://edp.org/monkey.htm" target="_blank">scratch monkey</a> at hand, and the LED and the ATtiny were undamaged. Removing the failed LM317 proved rather difficult, and retrofitting resistors between the LED ATtiny even more so. Ultimately, I found it easiest to put one of the resistors on the LED side of the board.</div>
<div>
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8523/8485440805_d5ae9b72d2.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="320" src="http://farm9.staticflickr.com/8523/8485440805_d5ae9b72d2.jpg" width="240" /></a><a href="http://farm9.staticflickr.com/8086/8485439617_6c1005f10e_z.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="239" src="http://farm9.staticflickr.com/8086/8485439617_6c1005f10e_z.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
I wanted to use the existing power switch built into the case, so I had to connect to the power switch, and to the bulb socket, which turned out to be rather frustrating work, so I ultimately cheated by adding some strategically placed aluminum foil:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8524/8486532576_8db5e02769_b.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="307" src="http://farm9.staticflickr.com/8524/8486532576_8db5e02769_b.jpg" width="640" /></a></div>
<br />
<h2>
The Result</h2>
<div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/bweBxuncQjo?feature=player_embedded' frameborder='0'></iframe></div>
<br /></div>
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-88241044606158406082012-12-31T00:14:00.003+01:002012-12-31T16:29:56.438+01:00Putting On My Hardware HatRecently, my son became interested in LED sneakers, so I pondered making something similar for him, which would be a good opportunity to explore the <a href="http://web.media.mit.edu/~leah/LilyPad/">LilyPad</a> textile friendly Arduino platform. I didn't like the odds of building something robust enough to survive in a shoe, and LilyPads are not all that small, so I decided on building a LED hat (with temperature sensitive LED patterns, to make it interesting).<br />
<br />
<span style="font-size: large;">Materials</span><br />
<br />
<a href="http://www.boxtec.ch/">Boxtec</a> carries a reasonable selection of LilyPad compatible boards to get started. In particular the <a href="http://shop.boxtec.ch/protosnap-lilypad-development-board-p-40961.html">ProtoSnap LilyPad development board</a> contains all the electronics used in this project, except for the colored LEDs, and also comes with a 110mAh LiPo battery, the conductive thread needed to connect everything, and an FTDI board for the USB connection (No separate charger for the battery is needed; the battery will charge when the LilyPad is connected to USB).<br />
<br />
Pretty much any hat should be OK for this project; the one I picked turned out to be a bit on the small side for the customer, and picking a color so close to the color of the conductive thread was not as clever a decision as I had originally thought.<br />
<br />
<span style="font-size: large;">Layout</span><br />
<br />
I started out by installing the LilyPad Simple processor board on the inside of the hat, at the very top, and a temperature sensor on the outside, at the top (The temperature sensor is not currently used, although I got it to work to some extent; more on this in a separate post).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8353/8326945052_3e3e7d32ff.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="LilyPad Simple board with hat" border="0" height="320" src="http://farm9.staticflickr.com/8353/8326945052_3e3e7d32ff.jpg" title="" width="240" /></a></div>
<br />
The LEDs are arranged in two staggered rings of 4 LEDs each, red on top, and alternating blue/green on the bottom.<br />
<br />
<span style="font-size: large;">Sewing the Connections</span><br />
<br />
This was the true challenge in this project. I may have learned a little bit of sewing as a child, but hadn't held a needle in more than 25 years. However, this <a href="http://www.instructables.com/id/How-to-Sew./">Instructable on Sewing</a> was quite helpful, and entirely sufficient to get the project done.<br />
<br />
Initially, I started with a planned pin assignment for the LEDs, but it turned out to be easier in some cases to stitch a connection from whatever pin was closest to the LED I wanted to connect, and adapt the code to the physical layout, rather than the other way around. Since I was not using PWM, and only one analog input, most pins were largely interchangeable for my purposes.<br />
<br />
<span style="font-size: large;">Writing the Code</span><br />
<br />
My plan was to run the red LEDs and the blue&green LEDs separately, so I could have one LED in each group lit. To save pins, I wired up the red LEDs using a <a href="http://en.wikipedia.org/wiki/Charlieplexing">Charlieplexing</a> scheme using 3 pins. However, when testing the result, one of the LEDs would not work cleanly, with two of its neighbors lighting up as well. Despite testing all the connections for short circuits, I was unable to find the cause. I suspected that the high impedance state might not have worked as planned, due to the peculiarities of LilyPad connections.<br />
<br />
To test this, I wired the blue/green LEDs using 4 pins, with a simpler multiplexing scheme that did not rely on tristate logic. Ultimately, though, the results were not much better, with one of the LEDs never lighting up. I probably would have been best off with a common cathode/anode, one pin per LED scheme, but for what it's worth, my code is <a href="https://gist.github.com/4414439">here</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8224/8326947130_31ae28f700.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Hat with blinking LEDs" border="0" height="240" src="http://farm9.staticflickr.com/8224/8326947130_31ae28f700.jpg" title="" width="320" /></a></div>
<br />
<span style="font-size: large;">Tying up the Loose Ends</span><br />
<br />
Having decided that my result was close enough to what I wanted to build, I installed the battery in place with some non-conductive thread.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8351/8326946578_b3864485d3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="Battery sewed in place on hat" border="0" height="320" src="http://farm9.staticflickr.com/8351/8326946578_b3864485d3.jpg" title="" width="240" /></a></div>
(Visuals like this are why it may be inadvisable to take homemade electronics through airport security).<br />
<br />
Finally, I wanted to cover up the LilyPad main board and the battery. Having the electronics in contact with someone's head seemed like a bad idea for the electronics, and the LilyPad has a rather prominent male 6 pin connector, which looked like an injury risk. A piece of black repair sheet, and some more non-conductive thread did the job reasonably well (with the opening of the stitching leaving enough space to insert the FTDI/USB board for reprogramming and recharging).<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8078/8325889041_8e46b9d341.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="LilyPad board covered with repair sheet stitched into place" border="0" height="300" src="http://farm9.staticflickr.com/8078/8325889041_8e46b9d341.jpg" title="" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: large;">Customer Test</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After some initial skepticism, my son decided that his hat was nearly as cool as a pair of LED sneakers:</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://i.ytimg.com/vi/6OdY_IocDN4/0.jpg" height="266" width="320"><param name="movie" value="http://www.youtube.com/v/6OdY_IocDN4?version=3&f=user_uploads&c=google-webdrive-0&app=youtube_gdata" /><param name="bgcolor" value="#FFFFFF" /><param name="allowFullScreen" value="true" /><embed width="320" height="266" src="http://www.youtube.com/v/6OdY_IocDN4?version=3&f=user_uploads&c=google-webdrive-0&app=youtube_gdata" type="application/x-shockwave-flash" allowfullscreen="true"></embed></object><br />
<br />
<span style="font-size: large;">Lessons Learned</span><br />
<br />
<br />
<ul>
<li>Working with conductive threat is the equivalent of building a circuit using non-insulated wires exclusively. It can be tricky to avoid short circuits.</li>
<li>My idea of having most of the stitching run between the outer and inner layers of the hat made it even harder to find out what’s going on.</li>
<li>It’s not clear whether the material of the hat might have been somewhat conductive itself.</li>
<li>Redoing a stitched connection can be quite a bit more work than redoing a wire, especially since I tried to run a single thread through several destinations, instead of doing strictly point to point connections.</li>
<li>That said, the stitching itself was not terribly difficult, as long as I was not overly fussy about the esthetics of the outcome.</li>
</ul>
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-3424945357459843459.post-32897296648136527342012-08-13T02:20:00.002+02:002012-08-13T02:20:45.127+02:00Foca 2.1 as AVR ISP<h1>
Turning a Misunderstanding into Reality</h1>
Recently I started dabbling in ATtiny programming, and I became tired of tying up my Arduino UNO as an ISP, so I wanted a standalone ISP.<br />
<br />
The <a href="http://imall.iteadstudio.com/im120525005.html">Foca 2.1 board</a> seemed to fit the bill. The product description mentioned it being a "Programmer for Arduino and compatible boards", and the data sheet showed a familiar looking 6 pin header in the "ISP Zone", so I bought the board from <a href="http://shop.boxtec.ch/">Boxtec</a>.<br />
<br />
Only when I started playing with the board did I realize that the 6 pin header simply was breaking out control pins for an RS232 serial interface, and that the "Arduino Programmer" was meant to program ATmegas with boot loaders through the serial port, not bare ATtinys through the SPI based in-system chip programming interface.<br />
<h2>
Enter Plan B</h2>
However, the FT232RL chip on the Foca board is very flexible, and supports a "Bitbang" mode, in which the data sent directly sets 8 control lines to arbitrary values, instead of being sent through a serial interface. Support for SPI based in-system chip programming was already in the avrdude SVN repository (though not in a release yet).<br />
<h2>
Dude, where's my AVR?</h2>
Checking out the latest version of avrdude from its <a href="http://savannah.nongnu.org/svn/?group=avrdude">SVN repository</a>, I initially had little success getting the ftdi_syncbb method to work.<br />
<br />
This turned out to be mainly due to the fact that OS X has linkable stubs for anonymous semaphore functions (sem_init, etc.), but actually returns errors from them. Code that does not check these functions for errors (like the ft245 code in avrdude) becomes wildly susceptible to race conditions.
<br />
<br />
After fixing this problem, the code worked, but only at very slow bit rates (2400 or less). While better than nothing, this was rather disappointing performance, and at faster rates, scary things like reprogrammed fuses happened.<br />
<h2>
Faster, SPI! Kill! Kill!</h2>
A <a href="http://tinyurl.com/d4bp974"> Technical Note</a> from FTDI suggested a reason for my problems: The data in bitbang mode was written based on a clock that was not synchronized to the data clock, so signal pulse widths were not reliable. The suggested remedy was to pad out the data.<br />
<br />
So I modified the writing code to write each data byte 4 times, and upon reading, only use every 4th byte (2x duplication helped as well, but beyond certain bit rates still failed). Despite having to write much more data for each bit (effectively 8 bytes per bit), thanks to the improved reliability, I now achieved data rates of more than 45000 bits per second, more than enough to program an ATtiny at blazing fast speeds.<br />
<h2>
Tweaking the Arduino IDE</h2>
Now that I had a working avrdude, all that I needed to do to get it working directly from the Arduino IDE was to copy the binary and the configuration file into the Arduino app, and to create a "programmer" entry in the hardware subfolder of my sketch folder.<br />
<h2>
Show me the code!</h2>
For those interested, the patches and detailed instructions are available <a href="http://dl.dropbox.com/u/12303087/foca-isp-10.zip">in this archive</a>.Unknownnoreply@blogger.com0