Slashdot Mirror


Parallel Programming For the Arduino

blackbearnh writes "As more non-traditional programmers start playing around with embedded platforms like the Arduino, the limitations and complications of interrupt-driven event handling can become an annoying barrier to entry. Now a group of academics have ported the parallel-processing language Occam to the Arduino. In an interview on O'Reilly Answers, Matt Jadud of Allegheny College describes how Occam helps artists using the Arduino in their installations, and how the advent of low-cost computing platforms is changing the educational experience for proto-makers in school. 'Basically, an artist or a tinkerer or a hacker has a goal. They don't really care about learning Occam. They don't care about how this language is different from C. They just want to make a cat door that keeps their cat out when the cat comes back with a mouse. Or they want to make some kind of installation piece. Trying to focus as much on the user and the possible goals they might have is what's motivating our work right now.'"

140 comments

  1. Threads by OopsIDied · · Score: 0, Redundant

    Or instead, people could just implement simple threading and learn something in the process rather than switch to a whole other language just for one problem.

    1. Re:Threads by Monkeedude1212 · · Score: 5, Interesting

      In my limitted experience, threads are one of the more difficult things for... people to understand. I find it difficult to describe their position, which I think Matt Jadud had a tough time too, (See how he said "an artist or a tinkerer or a hacker"). In my situation, I have a friend who is taking an engineering major at the local university. Now, a little background information; I don't know how it is in other cities across the world, but here, Engineering at the university is considered one of the hardest courses. You know, really ridiculously high drop out rates, cause most people can't handle it. Opening orientation, they say look to your left, look to your right. 2 out of the 3 of you won't make it past second year. So anyone who manages to make it through the first 2 years of Engineering gets this perception that they know to do stats as well as a stats major or know how to program as good as a programming major.

      Anyways, so my buddy is in engineering, and he knows enough C++ to essentially do any calculation he wants through the command line. He hasn't had to work with GUI's or anything like that. The most he did was a turn based Star Trek game where the command prompt simply reprints the "game board" everytime you make a move or perform an attack, prompting the player what to do at the end of each turn.

      So he tends to be the kind of user that they target with these kinds of ports. He's already loaded with a bunch of information in some other field. Be it engineering, arts, hacking, radio signals, whatever. They don't have a whole lot of time to run through the tutorials to learn threading and how its supposed to be done properly. There's no telling how long it'll be before they get into an issue with threading and they won't have enough knowledge on how to fix it and it'll be a big headache if they went and built their entire code that revolves around this segfault they created.

      So thats where these other languages come in. They are similar enough to a common language like C that anyone who does a beginner course can pick them up. They offer the features that users WANT without all the complications that come with learning how its done.

      I know, I know, teach a man to fish, right? But what if he only ever needs 1 fish in his entire lifetime?

    2. Re:Threads by AlecC · · Score: 2, Insightful

      Occam was intended as a reply to all the problems that can happen with threading, The ides with Occam is that a lot of the things that can go wrong with threads simply cannot happen in Occam. Think of it as Java to threading's C. Just as you cannot create random pointers in Java, you cannot lock random mutexes in Occam (which doesn't have mutexes),

      Traditional threading really is assembler level coding for parallelism; Occam tries to move to a high level language.

      --
      Consciousness is an illusion caused by an excess of self consciousness.
    3. Re:Threads by Anonymous Coward · · Score: 0

      Seriously? What is the set of people competent enough to know what to do with an Arduino, but not competent enough to know how to use an interrupt? WHERE IS THAT VENN DIAGRAM?

    4. Re:Threads by tibman · · Score: 1

      I don't think you can use the word "simple" with threading on the arduino. I've seen several proto-thread type deals but nothing approaching multi-threading. The problem isn't just making sure you don't have functions that block. Some IO stuff needs to be timed like serial/i2c and you have to be careful about interupts taking too much time.

      --
      http://soylentnews.org/~tibman
    5. Re:Threads by Tetsujin · · Score: 1

      Arduino IS the platform for people who don't know how to use an interrupt. Everyone who knows how stuff works skips the Arduino since it don't really add anything useful.

      I don't know... I mean, I started out with PICs. My wife bought me an Arduino for Christmas last year - I don't know that I ever would have bought one myself, but I've enjoyed it. It's kind of handy having a dev. board, with some good power supply options and a PC interface built-in, and it's kind of handy to be able to pick up "shield" hardware and run pre-made code to try things out...

      Sometimes I feel like it's made me kind of lazy - like I'm coming to rely too much on other people's code and hardware designs... So I try not to overuse it. :)

      --
      Bow-ties are cool.
    6. Re:Threads by kev0153 · · Score: 1

      I fall into the tinkerer category. I just built a robot using an Arduino as the brain. This would have been useful for some of the servo and sensor inputs I was trying to do.

    7. Re:Threads by TheTrueScotsman · · Score: 2, Interesting

      I did Occam in the 80s and server-side Java now. Java is way more powerful for parallel processing and the simplification in Occam (essentially a built-in parallel functional transform aka the 'threaded for loop') can be replicated with a fairly simple Java library that almost any experienced programmer has written for themselves. I literally use one every day. Only newbies are wrestling with Thread.start() and mutex locking. Everybody else has abstracted this long ago.

    8. Re:Threads by Pinky's+Brain · · Score: 2, Insightful

      PAR is not the important part of Occam. The fact that all message passing is synchronous and there is zero aliasing is what is important (it prevents a ton of errors, makes automatic reasoning about the programming much easier too). You can do synchronous message passing in any language, you can try to program aliasing free in any language too ... but few people do. They'd rather create abstractions for mutex locking and then rely on programming convention and programmer infallibility for their correct use.

      Modern Occam isn't 80's Occam by the way, creating complex data structures is much easier and you can pass data by reference for instance (the local reference gets destroyed when passed).

    9. Re:Threads by djd20 · · Score: 1

      See: http://en.wikipedia.org/wiki/JCSP - CSP for Java, why write your own, probably incorrect abstraction when good libraries for this already exist?

    10. Re:Threads by BillX · · Score: 1

      Agreed, Arduino definitely grows on you. My day job involves a lot of PIC assembler, often targeting micro-power and energy harvesting applications. My first time using an Arduino, I thought, "Wow, this is a noob toy." The second time: "Cool, I don't have to write my own string/memory/i2c/etc. libraries?" Third time: "How did I ever live without this?"

      Obviously, hand-written assembler is still king for my production work, but banging together a quick test (or test fixture!) with the Arduino platform is a huge time saver. One of these days I'm hoping to port some of the micropower tricks & toys back to the platform, just to see the applications that ravening hordes of weekend hardware tinkerers will come up with.

      --
      Caveat Emptor is not a business model.
    11. Re:Threads by TheTrueScotsman · · Score: 1

      Why write our own? Because we love doing it!

      As for that old chestnut, CSP: I'll quote the Bard:

      "There are more things in heaven and earth, Horatio, Than are dreamt of in your philosophy."

  2. That kind of thinking... by Anonymous Coward · · Score: 3, Funny

    "They don't really care about learning Occam. They don't care about how this language is different from C. They just want to make a cat door that keeps their cat out when the cat comes back with a mouse. Or they want to make some kind of installation piece. Trying to focus as much on the user and the possible goals they might have is what's motivating our work right now."

    Isn't this kind of thinking that lead us to why we have the security holes, shoddy programming, and bloat-ware today? People just want to code and not to learn the ins and outs required to craft a well-heeled, tuned, and functioning program or application?

    1. Re:That kind of thinking... by skelterjohn · · Score: 2, Insightful

      Arduinos are allowed to have security holes.

    2. Re:That kind of thinking... by Trepidity · · Score: 5, Insightful

      Next up I suppose you're going to complain about how Legos don't force you to learn proper civil engineering before building things?

    3. Re:That kind of thinking... by Bigjeff5 · · Score: 4, Funny

      I've been pushing for that for years! All children should have a proper engineering degree before playing with legos! I mean, have you seen what some kids come up with? Totally unworkable.

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    4. Re:That kind of thinking... by Anonymous Coward · · Score: 0

      I agree that it's a poor philosophy. Let me turn his argument around:

      The users' don't care about Occam. They don't care about how the language is different from C. They don't care how secure it is. Well, if they don't care, then why shouldn't you make it in the best possible way?

      This kind of catering-to-the-lowest thinking pops up all over the place. My thing is, you have two groups of people, one that isn't sophisticated enough to know or have an opinion on small things, and one that is expert and does. Why satisfy the higher requirement, since you admit that the casual users won't know the difference anyway?

      Personally, if I'm new at something, and I don't have enough in-depth knowledge to have an opinion on how something is being done, then I hope that those who DO have in-depth knowledge choose the better option.

    5. Re:That kind of thinking... by bb5ch39t · · Score: 3, Funny

      I agree with you. In the extreme, it might lead to gas pedals sticking in computer controlled cars. Oh, wait, that's already been done.

    6. Re:That kind of thinking... by John+Whitley · · Score: 4, Interesting

      Isn't this kind of thinking that lead us to why we have the security holes, shoddy programming, and bloat-ware today? People just want to code and not to learn the ins and outs required to craft a well-heeled, tuned, and functioning program or application?

      Repeat after me: programming languages and frameworks do not make developers dumber. It's this kind of thinking that forces every developer-user of a complicated system to be continually faced with issues outside of their domain of expertise, or even just the current problem focus. *That's* what causes these problems.

      For example, when doing embedded programming some years back, I noted that team members working on codec optimization were starting to crank out bad, broken ad-hoc synchronization logic to take advantage of some unique parallel hardware. Their specialties ran into numerical analysis and implementing low-level numerical optimizations, not into synchronization algorithms. I could take these folks and run them through an OS class, and walk them through the inevitable sea of mistakes...

      Or I could do what I did: I created a framework that abstracted away all of the platform synchronization concerns. They did their jobs neatly and cleanly by writing a class that contained some shared state and implementing just two virtual methods that embodied the parallel work. They were much happier, and the whole team was much happier because there was now *one* place to look for synchronization bugs. This was quickly hammered out into a very stable foundation for the other teams' work.

      Allowing our programming languages, libraries, and frameworks to do the heavy lifting so we humans can focus on the real problems we want to solve pretty much describes the history of real progress in software development.

    7. Re:That kind of thinking... by Anonymous Coward · · Score: 0

      no, but I will complain that the plural of lego brick is lego bricks...

    8. Re:That kind of thinking... by Anonymous Coward · · Score: 0

      Repeat after me: programming languages and frameworks do not make developers dumber.

      Mu.

      Repeat after me: people who don't want to learn programming will make lousy programmers.

      Maybe instead of coming up with straw men, you could address the point made?

    9. Re:That kind of thinking... by Gordonjcp · · Score: 0

      Repeat after me: people who don't want to learn hardware design will make lousy programmers.

      If you don't know how the computer works right down to transistor level, how do you expect to understand even a little of what you're doing?

    10. Re:That kind of thinking... by jd · · Score: 2, Interesting

      I was thinking more that all Engineering degrees require a combined combined LEGO/Mecchano device as a final-year project (to demonstrate interoperability), with internship at LEGOLand.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    11. Re:That kind of thinking... by jd · · Score: 1

      Admit it! At least the gas pedals didn't stick to the gas tank, causing the tank to rupture horribly over the over-heated engine, thus eliminating any possibility of an official complaint.
      .
      .
      Oh.
      .
      .
      Just been told that's next year's model.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    12. Re:That kind of thinking... by Monkeedude1212 · · Score: 1

      Allowing our programming languages, libraries, and frameworks to do the heavy lifting so we humans can focus on the real problems we want to solve pretty much describes the history of real progress in software development.

      If you can find a way to shorten that, just a bit, to 140 characters, that will be the best tweet ever made.

    13. Re:That kind of thinking... by Anonymous Coward · · Score: 0

      Arduinos are basically just development kits for Atmel AVR 8-bit microcontrollers. These controllers are embedded in many devices which often control machines which can do actual physical damage or harm. Software quality is an even bigger priority when you're dealing with embedded systems: Updates are harder (often impossible), consequences are expensive and/or dangerous (ask Toyota) and users don't expect "glitches" because the perceived complexity of a device is lower when there is no visible computer.

    14. Re:That kind of thinking... by ajlitt · · Score: 1

      Isn't this kind of thinking that lead us to why we have the security holes...

      I thought the Arduinos are supposed to be RoHS compliant?

    15. Re:That kind of thinking... by Anonymous Coward · · Score: 0

      Your example talks about the opposite: writing efficient code, not writing with the slow, bloated memory heavy runtimes of today's sandboxed software. oh, and no language is going to magically make the intrinsic aspects of the hardware disappear for no cost. You're right that such tools don't necessarily make programmers dumber, but they do encourage them to NOT look behind the curtain so to speak. So when the machinery behind it breaks, they're helpless. Oh, and then there's the fact that the user experience is ruined by performance and memory footprint of their clunky application.

    16. Re:That kind of thinking... by Anonymous Coward · · Score: 0

      Jokes on you, my Lego blocks were made of dark matter and had a near 1:1 ratio in weight with real bricks.

    17. Re:That kind of thinking... by blippo · · Score: 0

      Unfortunately, the idea that a smart guy can write a framework for the rest of us idiots, is what ACTUALLY is causing problems and life long misery.

      Most of the times, a problem is as complex as it is; yes you can "abstract away" the horrible details of your synchronization problem - but the nitty gritty details tend to leak through, and when a unforseen (real world) problem hits the framework, it tends to be hard to solve using the framework in a clean way, and you might need spend much more time on bending the framwork, than you ever had to do without it.

      What I am saying is that writing a framework is really really hard; at least 10 times more expensive than just coding something that works, and in the end, it won't magically protect you from developers that can't code.

    18. Re:That kind of thinking... by djd20 · · Score: 1

      Actually - you can run occam on Lego as well http://transterpreter.org/platforms/rcx/ A port for the NXT is underway. (I was one of the developers of the transterpreter virtual machine which occam runs on when used embedded)

    19. Re:That kind of thinking... by John+Whitley · · Score: 4, Insightful

      Repeat after me: people who don't want to learn programming will make lousy programmers.

      Fine then: the statement above is garden-variety developer egocentric stupidity. TFS' statement is right, these folks want to get their work done, but the specific tools are irrelevant. The qualities of those tools for the task are the only things that matter.

      It's insulting and stupid to propose that those looking to program and leverage an *Arduino* for their personal projects are somehow slackers uninterested in learning. Maybe they're just interested in learning what they want to, not what you want them to. I've walked the path of deep knowledge of programming, CS, etc. I've put my thousands and thousands of hours in. It's a good one for those who enjoy it, but it's not the end-all, be-all for all people.

      Lots of people "want to learn", but at the same time they don't have that "ten thousand hours to mastery" to invest in a new domain (here, programming/CS). There's a spectrum here: on one end, the deep knowledge of an experienced programmer. On the other, those who want and need to access the power of programming but don't want to be burdened with oceans of complexity and specialized domain knowledge. I'll apply an existing term, "end-user programming", for this.

      The most successful end-user programming environment by far is the spreadsheet. It provides simple, tabular model and some fairly rich programming capabilities within its scope. Another great example is the Max/MSP/Jitter environment for real-time audio/video signal processing -- very popular in the computer music and visuals world. Labview-based systems (which includes the Lego Mindstorms stuff) are another great example. Each of these environments is rich enough to allow programming, learning, and exploration. And all provide environments that are tailored to specific problem domains.

      There's a place in the middle, often called by programmers "tools for the task", where a programmer doesn't have to bend over backwards to address certain hairy problem domains. Libraries, frameworks, and programming languages can all meet these needs in their various ways -- even to the extreme that it transforms what some people consider the nature of "programming".

    20. Re:That kind of thinking... by Anonymous Coward · · Score: 0

      that was the most insightful comment I read in a while.

    21. Re:That kind of thinking... by Anonymous Coward · · Score: 1, Funny

      If you don't know how the computer works right down to transistor level, how do you expect to understand even a little of what you're doing?

      Sure.

      How do you expect to understand even a little of what you are programming without understanding Electronics?. Solid State Physics? And without Quantum Electrodynamics?

    22. Re:That kind of thinking... by Hurricane78 · · Score: 1

      I loved this fitting comic:
      http://ahoipolloi.blogger.de/stories/1531403/
      Unfortunately it’s in German, so I’ll translate:

      [Pic 1]
      Headline: New trend: Physical incorrectness!
      Builder: There’s no law against building that!

      [Pic 2]
      Headline: The pseudo-informed dogmatic laws of nature disagree.
      *Smack!*
      Builder: Oww!

      --
      Any sufficiently advanced intelligence is indistinguishable from stupidity.
    23. Re:That kind of thinking... by forkazoo · · Score: 1

      Repeat after me: programming languages and frameworks do not make developers dumber. It's this kind of thinking that forces every developer-user of a complicated system to be continually faced with issues outside of their domain of expertise, or even just the current problem focus. *That's* what causes these problems.

      I disagree. I just think that fancy tools like Python, Qt, and Visual Studio Intellisense, all make me dumber in ways that I find acceptable. I'm usually willing to trade being slightly stupider than I otherwise would be if it means that I am more productive as a result. Consider it a form of "ignorance is bliss."

    24. Re:That kind of thinking... by ultranova · · Score: 1

      Next up I suppose you're going to complain about how Legos don't force you to learn proper civil engineering before building things?

      Actually, they do. You either learn to build strong, light structures, or they are going to keep breaking a lot. Nothing like having a hollow plastic block be the strongest part to really drive home the principles of structural stress and why you should care about it.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    25. Re:That kind of thinking... by ultranova · · Score: 2, Insightful

      Repeat after me: programming languages and frameworks do not make developers dumber.

      But they do make promises that they cannot keep. The abstractions they offer leak, so when a developer works with these abstractions, the code develops weird bugs and slowdowns.

      It's this kind of thinking that forces every developer-user of a complicated system to be continually faced with issues outside of their domain of expertise, or even just the current problem focus. *That's* what causes these problems.

      No, what forces developers face issues outside their domain of experience is that modern computers still don't have artificial intelligence. Consequently, when the frameworks start leaking, they start leaking hard. You end up acquiring a lot of knowlede and habits just to work around the oddities caused by the mess.

      Frameworks and high-level languages are a good thing, but using them requires more, not less, expertize, since you need to know not only them but the underlaying system too - because that system will find a way to peek in.

      Allowing our programming languages, libraries, and frameworks to do the heavy lifting so we humans can focus on the real problems we want to solve pretty much describes the history of real progress in software development.

      Perhaps, but it also describes the history of weird little bugs that keep on creeping in from the leaky abstractions in every framework. Sooner or later you end up fighting the framework because it's limited in some way; fixing every such instance results in unbelievably convoluted frameworks that are really their own programming languages. At that point it would probably be better to just scrap the whole thing and start over with a newer, higher-level language.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    26. Re:That kind of thinking... by BillX · · Score: 1

      If someone's designing Arduino into automotive safety systems, they have bigger problems than russian hax0rz storing up to 16kB of illicit warez in their inadequately protected flash ROM.

      BTW, when most people talk about Arduino they are mainly referring to a software platform and its associated libraries.

      --
      Caveat Emptor is not a business model.
    27. Re:That kind of thinking... by Max+Romantschuk · · Score: 1

      You are making the assumption that you are alone working on a project. Abstractions do leak, and frameworks have bugs. But this does not mean that it's necessary your problem to go around or fix the issue.

      While it does offer a great advantage to know the layers of abstraction beneath your code it's not always necessary. In bigger teams you can simply go to whoever made that layer of abstraction and say: "I'm having this problem with $foo, it's breaking when $description."

      In a well oiled team people will work together to protect each other from problem domains that don't belong to them. Ideally they will also listen to each other's needs and try to accommodate for them in future versions of whatever they are building.

      Programming has come a long way from when it was realistic for the average developer to create a whole application from scratch in a limited time. (I'm not talking cute little mobile apps, but full blown featureful applications.) If you're creating anything that isn't very limited scope-wise you will need more than one person. Likely you will need people of differing expertise. Some to manage the nitty-gritty, some to work on the UI and interaction layers, and some in between. It's rare to find people who can assume all of these roles.

      --
      .: Max Romantschuk :: http://max.romantschuk.fi/
    28. Re:That kind of thinking... by Anonymous Coward · · Score: 0

      not funny. sorry you fail.

  3. Why do people struggle with this so much? by AthleteMusicianNerd · · Score: 1

    This just a race condition, which was taught when I was a sophomore in college(and I knew about in high school).

    1. Re:Why do people struggle with this so much? by Bigjeff5 · · Score: 3, Insightful

      A race condition between two processes is easy. A race condition between three is several times harder. Race conditions between a half dozen processes? Forget about it, at least for the hobbyist.

      Race conditions can be notoriously difficult to program around. You can go from 20 lines of code to 200 in a heartbeat with just one or two of them. Get five or six, and your 20 line program needs a thousand lines to deal with it all. That's pretty ridiculous, especially for hobbyists.

      If you've got a tool to eliminate the problem completely, why would you poopoo it?

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    2. Re:Why do people struggle with this so much? by Anonymous Coward · · Score: 0

      As someone who's been writing real-time systems for 20 yrs: you don't know what you are talking about. They aren't talking about "simple" race conditions. There is a lot more to designing a multi-threaded system that is correct, than just race conditions. And truly parallel systems, utilizing multiple processors is even harder.

    3. Re:Why do people struggle with this so much? by gyrogeerloose · · Score: 1

      This just a race condition, which was taught when I was a sophomore in college(and I knew about in high school).

      Probably because a lot of people who play with the Arudino (including me) are not professional programmers. They're largely self-taught amateurs--typically garage inventors and a surprisingly large number of artists who have probably never even heard of race condition and don't really care, either.

      --
      This ain't rocket surgery.
    4. Re:Why do people struggle with this so much? by AthleteMusicianNerd · · Score: 1

      Given that it will probably take at least a few hours to get that thing working, it would take about 5 minutes to read the wiki on race conditions. That 5 minutes might save the amateur several hours.
      So please read it!

      http://en.wikipedia.org/wiki/Race_condition

      This is actually over complicated, so consider the following example: ( It's hard to do with text, I'd like to draw a pic...nevertheless )

      Guy C takes apples every 5 seconds from Guy A and Guy B. If you give Guy A 8 apples and Guy B 11 apples, you would expect Guy C to run off with 19 apples.

      Now suppose Guy A trips while running to Guy C and takes 7 seconds to get to Guy C, but Guy B gets to Guy C in 3 seconds. Since Guy C is leaving at 5 seconds regardless, he runs off with only 11 apples rather than the expected 19.

      This is a hazard, or a race condition. In order to solve this, you need to inform Guy C that BOTH Guy A and Guy B have apples to bring him, and that he must wait until both have arrived before leaving.

    5. Re:Why do people struggle with this so much? by Haxamanish · · Score: 2, Funny

      This just a race condition, which was taught when I was a sophomore in college(and I knew about in high school).

      Are you sure you were not a semaphore?

    6. Re:Why do people struggle with this so much? by wurp · · Score: 1

      People address race conditions by adding more code? Yuck. The solution to a bug is rarely to add (significantly) more code.

      (Your first problem was using threads to solve something more suited to state engines feeding one another via queues, but that's pervasive.)

    7. Re:Why do people struggle with this so much? by Anonymous Coward · · Score: 0

      The Arduino is based on Atmel microcontrollers, 8-bit microcontrollers to be precise. There are things in these controllers which require in-depth system programming knowledge if you want to use them correctly. For example, interrupt handling is important when reading 16-bit registers. Do it the wrong way and you'll get false data without any indication of an error. Also, these are not fast machines compared to "real" computers, so you can't willy nilly disable interrupts for a few thousand clock cycles either, unless your application is not timing critical at all (and which uC application doesn't have critical timings?) If these people haven't heard of race conditions, then Arduino will introduce them to the concept sooner or later.

    8. Re:Why do people struggle with this so much? by ir · · Score: 0

      The artists should stick to art and stay out of technology if they're too lazy to RTFM.

      --
      Irina Romanov
    9. Re:Why do people struggle with this so much? by gyrogeerloose · · Score: 1

      The artists should stick to art and stay out of technology if they're too lazy to RTFM.

      You sound like this guy.

      --
      This ain't rocket surgery.
    10. Re:Why do people struggle with this so much? by Anonymous Coward · · Score: 0

      because it's too good to be true?

    11. Re:Why do people struggle with this so much? by Chirs · · Score: 1

      Threads and state engines are not orthogonal.

      Generally it doesn't matter, but if ultimate optimization is key threads can give better performance than processes because the TLB doesn't need to be flushed when switching between threads.

      The cost of course is the added risk/complexity of sharing the memory map between all your threads.

    12. Re:Why do people struggle with this so much? by wurp · · Score: 1

      Threads and state engines are not orthogonal.

      Sure, but the state engines and the thread mindset (share data and use mutexes/semaphores to control access) are.

  4. Python alternative by PaulIsTheName · · Score: 1, Informative

    Or try PyMite a.k.a. Python-on-a-chip or p14p if you really must... Also features threads and is a little more mainstream than Occam. And people do actually care about the amount of mental capacity goes to their tools while making the cat door open and close.

    1. Re:Python alternative by tibman · · Score: 1

      I think that would be too much for an arduino. Some PyMite requirements: 40 KB program memory; Initializes in 3KB RAM; print "hello world" needs 4KB; 8KB is the minimum recommended RAM.

      Arduino hardware: Flash Memory 16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used by bootloader
      SRAM 1 KB (ATmega168) or 2 KB (ATmega328).

      --
      http://soylentnews.org/~tibman
  5. "simple" threading by weston · · Score: 5, Insightful

    just implement simple threading

    Sure, and they could just learn to fly too, instead of relying on some convenient form of transportation that solves the problem for them.

    Threads are the famed "simple, clean and wrong" general solution to parallel programming tasks. The *concept* and *implementation* of threads can be simple, sure, but if you're working on anything other than simple problems, the trouble of keeping track of everything that's going on can become very challenging very quickly.

    a whole other language just for one problem.

    It's a big problem. Learning another language is generally a smaller problem. Particularly if you're the kind of Real Programmer(TM) that we're probably going to hear can manage with threads just fine.

     

    1. Re:"simple" threading by OopsIDied · · Score: 1

      Well I guess for the arduino's case you're right. It's already pretty dumbed down since they remove the need to know about port registers/actual serial communication/etc so not having to worry about threading would fit its purpose. It might be better if the actual arduino people implemented it into its standard language though.

  6. occam by Anonymous Coward · · Score: 4, Funny

    occam iits sh like all lel lanparalguages.

  7. XC by RoccamOccam · · Score: 1

    XMOS (http://xmos.com/) has developed a mostly-C language with a few Occam-like extensions, which might also be worth considering. It's called XC (http://www.xmos.com/system/files/xcuser_en.pdf/).

  8. Keep a cat out when it has a mouse?? by Anonymous Coward · · Score: 0

    How???

    1. Re:Keep a cat out when it has a mouse?? by ari_j · · Score: 4, Funny

      You embed RFID tags in the mice and then keep the door locked if one is detected.

    2. Re:Keep a cat out when it has a mouse?? by JoelMartinez · · Score: 2, Informative

      I read this story a *long* time ago, but I remember that someone built a cat door that used a webcam to capture the silhouette of his cat as he entered the cat door. The software would look at the shape, and use a computer learning algorithm to "recognize" the cat ... that way, when he tried to enter with a mouse in his mouth, it would block him. It also had the effect of keeping out raccoons because it obviously wouldn't fit the profile

    3. Re:Keep a cat out when it has a mouse?? by smellsofbikes · · Score: 2, Informative

      Here's the hackaday entry about the feline facial recognition project. The actual project itself is located on a pretty slow server, so you'll have to just go with that, but the idea (from 2003) is what you say: it lets in cats that aren't carrying stuff in their mouths, but doesn't let in raccoons or skunks, and since he's captured pictures of them trying to get in, that's pretty useful.

      --
      Nostalgia's not what it used to be.
    4. Re:Keep a cat out when it has a mouse?? by seandoyle44 · · Score: 1

      There is one edge case - what if the mouse is inside the cat? Are you going to deny access until it has passed? Or perhaps the RFID chips should be made to be digestible?

    5. Re:Keep a cat out when it has a mouse?? by ari_j · · Score: 1

      I don't know about you, but my cat is already shrouded in enough tinfoil to solve that case. That said, I'm thinking about taking off the foil suit, since an undigested RFID tag means increased likelihood of cat vomit on the carpet. It's a difficult judgment call more than it is a technical issue.

  9. Interrupt Service Routines by TwineLogic · · Score: 3, Interesting

    There is no limit to the functionality of Interrupt Service Routines (ISR) and the interrupt-driven "event model," as the OP put it.

    Programming an ISR may be difficult, but even the topic of this post, a parallel environment running on the Arduino, will be based upon ISR routines. The user-level programs will not interact with ISRs, but the Ocaml implementation will abstract them.

    Fundamentally, the hardware will continue to use interrupts to signal the availability of data from human input devices. Therefore, the fastest and most direct way to access this data is to write an assembly language ISR. The difficulty is that embedded systems programming such as this requires specialized technical knowledge on the part of the programmer.

    Clearly the Ocaml solution posted will ease the burden on the coder, and that is a good thing. But the way it works is not that it no longer uses ISRs. It almost certainly implements its own ISRs and polling routines. In this way, it will be like a library. The beneficial result is that individual programmers do not have to reimplement the ISRs. But there is no benefit in, and no possibility of, eliminating the very needed ISR itself.

    Personally, I question whether the MCUs selected for the Arduino are appropriate for the "cute tech" market that the Arduino-series-PCB-module (a.k.a. "shield") manufacturers seem to be going for. Possibly the availability of Ocaml will bring the platform more in line with, e.g., the BasicStamp or similar. Overall, I see an impedence mismatch between what people would like to do (make costumes) and what they get (asking their friends to write code for them).

    The fundamental first step will be describing to the Ocaml environment how it is that the peripherals have been wired to the chip. Then the Ocaml environment can, presumably, service these interfaces either through ISRs or polling. We'll see what transpires in simplifying the Arduino software landscape.... ;)

    1. Re:Interrupt Service Routines by Anonymous Coward · · Score: 0

      It's running Occam by the way, not Ocaml. They are very different beasts.

    2. Re:Interrupt Service Routines by AtrN · · Score: 1

      occam, not ocaml.

    3. Re:Interrupt Service Routines by jd · · Score: 1

      Ocaml's spit more.

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
  10. Parallax Propeller by BasilBrush · · Score: 5, Funny

    The best option for people who want to learn about parallel programming on an embedded processor is the Parallax Propeller. Genuine 8 core system on a chip, programmed to the bare metal. And so much fun.

    http://en.wikipedia.org/wiki/Parallax_Propeller

    1. Re:Parallax Propeller by vlm · · Score: 1

      I'm somewhat familiar with the Propeller. Parallelizes quite well up to eight simultaneous tasks. Nineth? Well, turn back around and back to hell.

      Its about on the level of saying, I've got eight tasks for my arduino, so since they're cheap enough, how about soldering in eight arduino chips. Laughable as this sounds on the surface, in an era of pic microcontroller that are cheaper than a can of soda, its not all that bad of an idea.

      On the other hand, if you wanted to run K or M of threads, perhaps the worlds most demented DSP implementation, thats not going to scale so well.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    2. Re:Parallax Propeller by BasilBrush · · Score: 2, Interesting

      I'm somewhat familiar with the Propeller. Parallelizes quite well up to eight simultaneous tasks. Nineth? Well, turn back around and back to hell.

      Very true. I've done 2 games with the Propeller, and hit the 8 core ceiling both times. So a lot of people are now doing projects with 2 (or more) propellers.

      Maybe not a great choice for production electronics. But great fun for tinkering and one off projects.

    3. Re:Parallax Propeller by Jerrry · · Score: 2, Interesting

      "I'm somewhat familiar with the Propeller. Parallelizes quite well up to eight simultaneous tasks. Nineth? Well, turn back around and back to hell."

      In that case take a look at the XMOS chips. Each core supports eight hardware threads and there are 1, 2, and 4 core versions available. Each core runs at 400 MHz. With the 4-core chip, you have 32 hardware threads to work with. Need more? No problem, just add more chips and connect them using the built-in Links hardware. XMOS sells a development board that has 16 of the 4-core chips for a total of 512 hardware threads.

      The development tools (IDE, compiler, debugger) for Windows, Linux, and OS X are free downloads from the XMOS site. XMOS has added parallel processing capabilities to C (calling it XC), but the development tools also support C, C++, and assembly. JTAG units are US$50, which is quite reasonable.

      Check it out: www.xmos.com www.xcore.com

      Disclaimer: I have no relationship with XMOS except as a satisfied customer.

    4. Re:Parallax Propeller by vlm · · Score: 1

      Thats some mighty cool hardware. But I don't think you get my point. Its possible to write software where there is a clearly defined ultra hard permanent fixed limit to the number of threads and no fancy concurrent stuff is necessary between the thread. In that case hardware multi-cores like the propeller and the xmos look beautiful. For example my camcorder has one thread pulling bits off he CCD and stuffing them on the SD card, another thread updating the real time clock, and another thread running the zoom lens in and out. No big deal.

      But, what if your thread design is linked to the UI? Simplest example, what if you tried to implement the UI for each automated worker unit in the "Civilization" game as a simultaneous thread, in which case it works great up to 8, or 32, or whatever but inevitably the user is gonna click "increment" when you're already maxed out at which time you get hard failure, kaboom. Actually the Civ example is terrible because all 32 settlers might simultaneously try to irrigate the same tile, because the hardware devices usually have little to no support for the hard parts of concurrency like mutex and race condition things, so they blow up. You didn't mention, and I didn't research if the xmos stuff supports that. Perhaps a real world example would be a hardware accelerated threaded webserver that is lightning fast until it reaches 8, or 32, or whatever simultaneous accesses, at which time it simply and completely fails, which may be completely unacceptable in some apps.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    5. Re:Parallax Propeller by newcastlejon · · Score: 1

      If it's a microcontroller I'd say it's in an appliance of some sort. Appliances don't run just any application; they just do a few jobs that are decided in advance. So if your ATM, for example, needs more than 8 hardware threads wouldn't you kludge some in software?

      I'm not sure the Civ analogy really works here; if you were recreating Civ on a camcorder, knowing what chip you had to work with, you wouldn't write it in such a way that it would fail as you suggest. Or perhaps you wouldn't write it at all... you'd write an OS that could do software threads across multiple cores and just run the one that Sid brought out.

      These things aren't designed to play games in my opinion, they generally just sit there unnoticed getting on with running our heating systems, our industrial automation, our alarm clocks, etc. Having 8 threads is fine and dandy but I'll bet you're more likely to see them controlling a robot with 8 limbs rather than 8 settlers.

      --
      If God forks the Universe every time you roll a die, he'd better have a damned good memory.
    6. Re:Parallax Propeller by Jerrry · · Score: 1

      Oh, I forgot to mention that David May, the creator of the XMOS chip, is also the creator of Occam, the language mentioned in TFA.

    7. Re:Parallax Propeller by ultranova · · Score: 1

      Having 8 threads is fine and dandy but I'll bet you're more likely to see them controlling a robot with 8 limbs rather than 8 settlers.

      6 limbs. You need a thread for overall control and body coordination, and could really use another to keep a look at environment.

      Actually, you could easily use hundreds of threads, doing basic processing with senses, integrating data, predicting how the world around you evolves, planning, etc. But certainly need more than "one thread per limb", or the damn thing can't even walk.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    8. Re:Parallax Propeller by BasilBrush · · Score: 1

      because the hardware devices usually have little to no support for the hard parts of concurrency like mutex and race condition things, so they blow up.

      The Propellor has locks, so mutexes are no problem. Race conditions are a bug that could happen in any concurrent system if a programmer makes a mistake. There's nothing particular about the propellor that would make it more likely.

      As to the larger point about it not being scalable to arbitrary numbers of processes, absolutely. But with embedded stuff you very often know how many processes you need.

      All engineering decisions are trade-offs. The Propeller has advantages as well as limitations. It gives a (relatively) easy intro to multi-core programming. Concurrency using multiple cores and no interrupts gives hard real-time response. And the built in SPIN programming language is great for old-time hacking.

    9. Re:Parallax Propeller by BasilBrush · · Score: 1

      Why would you need one thread per limb? Walking or manipulating an object is probably going to be a coordinated activity between limbs. Probably better to have one thread controlling them all. Likewise, there's no reason not to have one thread dealing with multiple sensors.

    10. Re:Parallax Propeller by newcastlejon · · Score: 1

      You missed the point of the entire post, which was that microcontrollers like this are far more likely to be used in industrial automation than in playing games.

      --
      If God forks the Universe every time you roll a die, he'd better have a damned good memory.
  11. Is it anything like C*? by NotSoHeavyD3 · · Score: 1

    Just curious. When I was an undergrad they had a parallel programming course and the language we used was C*. Basically it was C with this add on called a shape. Really it was just an array (Could be multi-dimentional) of virtual processors and associated data. (Basically a short, long, etc.) Then you'd just do a where statement on this array of processors. So in the where statement you'd just list the instructions you wanted done and each virtual processor would each run those instructions themselves. (Been a long time since I programmed in it.) It was actually pretty neat and worked pretty well. (They had us write a program to solve systems of linear equations. It was cool.)

    --
    Did you know 80 to 90% of the moderators on slashdot wouldn't recognize a troll even if one dragged them under a bridge.
    1. Re:Is it anything like C*? by Egelmex · · Score: 1

      I don't think so, Occam is based on CSP algebra, wikipidea has a reasonable description of the language http://en.wikipedia.org/wiki/Occam_programming_language

    2. Re:Is it anything like C*? by jd · · Score: 1
      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    3. Re:Is it anything like C*? by djd20 · · Score: 1

      See also: http://projects.cs.kent.ac.uk/projects/tock/trac/ - tock occam compiler, written in Haskell. It produces really fast code that supports large SMP systems, written by members of the KrOC group.

  12. Reasonable enough. by Animats · · Score: 3, Interesting

    Good idea. I'm impressed that they were able to cram Occam into an Atmel ATMega. Occam syntax is rather clunky by modern standards, but it gets the job done. It has a sane concurrency model and is safer than C.

    Next, Ada?

    1. Re:Reasonable enough. by Anonymous Coward · · Score: 0

      Is the ATMega an actual multiprocessing environment, or are they porting Occam over a threads model? I'm confused.

      I studied Occam 2 about 16 years ago; loved it.

    2. Re:Reasonable enough. by Anonymous Coward · · Score: 0

      Ahh, I see, at heart it is the KrOC compiler I remember from back then.

    3. Re:Reasonable enough. by augustw · · Score: 1

      Occam, "clunky"? You mean it doesn't use braces? Or that is uses semantic whitespace, like Python? It's very terse, and has little syntactic sugar. I'd love to see what you'd do to make it less "clunky".

    4. Re:Reasonable enough. by Atacama93 · · Score: 1

      I wrote a lot of Occam code for transputers around 1989-1992. I thought the language was well-designed, certainly for that time period, and very simple to learn. I was able to pick up all the syntax and start coding productively in less than an afternoon, although I already did know C. The message passing syntax is especially simple. The complete ABNF grammar is only a couple of pages.

      We built a parallel pipeline for signal processing. Adding more processors was as simple as connecting a few pins, modifying our config file and restarting the system. I usually ran it with 48 transputers in the grid. The same Occam code ran on each chip, though there was some special case code executed only by the chip taking in data from an array of Motorola DSP chips and the chip combining all the processed data to hand off to a 486 for display. The algorithm was effectively a pipelined map reduce with real-time constraints.

      Debugging was a bit challenging. We resorted to two approaches - hooking up LEDs to unused pins and raising a signal on a pin (obviously good for only simple stuff) and writing code to pass log messages down the pipeline that got funneled to one chip for display on a console.

  13. Propeller Chip by desmondmonster · · Score: 1

    Another option is to use the Parallax Propeller microcontroller. It's got 8 cores, 80Mhz clock speed, and 32k of ram, and you can either program in its higher-level Spin language or get right down into assembler. The Arduino is fun to learn on and accessible to people who don't have a strong programming background, but working with the Propeller is like advancing to the varsity squad.

    1. Re:Propeller Chip by vlm · · Score: 1

      It's got 8 cores

      How well does it handle the 9th thread? How well does the assembly code handle mutexs and race conditions?

      working with the Propeller is like advancing to the varsity squad.

      Hand the "Varsity eight person rowing team" a ninth oar, sit back and watch the fun?

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    2. Re:Propeller Chip by desmondmonster · · Score: 1

      Sure, 8 cores. That'll handle a few servos, audio input/output, light sensor, and video processing, all done natively. After all, it's a microcontroller, good for gadgets and robots. It's not like you're running MapReduce on it.

    3. Re:Propeller Chip by vlm · · Score: 2, Informative

      After all, it's a microcontroller

      You italicized the wrong syllables. Should have said microcontroller as it can only parallelize separate hardware threads. You can't, for example, do more than eight software threads.

      Here's a mixed model fail for an four person soccer video game:

      one cog runs the video out (hardware, OK)
      one cog runs the sound out (hardware, OK)
      one cog each for each human player, reading each joystick or bluetoothed wiimote or whatever (hardware-ish, OK)
      one cog each for each computer controlled AI player (software, danger! danger! danger!)

      That adds up to 10 cogs. And success or hard failure depends on a user configurable number of players due to inherent hardware architectural limitations.

      A better architecture in this situation would be scrap the hardware accelerated threads and go pure software threading, since none of the threads (well, except video) are terribly computationally difficult.

      Also note that lynxmotion sells numerous little robots with up to 32 little servos. Easy if your threads are done in software, not so easy if they are only done in hardware and you only get 8 or whatever.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    4. Re:Propeller Chip by fatboy · · Score: 1

      Why don't you just shift the HID devices into one cog? I am pretty sure that @ 20 MIPS you can read a lot of joystick information and copy it into hub RAM. Same with your AI players.

      I wrote a 16 channel DMX light dimmer that uses only 3 cogs. I could squeeze that into 2 cogs if I weren't so lazy. Doing away with interrupts made this a relatively easy project.

      --
      --fatboy
  14. Interrupts are bad by gr8_phk · · Score: 1

    In general, one should try to avoid interrupts whenever possible. I thought years of VB programming and the therac 25 taught people the pitfalls of event driven software. Think about polling, fixed time steps, and state machines. Now we're talking embedded systems and video games. To be fair, interrupts are unavoidable for some things - just try to minimize that and keep the interface between IRQ and non IRQ code minimal too.

    1. Re:Interrupts are bad by ClosedSource · · Score: 1

      I can honestly say in my 20+ years in the industry (including 10 years in embedded systems) I've never heard anyone claim that polling is superior to servicing interrupts.

      Now, if you can use a interrupt-driven real-time OS that allows you a lot of flexibility in waking up tasks, that's even better.

    2. Re:Interrupts are bad by vlm · · Score: 1

      I've never heard anyone claim that polling is superior to servicing interrupts.

      I can make a tight polling loop in single digit clock cycles. Some processors have extraordinarily long interrupt operations. The type that smacks the entire kitchen sink onto the stack before it'll look up the ISR address and jump to it, latencies at least an order of magnitude longer than the polling loop.

      This doesn't just bite midrange procs trying to do ultra fast stuff like video overlay, it also bites ultra low power / ultra low speed procs. At 60 KHZ clock, you might be hard pressed to handle more than a couple thousand interrupts/sec but if you poll, that's a piece of cake.

      Depends entirely on processor design and application. Arguably if the software guy "needs" to poll, that's evidence the hardware guy screwed up and/or the specs are simply unworkable.

      Or in summary, polling has great latency response, interrupts have (relatively) terrible latency response, and everyone tries to design around that.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
    3. Re:Interrupts are bad by ClosedSource · · Score: 1

      Well, as you illustrate, context makes all the difference.

      In practice, it seems that long interrupt response is usually associated with processors and supporting hardware that includes pre-fetching, caching and other non-deterministic characteristics that render software loop timing unpredictable. Of course, sometimes that doesn't matter.

    4. Re:Interrupts are bad by blair1q · · Score: 1

      polling has great latency response

      Only in situations where, as per your example, you can cram a couple thousand actions per second into a chip executing 60 thousand instructions per second; i.e., everything you do takes a couple dozen instructions or less. Pumping the brakes on an ABS might fit that sort of model, but guiding a car to parallel-park itself will not.

      Once your requirements get more complex, and involve a mix of long and short tasks at varying priorities (especially those where the long tasks are low priority and the short ones are safety-critical priority), you'll come running back to interrupt-driven designs and live happily ever after.

      Not least because you can modulate the clock speed on an interrupt-driven system to zero when there's no input (and no need for periodic output), lowering your power requirements to current-leakage levels. Try that on a polling system.

    5. Re:Interrupts are bad by KenSeymour · · Score: 1

      If it is a life-safety issue, it shouldn't be on a computer at all, unless it is a safety rated device,
      like a safety rated PLC.

      Physical or electro-mechanical interlocks are the order of the day. The therac didn't have a safety interlocking
      outside of the computer. The code had a race condition which killed people occasionally if the operator typed too fast.

      If you have an automated saw, are you going to put a computer between the emergency stop button and the motor
      power circuit? I wouldn't, whether it used polling or interrupts.

      And the emergency stop button should be normally closed so you discover the loose wire before you need to stop
      the saw.

      If you use polling in you software, that's alright. But the operating system uses ISRs to gather the data
      from the device for you.

      --
      "We can't solve problems by using the same kind of thinking we used when we created them." -- Albert Einstein
  15. Crap by Anonymous Coward · · Score: 0

    I'd support making ardruino more "user-friendly", except I have a feeling it will come at the expense of being "hacker-friendly". See pretty much any hacker project that later decided to become user-friendly as an example.

    Oh well, I looked forward to learning how to make a knitted cozy for my board.

    1. Re:Crap by Stormgren · · Score: 1

      If you're used to dealing with the AVR, and the C language on the AVR, the Arduino already looks awfully hacker unfriendly.

      --

      "All those tubes and wires and careful notes!"

    2. Re:Crap by alvieboy · · Score: 1

      Arduino is actually coded in C++, not C.

      Just for clarification.

    3. Re:Crap by Tetsujin · · Score: 1

      If you're used to dealing with the AVR, and the C language on the AVR, the Arduino already looks awfully hacker unfriendly.

      How's that?

      I mean, the Arduino Introduction page claims that the Arduino programming language is something called "Wiring", right? I've never really understood that. It looks like C or C++. As far as I can tell, it's just a set of libraries on a C++ environment.

      And if you don't like the Arduino programming environment, you don't need to use it. You can compile your code outside of the Arduino environment, and send it to the Arduino board with avrdude... All you'd need to do is make sure your program doesn't expect to occupy the flash space occupied by the bootloader... Though if you programmed the Arduino with ISP, you could overwrite the bootloader if you wanted...

      --
      Bow-ties are cool.
    4. Re:Crap by blair1q · · Score: 1

      They essentially defined their entire language in a couple of pages.

      That's not C, and it sure isn't C++.

      It's a tiny subset of either, but, like English, it's the subset pretty much any speaker can speak. And, like the commonly-spoken subset of English, it quickly hits its limitations should up anything complicated and technically constrained come.

    5. Re:Crap by Tetsujin · · Score: 1

      They essentially defined their entire language in a couple of pages.

      That's not C, and it sure isn't C++.

      It's a tiny subset of either, but, like English, it's the subset pretty much any speaker can speak. And, like the commonly-spoken subset of English, it quickly hits its limitations should up anything complicated and technically constrained come.

      Please explain. I really haven't seen any evidence that the Arduino programming environment reformulates "sketch" source code before passing it to GCC... The Wikipedia page for Arduino describes "Wiring" as a C++ library and says that Arduino "sketches" are written in C++...

      I would expect, as an optimization for the microcontroller, that features like exceptions and virtual methods might not be supported... Otherwise, anything they could do to impede access to C++'s capabilities seems like a waste of time.

      --
      Bow-ties are cool.
    6. Re:Crap by Anonymous Coward · · Score: 0

      The Arduino software environment is a library, a bunch of preprocessor macros and a framework. The language is actually C(++) though.

    7. Re:Crap by bluemax · · Score: 1

      hello
      I'm one of the creators of Arduino.

      The language is c++, we just hide a couple of the most "scary" elements to beginners (mostly the includes at the beginning of the code)

      anything you write after that is c/c++

      "They essentially defined their entire language in a couple of pages." actually a lot of people would find this appealing...

      if you don't like the IDE you can use a makefile to compile the code

      m

      --
      --
    8. Re:Crap by Anonymous Coward · · Score: 0

      It IS C++. The build system does nothing besides prepend a #include and append a main() and run it through a normal C++ compiler.

  16. Python alternative (actually not...) by PaulIsTheName · · Score: 1

    Ah you are right, thanks for looking that up. I just saw AVR and jumped to an incorrect conclusion.

  17. Is that this language that looks like Python? by Anonymous Coward · · Score: 0

    They stole their syntay! Argh!

    1. Re:Is that this language that looks like Python? by Egelmex · · Score: 2, Informative

      Python came out in 1991 but occam in 1983....

  18. Where is the port? by tibman · · Score: 1

    Where is it? I can't find the port. There is a link to: http://www.transterpreter.org/development_download

    But that link is for a Mac-only tool chain of some sort. Does this mean the arduino IDE will be replaced with this Transterpreter thing? If they have a library or something drop-in for the arduino IDE (written in java), i would think it would work for any platform.

    --
    http://soylentnews.org/~tibman
    1. Re:Where is the port? by Egelmex · · Score: 1

      As it says in the article there is only a Mac version at the moment, with windows and linux versions coming out for OSCON. If you are using Linux building it yourself is quite trivial. We know the naming is confusing, and I agree a plugin for the arduino IDE would be nice.

  19. cat door by Anonymous Coward · · Score: 0

    a cat door that keeps their cat out when the cat comes back with a mouse

    sauce?

  20. Google Go? by Anonymous Coward · · Score: 0

    Google Go seem to have some of the channel communication idioms and select statement semantics similar to occam.

    Now, what is really interesting is how so small CPU is capable of handling parallel execution context to begin with...there is only 2KB of RAM!
    I recall somebody made a preprocessor&select/break-statement-based "parallel" execution system w/o context switch state preservation (threads)...

  21. "Arduino" sounds like Ned Flanders word by walterbyrd · · Score: 2, Funny

    What does the Arduino diddly do?

  22. No by Anonymous Coward · · Score: 0

    You do not need parallel processing to make the LEDs in your uber-kitsch geek-art project blink on and off. Now GTFO my internets, and go back to reading MAKE.

  23. Artists are NOT going to be programming AVRs by Simonetta · · Score: 2, Interesting

    I'm an AVR programmer. I prefer to work with assembler, because I come from an electronics background and assembler is closer to the electrons. I can, and occasionally do, work in C on the AVR and Visual BASIC on the PC.

        Let me say, this stuff is hard. It's hard for programmers and electronic technicians. It's really hard for hobbyists and people who have little technical background. Artists are not going to be programming AVRs to make cool performance art projects with Arduinos. OK, maybe one or two, but not many.

        Even rock-bottom beginning simple stuff like blinking an LED or making a beep when a button is pressed can be challenging on a microcontroller. It's not hard to know what to do; it's hard to actually do it and make it work 100% all the time.

        Your average guy or performance artist is NOT going to be making a cat door that won't let the cat in the house with a mouse. Let's see, the cat pushes on the door with its nose. This flips a sensor that activates a camera that relays an image of the cat's face to a microcontroller. The MCU parses the pixels to determine that the image sector of the mouth of the cat is significantly different from the analysis of previous images of the cat's face. The door won't open.

        Now if you're reading this, then yes, you can program something that might be able to do this. You're a Slashdaughter, for Christ's sake, you can do anything technical, and you know it.
    But you wouldn't be able to do it on a $1.59 microcontroller. And you sure wouldn't be able to do it if you didn't have thousands of hours of programming experience and technical training.

        It doesn't matter what language or integrated development environment that you use, it's just not going to happen.

        And frankly, most of the cool projects that performance artists want to do with computers would require a real gigahertz/gigabyte/advanced_OS PC to do, not an 8-bit microcontroller with 1K of RAM that can just barely run a microwave oven, let alone a telephone.

        Performance artists want professional-level programming ability and talent at bargain-basement artists prices. But if you're not a beautiful woman into performance art who has the ability to hook up her beautiful friends to nerdy techno-geeks who actually do the programming, it's unlikely to happen.

    1. Re:Artists are NOT going to be programming AVRs by djd20 · · Score: 1

      I know for a fact that artists with litte or no programming experience have been able to pick occam up on the arduino or RCX. Its challenging when you have to write assembly, not when you have a library designed for that microcontroller and all you need to do is write 5-10 lines of code to start doing 'cool stuff'.

    2. Re:Artists are NOT going to be programming AVRs by Anonymous Coward · · Score: 0

      Wow. The adolescent stereotypes aside (e.g. beautiful girls aren't capable of cranking their own code), the idea that artists can't dive in and grok stuff if they feel they need too for a project is just wrong. Typing "digitalWrite(13, 1)" into an Arduino to turn on a LED turns out to be quite doable. Have you actually looked at the emerging art scene lately? You can't shake a stick for hitting a piece of physical computing, some of which are amazing, and run happily off pretty basic machines. Some galleries/programs/events as examples:

      http://www.mobius.org/
      http://www.nycresistor.com/2010/03/28/first-peek-at-the-arduino-art-show/
      http://itp.nyu.edu/itp/
      http://eyebeam.org/about/about

      Not to mention Processing, a language developed at MIT specifically to help artists out that runs on Macs and PCs and makes e.g. hooking up and playing with camera feeds a snap:

      http://processing.org/

    3. Re:Artists are NOT going to be programming AVRs by Zerth · · Score: 1

      I think even an artsy type can plug a camera shield, motor shield, and SD card shield into an Arduino and download an image comparison library.

      Somebody probably has a walkthrough on Instructables or arduino.cc so they can do it C&P voodoo style.

      An arduino won't be doing video recognition, but it can compare a still picture to an outline of a cat's head once a second, if it has somewhere to store the data.

    4. Re:Artists are NOT going to be programming AVRs by sugarmatic · · Score: 1

      Actually, I use mine to deconvolve a spherically distorted JPEG into a panorama. It does this very well. It stored data to an SD chip.

    5. Re:Artists are NOT going to be programming AVRs by alder · · Score: 1

      This flips a sensor that activates a camera ... The MCU parses the pixels ...

      Or they attach a couple of (IR, ultrasonic, whatever) range/distance sensors and measure the size of what's coming in. Then that $1.59 should be just fine ;-)

  24. I'm going to do it! by Anonymous Coward · · Score: 0

    I'll do it, there is nothing you can do to stop me!

    Imagine a Beowulf Clust--- Error 406

  25. C can do you wrong by electrostatic · · Score: 2, Interesting

    I've been playing with the Arduino and ran into these examples last night. The objective of the macro below is to set (1) or reset (0) a single bit in an 8-bit register. Register PORTH is mapped to 8 pins I/O pins on the Arduino and we want to control one of them: pin 12. This is the code I found. It's very helpful in that it shows register-to-pin mapping. (Pin 12 has previously been set as an output pin.)

       #define SET_PIN12(z)  ((z)>0)? PORTH |= (1 << 3) : PORTH  &= (0 << 3)

       Then usage would simply be like the following:
       SET_PIN12(1); //writes a 1 to PIN12
       SET_PIN12(0); //writes a 0 to PIN12

    There are some problems with this. ((z)>0) will not do what the programmer intended if z, an int, is negative. And there's no need to test for Z being non-zero. The expression should be replaced with z alone.

    The first statement of the conditional if, (1 << 3) : PORTH, works fine as it sets the desired bit to 1 while leaving the other bits as-is. But PORTH  &= (0 << 3) resets ALL 8 bits to zero. I suspect he was thinking that (0<<3)  is 11110111.
    In any case, PORTH  &= 0b11110111 functions properly. (The Arduino language is a subset of C++ with a few additions.) A simpler version is

       #define SET_PIN12(z)  (z ? PORTH |= (1 /</< 3) : PORTH  &= 0b11110111

    Another example. This is their code to read an input on pin 13. (Pin 13 has been set as an input pin.)

       #define READ_PIN13(z) ((PINL & 0x08) > 0) ? (z) = 1 : (z) = 0
       Usage would be
       READ_PIN13(temp); //reads 1 or 0 into temp depending on PIN13's state

    So we have
       (z) = 0;  // or
       (z) = 1;
    being executed. I didn't realize this would compile.

    The macro functions correctly but I simplified it and changed its usage from a conditional if to to a simple assignment
       #define READ_PIN13 ((PINL & 0x08) > 0)
       // ...
       temp =  READ_PIN13; //reads 1 or 0 into temp depending on PIN13's state

    I was tempted to simply further to

       #define READ_PIN13 (PINL & 0x08)  // returns 0 or 0x08

    But since there was a lot of this kind of (proper) code I didn't go that far.

       #define   HIGH   1
       // .....
       temp =  READ_PIN13;
       if (temp == HIGH) {...   // tests temp == 1, versus "true" (non-zero)

    After looking through lots of code on the web sites it got me thinking about how easy it is produce C code with unintended consequences.

    1. Re:C can do you wrong by electrostatic · · Score: 1

      Actually, the example I mentioned above does not apply to an Arduino itself, but to an add-on piece of hardware that uses a similar processor. The Arduino language has its own I/O pin functions.

    2. Re:C can do you wrong by mirix · · Score: 1

      You can just use this struct and some preprocessor magic, and then you can define pins if you won't want to bitmask port reads and writes.

      typedef struct
      {
          unsigned int bit0:1;
          unsigned int bit1:1;
          unsigned int bit2:1;
          unsigned int bit3:1;
          unsigned int bit4:1;
          unsigned int bit5:1;
          unsigned int bit6:1;
          unsigned int bit7:1;
      } _io_reg;

      #define REGISTER_BIT(rg,bt) ((volatile _io_reg*)&rg)->bit##bt
      #define TEMP REGISTER_BIT(PINB,5)
      #define RELAY REGISTER_BIT(PORTB,6)

      Then you can just do this:

      if (TEMP) //PINB bit 5 is high
          RELAY = 1; //engage relay (on PORTB bit 6)
      else RELAY = 0;

      Makes things a little more readable vs. bitmasking:

      if(PINB & 0x20) //if pinb bit5 is high
          PORTB |= 0x40; // set PB6
      else PORTB &= ~0x40; // else clear PB6

      I just use plain AVRs and the AVR port of GCC myself. Never bothered with the arduino stuff.

      --
      Sent from my PDP-11
    3. Re:C can do you wrong by Anonymous Coward · · Score: 0

      The main situation here is that most people fail to realize that an arduino is a fully featured ATmega microcontroller with the IO pins spread out, a 16MHz oscillator, a few voltage regulators and a level converter (the 232 chip which converts RS-232 to TTL).

      I don't see what's so hard about doing
      PORTH |= _BV(PH3); // to set
      PORTH &= ~_BV(PH3); // to clear

      Since we're working with PORTH, i'm assuming this deals with the ATmega1280 present in the Arduino Mega. This will then compile to a 2 clock instruction. The set operation compiles to sbi, the clear operation compiles to cbi. Sure, you can use the #define above, but I find that having any of those two operations is much simpler.

      One thing I've noticed from the arduino environment: It is too bloated. I began rewriting all my software using avr-libc directly. Why is it that stuff that used to compile to 3-7KB compiles to less than 0.5KB now? Is all that bloat really needed?

    4. Re:C can do you wrong by bluemax · · Score: 1

      FYI

      that is not Arduino code... that's regular C on an AVR chip...

      --
      --
  26. Interesting, by inhuman_4 · · Score: 2, Interesting

    This is interesting and I hope that it helps bring in new people to the embedded field. Having easy tools to introduce people to a system can make a big difference in the learning curve. Once they get hooked they can start to learn how to do things manually.

    For things like the ARM, Blackfin, etc. having multitasking is a huge benefit. But on lower end systems like PIC, AVR, etc. it's really just for show and tell.

    I have a fair bit of experience programing these low end devices and the golden rule is ISRs (Interrupt Service Routines) for everything. Everything should be done via ISRs, and when not running an ISR the chip should be in low power mode. A lot of embedded systems are battery powered and they simply don't have the power to waste on things like polling. If you have no choice but to poll (and there are very, very few cases for this) then use a timer ISR. Additionally ISRs give you interrupt priority and hard-realtime responses, something that many applications (especially safety) require.

    Putting occam on Arduinos should help people get started on these devices, but I seriously doubt it will see any use in the professional world.

  27. missed the point... by sugarmatic · · Score: 1

    Half the battle is accessibility. Arduino does that well. It accomplishes what many want it to do without fuss and esotericisms of "good" code. I'd rather have a set of tools I can work with for a one-off task. It beats waiting for an uppity code jockey who insists that it will take 4 weeks, $14k in developer tools,$2k in class fees, etc., to accomplish what a lot of sixth graders eagerly do in a few evenings from scratch. I've seen it happen- right where I work, and it is frustrating.

  28. Occam by physburn · · Score: 1

    I remember Occam I learned it back in 1993, it was designed to power specialized multi-CPU machines, transputers, microprocessor with dedicated high speed serial connects to there peer microprocessors. The company that made the transputer INMOS went burst, and disappeared into Olivetti and the transputer was never seen again. I'm surprised that Occam is still going after all this time. It wasn't a bad language and had parallelism as a very low level, which would make it useful for graphics programming or matrix maths, where you could split a for loop over multiple processors, were the answers where independent of result for other indexes.

  29. Tools for Idiots by Anonymous Coward · · Score: 0

    If you build tools for idiots, only idiots will use them.

    Tools such as these only manage to act as a crutch for incompetent developers. The real solution to the problem lies in proper education, practice, and experience. Everything else is just a shoddy patch, and one reason why most college grads can't code to save their life.

  30. Been done. by Anonymous Coward · · Score: 0

    We've been doing parallel programming and multi-threading on the Arduino for years before this.

  31. Programmed security holes by jpvlsmv · · Score: 1

    Absolutely, this sort of behavior is why we have security holes.

    A cat door is one of the biggest security holes there is. You never know what kind of cat/burglar might come in through the door. I mean, it could even be a cue:cat, or a /usr/bin/cat(1), or worse yet, a LOLCAT.

    --Joe

  32. I am an artist who uses Arduino by Anonymous Coward · · Score: 0

    It's pretty easy, actually, and I've never taken a programming class in my life. Even soldering your own board and programming the AVR directly with bitwise operators (albeit with C, not assembly) is not too tough.

    The Occam guys are completely correct. Artists just want to achieve their goals for a project, not learn best practices for software engineering. That's why I don't design high frequency trading platforms for a living! However, I do try to choose frameworks that are written by people who do care about software engineering and abstract that stuff away from me.

    I think this is the way of the future. All educated people should know how to program, but only a small number will become engineers.