[DIYbio] Re: Arduino vs raw chips

Arduino runs on Processing derived from work at the MIT Media Lab which runs on Java:

""ARDUINO 1.6.1 The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. It runs on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing and other open-source software.  This software can be used with any Arduino board.""
 

"But wait that's not what I meant, I meant the code in the chip", you're saying.  Well in fact, Arduino runs on 'Arduino language':


""The whole purpose of the Arduino language is that it is C with abstractions to make it nice and easy to program. You don't need to learn C++ at all."""


Now you are relieved because you don't really know C++ anyway, you only need to know libraries.   Arduino runs on Libraries and Arduino runs on Boards like the Arduino 0004:


""Libraries are files written in C or C++ (.c, .cpp) which provide your sketches with extra functionality (e.g. the ability to control an LED matrix, or read an encoder, etc.). They were introduced in Arduino 0004. "" 


Which is great because Arduino runs on GNU command line tools and on GCC or it could be said Arduino runs on AVR-tools:


""Sun Java SDK, avr-gcc, avr-g++, avr-libc, make, ant, and git.""



"But I don't want to learn C or C++ it's too hard!   I thought Arduino didn't require learning to write code! It's sposed to be easy!", you complain.   That's OK because Arduino runs on Wiring:

""The Arduino programming language is an implementation of Wiring, a similar physical computing platform, which is based on the Processing multimedia programming environment.   Wiring allows writing cross-platform software to control devices attached to a wide range of microcontroller boards to create all kinds of creative coding, interactive objects, spaces or physical experiences.    ""
 

Now you may be confused if you thought Arduino only runs on Windows, Mac, and Linux.  It does, and it runs on 'AVR language' too:


""The Arduino environment is based on Atmel Atmega microcontrollers. The AVR language is a "C" environment for programming Atmel chips. Much of the Arduino language is written with AVR constants and functions and there are many things that are still not easy to accomplish with the Arduino language without using some AVR code. """

 


Does this reveal some of the nomenclature problems with discussing Arduino?


The name is simultaneously,
 a development/debug application running on your computer,
 a board footprint with specific header placement for add-on boards,
 a set of kit boards,
 a set of chips for the compatible software,
 a set of libraries for running firmware,
 a language on top of Java,
 a language on top of C++,
 a language mixed in with C,
 a GNU compiler toolchain,
 a completed device running firmware,
 a binary file.

And to clear another misnomer, Arduino does not have USB [typically; exceptions exist].  Arduino has serial, and a bundled external serial converter chip in order to talk to a computer and use power via a USB plug.

 

Re: to correct Nathan's point :
""Again, no one needs an 8MHz computer to blink christmas lights or even
control thermocycling. If anyone used something faster, it might be
just as open to scrutiny.""

Invert the CPU clock speed to get instructions per second.  That is the underlying limitation on any timing (with some fiddling).    Note PIC is the champ at this because each instruction is 1 clock cycle so timing is easy [branches take 2].   AVR is variable timing so is more difficult to calculate [stack layers plus several multiple cycle instructions.  C++ timing also depends on libraries used.]   This is very important for example if you are controlling a stepper motor or a servo motor and want precise 2.5 microsecond timing per pulse for example [other reasons may prohibit PWM peripheral].  "Oh but the 3D printer guys do just fine on Arduino!" ..really?  Or are they using external motor control chips.. or taking special precautions.. or ..

Don't fall into the typical trap of saying: "Yeah x Mhz is fast enough for anyone because the programs are small anyway."   Wrong conclusion.  Microcontrollers often use timing loops which need fine precision.  Interrupts may add funky overheads into this.  How many variables is GCC allocating in there to push for the subroutine later which takes different timing each time the software is compiled?   "But I'm using 16 Mhz so that's in the nanoseconds anyway!"  Well, is that really OK?  Or is it not..

If you are measuring temperature even slowly, you want to do it precisely.  If you set up a delay loop to measure it every 1 second over the course of 4 weeks, you might think you'll get a total number of measurements like 4 * 7 * 24 hrs * 3600 sec [assuming my math is right].  But you won't.  Because the Arduino is likely slipping time due to poor precision, a measurement is triggered every 1 sec + delta sec.   Only if your measurement timing is 1.0000000 seconds [sub-microsecond resolution] might you get the total number of measurements you would expect.  This is a very basic example but you can imagine how it would extrapolate into a much larger error in a different case.    [OK I realize a hardware timer would remedy this simple example but I am making the larger point, suppose the hardware timer is not available for use.  And I realize the crystal will drift but that will have a bell curve due to temp or tolerance, vs constant slippage due to poor software design.   And other things..]

This is not a trivial detail to brush off even though x microsecond may seem like a trival error.  I dont want this to be taken too far out of context either  Timing must be consistent to some number of sig figs to get what you want.  Libraries are always suspect until proven golden, who knows what is happening inside there.   "Oh, I'll just use this open source PID library that I got off the internet, it will work fine."   Yea...  maybe, or maybe not.   Just blinking xmas lights?  Maybe no one cares about precision.  Thermocycler?  It's important to calculate the error - I would.  And this might be in a published biotech experiment?  Scary.    "8 Mhz is fast enough!" ...  Well is it....


Re: Nathan's "What's your point? Seriously."


Do a proper requirements analysis and design phase, aka, "do some critical thinking homework [means more than a 10 second google search to pick the first answer shown]".   Even new comers to electronics can surpass Arduino within 4 months after building a few "hello world"'s.  There is no one size fits all with embedded chips because embedded typically means integrated peripherals, which is application specific, which is why there are many vendors, but there are likely a top two or three possible choices that come out quickly from all others, and Arduino is perhaps not one of them in terms of the hacker ideal.  Look to convergence with next year's technology not the past decade ("murder your darlings").  Attempt to learn from professional examples rather than script kiddies on the Internet or from projects aimed at new students.  All of these sentences contain some element of "Cost".  Do project estimates and don't jump to arbitrary conclusions regarding what takes "too much effort to learn" and what doesn't because it is not readily apparent especially when doing something new, which parts are most ripe to beautify.    Read professional datasheets and application notes to avoid reinventing the wheel - Again.



## Jonathan Cline
## jcline@ieee.org
## Mobile: +1-805-617-0223
########################

--
-- You received this message because you are subscribed to the Google Groups DIYbio group. To post to this group, send email to diybio@googlegroups.com. To unsubscribe from this group, send email to diybio+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/diybio?hl=en
Learn more at www.diybio.org
---
You received this message because you are subscribed to the Google Groups "DIYbio" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diybio+unsubscribe@googlegroups.com.
To post to this group, send email to diybio@googlegroups.com.
Visit this group at http://groups.google.com/group/diybio.
To view this discussion on the web visit https://groups.google.com/d/msgid/diybio/2e6c545f-30d5-4780-9160-b7543790022c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comments:

Post a Comment