Pages: [1]   Go Down
Author Topic: Why people like Arduino  (Read 1633 times)
0 Members and 1 Guest are viewing this topic.
nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8475
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I was just browsing a thread over at AVR Freaks and noticed this code snippet that sets up a UART

Code:

    //Set baud rate
   UBRR0H = (unsigned char)( UBRRVAL>>8 );   //high byte
   UBRR0L = (unsigned char) UBRRVAL;         //low byte

   //Asynchronous normal speed
   UCSR0A = (0<<U2X0);

   //Enable Transmitter and Receiver and Interrupt on receive complete
   UCSR0B = (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0);

   //page 186 Set asynchronous mode,no parity, 1 stop bit, 8 bit size
   UCSR0C= (0<<UMSEL00)| (0<<UMSEL01)|          //Async
         (0<<UPM00)|(0<<UPM01)|               //Parity None
         (0<<USBS0) |                     //Stop bits 1
         (0<<UCSZ02)|(1<<UCSZ01)|(1<<UCSZ00);   //8 Bits

   //enable interrupts
   sei();
   }

Now this isn't as scary as it first looks and anyone used to working with embedded AVRs will feel quite at home with this code. But here's the Arduino equivalent

Code:
Serial.begin(BAUDRATE);

Ummm...is it any wonder that people who just want to make an interactive coffee table or even those more serious about getting into embedded processors are attracted to Arduino?

______
Rob


Logged

Rob Gray aka the GRAYnomad www.robgray.com

Hamburg, Germany
Offline Offline
Sr. Member
****
Karma: 6
Posts: 291
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

May the flame Wars.begin() smiley-wink

markbee
Logged


Manchester (England England)
Online Online
Brattain Member
*****
Karma: 604
Posts: 33421
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The arduino hides a lot of the detail you have to go through and lets you concentrate on the ideas you implement. That's why I like it, I've done all that lot years ago and it makes progress slow. I have even done in hex in the days before you could get assemblers let alone C compilers. That is writing down the mnemonic for each instruction and looking up the hex bits that implement it.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8475
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
May the flame Wars.begin()
Not my intention and I hope it doesn't degrade to that.

I'm fairly well versed on both sides of the fence and am well aware of the pros and cons of either side. It's just that for some reason the above example drove home to me the difference as I think a newbie would see it. In fact it's probably even worse because just getting to the stage where you are writing the first example can be a struggle whereas I suspect most people who get an Arduino will be at the second example in no time (albeit without the constant for the baud rate smiley)

And then, as Mike says, there are experienced people who just want to get a simple project up and running.

______
Rob
« Last Edit: July 28, 2011, 06:10:32 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Hamburg, Germany
Offline Offline
Sr. Member
****
Karma: 6
Posts: 291
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The good thing with Arduino is, that you may become interested to dig deeper into the structure and behaviour of microcontrollers after doing some projects that work quick and easy.
You may begin to write libraries, shift some bits or anything that is one or two layers below the "Arduino-Easy-Layer." I think that is one often overloked "feature" of Arduino beside getting quick and easy a project running. And if you are not interested - so what. Don't block creativity by forcing people to learn everything from scratch.
I like to compare it to a car: you have to know how to drive it, but do you really have to know how the mechanics/ electronics work?
I personally began with 8051 and I would have been more than happy having Arduinos at that time.

markbee
 
Logged


0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
And then, as Mike says, there are experienced people who just want to get a simple project up and running.
I tell people I know how to do all that, I'm just lazy and don't want to. smiley
Logged

Netherlands
Offline Offline
God Member
*****
Karma: 7
Posts: 642
A naughty mind is a joy forever.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's a reason for liking and... disliking at the same time IMHO.

Still knowing very little about C-languages it's nice to write just a few lines and
get a project working. The choice between Serial.begin(Baudrate) and writing 20 lines
to accomplish the same is easy to make.

Looking at others peoples software for arduino I do encounter loads of commands/functions
poorly/not explained in arduinos reference though. Since there's not much explanation it's hard
to know what is possible and what's better.

Every now&then I also see people responding "What you basically need is this or that
(unexplained) function" to a question. Although I love the relative simplicity of Arduino, while coding that sometimes makes me wonder whether a single "unexplained" function may have done it better as... writing 20 lines of code as well.
Logged

Boston Suburbs
Offline Offline
God Member
*****
Karma: 16
Posts: 955
I am above your silly so-called "Laws", Mister Ohm.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I liken it in some ways to VB (Visual Basic).  You sacrifice some raw power to get some refined power.  Arduino is better however, in that you can still inline code in lower languages like C and Assembler, which you can't in things like VB and PERL.  In my opinion, at any given time a project should be done in as HIGH level a language as possible, resorting to lower level coding ONLY where necessary.  Reinventing the wheel fifty times a week isn't to be applauded.. especially if nothing but wheels ever gets invented!

You can rely on it being an inefficient platform- resources wasted right and left; much of the horsepower is sacrificed or hidden from your use; the majority of the language is just macros, with a search and replace engine as the "compiler".

You'll start a Barbeque if you mention it's useful, all of a sudden you are surrounded by nothing but weenies and flamers.  My response to flamers and weenies is that unless you're making your own gates with a Bic lighter and a bucket of sand, whatever language you are programming in is no different or any "better" than any other, including VB/Arduino/TCL/What have you.. in fact, since this is the case, a very reasonable argument can be made that those mired in low-level coding are more of an impediment than a benefit.  It's ALL just variations of the search-and-replace theme.  

I don't discuss it often, as I really don't like "hating" on anybody- but understand how hostile the weenies can be.. I've been BBS'ing since the early 80's, and in thirty years I've been censored on two sites.  One of those was AVRFreaks.. because I asked if there was value in learning this "Arduino" platform over WinAVR and the uberweenies decided to flame the "new guy" for not knowing any better.  It went downhill from there.  Even more disturbing were the chain of posts and unsolicited personal emails to my private email address, full of profanity from one of the ADMINS.  AVR Freaks is what's WRONG with microcontroller and hobby development, no matter what the hardware is.. it's got nothing to do with AVR's, it just about the Freaks. That kind of attitude isn't found here, despite it being the same hardware.. and even many of the same people.  Happily, there's little actual content at AVRfreaks that isn't mirrored someplace else these days, and it seems they are going offline for days at a time randomly now.. guess it just toxified itself to death.. If I would have had no other resource for a forum for AVR development, I would have walked away from the entire hobby (and possibly electronics in general) based upon the general level of Weenie Roast there.  Hostility towards newcomers and those without a lot of experience doesn't fly here, happily.  It's not the hardware, it's not the language, the IDE or the compiler.  It's the people here.  Pat yourselves on the back guys, there's nothing quite like Arduino.

Arduino, like Visual Basic (and other thing like it, such as PYTHON and PERL, TCL, etc) is however indespensible when it comes to making a fast prototype or if you need to cobble together a quick "one off" tool to get a job done.  I can't tell you how many times during my working years I used VB as a front end for heavy lifting, and when it comes to building a simple database front end, I've never seen a tool that even came close.  Hate on it all you want, in the real world, VB is one of the most useful and used tools on the market.  In much the same way, Arduino makes it possible to quickly prototype with a modicum of experience, even if it's not the most efficient or "nerdy".

Arduino "wrappers" away much of the painful coding that would send most hobbyists looking for another hobby before they got their first projects running.  A working project... I dare >> any << language zealot to find fault with a working design, no matter how it was done.  Any whining you hear in the wings if your project works is just that- whining from people who couldn't actually DO the design, just complain...

I do think that maybe the Arduino compiler ought to make the compile stages more "accessible" or obvious to the user, to encourage them to "look under the hood".  It's there and generated, but maybe when you compile in the IDE, it should pop a tab open with what the program compiles to in ANSI C.  Assembler is just to dang painful to be useful in most cases.  Stopping at C makes sense in the same way as having a carpenter stop being an expert at the lumber level, he doesn't need to know how to grow a tree to build a doorframe.

« Last Edit: July 29, 2011, 10:28:38 am by focalist » Logged

When the testing is complete there will be... cake.

UK
Offline Offline
God Member
*****
Karma: 13
Posts: 903
Twitter: @simonmonk2
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

For the most part, the Arduino framework is a 'good interface'.

It provides services to use on the basis of 'how would I like to tell my board to do something' rather than irrelevant implementation incantations.

Good programmers want to make life easy for themselves. Really good programmers want to make things easy for others.
Logged

--
My New Arduino Book: http://www.arduinobook.com

Austin, TX
Online Online
Faraday Member
**
Karma: 71
Posts: 6141
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Serial.begin, digitalread(), digitalwrite(), and analogread() are the reasons I love Arduino.

Building a complete environment for the 8051 (15+ years ago) was fun, at the time, but not practical today.  Arduino reminded me of the fun of electronics.  Got an idea?  Twiddle some bits and go. 
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    //Set baud rate
   UBRR0H = (unsigned char)( UBRRVAL>>8 );   //high byte
   UBRR0L = (unsigned char) UBRRVAL;         //low byte

   //Asynchronous normal speed
   UCSR0A = (0<<U2X0);

   //Enable Transmitter and Receiver and Interrupt on receive complete
   UCSR0B = (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0);

   //page 186 Set asynchronous mode,no parity, 1 stop bit, 8 bit size
   UCSR0C= (0<<UMSEL00)| (0<<UMSEL01)|          //Async
         (0<<UPM00)|(0<<UPM01)|               //Parity None
         (0<<USBS0) |                     //Stop bits 1
         (0<<UCSZ02)|(1<<UCSZ01)|(1<<UCSZ00);   //8 Bits

   //enable interrupts
   sei();
   }

I wished that Serial.begin(baudrate) was overloaded with  Serial.begin(baudrate, parity, databits, stopbits);

so I could state Serial.begin(5438,E,7,2); or something weird smiley-wink

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 604
Posts: 33421
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I wished that Serial.begin(baudrate) was overloaded with ..............
The point is that it is not.

But even better the point is that if you need to do something weird then there is nothing stopping you from using the long code you posted.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6653
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, there was a thread on avrfreaks recently about Atmel's "Software Framework", and the differences between:
Code:
   gpio_clr_gpio_pin(LED0_GPIO);
and
Code:
   ioport_set_pin_low(LED0_GPIO);
Those are pretty ... unfriendly ... names compared to "digitalWrite(LED0, 0)"
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=110091&start=0&postdays=0&postorder=asc&highlight=framework
Logged

Pages: [1]   Go Up
Jump to: