As an aside, for the C/C++ purists amongst us, my understanding is that when we initiate a compilation, the IDE slips in a "main" function while we aren't looking.
Are you saying that the first step is to interpret the code into C and then compile it? Unless that step is very well handled, I can imagine the C compiler rejecting something and providing a cryptic reponse which would floor the beginners.
@Antedeluvian: Are you saying that the first step is to interpret the code into C and then compile it? Unless that step is very well handled, I can imagine the C compiler rejecting something and providing a cryptic reponse which would floor the beginners.
No, the code you write is essentially C/C++.I'm sure I didn't explain this very well. Let me take another stab at it. A regular C/C++ program contains one or more functions. One of these functions has to be called "main", e.g.:
// your statements go here
When you run your program, the operating system essentially hands control over to the "main" function in your program. The OS may also pass parameters into the "main" function. You can add a bunch of other functions in your program and these could be called from "main" (or one or more of them could be called from "main" and these could call the others).
When you are in the Arduino IDE, your programs (called "sketches") do not have a "main" function -- but they must have a "setup" function and a "loop" function as follows:
// Your statements go here
// Your statements go here
The Arduino documentation explains that the "setup" function (well, I think they say "the statements in the setup function") is executed one time, after which the "loop" function (the statements in the loop function") is executed over and over again.
Once again, you can add as many of your own functions as you wish. You can call your own functions from the "setup" function and/or the "loop" function; also some of your own functions can call others of your own functions, just like regular C/C++.
When I say that my understanding is that the Arduino IDE "slips in a 'main' function while we aren't looking," I think that what it does is take your sketch and use it to generate a temporary file that looks something like the following:
boolean keepDoingIt = true;
setup(); // Call "setup" function one time
while (keepDoingIt == true)
loop(); // Call "loop" function repeatedly
// This is your "setup" function
// This is your "loop" function
So the IDE doesn't interpret your code into C/C++; your code is C/C++. The temporary file (including the under-the-hood "main" function) is just handed over to a regular C/C++ compiler. Any error messages you receive are no more crypric than they usually are from a compiler :-)
Actually, the "main" function is defined among the other files in the hardware specific directory of the arduino ide installation. I just discovered this myself fairly recently while reading a book on programmin the arduino as an AVR platform.
since the Loop() function runs continously, that makes it a bit similar to programming in Structured Text on a PLC (programmable logic controller) -- the PLC code is run as a continuous loop, whether you're using ladder logic (ugh!) or structured text (better). The syntax is very different, however (ST is kinda BASIC/Pascal hybrid with PLC oddities).
AD - I can confirm that some of the error messages are rather cryptic. I've had a few that don't seem to give any actual information relative to what the error ended up being. That's kind of frustrating.
I've developed (in my head) a standard checklist of sorts to look at first when there's an unclear error message.
I agree -- having the Blink program pre-loaded is a great idea -- and even if it's not loaded, the fact that they provide a copy with the IDE and you can download it yourself over the USB cable really does make it easy to get up and running.
The impressive thing to me is how easy it is to get started in comparison to other standard IDEs. I just downloaded the update, placed it in my applications folder, fired it up and ran blink all in about 60sec. Try and do that with any other IDE and it takes at least 2 orders of magniture longer (if all goes perfect!).
Now the other IDEs do have lots more features, but getting that first design up and running is critical to grabbing my interest. There should be the 'simple' mode that the IDEs come up in to start and as you learn the esy tools other come 'online'. Now an expert can override this and just go to the full set, but the new users would be so much more comfortable.
The conclusion I come to is that most IDE manufacturers aren't really looking for new users...
@DrFPGA: The impressive thing to me is how easy it is to get started in comparison to other standard IDEs.
Ease of getting started is reflected both in the IDE and the hardware -- the fact that the Blink program is pre-loaded means that as soon as you connect your Arduino to your host computer via the USB cable, the USB powers the board and a LED on the board starts blibking to show you that all is well -- and this is before you've even downloaded the IDE...
@Max- Most simple eval board come with a preoaded demo- usually more complicated than Blink, but you can plug them into USB and have them do a demo. TI eval board for example can come up with the LCD screen showing the TI logo and a few user selectable routines ready to go (I like the one where you tilt the board and the cursor on the LCD screen slowly 'rolls' around.
But what these eval systems can't do is allow you to download the example code (from the IDE!), compile it and run it on the board all in 60 seconds. I'd love to see a comparison as to how long it takes for EACH vendors IDE to do that! Kind of like the fat content posted on a breakfast bar...
@Max- If we could get several volunteers to each try out one MCU/IDE combination I would be happy to compile all the info.
Start the timer.
Download the IDE used with a simple MCU eval board.
Download the code for Blink (or hello world, etc)
Compile and load the code into the board
Watch it work.
Report board, IDE and Time Required. (And any 'bumps' encountered, like license not working, need to update code, example design out of date, USB driver not installed correctly for your version of Windows, etc)
Let's find some takers. Anyone want to pick a particular board/IDE to start?
blinking and hello world are no problems. THey usually have that code ready to go with the board. However, where I find the most benefit to the Arduino community is that there are THOUSANDS of tutorials for things beyond that.
But what these eval systems can't do is allow you to download the example code (from the IDE!), compile it and run it on the board all in 60 seconds.
Without trying to cast aspersions on the Arduino, or any other evaluation- my experience with Android has caused me to be a little cautious of canned solutions that quickly show you your system is working. Android has a bulit in "hello world" and you can have it running in 10 seconds once you have installed the environment. But the next step of creating your own program is not a simple incremental progression.
You are correct that it is never as easy as it seems to get to your own design, and Arduino isn;t really built to create complex designs as we typically need for a production ready syste, BUT it is a great way to get a few simple projects 'under your belt' so moving to the next stage isn't as daunting...
For example, I wanted to do a simple project to play a short segemnt of a popular movie theme (Star Wars) when a timer expired. I was able to use an existing example design to quickly prototype it in about an hour (most of the time was spent downloading the sheet music and transcribing (with much trial and error) into the note data the program needed). Easy Peezy!
At least thats been my experience. If I was trying to build a remote controller robot from scratch with Arduino I might not be so positive about the experience...
AD - I have few negative things to say about the Arduino when used for it's intended purposes. The biggest issue I ran into originally was the limited amount of RAM and program storage FLASH available.
I was able to set up a wired Arduino web server amazingly quickly. However, when I tried to make it wireless, I ran out of space.
I got my Arduino working with a Ti CC3000 WiFi breakout board, but when I tried to add in a small OLED, I ran out of RAM.
Since that time, I've discovered 32 bit Arduino compatible boards. The ChipKIT PIC32-based Arduino I have has plenty of both RAM and FLASH. It's pretty compatible, but not quite 100%, so I've run into a few issues there.
Alex - Yes, the Due is 32 bit. There are more and more 32 bit Arduino compatibles popping up too. My theory is that with the more powerful procesors, the Arduino language will start to fnd acceptance in some commercial applications.
Even if people accept the open license terms of the arduino for some projects, wouldn't it just make sense to learn the mbed, and due to commercial friendly licensing terms , use it it in more projects , and get a better return on learning?
Also, yes there are plenty more content/code around the arduino than the mbed, but if we're talking about professionally usable content/code , how do they really compete ?
Alex - Right now, the Arduino doesn't really compete with the mbed in the comercial world. I think that's changing though. I think that the Arduino will end up as a decent alternative; especially in the cross over from maker to commercial community.
I'm a big fan of the mbed too. It's nice to see it showing up on more platforms as well.
Although I prefer the BeagleBone, I'm getting an Arduino for my nephew, because of the size of the ecosystem & amount of tutorials (he has NO electronics experience). However, instead of getting a kit with discrete parts, I'm buying a Seeeduino plus the Seeeduino Grove shield, some Grove devices, and (I hope I can get them to work at the same time) an Arduino motor shield R3 (which actually has Tinkerkit connectors).
The Grove & Tinkerkit systems are similar: there are standard connectors and then you can get various prewired devices. Devices can communicate via analog input, digital input, digital output, or I2C.
The Grove system is currently cheaper than Tinkerkit & has a wider variety of components, such as analog thumb joystick, button, motor controller, OLEDs, LEDs, current sensors, PIR, WiFi, Bluetooth, and much more. You can also get Grove kits, but I much prefer picking out exactly what I want, for substantially less than a kit (or the kits you showed).
Similar systems include Digilent's Pmods, Olimex's UEXT, mikro elecontrica's mikro bus, and Microsoft's Gadgeteer.
Blog Make a Frequency Plan Tom Burke 17 comments When designing a printed circuit board, you should develop a frequency plan, something that can be easily overlooked. A frequency plan should be one of your first steps ...