Differences in software

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
terranjerry
 
Posts: 38
Joined: Tue Feb 11, 2014 1:39 pm

Differences in software

Post by terranjerry »

I apologize for what might turn out to be a truly ignorant question but what is the difference between the type of software being used in the Monochron clock and the "sketches" used with Arduino?

Is it really just a difference in the supporting libraries used or are we talking about the use of the real C language in the Monochron and a unique (C-like but not C) language being used in the sketches?

I am just trying to understand the differences in the two development environments.

Thanks in advance for taking time to reply.
Jerry

User avatar
jarchie
 
Posts: 615
Joined: Sun Jun 24, 2012 2:16 pm

Re: Differences in software

Post by jarchie »

TerranJerry wrote:I apologize for what might turn out to be a truly ignorant question but what is the difference between the type of software being used in the Monochron clock and the "sketches" used with Arduino?
I've never used or programmed the Monochron clock, but since no one else has replied, I glanced at the Adafruit monochron docs and think I can answer your question.

The C language was designed for systems where program memory and data are both stored and accessed in RAM (like in any standard computer). Sure, data is also stored on the hard drive and other locations, but programs just have the operating system copy data to RAM, and those programs access the data in RAM. But chips like the ATmega328p (used in the Monochron) have a different architecture called AVR: the program code is stored in FLASH, working data in SRAM, and semipermanent data in EEPROM... and there's also no operating system. So to support the AVR architecture, the C language needed some nonstandard extensions. Most open hardware people seem to use the open-source GCC compiler for AVR, which has it's own extensions for handling AVR memories. The Monochron code seems to be written in that language which I call "AVR GCC C"--it's just standard C with extensions to support the different kinds of memory in AVR.

Arduino sketches are also programmed in AVR GCC C (***), but the Arduino IDE automatically adds stuff to your code before compiling: your code gets an "#include "Arduino.h"" at the top, and it's linked to the Arduino library and other libraries as needed depending on what header files you "#include." A full description of what happens is provided on the Arudino site. Unfortunately, limitations in the Arduino IDE make it unsuitable for sophisticated programs which need to be broken across multiple files for good design. The Monochron code seems sophisticated, and it seems to be programmed in raw AVR GCC C.

(***) NOTE: I was mistaken here, as Bill correctly notes in the following reply: Arduino code is programmed in AVR GCC C++, not AVR GCC C. The Arduino IDE does compile sketches with avr-gcc, but that program compiles both AVR GCC C and C++. So Arduino sketches are essentially written in C but with the standard C++ extensions to support classes in addition to nonstandard GCC extensions to support AVR memories. Apologies for the error!

The Monochron does seem to have one strange twist: an Arduino bootloader. Usually AVR chips are programmed through the standard mechanism: ISP (In System Programming; Google for more details). The Arduino bootloader is a tiny subprogram that allows you to program the nonbootloader FLASH through a serial interface, eliminating the need to buy or build an ISP programmer. The end result seems to be that you program the Monochron through the command line using an Adafruit FTDI Friend (USB-to-serial adapter) instead of an Adafruit USBtinyISP (USB-to-ISP adapter).

And now I'm going to go out on a limb and speculate: My guess is that the Monochron design was intended to be Arduino compatible, as it uses an Arduino bootloader to upload new program code. But anyone trying to write a program sophisticated enough to drive the Monochron will quickly realize that the Arduino IDE is not up to such a job. The only option left is to write the firmware in AVR GCC C, and if the hardware is designed for software uploads with the Arduino bootloader, then well... you just use an Arduino bootloader for the program written in AVR GCC C!
Last edited by jarchie on Tue Mar 04, 2014 5:18 pm, edited 1 time in total.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Differences in software

Post by adafruit_support_bill »

Mostly concur with what jarchie says here. But the Arduino language is actually based on C++ - although most of the object-oriented capabilities of that language are not commonly seen in most Arduino programming. The IDE tries to help out by hiding some of the more tedious aspects of the language from you, but in the process also makes it harder to take advantage of some of the more useful features too. Using AVR GCC directly gives you more control over how your code is organized and makes it easier to build and maintain more complex systems.

User avatar
jarchie
 
Posts: 615
Joined: Sun Jun 24, 2012 2:16 pm

Re: Differences in software

Post by jarchie »

adafruit_support_bill wrote:Mostly concur with what jarchie says here. But the Arduino language is actually based on C++
My goodness... what an obvious blunder on my part... Thank you so much for the catch! I'll add a note to that section of my first reply to avoid misleading people.

User avatar
terranjerry
 
Posts: 38
Joined: Tue Feb 11, 2014 1:39 pm

Re: Differences in software

Post by terranjerry »

Wow! Thanks jarchie for an "excellent" write-up describing the considerable differences in the two environments. I really appreciate that. You have given me many things upon which to study so I will be looking into this further. Thank you too Bill for your contribution to the discussion. I very much appreciate your kind responses.

I was able to get the Monochron development environment set up on my PC using Eclipse and compiling and downloading from the Eclipse IDE so that is my preferred development environment but I have also used the Arduino sketch IDE environment as well and it is ok but suffers from the short comings you both mentioned. However, it's a great entry level IDE for most beginning programmers. I just find the Eclipse IDE and methods for coding used in the Monochron are my preferred approach for many of the reasons you cited.

You have added to my knowledge especially as regards the differences in downloading the new firmware and that is very helpful to me.

Thanks again for this excellent dissertation regarding the differences in the platforms. I plan to save this away with my developer notes.

Kind regards to you both!
Jerry

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”