Home

 

August 2017 - Atmel Madness

I suppose I could blame the Ipswich Rally for this. The Essex Ham report also has some nice pictures of the event which was held in a field in Suffolk on a day that threatened to rain - but didn't. There were some good bargains to be had and I picked up a nice component tester kit (picture of completed item below), and there were other things to tempt me. [The tester gets a good review here].

Component Tester

Among the temptations was an Atmel Development kit for just £2.

stk200 Complete with all the leads and a tube full of 8 pin microcontrollers - all in a nice box. I couldn't resist!

The empty sockets are where you would plug a microcontroller that you are developing code for. They come in various sizes with increasing capability as the size increases. These are the microcontrollers that form the heart of the Arduino board that we've all come to love.

This board has LED's for showing output, various switches and potentiometers for input. Great for testing and developing.

"For two quid", I thought, "it would be fun to learn about them". It became clear very soon that it wouldn't end at two quid and the spending madness would escalate.!

When I got it home I discovered that the interface to the PC was via a parallel printer port.

[Note: There is a modern version of this kit that uses a USB connection to the PC]

Not many PC's have parallel printer ports now so I assembled an old Pentium 4 PC with Windows XP and started playing with the included software which was now some 15-20 years old. I found that I could inspect the flash memory of most of the chips that came with it, but really, only seeing the contents in hexadecimal wasn't useful and programming in assembler wasn't attractive now that I've begun to learn "C".

The other downside was that the old software had no concept of all the modern ATTiny and ATMega chips and the newer free software from Atmel had no knowledge of the old parallel board. Programming on an old (slow) XP PC held no attractions either.

I am fortunate to have an experienced "Atmel elmer" in the form of my friend Steve G0XAR and he steered me toward some more purchases on the journey to Atmel enlightenment.

Make - the bookThe first purchase was an excellent book that takes you through first principles with the hardware and the C code which enables all the clever things that these microcontrollers can do.

Short of having Steve G0XAR on 24 hour speed dial this is a super piece of writing by the author Elliot Williams.

 

 

 

 

 

 

It became clear from the book that I needed a modern programmer and these came with various price tags. The official programmer from Atmel that Steve has is no longer available. I presume that they gave up trying to compete with the many "clones" that are on sale. Steve consulted with the renowned programmer Hans G0UPL at Friedrichshafen and the recommendation was that I should get the same Olimex programmer that Hans uses and Farnell have them in stock. I placed an order and it came within days.

It didn't seem to work very reliably. The Olimex was designed to integrate completely with the Atmel Studio software, but in my case, mostly it wouldn't recognise it. When it did, the software couldn't detect the chip plugged into my target board.

I should explain target boards. The PC that you are developing the code on has a programmer plugged into a USB port. In turn, the programmer is connected to something that the Atmel chip is plugged into. These are available very cheaply and this one is very good quality.

I built mine onto a perspex base and included a battery so I could run the chip when not connected to the programmer. To the right is an adapter that I made for the 8 pin chips.

Frustrated that the programming was so unreliable I wondered whether it was my set up or a faulty programmer. The only real way to tell was to buy another one so I went for a cheap "USBasp" programmer that seemed to be popular. It comes as a bare board that sooner or later I knew I would short out - so I built it into one of my perspex enclosures.

USBasp programmer

The USBasp programmer worked perfectly from day one. Though it isn't integrated in the Atmel studio software it did transfer the hex code produced by Atmel Studio. I used the command line AVRDude software to transfer the code to chip flawlessly every time.

So the Olimex was definitely suspect. An email to Farnell produced a great result. I should dispose of the old programmer and they would send me a new one - they told me. The replacement worked perfectly.
Full marks to Farnell for great customer service.

In all, the Olimex was nearly four times the cost of the USBasp programmer. Of course, it comes all cased up and you do get a level of service that you might not get from an overseas order.

Finally I now had a set up that enabled me to work through the book. The first lessons involved getting LED's to wink under programming from the microcontroller. I found that the chip could be removed from the target board after programming and placed in the original £2 development board for the actual "LED winking".

In the video below you can see the LED chasing sequence - so reminiscent of the Cylons eyes from the TV show Battlestar Galactica.

The Atmel chip actually containing the program is an ATMega328 is mounted in a socket on the development board just out of shot in the video.

One of the things that I like about the Atmel Studio software is the ability to simulate a chip and run a debug session stepping through the code and seeing what effect it has on things like the output port to which the LED's are connected.

Debug in Atmel Studio This video shows the debug in action...

I was curious what the various signals coming from the AVR chip looked like.

I have a new toy - a logic analyser. Mine is USB based and works very nicely connected to an old "Nettop" mini PC. Attaching six leads to the development board LED connections I could see that voltage supply only goes to one LED at a time - as it should.

Logic Analyser

It has been a slow progress and I can't really say that Atmel enlightenment has happened yet. It has been something fun to learn - even if the cost ended up being a lot more than £2. I am never going to be the programmer that Hans and Steve are. You can see the kind of magic that can happen at QRPLabs.

I can however see tasks within my grasp where one little 8 pin chip could replace a lot of components. Imagine a QRP transceiver which needs various change over functions as you go from transmit to receive (and back again). All that switching control and timing can be done in software. Even adding CW sidetone would be possible within the restrictions of a very cheap 8 pin device.

I suppose there is an obvious question. Which way should a beginner go? Arduino or this way?
Without doubt I would say Arduino. You can buy a "Nano" for under three quid and it will probably even come with the required USB lead to connect to your computer. Essentially the Arduino contains its own programmer. The IDE software is also free and there is not much else needed other than perhaps a breadboard to develop on.

However, learning new stuff is in itself rewarding ... and really, it's all great fun isn't it?

The question to then maybe ask is "why doesn't QRP Labs (for instance) use Arduino"?
Cost being one reason. Bulk buying Atmel chips is cheaper and you get access to all resources inside whereas the Ardino uses some flash storage for the bootloader code. Size being another as an Atmel chip is usually much smaller than Arduino.

 

[RSS]

Articles (2017)

December 2017
Overtone Crystal tester
Simple and Cheap to build.

September 2017
My take on Earthing Rods
and a good excuse to buy an SDS drill.

September 2017
A font of knowledge
Some superb blogs to follow.

September 2017
Audio Amplifiers
and a great offer from GQRP club .

August 2017
Atmel Madness
Programming clever little chips .

June 2017
Auto Cut-Off Timer by Bob AE4IC
Saves on batteries.

May 2017
SNA Jr. by DuWayne KV4QB
Unbelievably useful test instrument. Link to DuWaynes Google +

April 2017
Aerial Phasing Noise Canceller
For battling that S9 local noise.

March 2017
QRP for the Tightwad
A Club Talk.

January 2017
A Comb Generator
Handy Wide Band Noise Source.