Sorry this post isn't going to have any pictures as its all ideas, or what I have done but not finished yet.
So yesterday I realised I hadn't actually done a project that involved buttons on the AVR. I had done so on the TI LaunchPad which I had used before I got the AVR hence why I thought I had done so (I only swapped 3 months ago). Due to this I have decided I'm going to make another test program which will take the state of four buttons and translate them into a 4 bit binary and display the decimal reading on an LCD screen. As I was getting my breadboard ready for the SPI test, I moved another AVR onto the same breadboard and downloaded the LCD code. Worked so I then started tidying up the code to make it more of a library rather than all in one file. I finally got the code to work (the statements for getting printf to work are quite hard to satisfy) and so downloaded to the AVR and the display did nothing. I thought it must be the code as it seemed to be working on the original chip on the board but not the second. So I spent the next hour trying to troubleshoot the code, eventually going back to the original code that I posted last time and it still didn't work. Eventually I found out that one of the crimped pins within the header plug on one end of the LCD cable had come loose and so the LCD wasn't actually receiving the data! Good lesson to remember - check the hardware first, don't assume its all ok, specially cables.
My next hurdle to overcome was bouncing buttons. I wanted a non-blocking solution so the system would be fast and would work well with multiple buttons. I first came up with the simple solution of just using a capacitor of in parallel with the button as I had used this before. I couldn't remember how to calculate the time constant and how it worked so I decided I would keep thinking. I next came up with a very elegant and well thought out way to do this in software using timers that can and change when more interrupts come in. This would be great if you wanted an all digital solution such as a remote control where you don't want capacitors for each and every button. (I'll detail this as could be useful someday or for someone visiting) This method worked by when the button changed state and interrupt was called, which then disabled the button a timer was called, the timer would then run and call a function for the button. If the button was still in the changed state it would now and only now do what the button is supposed to do. The timer function was the special part though. The timer function extraction is given the parameter of the function to call after the its executed and this is pushed onto its stack. The system timer is then set off with the required delay. When the system timer finishes, it calls the function from the bottom of the stack and removed it from the stack. If there is another timer that comes in before finished, it takes off what was left of the timer that is running and sets as the next timer to run after its finished and then puts the new call function above the previous one on the stack. Its quite easy to modify for varying times as well.
I decided I didn't really think this was necessary so went looking once more. I found sampling of everything at intervals could work after its been pressed but that would still need timers so would basically need the above as timers are limited on the chip. I found a guide to debouncing on google which explained lots of different types of techniques for helping. One of which was once again the RC (Resistor and Capacitor) circuit. This made me realise what the R value was but also made me think that I can't be bothered doing the maths at this stage and I can optimise components later. I've now put in 100nF (0.1μF) across the buttons and will just use that for testing (the size I choose as it was used on the LaunchPad experimenter board).
That is as far as I have go today as being the weekend, there is much more noise in the house with the folks around and I can't concentrate on programming (its hard enough getting into the mood to write this). Tomorrow I should get the program written as it shouldn't take too long and then might get started with looking into SPI a bit more.
In other news, I bought a large pile of things from element14. I bought an SMD SD card holder. The one I found had 2.54mm pitch spacing so should be able to be soldered onto strip board and easily attached to the breadboard for testing which is great. I bought some switches but ended up with the wrong type as I didn't realise that MOM meant momentary as I had already unchecked momentary in another column I thought, oh well can be used for something else. I bought some blue LEDs which are very good, I hadn't realised how bright they would be! The main thing I bought though was a set of four SMD tweezers. I had managed to get them to quote them down to less than $55 down from $110 or $170 depending on the if it was a set or individual. They are now displaying $65 for everyone. I got these as they should be amazing for dealing with SMD parts. As I've said in a previous post, I have managed to solder at SMD sizes so tweezers will help with that. I'm also thinking still that I could make a hot plate setup as I could get better temperature control than cheap (well not that cheap at $60+) hotplates available online. The only part that would seem hard to get hold of is the element but they are actually quite easy to get at the one of the tip shops (landfill shop) near where I live. So I would end up with a much much cheaper hotplate, that has better temperature control. Talking of which, I will have to make a temperature sensor project as I will need to be able to measure temperatures in the printer. I had a look into how to use thermistors this week while wasting time on the internet.
So I'm thinking I'll buy a Raspberry Pi or similar and set it up as a SVN server. In regards to SVN and Atmel Studio, I found out yesterday that to get the extension installed you must install the Atmel Gallery first which requires creating an Atmel account, before you are able to install other extensions such as the SVN one.
That is all for tonight, I should hopefully have my binary buttons program working tomorrow and will then start on either SPI or the thermistor. I have also finally got some decent sized heat sinks for the SMD stepper driver so I'll have a look at that soon as I can compare it with the other chip as they can both be active due to the two chips being on the breadboard at the moment.