2 Replies Latest reply on Jan 18, 2016 2:10 PM by French

    How can I get accurate dc motor velocity information on Galileo Gen 1


      Hi all,


      I have recently started playing with node js and mraa on Intel Galileo Gen 1. I want create a web server and provide the user with "real-time" ( I know it is not real-time) feed about the velocity of a DC motor. I am getting this information from an encoder and in theory the simplest way to do this is to set an interrupt on an IO and count the rotations per let's say 10 ms. I tried using the support from mraa for isr, but I encountered a show stopper since I can barely count 50 interrupts (this because mraa limits me to EDGE_BOTH) while the input signal is ~120Hz.

      I have read that there is no way to accelerate this, but the Arduino Sketch that uses the attachInterrupt managed to get @2Khz (some say). What I wanted to know, is there a fast way to use a sketch to read the IO and calculate vel as IRQs/10ms and then use node js to acquire that information? If there is, I'm thinking it is a better approach to run multiple sketches (i.e: one to control the motor and one to sample the encoder pin) and make them communicate with the node js web server.


      Are there any other viable solutions?

        • 1. Re: How can I get accurate dc motor velocity information on Galileo Gen 1

          Hello French,


          I'd say that the faster way to do it is with interruptions, in this case with attachInterrupt(). On the other hand, you can get the information from the Arduino sketch and use it in the Node.js script. The following document describes how to share information between environments, you might find it interesting: IoT - Data sharing between programming environments on Intel® Edison | Intel® Developer Zone




          • 2. Re: How can I get accurate dc motor velocity information on Galileo Gen 1

            Hi Diego,


            I read the article some time ago (definitely thinking outside the box ) since IPC can be done in many linux-oriented ways) and I discarded it since I believed that MRAA will be the answer to everything. Now, I might be tempted to try something similar. I think that a somewhat "model-view-controller" approach could work here to get maximum performance from this little project. Meaning I could use Arduino to fully control the DC motor and use NodeJS for the web server.

            I'm just curios if for this rather simple IPC use case there are more linux oriented approaches, because technically I would still rely on the mraa interrupt thread to notify node when the sketch has data to send.

            There are attempts to use shared memory, for which there is some support, but I haven't seen any simple examples. Also, I don't know if arduino sketches work well with Unix sockets (as an alternative). From this perspective, your suggestion is easier to implement and test.


            Thank you!