AVR Freaks

AVR forum - some newbie questions.....

Calgar - Dec 06, 2007 - 11:48 AM
Post subject: some newbie questions.....
hi, I am new to this, so i apologise if these questions sound rather.. umm.. ignorant, because they probably are.

anyway, I want to start programming avrs mainly (only?) because of an interest in robotics. I am not new to electronics (i have built a few BEAM bots among other things) or programming (i know quite a bit of visual basic (which, i was forced to learn at school) and i think i have the very basics of C nailed). i will probably be designing my own boards, sending them off to be made and soldering them in a toaster oven.

so, questions... uh, yes

1) what is a good "beginners" avr? (if the is such a thing) i was looking at either the ATmega2560 or the ATmega644 as these appear to be the most "powerful" avrs. which i assume would mean that i would have to deal with less hardware limitations and not have to worry so much about optimising my code whilst i learn.

2) is the a big difference between what is available for development under Linux than under windows? I prefer linux and the electronic design i have done so far has been using GNU EDA, which is only available for linux

3) what USB programmer should i get bearing in mind the above two questions? preferably it should be cheap, although i am willing to pay if it has features that merit that expenditure.

I think that is it, at least at the moment.

thanks in advance!
clawson - Dec 06, 2007 - 12:20 PM
Post subject: RE: some newbie questions.....
1) If it's a robot then the "big iron" like the 2560 probably fits the bill and means you won't run out of resource. Only downside of the big devices is that they aren't particularly "home solder" friendly but as long as you are happy you can cope with the package types they come in it's probably the way to go

2) the main thing you miss in Linux are (a) only one of the four or five main AVR C compilers is available to you (rest are all Win32 only) and (b) Atmel AVR Studio is not available to you (though some have reported success with "wine"). These things aren't the end of the world - but it's true that for development/debugging the Studio debugger and its support of Dragon/JTAGICE/JTAGICEmkII are probably the "slickest" - though there are Linux alternatives (avaraice and gdb)

3) the Linux toolchain generally has updates to suport the various USB programmers/debuggers these days so that, in itself, shouldn't be a limit. The interfaces from Atmel themseles are some of the nicest basically because they simply work! (though there may be a little price premium to pay)

Just one thing to say if you intend to JTAG (and on such a big project I suspect you will want to) is that on any AVR with more than 32K of flash you won't be able to use the Dragon (it's limited but it's also just $50). For the "modern" big devices the ONLY on chip debugger you can use is the JTAGICEmkII for which the list price is $300 but some suppliers (Arrow I think?) are currently doing it for $150. If you want a "big" device but want to use one of the old $30-$50 JTAGICE(mkI) clones then you are limited to the following chips:

ATmega16(L), ATmega162(L), ATmega169(L or V), ATmega32(L), ATmega323(L), ATmega64(L), ATmega128(L)

and for robotics you'd probably therefore be looking at the mega128
Calgar - Dec 06, 2007 - 08:45 PM
Post subject: Re: RE: some newbie questions.....
thankyou for the reply

clawson wrote:
1) If it's a robot then the "big iron" like the 2560 probably fits the bill and means you won't run out of resource. Only downside of the big devices is that they aren't particularly "home solder" friendly but as long as you are happy you can cope with the package types they come in it's probably the way to go

2) the main thing you miss in Linux are (a) only one of the four or five main AVR C compilers is available to you (rest are all Win32 only) and (b) Atmel AVR Studio is not available to you (though some have reported success with "wine"). These things aren't the end of the world - but it's true that for development/debugging the Studio debugger and its support of Dragon/JTAGICE/JTAGICEmkII are probably the "slickest" - though there are Linux alternatives (avaraice and gdb)


so, no IDE for linux? really? that kinda sucks. i have never NOT used an IDE really, so that could be a big problem

clawson wrote:

3) the Linux toolchain generally has updates to suport the various USB programmers/debuggers these days so that, in itself, shouldn't be a limit. The interfaces from Atmel themseles are some of the nicest basically because they simply work! (though there may be a little price premium to pay)

Just one thing to say if you intend to JTAG (and on such a big project I suspect you will want to) is that on any AVR with more than 32K of flash you won't be able to use the Dragon (it's limited but it's also just $50). For the "modern" big devices the ONLY on chip debugger you can use is the JTAGICEmkII for which the list price is $300 but some suppliers (Arrow I think?) are currently doing it for $150. If you want a "big" device but want to use one of the old $30-$50 JTAGICE(mkI) clones then you are limited to the following chips:

ATmega16(L), ATmega162(L), ATmega169(L or V), ATmega32(L), ATmega323(L), ATmega64(L), ATmega128(L)

and for robotics you'd probably therefore be looking at the mega128


what is so important about being able to JTAG?

can you give me the link for where i can get the "JTAGICEmkII" at $150? (or, even better, a UK supplier for £75) as that doesn't sound too bad if it has lots of features

thanks in advance!
bobgardner - Dec 06, 2007 - 11:31 PM
Post subject: RE: Re: RE: some newbie questions.....
Look at the ere.co.th mega128 board... a little carrier board with the 128 on it, about 2" square... it plugs into a carrier board with headers for all the io ports.... they also have ribbon cables and io boards with hi current buffers and stuff... and they sell a $40 jtag clone... also look at olimex.. they sell a jtag clone that works on the 128 (have a couple at work)
clawson - Dec 07, 2007 - 11:37 AM
Post subject: RE: Re: RE: some newbie questions.....
I didn't say no IDE for Linux, just that the "best" IDE for AVR (Atmel's Studio) is not available. You can use something like Eclipse and I believe there are others that have been used (is there one called something like code::blocks or something?)

There are various ways to debug an application:

1) use your brain and develop it faultlessly in the first place (this technique has a major proponent here!)

2) litter your code with printf()s to say what's going on and have these go up a UART to a PC terminal

3) litter your code with stuff to flash LEDs to give you an idea of what's going on "inside"

4) run the code in a simulator so you can single step it and watch the variables to see where something is going wrong (but simulators are never 100% accurate)

(2) and (3) suffer from the fact that in a complex system with a lot going on (such as a robot) you may not know exactly where the problem is occuring and where to start putting the LED/printf stuff so there's...

(5) use a JTAG - this lets you "look inside" the actual AVR. It's very like (4) but the code is running on the real AVR with the real external input and output circuitry. So now you can watch variables, memory, single step, run to breakpoints and so on and actually watch it light the lights or respond to the sensor inputs. For complex systems it's by far and away the easiest method to develop.

If the app was just anything up to 16K (say) then the (1), (2), (3), (4) are probably enough to sort things out as there'll just be one main thread of execution with maybe a handful of ISRs that might be interrupting form time to time. But above that the chances are you are going to have a number of "tasks" operating concurrently (maybe even using an RTOS) and trying to debug the interaction between those is almost impossible without (5)

Cliff
Calgar - Dec 08, 2007 - 04:19 PM
Post subject: RE: Re: RE: some newbie questions.....
thanks for that explanation clawson.

I guess i will try to get one of those cheap "jtagice2" things, although it doesn't look as though any UK supplier is selling them cheap, so i guess i will have to import it (if, arrow will ship to the UK)... or just start with a smaller chip

as for linux, i have found a program called "kontrollerLab" (dont you just love KDE fanboys? (well, i guess in this once instance i do, heh)) which, from a cursory glance seems to look rather good.

thanks for your help
bobgardner - Dec 08, 2007 - 04:27 PM
Post subject: RE: Re: RE: some newbie questions.....
I think my favorite Thailand ere company is represented in England by Futurelec... several AVR boards ready to program for sale there... maybe the robot should have several AVRs on a communication bus or network... one for sensors, one for navigation, one for motor control...
Calgar - Dec 12, 2007 - 12:11 AM
Post subject: Re: RE: Re: RE: some newbie questions.....
i think, perhaps i may just go for a cheapo programmer only device to start, and then shell out for a jtagice2 if/when i start pulling my hair out Laughing

so, another question, what is the cheapest ISP (shouldn't that be ICP?) that can program all the atmega controllers?

bobgardner wrote:
maybe the robot should have several AVRs on a communication bus or network... one for sensors, one for navigation, one for motor control...


umm... i dont suppose you could give me a link to a guide on how to do that could you possibly? for future reference as it does sound like a good idea, allowing more functions to be run and decisions to be made at the same time.

thanks in advance!! Cool
bobgardner - Dec 12, 2007 - 01:15 AM
Post subject: RE: Re: RE: Re: RE: some newbie questions.....
That Thailand company I mentioned sells a parallel port programmer for $5. Is that in your 'real cheap' programmer category? An envelope from Thailand to the US is $9. Wonder if its cheaper to the UK?
clawson - Dec 12, 2007 - 11:17 AM
Post subject: RE: Re: RE: Re: RE: some newbie questions.....
Bob,

If they take payments in US$ then yes they'll appear even greater bargains here because of the relative strength of Sterling to Dollar at the moment.

Another option for Calgar would be £14 ($28) on a Butterfly then load it up with Buttload and use that as an ISP programmer. Alternatively as the AVRISPmkII is about $35 I guess that makes it about £18 right now though, knowing UK distributors, I bet they charge more like £25 or perhaps even more.
Calgar - Dec 12, 2007 - 12:18 PM
Post subject: Re: RE: Re: RE: Re: RE: some newbie questions.....
bobgardner wrote:
That Thailand company I mentioned sells a parallel port programmer for $5. Is that in your 'real cheap' programmer category? An envelope from Thailand to the US is $9. Wonder if its cheaper to the UK?


needs to be usb, unfortunately. or a "proper" serial programmer that does not use bit bashing would work too (usb serial adapters dont work with bit bashing)

clawson wrote:
Bob,

If they take payments in US$ then yes they'll appear even greater bargains here because of the relative strength of Sterling to Dollar at the moment.

Another option for Calgar would be £14 ($2Cool on a Butterfly then load it up with Buttload and use that as an ISP programmer. Alternatively as the AVRISPmkII is about $35 I guess that makes it about £18 right now though, knowing UK distributors, I bet they charge more like £25 or perhaps even more.


hmm... thanks, i will look into those.
clawson - Dec 12, 2007 - 12:32 PM
Post subject: RE: Re: RE: Re: RE: Re: RE: some newbie questions.....
Rapid appear to have:

Butterfly - £16.45
AVRISPmkII - £26.44
Dragon - £39.95
STK500 - £79.31
JTAGICEmkII - £229.13

http://www.rapidonline.com/searchresult ... manu=Atmel

EDIT: added VAT

EDIT2: If you go for Bob's ere.co.th options then keep the value of any individual order to less than £18 and it will not attract VAT/duty/customs charges (while the VAT/duty may not be much the customs handling charge is something like a fixed £15-£20!)
jgmdesign - Dec 12, 2007 - 01:21 PM
Post subject: RE: Re: RE: Re: RE: Re: RE: some newbie questions.....
I just purchased an MKII from digikey for $39.00 plus shipping

HO HO HO Happy Christmas

Jim
clawson - Dec 12, 2007 - 01:59 PM
Post subject: RE: Re: RE: Re: RE: Re: RE: some newbie questions.....
Yup in the UK Digikey list that for £18.27 but if you go ahead to purchase you then have £5 "handling" added and £12 shipping for a total of £35.27 with the added promise that "VAT will be added at the time of delivery". Well that's 17.5% so it'll be £41.44 in total and with a $:£ exchange rate of 1:2.05 that means it costs us $84.96 here in the UK

(there's a phrase used locally "Rip Off Britain" meaning "why the heck are things so much more expensive here than in other countries"!!)
stu_san - Dec 12, 2007 - 05:29 PM
Post subject: Re: RE: Re: RE: Re: RE: Re: RE: some newbie questions.....
Cliff wrote:
there's a phrase used locally "Rip Off Britain" meaning "why the heck are things so much more expensive here than in other countries"!!
Because the rest of the world loves to watch your "stiff upper lip" routine. Twisted Evil 17.5% VAT? EEeewww! Shocked

And to the OP: Since robotics will depends so much on real-time control, I recommend dedicating some pins to LEDs or other debug functions so you get some clue about what's going on. Another option is to include a JTAG port so you can watch the chip on-the-fly, but the only pod that can handle the JTAG on-chip debugging protocol is the AVR JTAG ICE mkII which is pretty expensive for a hobbyist (~$300, sometimes available as part of a bundle for less).

Stu
clawson - Dec 12, 2007 - 05:36 PM
Post subject: RE: Re: RE: Re: RE: Re: RE: Re: RE: some newbie questions...
Yup that's the downside of robots - if you want a "big" processor that you want to JTAG then you ahve a choice of 1 (mega128) if you want to keep things cheap (because of the price of the JTAGICEmkII and the fact that only mega128 can be JTAGd by the old $30-$50 clones).

Maybe you should make your 256K out of a network of eight mega328's or something in which case you can individually debug them with a $50 Dragon (and it'd keep things nice and "modular"!)

Also a mega2560 has 86 I/O pins but eight mega328's have 8*23 = 184 I/O !! Wink
JohanEkdahl - Dec 12, 2007 - 08:47 PM
Post subject: RE: Re: RE: Re: RE: Re: RE: Re: RE: some newbie questions...
Quote:

there's a phrase used locally "Rip Off Britain" meaning "why the heck are things so much more expensive here than in other countries"

Bah! You spoiled brat! Wink

Quote:

17.5% VAT? EEeewww!

Sweden: 25% (Or as they put it in ESC: "Sweden - twenty-five, Suediose vignt-cinq, Schweden fünf-und-zwanzig ...")
clawson - Dec 12, 2007 - 09:39 PM
Post subject: RE: Re: RE: Re: RE: Re: RE: Re: RE: some newbie questions...
Johan,

This is turning into something like Monty Python's "Four Yorkshiremen"!

"You think YOUR economy is bad?...."
stu_san - Dec 13, 2007 - 04:20 PM
Post subject: Re: RE: Re: RE: Re: RE: Re: RE: Re: RE: some newbie question
Cliff wrote:
Maybe you should make your 256K out of a network of eight mega328's or something in which case you can individually debug them with a $50 Dragon (and it'd keep things nice and "modular"!)

Also a mega2560 has 86 I/O pins but eight mega328's have 8*23 = 184 I/O !! Wink
I personally think this is the right approach -- I've been intrigued with the idea of small, local processors for robotics (a la the MITS "bug" robots) as opposed to the single central monolith control-the-universe processor. In fact, I would go with the absolute smallest processor I could get and sprinkle them liberally throughout the design (ATtiny, anyone?).

Besides, they'd be easy to program, easy to debug.

Emergent behavior - that's the ticket! Very Happy

Stu
clawson - Dec 13, 2007 - 04:34 PM
Post subject: Re: RE: Re: RE: Re: RE: Re: RE: Re: RE: some newbie question
stu_san wrote:
Besides, they'd be easy to program, easy to debug.

They wouldn't if they were (OCD less) Tiny's Wink

But an army of mega48's working in unison could be fun.
All times are GMT + 1 Hour
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits