Skip to main content

nanoMoCo Demonstration Application

Posted in

Ok guys and gals, here's a quick demo app to show easy it will be to create Qt-based apps using nanoMoCo.

Please note, this is all -very- early stuff, and not ready for prime time, but just a neat little teaser. It only works on Windows, and can only be compiled on windows at the moment. The Qt control library isn't really a library yet, but the current version, which still needs work, is included in the source bundle.

Here's a screenshot:

The dial controls the speed of the stepper in steps per second (from 1 to 1000).

To use it:

1) Download the current branch of the nanomoco timelapse engine: http://openmoco.svn.sourceforge.net/viewvc/openmoco/OpenMocoComponents/TimeLapseEngine/branches/nanomoco/?view=tar
2) Modify the motor step, dir, and sleep pins as required for match to your wiring
3) upload to your arduino
4) Start the app by clicking on the OMQTGUI-2.exe file
5) input the com port # your arduino is connected to
6) hit connect
7) move the dial

Here's a zip file containing the binary and the source: nmdemoapp.zip

The source code is a Qt Creator project (C++), load the .pro file in Qt Creator.

If you really want to have fun, run doxygen against the source directory. Most of the library is documented at this point. Look at OMAxis, OMController, etc.

The following provides a basic example of using an OMAxis object to turn on a debug led on a specific axis. All commands are non-blocking, and we can ignore their return, or use a slot to handle the response from the engine for each command's value, when the command is completed.

  #include <QDebug>

  ...

  #include "omcontroller.h"
  #include "omaxis.h"
  ...

  int main(int argc, char *argv[])
  {

    ...

    char* serPort[] = "COM5";
    int address = 1234;

    OMController* ctrl = new OMController(serPort);

    OMAxis* axis = new OMAxis(ctrl, address);

    try {

        ctrl->connect();
    }
    catch (int e) {
        if( e == OpenMoCo::errSerialNotAvailable ) {
            qDebug() << "ERROR: Could not connect to serial port";
        }
        else {

            qDebug() << "ERROR: Caught signal: " << e;
        }

        exit();
    }

    qDebug() << "Successfully connected to " << serPort;

    int cmdId = axis->debug(true);

    qDebug() << "Sent enable debug led command, with id " << cmdId;

  }

!c

I tried this today and didn't

I tried this today and didn't get it to work. I don't have any Windows machines, so I tried this on a XP virtual machine (Parallels) on my Mac. I normally don't have any issues with Parallels, but I cannot rule out that this is the source of my problem.

First thing is that a new library TimerOne is used? It this the correct one:
http://code.google.com/p/arduino-timerone/ ?

There is no way that I can see if a connection to the TLE is made. I could try the code above, but I don't feel like installing QT Creator on my virtual machine. Maybe a popup in de GUI app could give more debug information?

Funny enough, I found -part-

Funny enough, I found -part- of it was failing on my laptop last night.

That is, it did successfully connect to the nanomoco, it put the motor driver into sleep state, and then who knows what. Will have to check out what's going on, but it does work fine on the build machine. Adding more info back to the user will be interesting, but I'd hope to do it in a way that doesn't take a lot of work for a demo *g* I'll have to do a debug version and see what pops up (there is a lot of debug info produced). Slim, however, worked fine =)

Yes, timer1 is used for motor driving on the arduino. Right now it triggers a control cycle that runs every 40uS, where the motor state is determined to be high or low (or no change). I may switch it into PWM mode later, if that gives better performance.

!c