Pen-Plotter Firmware Written Completely in Ada

[Fabian Chouteau] built a plotter out of CD-ROM parts. Yawn, you say? Besides being a beautiful physical build, this one has a twist. He wrote the software and firmware for the entire project himself, in Ada.

Ada is currently number two on our list of oddball programming languages that should be useful for embedded programming. It’s vaguely Pascal-y, but with some modern object-oriented twists. It was developed for safety-critical, real-time embedded systems (by the US Department of Defense), and is used in things like airplanes, rockets, and the French TGV trains. If that sounds like overkill for your projects, [Fabian]’s project shows that it’s still very tractable.

In his GitHub, he re-implements the GRBL G-code generator and then writes a GUI front-end for it. In his writeup, he mentions that the firmware and its simulator for the front-end use exactly the same code which is quite a nice trick, and guarantees no (firmware) surprises when moving from the modelled device to the real thing.

We looked quickly around for Ada resources and came up with: GNAT, the GNU Ada compiler, and its derivatives: GNAT for ARM (STM32-flavor), ARM-Ada (LPC21xx flavor), AVR-Ada, and MSP430-Ada.

Any of you out there use Ada in embedded work? We’d love to hear your thoughts.

43 thoughts on “Pen-Plotter Firmware Written Completely in Ada

      1. Why did you even have to go there? Have you ever tried to read a line of APL code out loud? Also, only language in the world that uses overstrikes in its keywords!

        One thing you can say for APL: it is equally understandable to all people regardless of their native (human) language.

    1. Erlang? Rust? You’re going the wrong way in time! (Though Erlang is actually #3.)

      Forth. I’m working through it on the STM32 / Mecrisp-Stellaris setup, and it’s very very fun, but very very weird. It does a bunch of hardware-near stuff in a very transparent way that I like, but it gives you a runtime to try stuff out live. The reverse-Polish programming style is a brain-expander, but I’m actually interested in seeing if it can be made useful. At the moment, things crash more often than I’d like.

      APL. Oh my.

      1. There is no such language as “ADA”. As my instructor in an Ada class told me, “Ada is named after Lady Lovelace, daughter of Lord Byron; ADA is the American Dental Association.”

        That’s right, my instructor in an Ada class, in college. I was one of the few who went through University of Washington’s engineering program during the one year (1994) when they decided that it was Ada rather than C that all engineers should know. Never saw it again after that. Apparently most of the electronics industry did not concur.

        But what the heck – as long as the GNU compiler is going to give you so many choices, write in whatever language suits you.

  1. Noooooo! Sorry. PTSD from exposure to ADA in about 1990 in DoD stuff at Boeing. Don’t scare me like that.

    If you want to contribute to work in science, imaging, massive networking research, AI, simulations, big data and data mining, physics, etc etc, Python3.5 paves the road to opportunity.

      1. I have been using MicroPython on Cortex M4 and Python with PyQt on embedded Linux almost exclusively. If you have been using Python as if it were C or BASIC, you are doing it wrong. MicroPython is 3.5 and runs on nearly everything now. You can embed assembly code if needed. No OS required or use under OS of your choice.

        1. Yes I was refering to MicroPython, and I do perceive it to be useless. If you have to embed assembly in Python of all things… that’s useless because I’m better office with C at that point due to it being faster and providing a more capable assembly abstraction.

          1. “more capable assembly abstraction”. I don’t know what that means. We used to embed assembly in Forth and we embedded assembly in Open-Boot at SUN and Apple (Forth, and Openboot, which is a version of Forth, have their own assemblers as does MicroPython. It is hardly something to turn up the nose at. We will have to see if MicroPython turns out to be useless. A bare metal Python3.5 on a 160MHz 32 bit ARM like a Discovery board I think will be pretty capable but so far, that is just an opinion. I have not done anything especially ambitious yet.

          2. I’m not turning up my nose per say… I just think you’ll have to do less optimization of it in C/C++ partly because it’s faster and partly because runtime overhead is stealing less from you. Writing your application in python and then rewriting hotspots in assembly or C is certainly not as good as just writing it in C to begin with IMO.

            I will say this… writing a menu or even driven code in python might be a great idea. But once you’ve done that and get into the nitty gritty… you may end up writing the part that needs to be fast if there is such a part in some other language. And yet you are still paying for the overhead of python even though you only really use it for something trivial.

        2. The experience of programmaing Ada is painful and masochistic, to the point where we used to affectionately call the compiler “Mistress”, given the intense beat downs it’s deliver over poor code. That level of insistent pedantry is great for critical systems.

          It’s pretty much the polar opposite to Python’s laissez faire approach, though, which is why I don’t think it’s a suitable substitute.

          (Love for Python seems common with scientists. I’ve always put t down to LINPACK Stockholm syndrome.)

  2. Ada is great for embedded work I find. Thank you Fabien for the great and helpful work you are doing with these projects! Also it should be noted that libre.adacore.com just released gnat2016. I like to use Ada for the TI Hercules series (RM57) (I did a hackaday.io proj on that). Nothing like a challenge and getting Ada going on it, it was fun!. Struggling a bit with gnat2016 on it as I am forced to build ARM code vs Thumb2 as multilib is now config’d to allow armv7-r + fpu (be or le) but not thumb (which is what I use).

  3. With all the excitement over 3D printing, let us not forget our first annoyance – 2D printing. It is costly and absurdly annoying. I’m all for squirting out plastic blobs into jagged action figures but PLEASE solve affordable 2D printing.

    1. I HATE my printer(2D). Getting a laser printer next time, I hope it’s the right choice!

      You must be sick of overpriced ink that needs to be used within 2 months or it dries out, right? ;)

      1. I was going to say something clever about using an FDM 3D printer to print single layers on paper, but then realized that this is almost exactly what the old Tektronix solid ink Phaser printers did! They did this in full color, by the way, and now that I think about it, had damn good resolution. Hmmm. Maybe one of these could be adapted to do 3D???

      2. For what is worth, the ink does not dries, just the nozzles get clogged with dry ink.
        If you put a little medical alcohol, the nozzles will work again.
        In my case the nozzles became clogged again very soon, so I put the cartridge on boiling water for 5 minutes.
        The cartridge is now working properly.

        I’m sure you can look up more information on the internet.

        1. Will try that out, thanks!

          My biggest problem is the warnings for low ink.
          I run out of yellow one time printing photos and it gave me a warning, as it should. But when I started printing black text the warnings continue, even afrer forcing ‘grayscale only’ in the settings.

          Smoke detectors have a ‘silence’ button.
          My printer should too!

  4. ADA? Ah, yes, I remember a few decades ago the Pentagon deemed it to be a new standard.

    To quote the Washington Post of July 17, 1988:
    Ada. It is not an acronym. It honours the 19th Century mathematician Lady Augusta Ada Byron, daughter of the poet Lord Byron. She collaborated with inventor Charles Babbage on a precursor of the mechanical calculator and is affectionately known in industry annals as the first programmer.

    The whole article is fascinating history. .

    Wikipedia also has an interesting entry .

  5. For anyone considering Ada for embedded systems – make the most of it and at least google up Spark and Ravenscar.

    (we use Ada at my dayjob – naval combat systems)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.