LED debugging the stereowrap hardware

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 the USB port. I used an LT1301 which comes with an application note for exactly my use case. It was easy to implement and worked from the first try.

Then I temporarily switched from an arduino duemillanove to a leo stick. Although it’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’s for that project. As I was not too familiar with these yet, I first did a hello world blinking LED’s. Soon after, I learned that neither the Attiny45 nor the AtTiny85 have a hardware UART. Well, I thought, there is an arduino software serial library. 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. It was quite a bit of trial and error to get something compiling, but it didn’t work initially. It all seemed a little cumbersome to pull in the library into an environment where it’s not supposed to be. So, I installed arduino-tiny, and getting something to compile was a lot easier, this time with the arduino IDE. But it still didn’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 application note from atmel. It was for a different compiler, but there were some ports. As I only need to receive data, I went with a simplistic implementation that comes with a good explanation. It seemed to be for a slightly different chip, as it didn’t compile for me. But it was close enough, so that I could figure out the rest with the help of the AtTiny datasheet. But it still didn’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’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 “message box debugging” was simplistic if you don’t have a debugger at hand. When I started working with micro controllers, I thought “uart debugging” was simplistic. Now I have nothing more than an LED to show me what’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’s only a byte at a time. I either send ‘l’ or ‘r’ for left or right. To visualize, I output the bits one per second to the LED. Of course the DSO Nano was very helpful too, but even more so would be a scope with two channels. Strange enough, for ‘l’ I received 00111101¬† and for ‘r’ I received 01001101. Within five minutes I couldn’t figure out how that resembles to an ASCII code for ‘l’ or ‘r’. But as I’m looking only for these two values, that’s ok, I just check for them. And guess what… It finally worked. The whole program that took me more than two evenings to write has a compiled size of 206 bytes. One should think a program of that size should even be manageable in assemby.

Now I’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.

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.

The code is at github

Update  4. Okt 2012: crystal clock

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.

Leave a Reply

Your email address will not be published. Required fields are marked *