{"id":741,"date":"2012-09-29T00:28:49","date_gmt":"2012-09-28T22:28:49","guid":{"rendered":"http:\/\/blog.ulrichard.ch\/?p=741"},"modified":"2012-09-29T00:28:49","modified_gmt":"2012-09-28T22:28:49","slug":"led-debugging-the-stereowrap-hardware","status":"publish","type":"post","link":"https:\/\/ulrichard.ch\/blog\/?p=741","title":{"rendered":"LED debugging the stereowrap hardware"},"content":{"rendered":"<p>I found out earlier <a href=\"http:\/\/blog.ulrichard.ch\/?p=463\">that 5V is not enough<\/a> to drive the shutter glasses. With my breadboard setup for <a href=\"https:\/\/github.com\/ulrichard\/stereowrap\" target=\"_blank\" rel=\"noopener\">stereowrap<\/a>, I fed 12V to the op amps from an external source. Now that I moved the thing to a strip board, I added a step up converter that generates 12V from the 5V available on the USB port. I used an <a href=\"http:\/\/www.conrad.ch\/ce\/de\/product\/171557\/\" target=\"_blank\" rel=\"noopener\">LT1301<\/a> which comes with an application note for exactly my use case. It was easy to implement and worked from the first try.<\/p>\n<p>Then I temporarily switched from an <a href=\"http:\/\/arduino.cc\/en\/Main\/ArduinoBoardDuemilanove\" target=\"_blank\" rel=\"noopener\">arduino duemillanove<\/a> to a <a href=\"http:\/\/www.freetronics.com\/products\/leostick\" target=\"_blank\" rel=\"noopener\">leo stick<\/a>. Although it&#8217;s a tiny clone which plugs directly into an USB port, it still seemed like a bit of an overkill. I thought of using one of the AtTiny&#8217;s for that project. As I was not too familiar with these yet, I first did a <a href=\"http:\/\/imakeprojects.com\/Projects\/avr-tutorial\/\" target=\"_blank\" rel=\"noopener\">hello world blinking LED&#8217;s<\/a>. Soon after, I learned that neither the Attiny45 nor the AtTiny85 have a hardware UART. Well, I thought, there is an <a href=\"http:\/\/arduino.cc\/en\/Reference\/SoftwareSerial\" target=\"_blank\" rel=\"noopener\">arduino software serial library<\/a>. Arduino libraries are generally very easy to use in the IDE. But as I programmed the chip directly this time I wanted to stay within CodeBlocks\/CMake and use the arduino library from here. <!--more-->It was quite a bit of trial and error to get something compiling, but it didn&#8217;t work initially. It all seemed a little cumbersome to pull in the library into an environment where it&#8217;s not supposed to be. So, I installed <a href=\"http:\/\/code.google.com\/p\/arduino-tiny\/downloads\/list\" target=\"_blank\" rel=\"noopener\">arduino-tiny<\/a>, and getting something to compile was a lot easier, this time with the arduino IDE. But it still didn&#8217;t work. As I had the impression, it pulls in way too much anyway, I went back to a more native approach, looking for lightweight software UART on the AtTiny. I found an <a href=\"http:\/\/www.atmel.com\/Images\/AVR274.pdf\" target=\"_blank\" rel=\"noopener\">application note from atmel<\/a>. It was for a different compiler, but there were some ports. As I only need to receive data, I went with a <a href=\"http:\/\/blog.ethanfrei.com\/2011\/08\/attiny84-uart-receive-naive.html\" target=\"_blank\" rel=\"noopener\">simplistic implementation that comes with a good explanation<\/a>. It seemed to be for a slightly different chip, as it didn&#8217;t compile for me. But it was close enough, so that I could figure out the rest with the help of the <a href=\"http:\/\/www.atmel.com\/Images\/doc2586.pdf\" target=\"_blank\" rel=\"noopener\">AtTiny datasheet<\/a>. But it still didn&#8217;t work. I wanted to debug it in the simulator, but simavr always crashed. Hence I did some LED debugging, to make sure the interrupts work the way I expect them to. Let me elaborate a bit on that. I&#8217;m used to have a debugger where I can step through my programs, inspect the variables, change values and skip statements. In the olden days I thought &#8220;message box debugging&#8221; was simplistic if you don&#8217;t have a debugger at hand. When I started working with micro controllers, I thought &#8220;uart debugging&#8221; was simplistic. Now I have nothing more than an LED to show me what&#8217;s going on. How simplistic is that? After I verified all the interrupt and port in and out stuff, I wanted to see what the chip received from my serial transmission. It&#8217;s only a byte at a time. I either send &#8216;l&#8217; or &#8216;r&#8217; for left or right. To visualize, I output the bits one per second to the LED. Of course the <a href=\"http:\/\/www.seeedstudio.com\/depot\/dso-nano-v2-p-681.html?cPath=174\" target=\"_blank\" rel=\"noopener\">DSO Nano<\/a> was very helpful too, but even more so would be a scope with two channels. Strange enough, for &#8216;l&#8217; I received 00111101\u00c2\u00a0 and for &#8216;r&#8217; I received 01001101. Within five minutes I couldn&#8217;t figure out how that resembles to an ASCII code for &#8216;l&#8217; or &#8216;r&#8217;. But as I&#8217;m looking only for these two values, that&#8217;s ok, I just check for them. And guess what&#8230; It finally worked. The whole program that took me more than two evenings to write has a compiled size of <strong>206 bytes<\/strong>. One should think a program of that size should even be manageable in assemby.<\/p>\n<p>Now I&#8217;m waiting for the $3 FTDI device from china to complete the assembly. Till then I use the USB to uart cable from the bifferboard. One thing that I did notice, is that the uart communication is not as reliable on the stripboard as it is on the breadboard. I suspect that the internal oscillator of the attiny is affected by the oscillations of the step up converter. Adding another capacitor improved the situation a bit, but I might have to investigate more, or even add a quartz.<\/p>\n<p>So, the next thing will be to fix the software side of things. Last time I tried, the two eyes were very unbalanced. Meaning One eye was blocked a lot longer than the other.<\/p>\n<p><a href=\"https:\/\/github.com\/ulrichard\/stereowrap\" target=\"_blank\" rel=\"noopener\">The code is at github<\/a><\/p>\n<table>\n<tbody>\n<tr>\n<td><a href=\"https:\/\/ulrichard.ch\/piwigo\/index.php?\/category\/48\"><img decoding=\"async\" src=\"https:\/\/ulrichard.ch\/piwigo\/_data\/i\/upload\/2015\/11\/09\/20151109234905-0d92f6e1-th.jpg\" alt=\"\" \/><\/a><\/td>\n<td><a href=\"https:\/\/ulrichard.ch\/piwigo\/index.php?\/category\/48\"><img decoding=\"async\" src=\"https:\/\/ulrichard.ch\/piwigo\/_data\/i\/upload\/2015\/11\/09\/20151109234905-4ce0ce33-th.jpg\" alt=\"\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Update\u00c2\u00a0 4. Okt 2012: crystal clock<\/h4>\n<p>I added an 8MHz crystal and two accompanying capacitors. Because I used the pin for the crystal for an output, I had to rearrange the pins a little bit. The reception is now totally reliable.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I found out earlier that 5V is not enough to drive the shutter glasses. With my breadboard setup for stereowrap, I fed 12V to the op amps from an external source. Now that I moved the thing to a strip board, I added a step up converter that generates 12V from the 5V available on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7,1],"tags":[19,26,28,163,199,213,214,229],"class_list":["post-741","post","type-post","status-publish","format-standard","hentry","category-projects","category-software","category-uncategorized","tag-arduino","tag-attiny","tag-avr","tag-opengl","tag-shutter","tag-stereoscopic","tag-stereowrap","tag-uart"],"_links":{"self":[{"href":"https:\/\/ulrichard.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ulrichard.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ulrichard.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ulrichard.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ulrichard.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=741"}],"version-history":[{"count":0,"href":"https:\/\/ulrichard.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/741\/revisions"}],"wp:attachment":[{"href":"https:\/\/ulrichard.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ulrichard.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ulrichard.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}