Tuesday, January 21, 2014

A Stand-alone ICSP Interface/programming board for 8 and 28 pin AVR microcontrollers

Several weeks ago I got an "Ultimate 3" transmitter kit from Hans, G0UPL (See the web page http://hanssummers.com for more information) and built it with no problems. As is often the case with a project like this, an updated version of software was released that fixed some bugs and added new features (sometimes it works the other way-round!) and Hans posted the object code (.HEX) files so that others could update their software.

A couple of months ago I had also gotten a clone of the AVR ISP MkII with which AVR projects that include the ICSP (In Circuit Serial Programming) interface can be programmed, but the Ultimate 3 kit didn't have the ICSP pins of the processor broken out on the board so I had to build a stand-alone circuit with which I could program the chip after having been removed from its socket on the Ultimate 3 board.

Figure 1, below is the result.

Figure 1:
The ICSP Interface board 8 and 28 pin AVRs built onto a 1-3/4" x 1-1/2" (approx. 45 x 40mm) prototype board.
The 6 pin ICSP connector may be seen along the right side of the board.
(Yes, I know that the label says "8 & 20" pins - I changed it after taking the picture...)
(Click on the image for a slightly larger version)
The Atmel AVR chips are quite popular these days, being the basis of many of the Arduino boards and variants, but they are also popular for "ground up" projects - that is, a custom design needing a microcontroller - the Ultimate 3 being just one example.  To reprogram the U3's processor I would need a 28 pin socket, but since there was room on the board I decided to include an 8 pin for the ATtiny chips as well should I decide to build something around one of those in the future.

In looking on the GoogleWeb I saw a plethora of diagrams showing how these chips would be connected to either a 6 pin or 10 pin ICSP connector, so I built  the board above (sans oscillator at first - more on that in a moment) and tried to read the chip's signature....

It didn't work.

Oops - I'd forgotten a power supply, as the AVRISP MkII programmer didn't supply power to the chip being programmed.  No problem: I threw a 78L05 and a pair of 0.1uF capacitors on the board so that I could supply a stable, clean source of 5 volts externally.  Connecting the programmer again it now read 5.1 volts via the ICSP connector.  I again tried reading the chip's signature.

It still didn't work.

Trying the programmer on an Arduino board I verified that it actually worked - and then I remembered that there was a very good chance that these AVRs would need a clock source in order to function.  Rummaging around in my collection of resonators I found a 3-lead 4.0 MHz ceramic resonator with built-in capacitors and plopped it onto the board.


For some reason, I decided that that wasn't enough:  I thought "What if the fuses on the chip were configured to take an external clock source and the device was not configured to an external crystal?" - could an AVR be configured to be that way - even during programming?  Rather than research that point I decided to completely circumvent the issue and put a 4 MHz "can" oscillator on the board instead of the resonator and connect it to the clock/crystal input pin of the AVR designated as "XTAL1" on each of the two sockets.

At the moment I have only a few AVRs with which to test:  One of them was configured to use a 20 MHz crystal while the other was set up to accept an external oscillator for the clock.  When originally tested with the 4 MHz ceramic resonator, the one configured to use the crystal did work in this circuit but the other one did not.  Once I changed to a 4 MHz oscillator module they could both be read and written.
Figure 2: 
 Schematic diagram of the AVR ICSP interface board
(Click on the image for a larger version)

In Figure 2, above, you can see the final result and some notes.

I find it quite interesting that while I could find the ICSP connections for the AVR all over the InterWeb (or is it GoogleFace?) I could find not one of them (at least in the first half dozen pages of results...) that actually made mention of the need for a clock source or a self-contained power supply!  The assumption seemed to be that anyone, anywhere, would include the ICSP connections on their project board, already and never have a need to program a "free-standing" chip.

While my programmer has only the 6 pin ICSP connector I dug up the 10 pin connector pinout for the convenience of someone else who might have that.  I also included in the notes the option of using either a ceramic resonator/quartz crystal OR a 4 MHz "can" oscillator.

Later, I decided to add R1 on the oscillator module's output - just in case the fuses on the processor had been set to cause this pin be a logic output as might be the case if the AVR's internal oscillator is used - in which case, it probably wouldn't need any external crystal or oscillator at all.  The 470 ohm resistor allows the line to be driven easily, but limit the current to a very safe value were it set to a 0 or 1.

The actual frequency of the crystal, oscillator or resonator is not important, but it must be within the ratings of the processor being programmed at the operating voltage provided by the programming circuit.  Also, the programming clock speed - selectable in the programming software - must be no faster than 1/4th of the oscillator/crystal/resonator frequency.
The default of 250 kHz is used in the version of Atmel Studio that I was running.  Anything in the 1 MHz to 8 MHz range for a crystal, resonator or oscillator module is likely to work equally well.  If the AVR is configured to use a very slow internal oscillator, the programming software would need to have its programming clock frequency changed accordingly.

While I used a 78L05 for the voltage supply to the chip being programmed, about anything that provides a stable and clean source of 3.3-5.5 volts would probably work (you'd have to verify the operating voltage range of the processor that you are programming) and this could even include the use of 3 AA or AAA cells in series to get 3-5 volts, the exact voltage depending on the condition of the battery.

If you do use a battery to provide power for the processor during programming make sure that there is at least one 0.1uF capacitor located near-ish U2 and/or U3.  If you use the crystal can oscillator with a battery you will need to add an on/off switch, but if you chose to use the crystal or ceramic resonator, instead, you could forgo the switch - provided that you never left a processor in either the U2 or U3 socket when done!

A switch may be a good idea, anyway as it is recommended that one removes the power before plugging in or unplugging the processor from its socket - but I will admit that I frequently don't bother doing that and have never had a problem... yet...
There are AVRs out there than those with 8 and 28 pins - and maybe even some 8 or 28 pin devices with pin-outs that don't match Figure 2, but the 8 and 28 pin versions for which the sockets are wired are the two sizes for which I expect to have immediate need.

One thing that the AVR ISP and this board cannot deal with is if the AVR's LVP (Low Voltage Programming) has been disabled.  If you configure an AVR such that this feature is disabled it is possible that you will need to seek out a programmer with "High Voltage Programming" to reset the fuse and re-enable LVP. 

My prototype board is only 1-3/4"x1-1/2" (approx. 45x40mm) so there wasn't really enough room to put anything on it other than what I did - and I was barely able to cram the 4 MHz can oscillator on the board as it was!


This page stolen from ka7oei.blogspot.com

Tuesday, January 7, 2014

RIP Gretchen cat

In the summer of 2001, in the courtyard of the apartment complex where my older brother lived at the time a feral mother cat had a litter of 4 kittens:  Two males and two females.  When they were about 5-6 weeks old I got one of them (which was named Oscar) and a co-worker of mine who'd come along got one of the female kittens.  Both were somewhat sickly at the time and I while managed to nurse Oscar back to health, the female kitten died.  A week or so later we went back and he was able to capture the other male, leaving a female kitten there.

Some months later - October, I believe - my brother reported that the remaining female kitten was still there and I was goaded into coming over.  I had two cats already:  Oscar, and a then 4-year old Siamese named Thomas, and I was somewhat reluctantly convinced to adopt another cat.  Somewhere we found a fish net and managed to catch the small, wild, hissing furball and stuff her in a pet carrier, everyone involved getting scratched in the process.  Taking her to the vet she was pronounced healthy and in due course she got both vaccinations and "fixed."  Near the beginning of all of this, someone - I'm not sure who - decided that her name would be Gretchen.

For the first few months that I had her she was little but an elusive shadow that I would only occasionally see around the house, but she slowly became bolder, eventually getting brave enough to leap onto the bed at night, demand to be petted for a few minutes and then wander off somewhere else to sleep - and there were many days in the beginning when that would be the only time that I would see her.

Unfortunately, she and her brother, Oscar, never got along and pretty much avoided each other, occasionally getting into brief, noisy fights and very occasionally I'd find that one of them had been contacted by the sharp claws of the other.  Gradually she became attached to me and would usually park herself somewhere in the same room is I - usually just out of sight until she'd suddenly hop into my lap and curl up, purring while I scratched her neck.

Today, however, I had to let go of Gretchen the cat.

Late last week she was off her food and seemed lethargic - a rather sudden change from her normal behavior of just a few days before.  Seeing that she was dehydrated I gave her about 150 milliliters of ringers lactate subcutaneously (I had this paraphernalia on hand from a previous health scare with Oscar:  I would recommend that anyone with aging cats obtain this from a vet and learn how to use it!) and called the vet as soon as its office opened the next morning, a Saturday.

Upon examination the news was not good:  She had rapidly and recently acquired some gum lesions and her blood work showed that her kidneys were nearly nonfunctional and she also had an infection which the vet said was likely a result of her kidney problems rather than the cause.  Despite being rather doubtful of the ultimate outcome, the vet gave me some antibiotics and more ringers lactate, sending me home with her.

It would not surprise you to know that despite the antibiotics and infusions she did not get any better.  On Saturday she ate a bit of the special food that the vet had given me, a bit less on Sunday and nothing on Monday.

This morning I found her in the room where the waterbowl and litter box are, lying weakly on the carpet and she could barely stand when coaxed to do so.  At such this point a difficult decision had to be made - and you already know that that was.

I called the vet, made an appointment, went in with a cat, stayed with her until after she passed away and left with an empty pet carrier.

I do still have Oscar, Gretchen's brother and the Siamese cat, Thomas who is now approaching 18 years old.  Both of them have their problems:  Oscar had transient renal failure two years ago and somehow recovered (for now...) while Thomas is suffering largely from old age.  Even though she only appeared from her hiding places when I was home alone and was very particular in deciding when she wanted my attention, I will miss this cat.

Gretchen the cat - a picture taken on January 5, 2014, two days before she died.


In the months that followed, I have lost the other two cats mentioned above.  Thomas died in May due to old age and in July, Oscar, Gretchen's sibling, died of complications of renal and hepatic failure.  Later that year I got another cat from my niece - a 16 year old grimalkin:  I had her for about two and a half years before she also succumbed to old age in July of 2016.

At the moment I have one cat - Izzy - a fuzzy, mixed-breed (mostly) Japanese bobtail female that I got from my niece in February or March when she moved into a place where should could not have pets.  A bit of a derp, she's an affectionate cat, but not bonded to any particular person like the other three cats - but still company, nonetheless.


This page stolen from ka7oei.blogspot.com